From 6c62436753ade3bf52cf3b58484d43050d04d910 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Thu, 9 Mar 2023 20:13:55 +0100 Subject: [PATCH] fix adding of plots --- .../add-text-dialog/add-text-dialog.component.html | 5 +++++ .../add-text-dialog/add-text-dialog.component.scss | 3 --- .../add-text-dialog/add-text-dialog.component.ts | 3 +-- .../dashboard/dashboard.component.ts | 14 +++++++++++--- .../plot-widget/plot-widget.component.html | 6 +++++- .../dashboard/plot-widget/plot-widget.component.ts | 7 ++++--- pdb-js/src/app/dashboard.service.ts | 2 +- 7 files changed, 27 insertions(+), 13 deletions(-) delete mode 100644 pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.scss diff --git a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.html b/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.html index 0336823..4da148f 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.html +++ b/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.html @@ -1,3 +1,8 @@ +

Add Text

diff --git a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.scss b/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.scss deleted file mode 100644 index d153bf3..0000000 --- a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -textarea { - height: 5em; -} \ No newline at end of file diff --git a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.ts b/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.ts index 4e681bc..0483791 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.ts +++ b/pdb-js/src/app/dashboard-page/dashboard/add-text-dialog/add-text-dialog.component.ts @@ -3,8 +3,7 @@ import { MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-add-text-dialog', - templateUrl: './add-text-dialog.component.html', - styleUrls: ['./add-text-dialog.component.scss'] + templateUrl: './add-text-dialog.component.html' }) export class AddTextDialogComponent { text = ""; diff --git a/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts b/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts index e3f37f3..c362a6e 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts +++ b/pdb-js/src/app/dashboard-page/dashboard/dashboard.component.ts @@ -143,7 +143,9 @@ export class DashboardComponent implements OnInit { this.dialog.open(AddTextDialogComponent,{ width: '600px' }).afterClosed().subscribe((text: string) => { - this.dashboard!.texts.push(new TextWidget(crypto.randomUUID(),'MEDIUM', text)); + const widget = new TextWidget(crypto.randomUUID(),'MEDIUM', text); + this.dashboard!.texts.push(widget); + this.dashboard!.arrangement[0].push(widget.id); }); } @@ -151,8 +153,14 @@ export class DashboardComponent implements OnInit { this.dialog.open(AddPlotDialogComponent,{ width: 'calc(100% - 1em)', height: 'calc(100% - 1em)' - }).afterClosed().subscribe((config: PlotConfig) => { - this.dashboard!.plots.push(new PlotWidget(crypto.randomUUID(), 'MEDIUM', config)); + }).afterClosed().subscribe((config: PlotConfig | "") => { + if (config != "" && config.query.length > 0) { + const widget = new PlotWidget(crypto.randomUUID(), 'MEDIUM', config); + this.dashboard!.plots.push(widget); + this.dashboard!.arrangement[0].push(widget.id); + this.plotWidgetRenderData.push(new PlotWidgetRenderData(widget)); + this.loadImages(this.plotWidgetRenderData.length-1, this.plotWidgetRenderData); + } }); } diff --git a/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.html b/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.html index 60e1e0d..cd5274c 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.html +++ b/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.html @@ -12,11 +12,15 @@ width: 602px; height: 402px; } + .size-small { + width: 402px; + height: 302px; + } img { cursor: zoom-in; } -
+
diff --git a/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.ts b/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.ts index 6abe94f..c6ca11f 100644 --- a/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.ts +++ b/pdb-js/src/app/dashboard-page/dashboard/plot-widget/plot-widget.component.ts @@ -26,11 +26,12 @@ export class PlotWidgetComponent implements AfterViewInit { } hasRender(name: string): boolean{ - return this.data.plotResponse!.rendered[name] !== undefined; + const hasRender = this.data !== undefined && this.data.plotResponse !== undefined && this.data.plotResponse?.rendered[name] !== undefined; + return hasRender; } - getImageUrl(name: string ): string { - return this.data.plotResponse!.rendered[name]; + getImageUrl(name: string ): string | undefined { + return this.data?.plotResponse?.rendered[name]; } showFullScreenImage(){ diff --git a/pdb-js/src/app/dashboard.service.ts b/pdb-js/src/app/dashboard.service.ts index 2b572ce..14ab4de 100644 --- a/pdb-js/src/app/dashboard.service.ts +++ b/pdb-js/src/app/dashboard.service.ts @@ -64,7 +64,7 @@ export class TextWidget extends BaseWidget { } } export class PlotWidget extends BaseWidget { - constructor(override id: string, override size: PlotSize, public config: PlotConfig) { + constructor(override id: string, override size: 'SMALL'|'MEDIUM'|'LARGE', public config: PlotConfig) { super(id, 'PLOT', size); } }