* funService created to share animgifs and cameraurl between the two modules

* funService is provider for both modules
* animgifs are still TBD, camera is visible in kanbanview between 11:30-12:30
This commit is contained in:
Dávid Danyi 2017-09-08 17:54:50 +02:00
parent d37a6f68c6
commit 6494c5c75c
18 changed files with 172 additions and 15 deletions

View File

@ -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 { }

View File

@ -14,5 +14,10 @@
<div app-kanban-entry-item class="four wide column"
rowHeading="DÖNER"
[kanbanEntries]="kanbanBoard.done"></div>
<app-animgif *ngIf="showSomeFun"
class="kanban-view"
title="ANIMATED IMPORTANCE"
[data]="fun.animGifs"
[cameraUrls]="fun.cameraUrls"></app-animgif>
</div>
</div>

View File

@ -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;
}

View File

@ -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,
},
}
];

View File

@ -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,

View File

@ -0,0 +1,6 @@
import {AnimGif} from "./anim-gif.model";
export class Fun {
public cameraUrls: Array<string> = [];
public animGifs: Array<AnimGif> = [];
}

View File

@ -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();
}));
});

View File

@ -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<Fun>}
*/
public getList(): Observable<Fun> {
return this.httpService.get(this.url).map(res => <Fun>res.json());
}
/**
* Route preload resolver
*
* @param {ActivatedRouteSnapshot} route
* @returns {Promise<Fun>}
*/
public resolve(route: ActivatedRouteSnapshot): Promise<Fun> {
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;
}
}

4
src/app/shared/index.ts Normal file
View File

@ -0,0 +1,4 @@
export * from './anim-gif.model';
export * from './fun.model';
export * from './fun.service';

View File

@ -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;
}

View File

@ -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";

View File

@ -17,6 +17,6 @@
<app-animgif
class="col3 row2"
title="ANIMATED IMPORTANCE"
[data]="tspInfo.animGifs"
[cameraUrls]="tspInfo.cameraUrls"></app-animgif>
[data]="fun.animGifs"
[cameraUrls]="fun.cameraUrls"></app-animgif>
</p>

View File

@ -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;
}
}

View File

@ -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';

View File

@ -1,5 +1,4 @@
import {
AnimGif,
ExpediteInfo,
LabTemperature,
PrioValues,
@ -9,8 +8,6 @@ import {
export class TspInfo {
public cameraUrls: Array<string> = [];
public animGifs: Array<AnimGif> = [];
public praGoals: {
core: PrioValues,
sig: PrioValues,

View File

@ -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,
},
}
];

View File

@ -18,6 +18,9 @@ import {HttpModule} from "@angular/http";
HttpModule,
TspInfoRoutingModule
],
exports:[
AnimgifComponent,
],
declarations: [
InfoBoxComponent,
TrProgressComponent,