From 9f1d5d4d9accf49a57ba53b176434e23d2e14456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Thu, 14 Sep 2017 12:46:55 +0200 Subject: [PATCH] * added kanban-fixed route --- src/app/app.component.ts | 28 ++++++++++++++++++------- src/app/kanban/kanban-routing.module.ts | 14 +++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2fdcb4e..d1d3394 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -3,7 +3,7 @@ import {Subscription} from "rxjs/Subscription"; import {TimerObservable} from "rxjs/observable/TimerObservable"; import {KanbanService} from "./kanban/shared/kanban.service"; -import {ActivatedRoute, Router} from "@angular/router"; +import {ActivatedRoute, NavigationEnd, Router} from "@angular/router"; import {SelfUpdaterService} from "./kanban/shared/self-updater.service"; import {TspInfoService} from "./tsp-info/shared/tsp-info.service"; @@ -64,12 +64,24 @@ export class AppComponent implements OnInit, OnDestroy { this.reloadTspInfoTimer = timer2.subscribe(() => { this.tspInfoService.reload(); }); - this.activatedRoute.queryParamMap.subscribe(params => { - if (!params.has("disableAutoSwitch")) { - let timer4 = TimerObservable.create(TIMER_PAGE_SWITCH_TICK, TIMER_PAGE_SWITCH_TICK); - this.pageSwitchTimer = timer4.subscribe(this.switchSubscriber.bind(this)); - } - }); + + this.router.events + .filter(e => e instanceof NavigationEnd) + .map(() => { + let route = this.activatedRoute; + while (route.firstChild) { + route = route.firstChild; + } + return route; + }) + .filter((route) => route.outlet === 'primary') + .mergeMap((route) => route.data) + .subscribe(data => { + if (!data['disableAutoSwitch']) { + let timer4 = TimerObservable.create(TIMER_PAGE_SWITCH_TICK, TIMER_PAGE_SWITCH_TICK); + this.pageSwitchTimer = timer4.subscribe(this.switchSubscriber.bind(this)); + } + }); } public ngOnDestroy() { @@ -86,7 +98,7 @@ export class AppComponent implements OnInit, OnDestroy { let weekDay = now.getDay(); // on weekdays if (weekDay > 0 && weekDay < 6) { - if(now.getHours() == 10) { + if (now.getHours() == 10) { if (this.autoSwitchEnabled && now.getMinutes() > 14) { this.navigateToPage(PAGE_KANBAN); this.autoSwitchEnabled = false; diff --git a/src/app/kanban/kanban-routing.module.ts b/src/app/kanban/kanban-routing.module.ts index 8b4263a..88e2326 100644 --- a/src/app/kanban/kanban-routing.module.ts +++ b/src/app/kanban/kanban-routing.module.ts @@ -13,6 +13,20 @@ const routes: Routes = [ kanbanBoard: KanbanService, fun: FunService, }, + data: { + disableAutoSwitch: false + } + }, { + path: 'kanban-fixed', + children: [], + component: KanbanBoardComponent, + resolve: { + kanbanBoard: KanbanService, + fun: FunService, + }, + data: { + disableAutoSwitch: true + } } ];