Last active
May 13, 2018 14:51
-
-
Save chandermani/4d9ab6b62a53cd69a23dc294da242c6d to your computer and use it in GitHub Desktop.
Revisions
-
chandermani revised this gist
May 13, 2018 . 1 changed file with 37 additions and 35 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,49 +1,51 @@ import { CoreModule } from './core.module'; import { Injectable } from '@angular/core'; import { ExercisePlan } from '../workout-runner/model'; @Injectable({ providedIn: CoreModule }) export class WorkoutHistoryTrackerService { private maxHistoryItems = 20; // Tracking last 20 exercises private currentWorkoutLog: WorkoutLogEntry = null; private workoutHistory: Array<WorkoutLogEntry> = []; private workoutTracked: boolean; constructor() { } get tracking(): boolean { return this.workoutTracked; } startTracking() { this.workoutTracked = true; this.currentWorkoutLog = new WorkoutLogEntry(new Date()); if (this.workoutHistory.length >= this.maxHistoryItems) { this.workoutHistory.shift(); } this.workoutHistory.push(this.currentWorkoutLog); } exerciseComplete(exercise: ExercisePlan) { this.currentWorkoutLog.lastExercise = exercise.exercise.title; ++this.currentWorkoutLog.exercisesDone; } endTracking(completed: boolean) { this.currentWorkoutLog.completed = completed; this.currentWorkoutLog.endedOn = new Date(); this.currentWorkoutLog = null; this.workoutTracked = false; } getHistory(): Array<WorkoutLogEntry> { return this.workoutHistory; } } export class WorkoutLogEntry { constructor( public startedOn: Date, public completed: boolean = false, public exercisesDone: number = 0, public lastExercise?: string, public endedOn?: Date) { } } -
chandermani revised this gist
May 10, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ import { ExercisePlan } from '../workout-runner/model'; import { CoreModule } from './core.module'; @Injectable({ providedIn: CoreModule }) export class WorkoutHistoryTrackerService { private maxHistoryItems = 20; //Tracking last 20 exercises private currentWorkoutLog: WorkoutLogEntry = null; -
chandermani revised this gist
May 10, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ import { ExercisePlan } from '../workout-runner/model'; import { CoreModule } from './core.module'; export class WorkoutHistoryTrackerService { private maxHistoryItems = 20; //Tracking last 20 exercises private currentWorkoutLog: WorkoutLogEntry = null; -
chandermani created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ import { ExercisePlan } from '../workout-runner/model'; export class WorkoutHistoryTrackerService { private maxHistoryItems = 20; //Tracking last 20 exercises private currentWorkoutLog: WorkoutLogEntry = null; private workoutHistory: Array<WorkoutLogEntry> = []; private workoutTracked: boolean; constructor() { } get tracking(): boolean { return this.workoutTracked; } startTracking() { this.workoutTracked = true; this.currentWorkoutLog = new WorkoutLogEntry(new Date()); if (this.workoutHistory.length >= this.maxHistoryItems) { this.workoutHistory.shift(); } this.workoutHistory.push(this.currentWorkoutLog); } exerciseComplete(exercise: ExercisePlan) { this.currentWorkoutLog.lastExercise = exercise.exercise.title; ++this.currentWorkoutLog.exercisesDone; } endTracking(completed: boolean) { this.currentWorkoutLog.completed = completed; this.currentWorkoutLog.endedOn = new Date(); this.currentWorkoutLog = null; this.workoutTracked = false; }; getHistory(): Array<WorkoutLogEntry> { return this.workoutHistory; } } export class WorkoutLogEntry { constructor( public startedOn: Date, public completed: boolean = false, public exercisesDone: number = 0, public lastExercise?: string, public endedOn?: Date) { } }