Browse Source

UI: liquid level widget added additional checkup for datasources

pull/9606/head
Dmitriymush 3 years ago
parent
commit
8dce7dcad2
  1. 42
      ui-ngx/src/app/modules/home/components/widget/lib/indicator/liquid-level-widget.component.ts

42
ui-ngx/src/app/modules/home/components/widget/lib/indicator/liquid-level-widget.component.ts

@ -160,26 +160,30 @@ export class LiquidLevelWidgetComponent implements OnInit {
} }
private getData(): Observable<{ svg: string; volume: number; units: string }> { private getData(): Observable<{ svg: string; volume: number; units: string }> {
const entityId: EntityId = { if (this.ctx.datasources?.length) {
entityType: this.ctx.datasources[0].entityType, const entityId: EntityId = {
id: this.ctx.datasources[0].entityId entityType: this.ctx.datasources[0].entityType,
}; id: this.ctx.datasources[0].entityId
};
return this.getShape(entityId).pipe(
switchMap(shape => {
this.shape = shape;
this.svgParams = svgMapping.get(shape);
if (this.svgParams) {
return forkJoin([
this.resourcesService.loadJsonResource<string>(this.svgParams.svg),
this.getTankersParams(entityId)
]).pipe(
map(params => ({svg: params[0], ...params[1]}))
);
}
return of(null);
})
);
}
return this.getShape(entityId).pipe( return of(null);
switchMap(shape => {
this.shape = shape;
this.svgParams = svgMapping.get(shape);
if (this.svgParams) {
return forkJoin([
this.resourcesService.loadJsonResource<string>(this.svgParams.svg),
this.getTankersParams(entityId)
]).pipe(
map(params => ({svg: params[0], ...params[1]}))
);
}
return of(null);
})
);
} }
public onInit() { public onInit() {

Loading…
Cancel
Save