From e1aa1342c24837d92d861446f96b21b3af1d5159 Mon Sep 17 00:00:00 2001 From: jgerstbe Date: Thu, 29 Oct 2020 18:27:33 +0100 Subject: [PATCH] [A] profile, channe-list, channel, dashboard, standup.service --- src/app/api/supabase/standup.service.spec.ts | 16 ++++++ src/app/api/supabase/standup.service.ts | 55 +++++++++++++++++++ src/app/api/supabase/standup.ts | 5 ++ src/app/app-routing.module.ts | 21 ++++++- src/app/app.component.html | 15 +++-- src/app/app.component.scss | 24 ++++++++ src/app/app.module.ts | 12 +++- .../channel-list/channel-list.component.html | 17 ++++++ .../channel-list/channel-list.component.scss | 22 ++++++++ .../channel-list.component.spec.ts | 25 +++++++++ .../channel-list/channel-list.component.ts | 29 ++++++++++ src/app/channel/channel.component.html | 1 + src/app/channel/channel.component.scss | 0 src/app/channel/channel.component.spec.ts | 25 +++++++++ src/app/channel/channel.component.ts | 15 +++++ src/app/dashboard/dashboard.component.html | 1 + src/app/dashboard/dashboard.component.scss | 0 src/app/dashboard/dashboard.component.spec.ts | 25 +++++++++ src/app/dashboard/dashboard.component.ts | 15 +++++ src/app/huddle/huddle.component.ts | 7 ++- src/app/profile/profile.component.html | 6 ++ src/app/profile/profile.component.scss | 0 src/app/profile/profile.component.spec.ts | 25 +++++++++ src/app/profile/profile.component.ts | 24 ++++++++ src/app/recorder/recorder.component.html | 19 ++++--- src/app/recorder/recorder.component.scss | 6 ++ src/styles.scss | 1 + 27 files changed, 393 insertions(+), 18 deletions(-) create mode 100644 src/app/api/supabase/standup.service.spec.ts create mode 100644 src/app/api/supabase/standup.service.ts create mode 100644 src/app/api/supabase/standup.ts create mode 100644 src/app/channel-list/channel-list.component.html create mode 100644 src/app/channel-list/channel-list.component.scss create mode 100644 src/app/channel-list/channel-list.component.spec.ts create mode 100644 src/app/channel-list/channel-list.component.ts create mode 100644 src/app/channel/channel.component.html create mode 100644 src/app/channel/channel.component.scss create mode 100644 src/app/channel/channel.component.spec.ts create mode 100644 src/app/channel/channel.component.ts create mode 100644 src/app/dashboard/dashboard.component.html create mode 100644 src/app/dashboard/dashboard.component.scss create mode 100644 src/app/dashboard/dashboard.component.spec.ts create mode 100644 src/app/dashboard/dashboard.component.ts create mode 100644 src/app/profile/profile.component.html create mode 100644 src/app/profile/profile.component.scss create mode 100644 src/app/profile/profile.component.spec.ts create mode 100644 src/app/profile/profile.component.ts diff --git a/src/app/api/supabase/standup.service.spec.ts b/src/app/api/supabase/standup.service.spec.ts new file mode 100644 index 0000000..2bcfc24 --- /dev/null +++ b/src/app/api/supabase/standup.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { StandupService } from './standup.service'; + +describe('StandupService', () => { + let service: StandupService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(StandupService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/api/supabase/standup.service.ts b/src/app/api/supabase/standup.service.ts new file mode 100644 index 0000000..f7953e0 --- /dev/null +++ b/src/app/api/supabase/standup.service.ts @@ -0,0 +1,55 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Observable } from 'rxjs'; +import { StandUp } from './standup'; +import { SupaService } from './supa.service'; + +@Injectable({ + providedIn: 'root' +}) +export class StandupService { + // standupMap: Map = new Map(); + standupMap = {}; + standups: BehaviorSubject = new BehaviorSubject([]); + + constructor( + private supa: SupaService, + ) { } + + getStandUps(): Observable { + if (Object.values(this.standupMap).length === 0) { + console.log('getStandUps - REFRESH') + return this.refreshStandUps(); + } else { + console.log('getStandUps - LOCAL') + return this.standups.asObservable(); + } + } + + refreshStandUps(): Observable { + this.supa.client.from('standup').select('id, name, description') + .then(standups => this.updateStore(standups.body)) + .catch(error => console.log('Error: ', error)); + return this.standups.asObservable(); + } + + updateStore(standups: StandUp[]) { + standups.forEach(e => { + // this.standupMap.set(e.id, e); + this.standupMap[e.id] = e; + }); + this.standups.next(Object.values(this.standupMap)); + } + + updateOne(standup: StandUp) { + + } + + deleteOne(standup: StandUp) { + + } + + addOne(standup: StandUp) { + + } + +} diff --git a/src/app/api/supabase/standup.ts b/src/app/api/supabase/standup.ts new file mode 100644 index 0000000..b6aa608 --- /dev/null +++ b/src/app/api/supabase/standup.ts @@ -0,0 +1,5 @@ +export class StandUp { + id: number; + name: string; + description: string; +} \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f6a49fa..2144629 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -6,12 +6,29 @@ import { HuddleComponent } from './huddle/huddle.component'; import { LoginComponent } from './login/login.component'; import { SignupComponent } from './signup/signup.component'; import { AuthGuard } from './authguard.service'; +import { ProfileComponent } from './profile/profile.component'; +import { DashboardComponent } from './dashboard/dashboard.component'; +import { ChannelComponent } from './channel/channel.component'; const routes: Routes = [ { - path: 'huddle', + path: 'huddle/:id', component: HuddleComponent, canActivate: [AuthGuard] + },{ + path: 'channel/:id', + component: ChannelComponent, + canActivate: [AuthGuard] + }, + { + path: 'profile', + component: ProfileComponent, + canActivate: [AuthGuard] + }, + { + path: 'home', + component: DashboardComponent, + canActivate: [AuthGuard] }, { path: 'login', @@ -21,7 +38,7 @@ const routes: Routes = [ path: 'signup', component: SignupComponent, }, - { path: '**', redirectTo: '/huddle', pathMatch: 'full' }, + { path: '**', redirectTo: '/home', pathMatch: 'full' }, ] @NgModule({ diff --git a/src/app/app.component.html b/src/app/app.component.html index 2bcf31b..5acaf4c 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,7 +1,14 @@ -