X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fsupervision%2Fsupervision.component.ts;h=3fff2b7bcac2138ccfb08ffbbc462f1a203fb20a;hb=c2d621f58c1446579961bac245bc6376a02efe63;hp=219f28f2465911b2d45cc6b41e2e938ad0f17f39;hpb=ee66af78c42c4d7ff33f104415bc09d60dbdc27b;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/supervision/supervision.component.ts b/webapp/src/app/pages/supervision/supervision.component.ts index 219f28f..3fff2b7 100644 --- a/webapp/src/app/pages/supervision/supervision.component.ts +++ b/webapp/src/app/pages/supervision/supervision.component.ts @@ -22,6 +22,7 @@ import { Subject } from 'rxjs/Subject'; import { NbThemeService } from '@nebular/theme'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; +import { ConfigService, IConfig } from '../../@core-xds/services/config.service'; import { SupervisionService } from '../../@core-xds/services/supervision.service'; import { AlertService } from '../../@core-xds/services/alert.service'; @@ -47,9 +48,11 @@ export interface GrafanaPanel { export class SupervisionComponent implements OnInit { + /* TODO bind tm_* and refresh in UI */ @Input() theme = 'light'; - @Input() tm_from = 1528988550450; - @Input() tm_to = 1528988842496; + @Input() tm_from = 'now-60s'; + @Input() tm_to = 'now'; + @Input() refresh = '5s'; @Input() scroll_factor = 10000; @Input() zoom_factor = 100000; @@ -70,10 +73,15 @@ export class SupervisionComponent implements OnInit { private alert: AlertService, private themeService: NbThemeService, private sanitizer: DomSanitizer, + private configSvr: ConfigService, ) { } + Config: IConfig = {}; + ngOnInit() { + this.configSvr.Conf$.subscribe(cfg => this.Config = cfg); + this._initDashboard(); this._initPanels(); @@ -105,47 +113,61 @@ export class SupervisionComponent implements OnInit { } timeChange(val: number) { + /* TODO: convert tm_from string to number this.tm_from += val * this.scroll_factor; this.tm_to += val * this.scroll_factor; this._initPanels(); + */ } zoomOut() { + /* TODO: convert tm_from string to number this.tm_from -= this.zoom_factor; this.tm_to += this.zoom_factor; this._initPanels(); + */ } - private _initDashboard() { + // http://localhost:3000/d/Lbpwc6Iiz/agl-xds-supervisor?from=now-40s&to=now&refresh=5s this.dashboards.forEach(dd => { - dd.url = this._buildDashboardUrl(dd.shortname, this.tm_from, this.tm_to, this.theme); + dd.url = this._buildDashboardUrl(dd.shortname, this.tm_from, this.tm_to, this.refresh, this.theme); dd.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(dd.url); }); } private _initPanels() { this.panels.forEach(gg => { - gg.url = this._buildPanelUrl(gg.index, this.tm_from, this.tm_to, this.theme); + gg.url = this._buildPanelUrl(gg.index, this.tm_from, this.tm_to, this.refresh, this.theme); gg.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(gg.url); }); } - private _buildDashboardUrl(sname: string, from: number, to: number, theme: string) { + private _buildDashboardUrl(sname, from, to, refresh, theme: string) { + // FIXME get sname from config to support several dashboards let url = 'http://localhost:3000/d/Lbpwc6Iiz/' + sname; + if (this.Config.grafanaDashboardUrl !== '') { + url = this.Config.grafanaDashboardUrl; + } url += '?orgId=1'; - url += '&from=' + from; - url += '&to=' + to; - url += '&theme=' + theme; + if (from !== '') { url += '&from=' + from; } + if (to !== '') { url += '&to=' + to; } + if (theme !== '') { url += '&theme=' + theme; } + if (refresh !== '') { url += '&refresh=' + refresh; } + url += '&sidemenu=close'; return url; } - private _buildPanelUrl(idx: string, from: number, to: number, theme: string) { + private _buildPanelUrl(idx, from, to, refresh, theme: string) { let url = 'http://localhost:3000/d-solo/Lbpwc6Iiz/agl-xds-supervisor'; + if (this.Config.grafanaDashboardUrl !== '') { + url = this.Config.grafanaDashboardUrl; + } url += '?panelId=' + idx; url += '&orgId=1'; - url += '&from=' + from; - url += '&to=' + to; - url += '&theme=' + theme; + if (from !== '') { url += '&from=' + from; } + if (to !== '') { url += '&to=' + to; } + if (theme !== '') { url += '&theme=' + theme; } + if (refresh !== '') { url += '&refresh=' + refresh; } url += '&sidemenu=close'; return url; }