generated from mchirico/ts
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
11 changed files
with
195 additions
and
1 deletion.
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
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
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
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
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,14 @@ | ||
<h1 mat-dialog-title>{{data.name}}</h1> | ||
<div mat-dialog-content> | ||
|
||
<mat-form-field> | ||
<mat-label>Task Minutes</mat-label> | ||
<input matInput [(ngModel)]="data.minutes"> | ||
</mat-form-field> | ||
</div> | ||
|
||
<div mat-dialog-actions> | ||
<p>Ready to execute task?</p> | ||
<button mat-button (click)="onNoClick()">Cancel</button> | ||
<button mat-button [mat-dialog-close]="data.minutes" cdkFocusInitial>Execute</button> | ||
</div> |
Empty file.
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,19 @@ | ||
<p>pomodoro works!</p> | ||
|
||
<div> | ||
<mat-form-field> | ||
<mat-label>Task name?</mat-label> | ||
<input matInput [(ngModel)]="name"> | ||
</mat-form-field> | ||
</div> | ||
|
||
<div> | ||
<mat-form-field> | ||
<mat-label>Time in minutes</mat-label> | ||
<input matInput [(ngModel)]="minutes"> | ||
</mat-form-field> | ||
</div> | ||
|
||
<div> | ||
<button mat-raised-button (click)="openDialog()">Set</button> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
angular/src/app/navpages/pomodoro/pomodoro.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,25 @@ | ||
// import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
// | ||
// import { PomodoroComponent } from './pomodoro.component'; | ||
// | ||
// describe('PomodoroComponent', () => { | ||
// let component: PomodoroComponent; | ||
// let fixture: ComponentFixture<PomodoroComponent>; | ||
// | ||
// beforeEach(async(() => { | ||
// TestBed.configureTestingModule({ | ||
// declarations: [ PomodoroComponent ] | ||
// }) | ||
// .compileComponents(); | ||
// })); | ||
// | ||
// beforeEach(() => { | ||
// fixture = TestBed.createComponent(PomodoroComponent); | ||
// component = fixture.componentInstance; | ||
// fixture.detectChanges(); | ||
// }); | ||
// | ||
// it('should create', () => { | ||
// expect(component).toBeTruthy(); | ||
// }); | ||
// }); |
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,68 @@ | ||
import {Component, Inject, OnInit} from '@angular/core'; | ||
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog'; | ||
import {DataService, Data} from '../../service/firebase/pomodoro/data.service'; | ||
|
||
export interface DialogData { | ||
minutes: string; | ||
name: string; | ||
} | ||
|
||
|
||
@Component({ | ||
selector: 'app-pomodoro', | ||
templateUrl: './pomodoro.component.html', | ||
styleUrls: ['./pomodoro.component.css'] | ||
}) | ||
export class PomodoroComponent implements OnInit { | ||
name: string; | ||
minutes: string; | ||
data: Data = {date: '', id: 0, minutes: 0, name: '', timeStamp: undefined}; | ||
dataService: DataService; | ||
constructor(public dialog: MatDialog, dataService: DataService) { | ||
this.dataService = dataService; | ||
} | ||
openDialog(): void { | ||
const dialogRef = this.dialog.open(DialogComponent, { | ||
width: '250px', | ||
data: {name: this.name, minutes: this.minutes} | ||
}); | ||
|
||
dialogRef.afterClosed().subscribe(result => { | ||
console.log('The dialog was closed'); | ||
this.minutes = result; | ||
this.updateFirebase(); | ||
}); | ||
} | ||
|
||
updateFirebase(): void { | ||
|
||
const timeStamp = new Date(); | ||
this.data.name = this.name; | ||
this.data.minutes = parseInt(this.minutes, 10); | ||
this.data.timeStamp = timeStamp; | ||
this.data.date = timeStamp.toDateString(); | ||
this.dataService.addData(this.data); | ||
|
||
} | ||
|
||
|
||
ngOnInit(): void { | ||
} | ||
|
||
} | ||
|
||
@Component({ | ||
selector: 'app-dialog', | ||
templateUrl: './dialog-dialog.html', | ||
}) | ||
export class DialogComponent { | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<DialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) public data: DialogData) {} | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
angular/src/app/service/firebase/pomodoro/data.service.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,16 @@ | ||
// import { TestBed } from '@angular/core/testing'; | ||
// | ||
// import { DataService } from './data.service'; | ||
// | ||
// describe('DataService', () => { | ||
// let service: DataService; | ||
// | ||
// beforeEach(() => { | ||
// TestBed.configureTestingModule({}); | ||
// service = TestBed.inject(DataService); | ||
// }); | ||
// | ||
// it('should be created', () => { | ||
// expect(service).toBeTruthy(); | ||
// }); | ||
// }); |
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,44 @@ | ||
import { Injectable } from '@angular/core'; | ||
import {AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument} from '@angular/fire/firestore'; | ||
import {Observable} from 'rxjs'; | ||
import {Gmail} from '../../../firebase/data/data.component'; | ||
|
||
|
||
export interface Data { | ||
name: string; | ||
minutes: number; | ||
timeStamp: Date; | ||
id: number; | ||
date?: string; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DataService { | ||
data: Observable<Data>; | ||
now: Date; | ||
|
||
// private collection: AngularFirestoreCollection<Data>; | ||
private dataDoc: AngularFirestoreDocument<Data>; | ||
|
||
|
||
constructor(private afs: AngularFirestore) { | ||
// this.collection = afs.collection<Data>('pomodoro/mchirico/tasks') | ||
// this.data = this.collection.valueChanges(); | ||
// this.now = new Date(); | ||
|
||
this.dataDoc = afs.doc<Data>('pomodoro/mchirico/tasks/0'); | ||
this.data = this.dataDoc.valueChanges(); | ||
|
||
|
||
|
||
} | ||
addData(data: Data): void { | ||
|
||
this.dataDoc.set(data).catch(e => { | ||
console.log(e); | ||
}); | ||
|
||
} | ||
} |