diff --git a/.gitignore b/.gitignore index 86d943a..e841990 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. # compiled output -/dist /tmp /out-tsc # Only exists if Bazel was run diff --git a/package-lock.json b/package-lock.json index dd01868..c23fb00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1270,9 +1270,9 @@ "dev": true }, "@types/node": { - "version": "8.9.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.5.tgz", - "integrity": "sha512-jRHfWsvyMtXdbhnz5CVHxaBgnV6duZnPlQuRSo/dm/GnmikNcmZhxIES4E9OZjUmQ8C+HCl4KJux+cXN/ErGDQ==", + "version": "8.10.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.60.tgz", + "integrity": "sha512-YjPbypHFuiOV0bTgeF07HpEEqhmHaZqYNSdCKeBJa+yFoQ/7BC+FpJcwmi34xUIIRVFktnUyP1dPU8U0612GOg==", "dev": true }, "@types/q": { diff --git a/package.json b/package.json index 0db12f7..b0b3e56 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "node server.js", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, + "engines":{"node":"8.12.0","npm":"6.4.1"}, "private": true, "dependencies": { "@angular/animations": "~8.2.0", @@ -28,9 +29,9 @@ "@angular/cli": "~8.2.2", "@angular/compiler-cli": "~8.2.0", "@angular/language-service": "~8.2.0", - "@types/node": "~8.9.4", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", + "@types/node": "^8.10.60", "codelyzer": "^5.0.0", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", diff --git a/server.js b/server.js new file mode 100644 index 0000000..bec4383 --- /dev/null +++ b/server.js @@ -0,0 +1,16 @@ +//Install express server +const express = require('express'); +const path = require('path'); + +const app = express(); + +// Serve only the static files form the dist directory +app.use(express.static('./dist/{{your-app-name}}')); + +app.get('/*', function(req,res) { + +res.sendFile(path.join(__dirname,'/dist/{{your-app-name}}/index.html')); +}); + +// Start the app by listening on the default Heroku port +app.listen(process.env.PORT || 8080); \ No newline at end of file diff --git a/src/app/app.component.html b/src/app/app.component.html index 5226d57..3d590de 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,20 +1 @@ - -
-

- Welcome to {{ title }}! -

- Angular Logo -
-

Here are some links to help you start:

- - +
\ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f657163..2051b30 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,16 +1,25 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; +import {ReactiveFormsModule, FormsModule} from '@angular/forms' import { AppComponent } from './app.component'; +import { MainComponent } from './components/main/main.component'; +import { CardComponent } from './components/card/card.component'; @NgModule({ declarations: [ - AppComponent + AppComponent, + MainComponent, + CardComponent, ], imports: [ - BrowserModule + BrowserModule, + ReactiveFormsModule, + FormsModule ], providers: [], bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule { + +} diff --git a/src/app/components/card/card.component.css b/src/app/components/card/card.component.css new file mode 100644 index 0000000..ffd532c --- /dev/null +++ b/src/app/components/card/card.component.css @@ -0,0 +1,3 @@ +.margins { + margin: 12px; +} \ No newline at end of file diff --git a/src/app/components/card/card.component.html b/src/app/components/card/card.component.html new file mode 100644 index 0000000..9b36f78 --- /dev/null +++ b/src/app/components/card/card.component.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/app/components/card/card.component.spec.ts b/src/app/components/card/card.component.spec.ts new file mode 100644 index 0000000..e141708 --- /dev/null +++ b/src/app/components/card/card.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CardComponent } from './card.component'; + +describe('CardComponent', () => { + let component: CardComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CardComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/card/card.component.ts b/src/app/components/card/card.component.ts new file mode 100644 index 0000000..9491c46 --- /dev/null +++ b/src/app/components/card/card.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit, Input, Output, SimpleChanges, ChangeDetectorRef } from '@angular/core'; +import { EventEmitter } from '@angular/core'; + +@Component({ + selector: 'card', + templateUrl: './card.component.html', + styleUrls: ['./card.component.css'] +}) +export class CardComponent implements OnInit { + @Input() public number; + @Input() public suit; + public fileString: string; + @Output() cardEmitter: EventEmitter = new EventEmitter(); + constructor(private changeDetector: ChangeDetectorRef) { } + + ngOnInit() { + console.log(this.number); + if (this.number < 10) { + this.fileString = this.suit + '0' + this.number; + } if (this.number >= 10) { + this.fileString = this.suit + this.number; + } + } + + ngOnChanges(changes: SimpleChanges): void { + //Called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here. + //Add '${implements OnChanges}' to the class. + this.ngOnInit(); + this.changeDetector.detectChanges(); + + } + +} diff --git a/src/app/components/main/exercises.json b/src/app/components/main/exercises.json new file mode 100644 index 0000000..4d8a1ee --- /dev/null +++ b/src/app/components/main/exercises.json @@ -0,0 +1,26 @@ +{ + "c": [ + "Pull Up", + "Table/Desk Inverted Row", + "Rear Delt Fly (Dumbbell or Milk Jug", + "Upright Row (Backpack or Milk Jug)" + ], + "d": [ + "Bicep Curl", + "Skullcrushers (on a table) or Close Grip Pus-Ups", + "Bicycle Crunch or Reverse Crunch", + "Standing Calf Raise" + ], + "h": [ + "Walking Lunge (Dumbbell or backpack to load)", + "Bulgarian Split Squat", + "Single Leg Hip Thrust", + "Nordic Ham Curl" + ], + "s": [ + "Push-Up or Incline Push-Up", + "Pike Push-Up or Vertical Push-Up", + "Standing Press (Milk jug or dumbbells)", + "Milk Jug Lateral Raise or Doorway Lateral Raise (for time)" + ] +} \ No newline at end of file diff --git a/src/app/components/main/main.component.css b/src/app/components/main/main.component.css new file mode 100644 index 0000000..887c9a1 --- /dev/null +++ b/src/app/components/main/main.component.css @@ -0,0 +1,16 @@ +.container { + margin-top: 2em; +} + +.alert { + text-align: center; +} + +.center { + display: flex; + justify-content: center; +} +.sticky-card { + max-height: 50%; + width: 100%; +} \ No newline at end of file diff --git a/src/app/components/main/main.component.html b/src/app/components/main/main.component.html new file mode 100644 index 0000000..3abcfb9 --- /dev/null +++ b/src/app/components/main/main.component.html @@ -0,0 +1,63 @@ +
+
+
+
+
+ Card Workout! +
+
+
+ + +
+ + +
+
+
+
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+
+
+
{{exercise}}
+

{{reps}} reps

+
+
+
+
+
\ No newline at end of file diff --git a/src/app/components/main/main.component.spec.ts b/src/app/components/main/main.component.spec.ts new file mode 100644 index 0000000..0878044 --- /dev/null +++ b/src/app/components/main/main.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MainComponent } from './main.component'; + +describe('MainComponent', () => { + let component: MainComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MainComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MainComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/main/main.component.ts b/src/app/components/main/main.component.ts new file mode 100644 index 0000000..9acaeec --- /dev/null +++ b/src/app/components/main/main.component.ts @@ -0,0 +1,130 @@ +import { Component, OnInit, ChangeDetectorRef } from '@angular/core'; + +@Component({ + selector: 'main', + templateUrl: './main.component.html', + styleUrls: ['./main.component.css'] +}) +export class MainComponent implements OnInit { + public deck; + public numCards: number = 20; + public showCards: boolean; + public workoutDeck: any; + public previousCardNumber: number = -1; + public currentCardNumber: number = 0; + public defaultCardNumber: number = 20; + public suits = ['s', 'd', 'c', 'h']; + public values = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13']; + + public reps: number; + public rest: boolean; + public exercise: any; + public exercisesJson = require('./exercises.json'); + + public cCounter: number = 0; + public dCounter: number = 0; + public hCounter: number = 0; + public sCounter: number = 0; + + constructor(private changeDetector: ChangeDetectorRef) { } + + public ngOnInit() { + this.deck = this.createDeck(); + this.shuffleDeck(this.deck); + } + + public createCards(): void { + this.showCards = true; + this.workoutDeck = this.deck.slice(0,this.numCards); + this.displayExercise(); + } + + public resetCards(): void { + this.showCards = false; + this.deck = undefined; + this.deck = this.createDeck(); + this.shuffleDeck(this.deck); + this.workoutDeck = this.deck.slice(0,this.numCards); + this.showCards = true; + this.reps = undefined; + this.rest = false; + this.exercise = undefined; + this.currentCardNumber = 0; + this.previousCardNumber = -1; + } + + public createDeck() { + let deck = new Array(); + let card; + for(let i=0; i < this.suits.length; i++) { + for(let n=0; n < this.values.length; n++) { + card = {value: this.values[n], suit: this.suits[i]}; + deck.push(card); + } + } + return deck; + } + + public shuffleDeck(deck) { + let location1; + let location2; + let temp; + for(let i = 0; i < 2000; i++) { + location1 = Math.floor((Math.random() * deck.length)); + location2 = Math.floor((Math.random() * deck.length)); + temp = deck[location1]; + + deck[location1] = deck[location2]; + deck[location2] = temp; + } + } + + public displayExercise() { + const currentCard = this.workoutDeck[this.currentCardNumber] + console.log(currentCard); + if (currentCard.value !== 1) { + this.rest = undefined + this.reps = Number(currentCard.value)+10; + + if (currentCard.suit === 'c') { + this.exercise = this.exercisesJson.c[this.cCounter]; + this.cCounter += 1; + } else if (currentCard.suit === 'd') { + this.exercise = this.exercisesJson.d[this.dCounter]; + this.dCounter += 1; + } else if (currentCard.suit === 'h') { + this.exercise = this.exercisesJson.h[this.hCounter]; + this.hCounter += 1; + } else if (currentCard.suit === 's') { + this.exercise = this.exercisesJson.s[this.sCounter]; + this.sCounter += 1; + } + + if (this.cCounter > 3) { + this.cCounter = 0; + } else if (this.dCounter > 3) { + this.dCounter = 0; + } else if (this.hCounter > 3) { + this.hCounter = 0; + } else if (this.sCounter > 3) { + this.sCounter = 0; + } + } else { + this.exercise = undefined; + this.reps = undefined; + this.rest = true; + } + } + + public incrementCardCounter() { + this.displayExercise(); + this.currentCardNumber += 1; + this.previousCardNumber += 1; + } + + public decrementCardCounter() { + this.displayExercise() + this.currentCardNumber -= 1; + this.previousCardNumber -= 1; + } +} diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/assets/back.png b/src/assets/back.png new file mode 100644 index 0000000..3ab66fd Binary files /dev/null and b/src/assets/back.png differ diff --git a/src/assets/c01.png b/src/assets/c01.png new file mode 100644 index 0000000..c763165 Binary files /dev/null and b/src/assets/c01.png differ diff --git a/src/assets/c02.png b/src/assets/c02.png new file mode 100644 index 0000000..6e6a38c Binary files /dev/null and b/src/assets/c02.png differ diff --git a/src/assets/c03.png b/src/assets/c03.png new file mode 100644 index 0000000..746f195 Binary files /dev/null and b/src/assets/c03.png differ diff --git a/src/assets/c04.png b/src/assets/c04.png new file mode 100644 index 0000000..920a1f4 Binary files /dev/null and b/src/assets/c04.png differ diff --git a/src/assets/c05.png b/src/assets/c05.png new file mode 100644 index 0000000..75dced2 Binary files /dev/null and b/src/assets/c05.png differ diff --git a/src/assets/c06.png b/src/assets/c06.png new file mode 100644 index 0000000..1eb8764 Binary files /dev/null and b/src/assets/c06.png differ diff --git a/src/assets/c07.png b/src/assets/c07.png new file mode 100644 index 0000000..4765fba Binary files /dev/null and b/src/assets/c07.png differ diff --git a/src/assets/c08.png b/src/assets/c08.png new file mode 100644 index 0000000..f6b713a Binary files /dev/null and b/src/assets/c08.png differ diff --git a/src/assets/c09.png b/src/assets/c09.png new file mode 100644 index 0000000..b1aa60d Binary files /dev/null and b/src/assets/c09.png differ diff --git a/src/assets/c10.png b/src/assets/c10.png new file mode 100644 index 0000000..2ee820e Binary files /dev/null and b/src/assets/c10.png differ diff --git a/src/assets/c11.png b/src/assets/c11.png new file mode 100644 index 0000000..00daa6c Binary files /dev/null and b/src/assets/c11.png differ diff --git a/src/assets/c12.png b/src/assets/c12.png new file mode 100644 index 0000000..8de5063 Binary files /dev/null and b/src/assets/c12.png differ diff --git a/src/assets/c13.png b/src/assets/c13.png new file mode 100644 index 0000000..34158ef Binary files /dev/null and b/src/assets/c13.png differ diff --git a/src/assets/d01.png b/src/assets/d01.png new file mode 100644 index 0000000..8be6e52 Binary files /dev/null and b/src/assets/d01.png differ diff --git a/src/assets/d02.png b/src/assets/d02.png new file mode 100644 index 0000000..45c6fa0 Binary files /dev/null and b/src/assets/d02.png differ diff --git a/src/assets/d03.png b/src/assets/d03.png new file mode 100644 index 0000000..8547a6e Binary files /dev/null and b/src/assets/d03.png differ diff --git a/src/assets/d04.png b/src/assets/d04.png new file mode 100644 index 0000000..4c751f9 Binary files /dev/null and b/src/assets/d04.png differ diff --git a/src/assets/d05.png b/src/assets/d05.png new file mode 100644 index 0000000..adf5b8e Binary files /dev/null and b/src/assets/d05.png differ diff --git a/src/assets/d06.png b/src/assets/d06.png new file mode 100644 index 0000000..4a9c88d Binary files /dev/null and b/src/assets/d06.png differ diff --git a/src/assets/d07.png b/src/assets/d07.png new file mode 100644 index 0000000..742fb80 Binary files /dev/null and b/src/assets/d07.png differ diff --git a/src/assets/d08.png b/src/assets/d08.png new file mode 100644 index 0000000..931429b Binary files /dev/null and b/src/assets/d08.png differ diff --git a/src/assets/d09.png b/src/assets/d09.png new file mode 100644 index 0000000..3e24e38 Binary files /dev/null and b/src/assets/d09.png differ diff --git a/src/assets/d10.png b/src/assets/d10.png new file mode 100644 index 0000000..b08b078 Binary files /dev/null and b/src/assets/d10.png differ diff --git a/src/assets/d11.png b/src/assets/d11.png new file mode 100644 index 0000000..26f1de5 Binary files /dev/null and b/src/assets/d11.png differ diff --git a/src/assets/d12.png b/src/assets/d12.png new file mode 100644 index 0000000..b8511ed Binary files /dev/null and b/src/assets/d12.png differ diff --git a/src/assets/d13.png b/src/assets/d13.png new file mode 100644 index 0000000..ae46388 Binary files /dev/null and b/src/assets/d13.png differ diff --git a/src/assets/h01.png b/src/assets/h01.png new file mode 100644 index 0000000..db51f28 Binary files /dev/null and b/src/assets/h01.png differ diff --git a/src/assets/h02.png b/src/assets/h02.png new file mode 100644 index 0000000..0c0509a Binary files /dev/null and b/src/assets/h02.png differ diff --git a/src/assets/h03.png b/src/assets/h03.png new file mode 100644 index 0000000..8d07ad6 Binary files /dev/null and b/src/assets/h03.png differ diff --git a/src/assets/h04.png b/src/assets/h04.png new file mode 100644 index 0000000..72853b4 Binary files /dev/null and b/src/assets/h04.png differ diff --git a/src/assets/h05.png b/src/assets/h05.png new file mode 100644 index 0000000..8883b8c Binary files /dev/null and b/src/assets/h05.png differ diff --git a/src/assets/h06.png b/src/assets/h06.png new file mode 100644 index 0000000..0a68d76 Binary files /dev/null and b/src/assets/h06.png differ diff --git a/src/assets/h07.png b/src/assets/h07.png new file mode 100644 index 0000000..7a45161 Binary files /dev/null and b/src/assets/h07.png differ diff --git a/src/assets/h08.png b/src/assets/h08.png new file mode 100644 index 0000000..2551bda Binary files /dev/null and b/src/assets/h08.png differ diff --git a/src/assets/h09.png b/src/assets/h09.png new file mode 100644 index 0000000..2feffc4 Binary files /dev/null and b/src/assets/h09.png differ diff --git a/src/assets/h10.png b/src/assets/h10.png new file mode 100644 index 0000000..9c9e526 Binary files /dev/null and b/src/assets/h10.png differ diff --git a/src/assets/h11.png b/src/assets/h11.png new file mode 100644 index 0000000..3609495 Binary files /dev/null and b/src/assets/h11.png differ diff --git a/src/assets/h12.png b/src/assets/h12.png new file mode 100644 index 0000000..21682b9 Binary files /dev/null and b/src/assets/h12.png differ diff --git a/src/assets/h13.png b/src/assets/h13.png new file mode 100644 index 0000000..2bb8fde Binary files /dev/null and b/src/assets/h13.png differ diff --git a/src/assets/s01.png b/src/assets/s01.png new file mode 100644 index 0000000..02adb14 Binary files /dev/null and b/src/assets/s01.png differ diff --git a/src/assets/s02.png b/src/assets/s02.png new file mode 100644 index 0000000..4979e43 Binary files /dev/null and b/src/assets/s02.png differ diff --git a/src/assets/s03.png b/src/assets/s03.png new file mode 100644 index 0000000..f4f33a4 Binary files /dev/null and b/src/assets/s03.png differ diff --git a/src/assets/s04.png b/src/assets/s04.png new file mode 100644 index 0000000..6337f61 Binary files /dev/null and b/src/assets/s04.png differ diff --git a/src/assets/s05.png b/src/assets/s05.png new file mode 100644 index 0000000..e673f7d Binary files /dev/null and b/src/assets/s05.png differ diff --git a/src/assets/s06.png b/src/assets/s06.png new file mode 100644 index 0000000..ea34253 Binary files /dev/null and b/src/assets/s06.png differ diff --git a/src/assets/s07.png b/src/assets/s07.png new file mode 100644 index 0000000..e9562e2 Binary files /dev/null and b/src/assets/s07.png differ diff --git a/src/assets/s08.png b/src/assets/s08.png new file mode 100644 index 0000000..a31de42 Binary files /dev/null and b/src/assets/s08.png differ diff --git a/src/assets/s09.png b/src/assets/s09.png new file mode 100644 index 0000000..d475f16 Binary files /dev/null and b/src/assets/s09.png differ diff --git a/src/assets/s10.png b/src/assets/s10.png new file mode 100644 index 0000000..1f6192b Binary files /dev/null and b/src/assets/s10.png differ diff --git a/src/assets/s11.png b/src/assets/s11.png new file mode 100644 index 0000000..cb9ae17 Binary files /dev/null and b/src/assets/s11.png differ diff --git a/src/assets/s12.png b/src/assets/s12.png new file mode 100644 index 0000000..388e584 Binary files /dev/null and b/src/assets/s12.png differ diff --git a/src/assets/s13.png b/src/assets/s13.png new file mode 100644 index 0000000..df4ced7 Binary files /dev/null and b/src/assets/s13.png differ diff --git a/src/index.html b/src/index.html index c2d0eec..5c15869 100644 --- a/src/index.html +++ b/src/index.html @@ -1,14 +1,28 @@ - - - CardWorkout - - - + + + + + + + CardWorkout + + + + + - + - + + \ No newline at end of file diff --git a/tsconfig.app.json b/tsconfig.app.json index 565a11a..1dd4511 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -2,7 +2,8 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/app", - "types": [] + "types": ["node"], + "typeRoots": ["../node_modules/@types"] }, "files": [ "src/main.ts",