summaryrefslogtreecommitdiff
path: root/recipeBuddy/src
diff options
context:
space:
mode:
Diffstat (limited to 'recipeBuddy/src')
-rw-r--r--recipeBuddy/src/app/cook-page/cook-page.component.css14
-rw-r--r--recipeBuddy/src/app/cook-page/cook-page.component.html22
-rw-r--r--recipeBuddy/src/app/cook-page/cook-page.component.ts78
-rw-r--r--recipeBuddy/src/app/cook-page/step-card/step-card.component.css0
-rw-r--r--recipeBuddy/src/app/cook-page/step-card/step-card.component.html1
-rw-r--r--recipeBuddy/src/app/cook-page/step-card/step-card.component.spec.ts25
-rw-r--r--recipeBuddy/src/app/cook-page/step-card/step-card.component.ts9
7 files changed, 83 insertions, 66 deletions
diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.css b/recipeBuddy/src/app/cook-page/cook-page.component.css
index 41b3d42..4f44224 100644
--- a/recipeBuddy/src/app/cook-page/cook-page.component.css
+++ b/recipeBuddy/src/app/cook-page/cook-page.component.css
@@ -11,13 +11,20 @@
.previous {
margin: auto;
+ width: 200px;
+ height: 200px;
border: solid;
+ align: center;
text-align: center;
grid-column: 1;
+
+
}
.current {
margin: auto;
+ width: 300px;
+ height:300px;
border: solid;
text-align: center;
grid-column: 2;
@@ -25,7 +32,10 @@
.next {
margin: auto;
+ width: 200px;
+ height: 200px;
border: solid;
+ align: center;
text-align: center;
grid-column: 3;
@@ -37,3 +47,7 @@
grid-gap: 10px;
grid-template-rows: 1fr;
}
+
+.step-count {
+ text-align: center;
+}
diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.html b/recipeBuddy/src/app/cook-page/cook-page.component.html
index 39bef2e..db1c0a8 100644
--- a/recipeBuddy/src/app/cook-page/cook-page.component.html
+++ b/recipeBuddy/src/app/cook-page/cook-page.component.html
@@ -1,22 +1,26 @@
<div class="container">
- <div class="previous">
- <h1>Step {{step -1}}</h1>
+ <div class="previous" *ngIf="!firstStep">
+ <h1>Step {{stepNum -1}}</h1>
<p>{{previousStep}}</p>
</div>
<div class="current">
- <h1>Step {{step}}</h1>
+ <h1>Step {{stepNum}}</h1>
<p>{{currentStep}}</p>
- <p>{{timeLeft}}</p>
- <div>
+ <div *ngIf="hasTimer()">
+ <p>{{timeLeft}}</p>
<button (click)="startTimer()">Start Timer</button>
</div>
- <button (click)="previous()">Previous</button>
- <button (click)="next()">next</button>
+ <button *ngIf="!firstStep" (click)="previous()">Previous</button>
+ <button *ngIf="!lastStep" (click)="next()">next</button>
</div>
- <div class="next">
- <h1>Step {{step +1}}</h1>
+ <div class="next" *ngIf="!lastStep">
+ <h1>Step {{stepNum +1}}</h1>
<p>{{nextStep}}</p>
</div>
</div>
+
+<div class="step-count">
+ <h1>Step: {{stepNum}}/{{steps.length}}</h1>
+</div>
diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.ts b/recipeBuddy/src/app/cook-page/cook-page.component.ts
index 51a4c67..f114634 100644
--- a/recipeBuddy/src/app/cook-page/cook-page.component.ts
+++ b/recipeBuddy/src/app/cook-page/cook-page.component.ts
@@ -1,17 +1,20 @@
import {Component, OnInit} from '@angular/core';
+import {Recipe} from '../DataModels/recipe';
+import {Step} from '../DataModels/step';
+import {RecipePassService} from '../recipePass/recipe-pass.service'
-/**
- * @title Card with multiple sections
- */
@Component({
selector: 'app-cook-page',
templateUrl: './cook-page.component.html',
styleUrls: ['./cook-page.component.css'],
})
export class CookPageComponent implements OnInit {
- step: number;
- instructions: string[] = ["Cut the bread", "Toast the bread", "Warm the butter", "Apply butter to bread", "Enjoy"];
- timers: number[] = [5,60,30,0,0];
+ steps: Step[];
+ stepNum: number;
+
+ firstStep: boolean = true;
+ lastStep: boolean = false;
+
previousStep: string;
currentStep: string;
nextStep: string;
@@ -19,30 +22,62 @@ export class CookPageComponent implements OnInit {
timerInterval;
+ constructor(private recipePass: RecipePassService){}
+
ngOnInit() {
- this.step = 1;
- this.previousStep = "";
- this.currentStep = this.instructions[this.step-1];
- this.nextStep = this.instructions[this.step];
- this.timeLeft = this.timers[this.step-1];
+ this.getSteps();
+ this.stepNum = 1;
+ this.currentStep = this.steps[this.stepNum-1].getInstruction();
+ this.nextStep = this.steps[this.stepNum].getInstruction();
+ this.timeLeft = this.steps[this.stepNum-1].getTimer();
+ }
+
+ getSteps(): void {
+/**
+* var recipe: Recipe;
+* recipe = this.recipePass.getRecipe();
+* this.steps = recipe.getSteps();
+*/
+ var tmpSteps: Step[] = [];
+ tmpSteps[0] = new Step("Cut the bread", 0);
+ tmpSteps[1] = new Step("Warm the butter", 5);
+ tmpSteps[2] = new Step("Enjoy", 0);
+ this.steps = tmpSteps;
}
next(): void {
+ this.firstStep = false;
clearInterval(this.timerInterval);
- this.step++;
- this.previousStep = this.instructions[this.step-2];
- this.currentStep = this.instructions[this.step-1];
- this.nextStep = this.instructions[this.step];
- this.timeLeft = this.timers[this.step-1];
+ this.stepNum++;
+ if(this.stepNum == this.steps.length) {
+ this.lastStep = true;
+ } else {
+ this.nextStep = this.steps[this.stepNum].getInstruction();
+ }
+ this.previousStep = this.steps[this.stepNum-2].getInstruction();
+ this.currentStep = this.steps[this.stepNum-1].getInstruction();
+ this.timeLeft = this.steps[this.stepNum-1].getTimer();
}
previous(): void {
+ this.lastStep = false;
clearInterval(this.timerInterval);
- this.step--;
- this.previousStep = this.instructions[this.step-2];
- this.currentStep = this.instructions[this.step-1];
- this.nextStep = this.instructions[this.step];
- this.timeLeft = this.timers[this.step-1];
+ this.stepNum--;
+ if(this.stepNum == 1) {
+ this.firstStep = true;
+ } else {
+ this.previousStep = this.steps[this.stepNum-2].getInstruction();
+ }
+ this.currentStep = this.steps[this.stepNum-1].getInstruction();
+ this.nextStep = this.steps[this.stepNum].getInstruction();
+ this.timeLeft = this.steps[this.stepNum-1].getTimer();
+ }
+
+ hasTimer(): boolean {
+ if(this.steps[this.stepNum - 1].getTimer() > 0)
+ return true;
+ else
+ return false;
}
startTimer(): void {
@@ -56,4 +91,3 @@ export class CookPageComponent implements OnInit {
}, 1000)
}
}
-
diff --git a/recipeBuddy/src/app/cook-page/step-card/step-card.component.css b/recipeBuddy/src/app/cook-page/step-card/step-card.component.css
deleted file mode 100644
index e69de29..0000000
--- a/recipeBuddy/src/app/cook-page/step-card/step-card.component.css
+++ /dev/null
diff --git a/recipeBuddy/src/app/cook-page/step-card/step-card.component.html b/recipeBuddy/src/app/cook-page/step-card/step-card.component.html
deleted file mode 100644
index c3edca3..0000000
--- a/recipeBuddy/src/app/cook-page/step-card/step-card.component.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>step-card works!</p>
diff --git a/recipeBuddy/src/app/cook-page/step-card/step-card.component.spec.ts b/recipeBuddy/src/app/cook-page/step-card/step-card.component.spec.ts
deleted file mode 100644
index 011bc44..0000000
--- a/recipeBuddy/src/app/cook-page/step-card/step-card.component.spec.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
-import { StepCardComponent } from './step-card.component';
-
-describe('StepCardComponent', () => {
- let component: StepCardComponent;
- let fixture: ComponentFixture<StepCardComponent>;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- declarations: [ StepCardComponent ]
- })
- .compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(StepCardComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/recipeBuddy/src/app/cook-page/step-card/step-card.component.ts b/recipeBuddy/src/app/cook-page/step-card/step-card.component.ts
deleted file mode 100644
index 6d490b7..0000000
--- a/recipeBuddy/src/app/cook-page/step-card/step-card.component.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Component } from '@angular/core';
-
-@Component({
- selector: 'step-card',
- templateUrl: 'step-card.component.html',
- styleUrls: ['step-card.component.css']
-})
-export class StepCardComponent{
-}