diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 658f838..ee80576 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -5,6 +5,7 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { KanbanModule } from './kanban/kanban.module'; import { TspInfoModule } from "./tsp-info/tsp-info.module"; +import { FunService } from "./shared/fun.service"; @NgModule({ declarations: [ @@ -16,7 +17,9 @@ import { TspInfoModule } from "./tsp-info/tsp-info.module"; KanbanModule, TspInfoModule, ], - providers: [], + providers: [ + FunService, + ], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/app/kanban/kanban-board/kanban-board.component.html b/src/app/kanban/kanban-board/kanban-board.component.html index 435b752..c85c07a 100644 --- a/src/app/kanban/kanban-board/kanban-board.component.html +++ b/src/app/kanban/kanban-board/kanban-board.component.html @@ -14,5 +14,10 @@
+ diff --git a/src/app/kanban/kanban-board/kanban-board.component.ts b/src/app/kanban/kanban-board/kanban-board.component.ts index 74921c8..44b3708 100644 --- a/src/app/kanban/kanban-board/kanban-board.component.ts +++ b/src/app/kanban/kanban-board/kanban-board.component.ts @@ -1,4 +1,4 @@ -import {Component, HostBinding, HostDecorator, HostListener, OnInit} from '@angular/core'; +import {Component, HostBinding, HostListener, OnDestroy, OnInit} from '@angular/core'; import {Title} from '@angular/platform-browser'; import {ActivatedRoute} from '@angular/router'; @@ -7,6 +7,12 @@ import { KanbanService, KanbanEntry, } from "../shared"; +import { + Fun, + FunService, +} from "../../shared"; +import {Subscription} from "rxjs/Subscription"; +import {TimerObservable} from "rxjs/observable/TimerObservable"; const WIP_LIMIT_INPROGRESS = 12; const WIP_LIMIT_VERIFICATION = 8; @@ -14,18 +20,24 @@ const WIP_LIMIT_VERIFICATION = 8; const STYLE_HIDDEN = 'hidden'; const STYLE_VISIBLE = 'scroll'; +const FUN_TIMER = 3000; + @Component({ selector: 'app-kanban-board', templateUrl: './kanban-board.component.html', styleUrls: ['./kanban-board.component.css'] }) -export class KanbanBoardComponent implements OnInit { +export class KanbanBoardComponent implements OnInit, OnDestroy { + + private funTimer: Subscription; @HostBinding('style.overflow') hostOverflow = STYLE_HIDDEN; + public showSomeFun: boolean = true; constructor(private titleService: Title, private route: ActivatedRoute, - private kanbanService: KanbanService) { + private kanbanService: KanbanService, + private funService: FunService) { } /** @@ -33,7 +45,27 @@ export class KanbanBoardComponent implements OnInit { */ ngOnInit() { this.titleService.setTitle('TaurusXFT : Kanban board'); - this.route.data.subscribe((data: { kanbanBoard: KanbanBoard }) => this.kanbanBoard = data.kanbanBoard); + this.route.data.subscribe((data: { + kanbanBoard: KanbanBoard, + fun: Fun, + }) => { + this.kanbanBoard = data.kanbanBoard; + this.fun = data.fun; + }); + + let timer0 = TimerObservable.create(FUN_TIMER, FUN_TIMER); + this.funTimer = timer0.subscribe(() => { + let now = new Date(); + if((now.getHours() == 10 && now.getMinutes() > 28) || (now.getHours() == 11 && now.getMinutes() < 30)) { + this.showSomeFun = true; + } else { + this.showSomeFun = false; + } + }); + } + + ngOnDestroy() { + this.funTimer.unsubscribe(); } get kanbanBoard(): KanbanBoard { @@ -44,6 +76,13 @@ export class KanbanBoardComponent implements OnInit { this.kanbanService.kanbanBoard = kanbanBoard; } + get fun(): Fun { + return this.funService.fun; + } + + set fun(fun: Fun) { + this.funService.fun = fun; + } get inprogressWipLimit(): number { return WIP_LIMIT_INPROGRESS; } diff --git a/src/app/kanban/kanban-routing.module.ts b/src/app/kanban/kanban-routing.module.ts index 21862f6..8b4263a 100644 --- a/src/app/kanban/kanban-routing.module.ts +++ b/src/app/kanban/kanban-routing.module.ts @@ -2,6 +2,7 @@ import {NgModule} from '@angular/core'; import {Routes, RouterModule} from '@angular/router'; import {KanbanBoardComponent} from "./kanban-board/kanban-board.component"; import {KanbanService} from "./shared/kanban.service"; +import {FunService} from "../shared/fun.service"; const routes: Routes = [ { @@ -10,6 +11,7 @@ const routes: Routes = [ component: KanbanBoardComponent, resolve: { kanbanBoard: KanbanService, + fun: FunService, }, } ]; diff --git a/src/app/kanban/kanban.module.ts b/src/app/kanban/kanban.module.ts index 1e9d2f8..cc1ae9d 100644 --- a/src/app/kanban/kanban.module.ts +++ b/src/app/kanban/kanban.module.ts @@ -11,12 +11,14 @@ import { ShortenTextPipe } from './shared/shorten-text.pipe'; import { SelfUpdaterService } from './shared/self-updater.service'; import { BlockedDaysPipe } from './shared/blocked-days.pipe'; import {KanbanRoutingModule} from "./kanban-routing.module"; +import {TspInfoModule} from "../tsp-info/tsp-info.module"; @NgModule({ imports: [ CommonModule, HttpModule, - KanbanRoutingModule + KanbanRoutingModule, + TspInfoModule ], declarations: [ KanbanBoardComponent, diff --git a/src/app/tsp-info/shared/anim-gif.model.ts b/src/app/shared/anim-gif.model.ts similarity index 100% rename from src/app/tsp-info/shared/anim-gif.model.ts rename to src/app/shared/anim-gif.model.ts diff --git a/src/app/shared/fun.model.ts b/src/app/shared/fun.model.ts new file mode 100644 index 0000000..31e58a2 --- /dev/null +++ b/src/app/shared/fun.model.ts @@ -0,0 +1,6 @@ +import {AnimGif} from "./anim-gif.model"; + +export class Fun { + public cameraUrls: Array = []; + public animGifs: Array = []; +} diff --git a/src/app/shared/fun.service.spec.ts b/src/app/shared/fun.service.spec.ts new file mode 100644 index 0000000..2995898 --- /dev/null +++ b/src/app/shared/fun.service.spec.ts @@ -0,0 +1,15 @@ +import { TestBed, inject } from '@angular/core/testing'; + +import { FunService } from './fun.service'; + +describe('FunService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [FunService] + }); + }); + + it('should be created', inject([FunService], (service: FunService) => { + expect(service).toBeTruthy(); + })); +}); diff --git a/src/app/shared/fun.service.ts b/src/app/shared/fun.service.ts new file mode 100644 index 0000000..0734fd1 --- /dev/null +++ b/src/app/shared/fun.service.ts @@ -0,0 +1,53 @@ +import {Injectable} from '@angular/core'; +import {Http, Headers} from "@angular/http"; +import 'rxjs/Rx'; +import {Router, Resolve, ActivatedRouteSnapshot} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; + +import {environment} from '../../environments/environment'; +import {Fun} from "./fun.model"; + +@Injectable() +export class FunService { + private url = environment.apiUri + '/api/want-some-fun'; + + private cachedFun: Fun = new Fun(); + + constructor(private httpService: Http) { + } + + /** + * Returns an observable instance to the kanban board api + * + * @returns {Observable} + */ + public getList(): Observable { + return this.httpService.get(this.url).map(res => res.json()); + } + + /** + * Route preload resolver + * + * @param {ActivatedRouteSnapshot} route + * @returns {Promise} + */ + public resolve(route: ActivatedRouteSnapshot): Promise { + return this.getList().toPromise().then(result => result ? result : false); + } + + /** + * Reload the board + */ + public reload() { + this.getList().subscribe(result => this.cachedFun = result); + } + + get fun(): Fun { + return this.cachedFun; + } + + set fun(fun: Fun) { + this.cachedFun = fun; + } + +} diff --git a/src/app/shared/index.ts b/src/app/shared/index.ts new file mode 100644 index 0000000..3e3cee6 --- /dev/null +++ b/src/app/shared/index.ts @@ -0,0 +1,4 @@ +export * from './anim-gif.model'; +export * from './fun.model'; + +export * from './fun.service'; diff --git a/src/app/tsp-info/animgif/animgif.component.css b/src/app/tsp-info/animgif/animgif.component.css index f58749a..f3b6776 100644 --- a/src/app/tsp-info/animgif/animgif.component.css +++ b/src/app/tsp-info/animgif/animgif.component.css @@ -1,3 +1,13 @@ +:host(.kanban-view) { + position: absolute; + z-index: 100; + bottom: 0; + right: 0; + background-color: rgba(0,41,94,0.95); + width: 480px; + height: 500px; +} + .widget.camera { padding: 0; } diff --git a/src/app/tsp-info/animgif/animgif.component.ts b/src/app/tsp-info/animgif/animgif.component.ts index 7807dad..3d92881 100644 --- a/src/app/tsp-info/animgif/animgif.component.ts +++ b/src/app/tsp-info/animgif/animgif.component.ts @@ -1,6 +1,6 @@ import {Component, Input, OnDestroy, OnInit} from '@angular/core'; import {InfoBoxComponent} from "../info-box/info-box.component"; -import {AnimGif} from "../shared/anim-gif.model"; +import {AnimGif} from "../../shared/anim-gif.model"; // import gifyParse from "gify-parse/gify-parse"; diff --git a/src/app/tsp-info/info-page/info-page.component.html b/src/app/tsp-info/info-page/info-page.component.html index a36e504..8387feb 100644 --- a/src/app/tsp-info/info-page/info-page.component.html +++ b/src/app/tsp-info/info-page/info-page.component.html @@ -17,6 +17,6 @@ + [data]="fun.animGifs" + [cameraUrls]="fun.cameraUrls">

diff --git a/src/app/tsp-info/info-page/info-page.component.ts b/src/app/tsp-info/info-page/info-page.component.ts index 7159838..2428a3d 100644 --- a/src/app/tsp-info/info-page/info-page.component.ts +++ b/src/app/tsp-info/info-page/info-page.component.ts @@ -6,6 +6,8 @@ import { TspInfo, TspInfoService, } from "../shared"; +import {FunService} from "../../shared/fun.service"; +import {Fun} from "../../shared/fun.model"; @Component({ selector: 'app-info-page', @@ -16,12 +18,19 @@ export class InfoPageComponent implements OnInit { constructor(private titleService: Title, private route: ActivatedRoute, - private tspInfoService: TspInfoService) { + private tspInfoService: TspInfoService, + private funService: FunService) { } ngOnInit() { this.titleService.setTitle('TaurusXFT : TSP INFO'); - this.route.data.subscribe((data: { tspInfo: TspInfo }) => this.tspInfo = data.tspInfo); + this.route.data.subscribe((data: { + tspInfo: TspInfo, + fun: Fun + }) => { + this.tspInfo = data.tspInfo; + this.fun = data.fun; + }); } get tspInfo(): TspInfo { @@ -31,4 +40,12 @@ export class InfoPageComponent implements OnInit { set tspInfo(tspInfo: TspInfo) { this.tspInfoService.tspInfo = tspInfo; } + + get fun(): Fun { + return this.funService.fun; + } + + set fun(fun: Fun) { + this.funService.fun = fun; + } } diff --git a/src/app/tsp-info/shared/index.ts b/src/app/tsp-info/shared/index.ts index 448105c..e375372 100644 --- a/src/app/tsp-info/shared/index.ts +++ b/src/app/tsp-info/shared/index.ts @@ -1,4 +1,3 @@ -export * from './anim-gif.model'; export * from './expedite-info.model'; export * from './lab-temperature.model'; export * from './tr-flow-error.model'; diff --git a/src/app/tsp-info/shared/tsp-info.model.ts b/src/app/tsp-info/shared/tsp-info.model.ts index e31add0..cdee451 100644 --- a/src/app/tsp-info/shared/tsp-info.model.ts +++ b/src/app/tsp-info/shared/tsp-info.model.ts @@ -1,5 +1,4 @@ import { - AnimGif, ExpediteInfo, LabTemperature, PrioValues, @@ -9,8 +8,6 @@ import { export class TspInfo { - public cameraUrls: Array = []; - public animGifs: Array = []; public praGoals: { core: PrioValues, sig: PrioValues, diff --git a/src/app/tsp-info/tsp-info-routing.module.ts b/src/app/tsp-info/tsp-info-routing.module.ts index 5681a67..a707103 100644 --- a/src/app/tsp-info/tsp-info-routing.module.ts +++ b/src/app/tsp-info/tsp-info-routing.module.ts @@ -2,6 +2,7 @@ import {NgModule} from '@angular/core'; import {Routes, RouterModule} from '@angular/router'; import {InfoPageComponent} from "./info-page/info-page.component"; import {TspInfoService} from "./shared/tsp-info.service"; +import {FunService} from "../shared/fun.service"; const routes: Routes = [ { @@ -10,6 +11,7 @@ const routes: Routes = [ component: InfoPageComponent, resolve: { tspInfo: TspInfoService, + fun: FunService, }, } ]; diff --git a/src/app/tsp-info/tsp-info.module.ts b/src/app/tsp-info/tsp-info.module.ts index 6f64a0a..b70f537 100644 --- a/src/app/tsp-info/tsp-info.module.ts +++ b/src/app/tsp-info/tsp-info.module.ts @@ -18,6 +18,9 @@ import {HttpModule} from "@angular/http"; HttpModule, TspInfoRoutingModule ], + exports:[ + AnimgifComponent, + ], declarations: [ InfoBoxComponent, TrProgressComponent,