summaryrefslogtreecommitdiff
path: root/recipeBuddy/src/app/cook-page/cook-page.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'recipeBuddy/src/app/cook-page/cook-page.component.ts')
-rw-r--r--recipeBuddy/src/app/cook-page/cook-page.component.ts30
1 files changed, 23 insertions, 7 deletions
diff --git a/recipeBuddy/src/app/cook-page/cook-page.component.ts b/recipeBuddy/src/app/cook-page/cook-page.component.ts
index a3a1dfe..fea2611 100644
--- a/recipeBuddy/src/app/cook-page/cook-page.component.ts
+++ b/recipeBuddy/src/app/cook-page/cook-page.component.ts
@@ -1,7 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {Recipe} from '../DataModels/recipe';
import {Step} from '../DataModels/step';
-import {RecipePassService} from '../recipePass/recipe-pass.service'
+import {RecipePassService} from '../recipePass/recipe-pass.service';
@Component({
selector: 'app-cook-page',
@@ -9,8 +9,10 @@ import {RecipePassService} from '../recipePass/recipe-pass.service'
styleUrls: ['./cook-page.component.css']
})
export class CookPageComponent implements OnInit {
+ recipe:Recipe;
steps: Step[];
stepNum: number;
+ name: string;
firstStep: boolean = true;
lastStep: boolean = false;
@@ -33,9 +35,10 @@ export class CookPageComponent implements OnInit {
constructor(private recipePass: RecipePassService){}
ngOnInit() {
- var recipe: Recipe = this.recipePass.getRecipe();
- this.steps = recipe.steps;
- this.servingSize = recipe.servingSize;
+ this.recipe = this.recipePass.getRecipe();
+ this.name = this.recipe.name;
+ this.steps = this.recipe.steps;
+ this.servingSize = this.recipe.servingSize;
this.stepNum = 1;
this.currentStep = this.steps[this.stepNum-1].instruction;
if(this.steps.length > 1)
@@ -43,7 +46,7 @@ export class CookPageComponent implements OnInit {
else
this.lastStep = true;
- this.timeLeft = this.steps[this.stepNum-1].timer;
+ this.timeLeft = this.steps[this.stepNum-1].timer*60;
this.timeHoursFirst = Math.floor(this.timeLeft/3600/10);
this.timeHoursSecond = Math.floor(this.timeLeft/3600%10);
this.timeMinutesFirst = Math.floor(this.timeLeft%3600/60/10);
@@ -63,7 +66,13 @@ export class CookPageComponent implements OnInit {
}
this.previousStep = this.steps[this.stepNum-2].instruction;
this.currentStep = this.steps[this.stepNum-1].instruction;
- this.timeLeft = this.steps[this.stepNum-1].timer;
+ this.timeLeft = this.steps[this.stepNum-1].timer*60;
+ this.timeHoursFirst = Math.floor(this.timeLeft/3600/10);
+ this.timeHoursSecond = Math.floor(this.timeLeft/3600%10);
+ this.timeMinutesFirst = Math.floor(this.timeLeft%3600/60/10);
+ this.timeMinutesSecond = Math.floor(this.timeLeft%3600/60%10);
+ this.timeSecondsFirst = Math.floor(this.timeLeft%3600%60/10);
+ this.timeSecondsSecond = Math.floor(this.timeLeft%3600%60%10);
}
previous(): void {
@@ -77,7 +86,13 @@ export class CookPageComponent implements OnInit {
}
this.currentStep = this.steps[this.stepNum-1].instruction;
this.nextStep = this.steps[this.stepNum].instruction;
- this.timeLeft = this.steps[this.stepNum-1].timer;
+ this.timeLeft = this.steps[this.stepNum-1].timer*60;
+ this.timeHoursFirst = Math.floor(this.timeLeft/3600/10);
+ this.timeHoursSecond = Math.floor(this.timeLeft/3600%10);
+ this.timeMinutesFirst = Math.floor(this.timeLeft%3600/60/10);
+ this.timeMinutesSecond = Math.floor(this.timeLeft%3600/60%10);
+ this.timeSecondsFirst = Math.floor(this.timeLeft%3600%60/10);
+ this.timeSecondsSecond = Math.floor(this.timeLeft%3600%60%10);
}
hasTimer(): boolean {
@@ -91,6 +106,7 @@ export class CookPageComponent implements OnInit {
console.log("timerStarted");
this.timerInterval = setInterval(() => {
if(this.timeLeft > 0) {
+ this.timeLeft--;
this.timeHoursFirst = Math.floor(this.timeLeft/3600/10);
this.timeHoursSecond = Math.floor(this.timeLeft/3600%10);
this.timeMinutesFirst = Math.floor(this.timeLeft%3600/60/10);