diff --git a/monitor-admin/utils/cache-indicators/cache-indicators.component.ts b/monitor-admin/utils/cache-indicators/cache-indicators.component.ts
index 8f2211aa..ad39c570 100644
--- a/monitor-admin/utils/cache-indicators/cache-indicators.component.ts
+++ b/monitor-admin/utils/cache-indicators/cache-indicators.component.ts
@@ -1,18 +1,33 @@
-import {Component, Inject, Input, OnChanges, OnDestroy, OnInit, PLATFORM_ID, SimpleChanges} from "@angular/core";
+import {
+ Component,
+ Inject,
+ InjectionToken,
+ Input,
+ OnChanges,
+ OnDestroy,
+ OnInit,
+ PLATFORM_ID,
+ SimpleChanges
+} from "@angular/core";
import {Report} from "./cache-indicators";
import {CacheIndicatorsService} from "./cache-indicators.service";
import {interval, Subject, Subscription} from "rxjs";
import {map, switchMap, takeUntil} from "rxjs/operators";
+import {isPlatformBrowser} from "@angular/common";
@Component({
selector: 'cache-indicators',
template: `
-
+
`,
styleUrls: ['cache-indicators.component.less']
})
@@ -24,7 +39,7 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
@Input() alias: string;
constructor(private cacheIndicatorsService: CacheIndicatorsService,
- @Inject(PLATFORM_ID) private platformId) {
+ @Inject(PLATFORM_ID) private platformId: any) {
}
ngOnInit() {
@@ -32,28 +47,30 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
}
ngOnChanges(changes: SimpleChanges) {
- if(changes.alias) {
+ if (changes.alias) {
+ this.clear();
this.getReport();
}
}
getReport() {
- this.clear();
this.subscriptions.push(this.cacheIndicatorsService.getReport(this.alias).subscribe(report => {
this.getReportInterval(report);
+ }, error => {
+ this.report = null;
}));
}
getReportInterval(report: Report) {
- if(this.isBrowser && (this.report || !report?.completed)) {
+ if (this.isBrowser && (this.report || !report?.completed)) {
this.report = report;
this.subscriptions.push(interval(this.interval).pipe(
map(() => this.cacheIndicatorsService.getReport(this.alias)),
switchMap(report => report),
- takeUntil(this.destroy$)).subscribe(report => {
- console.log(this.alias);
+ takeUntil(this.destroy$)).
+ subscribe(report => {
this.report = report;
- if(this.report.completed) {
+ if (this.report.completed) {
this.destroy$.next();
}
}));
@@ -62,14 +79,15 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
clear() {
this.subscriptions.forEach(subscription => {
- subscription.unsubscribe();
- })
+ if (subscription instanceof Subscription) {
+ subscription.unsubscribe();
+ }
+ });
this.report = null;
}
-
get isBrowser() {
- return this.platformId === 'browser';
+ return isPlatformBrowser(this.platformId);
}
ngOnDestroy() {
diff --git a/sharedComponents/input/input.component.ts b/sharedComponents/input/input.component.ts
index 8b26c2da..fb51cebc 100644
--- a/sharedComponents/input/input.component.ts
+++ b/sharedComponents/input/input.component.ts
@@ -374,21 +374,25 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
@Input()
set options(options: (Option | string | number) []) {
- this.optionsArray = options.map(option => {
- if (option === null) {
- return {
- label: this.noValueSelected,
- value: ''
- };
- } else if (typeof option === 'string' || typeof option === 'number') {
- return {
- label: option.toString(),
- value: option
- };
- } else {
- return option;
- }
- });
+ if(options) {
+ this.optionsArray = options.map(option => {
+ if (option === null) {
+ return {
+ label: this.noValueSelected,
+ value: ''
+ };
+ } else if (typeof option === 'string' || typeof option === 'number') {
+ return {
+ label: option.toString(),
+ value: option
+ };
+ } else {
+ return option;
+ }
+ });
+ } else {
+ this.optionsArray = [];
+ }
if (!this.tooltip) {
this.tooltip = this.optionsArray.length > 0;
}