dashboard #1
@@ -1,4 +1,23 @@
|
|||||||
<style>
|
<style>
|
||||||
|
:host {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.dashboard-card {
|
||||||
|
border: solid 1px red;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.size-medium {
|
||||||
|
width: 602px;
|
||||||
|
height: 502px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<p>{{data.config.query}}</p>
|
<div class="dashboard-card" [ngClass]="{'size-medium' : data.size=='MEDIUM'}">
|
||||||
|
<mat-spinner *ngIf="!thumbnailUrl && !isError"></mat-spinner>
|
||||||
|
<img *ngIf="thumbnailUrl" src="{{thumbnailUrl}}" />
|
||||||
|
<div *ngIf="isError">
|
||||||
|
There was an error! This is a good time to panic!
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,53 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||||
import { PlotWidget } from 'src/app/dashboard.service';
|
import { PlotWidget } from 'src/app/dashboard.service';
|
||||||
|
import { PlotViewComponent } from 'src/app/plot-view/plot-view.component';
|
||||||
|
import { PlotRequest, PlotResponse, PlotService } from 'src/app/plot.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-plot-widget',
|
selector: 'app-plot-widget',
|
||||||
templateUrl: './plot-widget.component.html'
|
templateUrl: './plot-widget.component.html'
|
||||||
})
|
})
|
||||||
export class PlotWidgetComponent {
|
export class PlotWidgetComponent implements AfterViewInit {
|
||||||
@Input("data")
|
@Input("data")
|
||||||
data!: PlotWidget;
|
data!: PlotWidget;
|
||||||
|
|
||||||
|
thumbnailUrl = "";
|
||||||
|
|
||||||
|
isError = false;
|
||||||
|
|
||||||
|
@ViewChild("plotView") plotView!: PlotViewComponent;
|
||||||
|
|
||||||
|
constructor(private plotService : PlotService){}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
|
||||||
|
|
||||||
|
const plotRequest = this.createPlotRequest();
|
||||||
|
this.plotService.sendPlotRequest(plotRequest).subscribe({
|
||||||
|
next: (response: PlotResponse) => {
|
||||||
|
this.thumbnailUrl = response.thumbnailUrl;
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
this.isError = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createPlotRequest(): PlotRequest {
|
||||||
|
|
||||||
|
const height = window.innerHeight - 20;
|
||||||
|
const width = window. innerWidth - 20;
|
||||||
|
|
||||||
|
const request = new PlotRequest(
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
600, // thumbnailMaxWidth
|
||||||
|
500, // thumbnailMaxHeight
|
||||||
|
false, // keyOutside
|
||||||
|
true, // generateThumbnail
|
||||||
|
(<any>window).submitterId,
|
||||||
|
this.data.config!);
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,4 +53,8 @@ export class PlotWidget extends BaseWidget {
|
|||||||
constructor(override size: 'SMALL'|'MEDIUM'|'LARGE', public config: PlotConfig) {
|
constructor(override size: 'SMALL'|'MEDIUM'|'LARGE', public config: PlotConfig) {
|
||||||
super('PLOT', size);
|
super('PLOT', size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class WidgetDimensions{
|
||||||
|
constructor(public width: number, public height: number){}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
|||||||
import { DataType, AxesTypes, PlotResponseStats, PlotConfig, PlotService, PlotResponse, PlotRequest } from '../plot.service';
|
import { DataType, AxesTypes, PlotResponseStats, PlotConfig, PlotService, PlotResponse, PlotRequest } from '../plot.service';
|
||||||
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar';
|
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { WidgetDimensions } from '../dashboard.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pdb-plot-view',
|
selector: 'pdb-plot-view',
|
||||||
@@ -46,8 +47,6 @@ export class PlotViewComponent implements OnInit {
|
|||||||
|
|
||||||
config? : PlotConfig;
|
config? : PlotConfig;
|
||||||
|
|
||||||
submitterId = crypto.randomUUID();
|
|
||||||
|
|
||||||
constructor(private service : PlotService, private snackBar: MatSnackBar) { }
|
constructor(private service : PlotService, private snackBar: MatSnackBar) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -221,13 +220,36 @@ export class PlotViewComponent implements OnInit {
|
|||||||
this.showStats = false;
|
this.showStats = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAxes(): AxesTypes{
|
||||||
|
const plotTypes = this.service.getPlotTypes();
|
||||||
|
|
||||||
|
this.config?.aggregates
|
||||||
|
|
||||||
|
const x = new Array<DataType>();
|
||||||
|
const y = new Array<DataType>();
|
||||||
|
|
||||||
|
for(var i = 0; i < this.config!.aggregates.length; i++){
|
||||||
|
const aggregateType = this.config?.aggregates[i];
|
||||||
|
const plotType = plotTypes.find((p) => p.id == aggregateType);
|
||||||
|
if (plotType) {
|
||||||
|
if (!x.includes(plotType.xAxis)) {
|
||||||
|
x.push(plotType.xAxis);
|
||||||
|
}
|
||||||
|
if (!y.includes(plotType.yAxis)) {
|
||||||
|
y.push(plotType.yAxis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AxesTypes(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
plot(config : PlotConfig, axes: AxesTypes){
|
plot(config : PlotConfig, dimension: WidgetDimensions | (()=>WidgetDimensions)){
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.axes = axes;
|
this.axes = this.getAxes();
|
||||||
|
|
||||||
const request = this.createPlotRequest();
|
const request = this.createPlotRequest(dimension);
|
||||||
|
|
||||||
this.loadingEvent.emit(new LoadingEvent(true));
|
this.loadingEvent.emit(new LoadingEvent(true));
|
||||||
const x = this.service.sendPlotRequest(request).subscribe({
|
const x = this.service.sendPlotRequest(request).subscribe({
|
||||||
@@ -247,21 +269,20 @@ export class PlotViewComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createPlotRequest(): PlotRequest {
|
createPlotRequest( dimension: WidgetDimensions | (()=>WidgetDimensions)): PlotRequest {
|
||||||
const results = document.getElementById("results");
|
|
||||||
|
const actualDimension = typeof dimension === "function" ? dimension() : dimension;
|
||||||
|
|
||||||
|
|
||||||
const request = new PlotRequest(
|
const request = new PlotRequest(
|
||||||
results != null ? results.offsetHeight-1: 1024,
|
actualDimension.height,
|
||||||
results != null ? results.offsetWidth-1 : 1024,
|
actualDimension.width,
|
||||||
300, // thumbnailMaxWidth
|
300, // thumbnailMaxWidth
|
||||||
200, // thumbnailMaxHeight
|
200, // thumbnailMaxHeight
|
||||||
false, // keyOutside
|
false, // keyOutside
|
||||||
false, // generateThumbnail
|
false, // generateThumbnail
|
||||||
this.submitterId,
|
(<any>window).submitterId,
|
||||||
this.config!);
|
this.config!);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomp
|
|||||||
import { PlotViewComponent, SelectionRange, DateAnchor, LoadingEvent } from '../plot-view/plot-view.component';
|
import { PlotViewComponent, SelectionRange, DateAnchor, LoadingEvent } from '../plot-view/plot-view.component';
|
||||||
import { GalleryViewComponent } from '../gallery-view/gallery-view.component';
|
import { GalleryViewComponent } from '../gallery-view/gallery-view.component';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { WidgetDimensions } from '../dashboard.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pdb-visualization-page',
|
selector: 'pdb-visualization-page',
|
||||||
@@ -54,8 +55,6 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
intervalValue = 1;
|
intervalValue = 1;
|
||||||
renderBarChartTickLabels = false;
|
renderBarChartTickLabels = false;
|
||||||
|
|
||||||
submitterId = crypto.randomUUID();
|
|
||||||
|
|
||||||
plotJobActive = false;
|
plotJobActive = false;
|
||||||
|
|
||||||
constructor(private plotService: PlotService, private snackBar: MatSnackBar) {
|
constructor(private plotService: PlotService, private snackBar: MatSnackBar) {
|
||||||
@@ -147,7 +146,7 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abort() {
|
abort() {
|
||||||
this.plotService.abort(this.submitterId).subscribe({
|
this.plotService.abort((<any>window).submitterId).subscribe({
|
||||||
complete: () => {
|
complete: () => {
|
||||||
this.plotView.imageUrl = '';
|
this.plotView.imageUrl = '';
|
||||||
this.plotView.stats = null;
|
this.plotView.stats = null;
|
||||||
@@ -160,8 +159,13 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
|
|
||||||
plot(){
|
plot(){
|
||||||
const config = this.createPlotConfig();
|
const config = this.createPlotConfig();
|
||||||
const axes = this.getAxes();
|
this.plotView.plot(config, this.plotDimensionSupplier);
|
||||||
this.plotView.plot(config, axes);
|
}
|
||||||
|
|
||||||
|
plotDimensionSupplier(): WidgetDimensions{
|
||||||
|
const results = document.getElementById("results");
|
||||||
|
return new WidgetDimensions(results != null ? results.offsetHeight-1: 1024,
|
||||||
|
results != null ? results.offsetWidth-1 : 1024,);
|
||||||
}
|
}
|
||||||
|
|
||||||
createPlotConfig(): PlotConfig {
|
createPlotConfig(): PlotConfig {
|
||||||
@@ -199,7 +203,7 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
200, // thumbnailMaxHeight
|
200, // thumbnailMaxHeight
|
||||||
false, // keyOutside
|
false, // keyOutside
|
||||||
this.enableGallery, // generateThumbnail
|
this.enableGallery, // generateThumbnail
|
||||||
this.submitterId,
|
(<any>window).submitterId,
|
||||||
config);
|
config);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ if (environment.production) {
|
|||||||
enableProdMode();
|
enableProdMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(<any>window).submitterId = crypto.randomUUID();
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
|
|||||||
Reference in New Issue
Block a user