-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
114ecb9
commit 5f0efcb
Showing
46 changed files
with
1,180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', loadChildren: './pages/tabs/tabs.module#TabsPageModule' }, | ||
]; | ||
@NgModule({ | ||
imports: [ | ||
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) | ||
], | ||
exports: [RouterModule] | ||
}) | ||
export class AppRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<ion-app> | ||
<ion-router-outlet></ion-router-outlet> | ||
</ion-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { TestBed, async } from '@angular/core/testing'; | ||
|
||
import { Platform } from '@ionic/angular'; | ||
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | ||
import { StatusBar } from '@ionic-native/status-bar/ngx'; | ||
|
||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
|
||
let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; | ||
|
||
beforeEach(async(() => { | ||
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); | ||
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); | ||
platformReadySpy = Promise.resolve(); | ||
platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [AppComponent], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
providers: [ | ||
{ provide: StatusBar, useValue: statusBarSpy }, | ||
{ provide: SplashScreen, useValue: splashScreenSpy }, | ||
{ provide: Platform, useValue: platformSpy }, | ||
], | ||
}).compileComponents(); | ||
})); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
it('should initialize the app', async () => { | ||
TestBed.createComponent(AppComponent); | ||
expect(platformSpy.ready).toHaveBeenCalled(); | ||
await platformReadySpy; | ||
expect(statusBarSpy.styleDefault).toHaveBeenCalled(); | ||
expect(splashScreenSpy.hide).toHaveBeenCalled(); | ||
}); | ||
|
||
// TODO: add more tests! | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import { Platform } from '@ionic/angular'; | ||
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | ||
import { StatusBar } from '@ionic-native/status-bar/ngx'; | ||
import { AuthService } from './services/auth.service'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: 'app.component.html' | ||
}) | ||
export class AppComponent { | ||
constructor( | ||
private auth: AuthService, | ||
private platform: Platform, | ||
private splashScreen: SplashScreen, | ||
private statusBar: StatusBar | ||
) { | ||
this.initializeApp(); | ||
} | ||
|
||
initializeApp() { | ||
this.platform.ready().then(() => { | ||
this.statusBar.styleDefault(); | ||
this.splashScreen.hide(); | ||
|
||
// Perform required auth actions | ||
this.auth.load_jwts(); | ||
this.auth.check_token_fragment(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { RouteReuseStrategy } from '@angular/router'; | ||
|
||
import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; | ||
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | ||
import { StatusBar } from '@ionic-native/status-bar/ngx'; | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { AppComponent } from './app.component'; | ||
|
||
import { DrinksService } from './services/drinks.service'; | ||
import { AuthService } from './services/auth.service'; | ||
|
||
import { HttpClientModule } from '@angular/common/http'; | ||
|
||
import { from } from 'rxjs'; | ||
|
||
@NgModule({ | ||
declarations: [AppComponent], | ||
entryComponents: [], | ||
imports: [ | ||
BrowserModule, | ||
IonicModule.forRoot(), | ||
HttpClientModule, | ||
AppRoutingModule | ||
], | ||
providers: [ | ||
StatusBar, | ||
SplashScreen, | ||
AuthService, | ||
DrinksService, | ||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } | ||
], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule {} |
41 changes: 41 additions & 0 deletions
41
frontend/src/app/pages/drink-menu/drink-form/drink-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title *ngIf="isNew">New Drink Creator</ion-title> | ||
<ion-title *ngIf="!isNew">Drink Editor</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content *ngIf="drink"> | ||
<app-drink-graphic [drink]="drink"></app-drink-graphic> | ||
|
||
<form (ngSubmit)="logForm()"> | ||
<ion-item> | ||
<ion-label>Drink Title</ion-label> | ||
<ion-input type="text" [(ngModel)]="drink.title" name="title"></ion-input> | ||
</ion-item> | ||
|
||
<ion-item *ngFor="let ingredient of drink.recipe; let i = index; trackBy: customTrackBy"> | ||
<ion-label>Ingredient Name</ion-label> | ||
<ion-input [(ngModel)]="drink.recipe[i].name" [name]="'Ingredient Title'+i"></ion-input> | ||
|
||
<ion-label>Number of Parts</ion-label> | ||
<ion-input type="number" [(ngModel)]="drink.recipe[i].parts" [name]="'Ingredient Parts'+i"></ion-input> | ||
|
||
<ion-label>Color</ion-label> | ||
<ion-input type="text" [(ngModel)]="drink.recipe[i].color" [name]="'Ingredient Color'+i"></ion-input> | ||
|
||
<ion-button (click)="removeIngredient(i)" [disabled]="i==0 && drink.recipe.length==1">Remove</ion-button><br /> | ||
<ion-button (click)="addIngredient(i)" [disabled]="drink.recipe.length==5">ADD</ion-button><br /> | ||
|
||
</ion-item> | ||
|
||
<ion-button | ||
[disabled]="!auth.can('delete:drinks')" | ||
(click)="deleteClicked()">Delete</ion-button><br /> | ||
<ion-button (click)="closeModal()">Cancel</ion-button> | ||
<ion-button | ||
[disabled]="!auth.can('patch:drinks') || !auth.can('post:drinks')" | ||
(click)="saveClicked()">Save</ion-button> | ||
|
||
</form> | ||
</ion-content> |
Empty file.
27 changes: 27 additions & 0 deletions
27
frontend/src/app/pages/drink-menu/drink-form/drink-form.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DrinkFormComponent } from './drink-form.component'; | ||
|
||
describe('DrinkFormComponent', () => { | ||
let component: DrinkFormComponent; | ||
let fixture: ComponentFixture<DrinkFormComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DrinkFormComponent ], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DrinkFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
57 changes: 57 additions & 0 deletions
57
frontend/src/app/pages/drink-menu/drink-form/drink-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { Drink, DrinksService } from 'src/app/services/drinks.service'; | ||
import { ModalController } from '@ionic/angular'; | ||
import { AuthService } from 'src/app/services/auth.service'; | ||
|
||
@Component({ | ||
selector: 'app-drink-form', | ||
templateUrl: './drink-form.component.html', | ||
styleUrls: ['./drink-form.component.scss'], | ||
}) | ||
export class DrinkFormComponent implements OnInit { | ||
@Input() drink: Drink; | ||
@Input() isNew: boolean; | ||
|
||
constructor( | ||
public auth: AuthService, | ||
private modalCtrl: ModalController, | ||
private drinkService: DrinksService | ||
) { } | ||
|
||
ngOnInit() { | ||
if (this.isNew) { | ||
this.drink = { | ||
id: -1, | ||
title: '', | ||
recipe: [] | ||
}; | ||
this.addIngredient(); | ||
} | ||
} | ||
|
||
customTrackBy(index: number, obj: any): any { | ||
return index; | ||
} | ||
|
||
addIngredient(i: number = 0) { | ||
this.drink.recipe.splice(i + 1, 0, {name: '', color: 'white', parts: 1}); | ||
} | ||
|
||
removeIngredient(i: number) { | ||
this.drink.recipe.splice(i, 1); | ||
} | ||
|
||
closeModal() { | ||
this.modalCtrl.dismiss(); | ||
} | ||
|
||
saveClicked() { | ||
this.drinkService.saveDrink(this.drink); | ||
this.closeModal(); | ||
} | ||
|
||
deleteClicked() { | ||
this.drinkService.deleteDrink(this.drink); | ||
this.closeModal(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
frontend/src/app/pages/drink-menu/drink-graphic/drink-graphic.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="cup"> | ||
<div | ||
*ngFor="let ingredient of drink && drink.recipe" | ||
class="ingredient" | ||
[style.flexGrow]="ingredient.parts" | ||
[style.background]="ingredient.color"> | ||
{{t}} | ||
</div> | ||
</div> |
13 changes: 13 additions & 0 deletions
13
frontend/src/app/pages/drink-menu/drink-graphic/drink-graphic.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.cup { | ||
width: 50px; | ||
height: 50px; | ||
display: flex; | ||
flex-direction: column; | ||
border-radius: 7px; | ||
overflow: hidden; | ||
} | ||
|
||
.ingredient { | ||
width: 50px; | ||
flex-grow: 1; | ||
} |
27 changes: 27 additions & 0 deletions
27
frontend/src/app/pages/drink-menu/drink-graphic/drink-graphic.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DrinkGraphicComponent } from './drink-graphic.component'; | ||
|
||
describe('DrinkGraphicComponent', () => { | ||
let component: DrinkGraphicComponent; | ||
let fixture: ComponentFixture<DrinkGraphicComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DrinkGraphicComponent ], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DrinkGraphicComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
frontend/src/app/pages/drink-menu/drink-graphic/drink-graphic.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
import { Drink } from 'src/app/services/drinks.service'; | ||
|
||
@Component({ | ||
selector: 'app-drink-graphic', | ||
templateUrl: './drink-graphic.component.html', | ||
styleUrls: ['./drink-graphic.component.scss'], | ||
}) | ||
export class DrinkGraphicComponent implements OnInit { | ||
@Input() drink: Drink; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { DrinkMenuPage } from './drink-menu.page'; | ||
import { DrinkGraphicComponent } from './drink-graphic/drink-graphic.component'; | ||
import { DrinkFormComponent } from './drink-form/drink-form.component'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: DrinkMenuPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
RouterModule.forChild(routes) | ||
], | ||
entryComponents: [DrinkFormComponent], | ||
declarations: [DrinkMenuPage, DrinkGraphicComponent, DrinkFormComponent], | ||
}) | ||
export class DrinkMenuPageModule {} |
Oops, something went wrong.