diff --git a/pdb-js/src/app/app.component.scss b/pdb-js/src/app/app.component.scss index 4e03b90..e6da2a7 100644 --- a/pdb-js/src/app/app.component.scss +++ b/pdb-js/src/app/app.component.scss @@ -1,7 +1,7 @@ #main-toolbar { - height: 1.5em; + height: 2.0em; width: 100%; padding-bottom: 0.5em; border-bottom: solid 1px black; diff --git a/pdb-js/src/app/app.module.ts b/pdb-js/src/app/app.module.ts index 2cc5148..6771ee0 100644 --- a/pdb-js/src/app/app.module.ts +++ b/pdb-js/src/app/app.module.ts @@ -20,6 +20,7 @@ import {MatTooltipModule} from '@angular/material/tooltip'; import { YAxisRangeComponent } from './y-axis-range/y-axis-range.component'; import { QueryAutocompleteComponent } from './query-autocomplete/query-autocomplete.component'; import { LimitByComponent } from './limit-by/limit-by.component'; +import { PlotViewComponent } from './plot-view/plot-view.component'; @NgModule({ declarations: [ @@ -31,6 +32,7 @@ import { LimitByComponent } from './limit-by/limit-by.component'; YAxisRangeComponent, QueryAutocompleteComponent, LimitByComponent, + PlotViewComponent, ], imports: [ BrowserModule, diff --git a/pdb-js/src/app/plot-view/plot-view.component.html b/pdb-js/src/app/plot-view/plot-view.component.html new file mode 100644 index 0000000..34e94c9 --- /dev/null +++ b/pdb-js/src/app/plot-view/plot-view.component.html @@ -0,0 +1,5 @@ + + +
{{errorMessage}}
diff --git a/pdb-js/src/app/plot-view/plot-view.component.scss b/pdb-js/src/app/plot-view/plot-view.component.scss new file mode 100644 index 0000000..0cbb92a --- /dev/null +++ b/pdb-js/src/app/plot-view/plot-view.component.scss @@ -0,0 +1,4 @@ + +img { + display:block; /* removes 3 pixels extra height around the image */ +} \ No newline at end of file diff --git a/pdb-js/src/app/plot-view/plot-view.component.spec.ts b/pdb-js/src/app/plot-view/plot-view.component.spec.ts new file mode 100644 index 0000000..f38d58f --- /dev/null +++ b/pdb-js/src/app/plot-view/plot-view.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PlotViewComponent } from './plot-view.component'; + +describe('PlotViewComponent', () => { + let component: PlotViewComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PlotViewComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PlotViewComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/pdb-js/src/app/plot-view/plot-view.component.ts b/pdb-js/src/app/plot-view/plot-view.component.ts new file mode 100644 index 0000000..05662db --- /dev/null +++ b/pdb-js/src/app/plot-view/plot-view.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'pdb-plot-view', + templateUrl: './plot-view.component.html', + styleUrls: ['./plot-view.component.scss'] +}) +export class PlotViewComponent implements OnInit { + + imageUrl : string; + + errorMessage: string; + + constructor() { } + + ngOnInit() { + } + +} diff --git a/pdb-js/src/app/plot.service.ts b/pdb-js/src/app/plot.service.ts index a8c37bd..739eb5a 100644 --- a/pdb-js/src/app/plot.service.ts +++ b/pdb-js/src/app/plot.service.ts @@ -148,7 +148,7 @@ export class PlotRequest { thumbnailMaxHeight : number = 200; groupBy : Array; limitBy : string; - yAxis : string; + yAxisScale : string; limit : number; dateRange : string; aggregates : Array; diff --git a/pdb-js/src/app/query-autocomplete/query-autocomplete.component.scss b/pdb-js/src/app/query-autocomplete/query-autocomplete.component.scss index 92d41b1..4513308 100644 --- a/pdb-js/src/app/query-autocomplete/query-autocomplete.component.scss +++ b/pdb-js/src/app/query-autocomplete/query-autocomplete.component.scss @@ -9,4 +9,5 @@ border-radius: 5px; box-sizing: border-box; padding: 5px; -} \ No newline at end of file +} + diff --git a/pdb-js/src/app/visualization-page/visualization-page.component.html b/pdb-js/src/app/visualization-page/visualization-page.component.html index 4630f5f..b4ab7b3 100644 --- a/pdb-js/src/app/visualization-page/visualization-page.component.html +++ b/pdb-js/src/app/visualization-page/visualization-page.component.html @@ -20,7 +20,7 @@ - Combine with: + Combine With Type: - @@ -40,9 +40,9 @@ Y-Axis: - - Logarithm - Linear + + Logarithm + Linear @@ -83,7 +83,9 @@ -
+
+ +
diff --git a/pdb-js/src/app/visualization-page/visualization-page.component.scss b/pdb-js/src/app/visualization-page/visualization-page.component.scss index cdb8d97..f5e0a94 100644 --- a/pdb-js/src/app/visualization-page/visualization-page.component.scss +++ b/pdb-js/src/app/visualization-page/visualization-page.component.scss @@ -50,6 +50,8 @@ #results { grid-area: results; + overflow: hidden; + margin-right: 1em; } #plot-button-bar { diff --git a/pdb-js/src/app/visualization-page/visualization-page.component.ts b/pdb-js/src/app/visualization-page/visualization-page.component.ts index 017a9d8..2d73696 100644 --- a/pdb-js/src/app/visualization-page/visualization-page.component.ts +++ b/pdb-js/src/app/visualization-page/visualization-page.component.ts @@ -5,6 +5,7 @@ import { FormControl, Validators } from '@angular/forms'; import { LimitByComponent } from '../limit-by/limit-by.component'; import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component'; import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomplete.component'; +import {PlotViewComponent } from '../plot-view/plot-view.component' @Component({ @@ -31,7 +32,7 @@ export class VisualizationPageComponent implements OnInit { @ViewChild(LimitByComponent, {static: false}) private limitbycomponent : LimitByComponent; - yAxis: string; + yAxisScale: string; @ViewChild(YAxisRangeComponent, {static: false}) private yAxisRangeComponent : YAxisRangeComponent; @@ -39,6 +40,8 @@ export class VisualizationPageComponent implements OnInit { @ViewChild(QueryAutocompleteComponent, {static: false}) query: QueryAutocompleteComponent; + @ViewChild(PlotViewComponent, {static: false}) + plotView: PlotViewComponent; enableGallery = false; splitBy = new FormControl(null, [ @@ -58,7 +61,7 @@ export class VisualizationPageComponent implements OnInit { this.combinePlotTypes = this.getCombinablePlotTypes(this.selectedPlotType.value); this.tagFields = this.plotService.getTagFields(); - this.yAxis = "log"; + this.yAxisScale = "LOG10"; this.selectedPlotType.valueChanges.subscribe(function(selectedMainPlotType){ that.combinePlotTypes = that.getCombinablePlotTypes(selectedMainPlotType); @@ -81,7 +84,7 @@ export class VisualizationPageComponent implements OnInit { } plot(){ - + const that = this; var aggregates = []; aggregates.push(this.selectedPlotType.value.id); if (this.selectedCombinePlotType.value){ @@ -90,13 +93,13 @@ export class VisualizationPageComponent implements OnInit { var request = new PlotRequest(); request.query = this.query.query; - request.height = document.getElementById("results").offsetHeight; - request.width = document.getElementById("results").offsetWidth; + request.height = document.getElementById("results").offsetHeight-1; + request.width = document.getElementById("results").offsetWidth-1; request.groupBy = this.groupBy.map(o => o.name); request.limitBy = this.limitbycomponent.limitBy; request.limit = this.limitbycomponent.limit; request.dateRange = (document.getElementById("search-date-range")).value; - request.yAxis = this.yAxis; + request.yAxisScale = this.yAxisScale; request.aggregates = aggregates; request.keyOutside = false; request.generateThumbnail = this.enableGallery; @@ -107,6 +110,12 @@ export class VisualizationPageComponent implements OnInit { this.plotService.sendPlotRequest(request).subscribe(function(plotResponse){ console.log("response: " + JSON.stringify(plotResponse)); + that.plotView.imageUrl = "http://"+window.location.hostname+':8080/'+plotResponse.imageUrl; + }, + error => { + that.plotView.imageUrl = ''; + //that.plotView.errorMessage = JSON.stringify(error) + that.plotView.errorMessage = error.error.message; }); } diff --git a/pdb-js/src/app/y-axis-range/y-axis-range.component.html b/pdb-js/src/app/y-axis-range/y-axis-range.component.html index 6ab5e6a..ee39d05 100644 --- a/pdb-js/src/app/y-axis-range/y-axis-range.component.html +++ b/pdb-js/src/app/y-axis-range/y-axis-range.component.html @@ -1,6 +1,6 @@
- Unit: + Y-Axis Range: automatic milli seconds diff --git a/pdb-js/src/app/y-axis-range/y-axis-range.component.ts b/pdb-js/src/app/y-axis-range/y-axis-range.component.ts index f116dfe..81a255d 100644 --- a/pdb-js/src/app/y-axis-range/y-axis-range.component.ts +++ b/pdb-js/src/app/y-axis-range/y-axis-range.component.ts @@ -7,9 +7,9 @@ import { Component, Input } from '@angular/core'; }) export class YAxisRangeComponent { - yAxisUnit: string = "AUTOMATIC"; - minYValue: number = 1; - maxYValue: number = 60; + yAxisUnit: string = "SECONDS"; + minYValue: number = 0; + maxYValue: number = 300; constructor() { } diff --git a/pdb-js/src/styles.scss b/pdb-js/src/styles.scss index f6d8fe4..e7c40e5 100644 --- a/pdb-js/src/styles.scss +++ b/pdb-js/src/styles.scss @@ -21,12 +21,14 @@ $background-color: #CBD7F4; -@import '~@angular/material/prebuilt-themes/deeppurple-amber.css'; +//@import '~@angular/material/prebuilt-themes/deeppurple-amber.css'; +@import 'custom-theme.scss'; *, body { font-family: Arial, sans-serif; font-size: 14px; margin: 0; + box-sizing: border-box; } .icon-inline { @@ -73,9 +75,8 @@ a.external-link:after { display: inline-block; } - -body .mat-select-panel { - max-height: 500px; +body .mat-select-panel, body .mat-autocomplete-panel { + max-height: 512px; } mat-form-field { @@ -93,3 +94,8 @@ mat-form-field.pdb-form-mid { } +.errorPanel { + padding: 1ex; + background-color: map-get($mat-red, 100); +} + diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java b/pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java index 06e6e3f..1198f02 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/BadRequest.java @@ -3,7 +3,7 @@ package org.lucares.pdbui; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; -@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "BadRequest") +@ResponseStatus(value = HttpStatus.BAD_REQUEST) public class BadRequest extends RuntimeException { private static final long serialVersionUID = 694206253376122420L; diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/NotFoundException.java b/pdb-ui/src/main/java/org/lucares/pdbui/NotFoundException.java index eac3fac..4c19ebd 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/NotFoundException.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/NotFoundException.java @@ -3,7 +3,7 @@ package org.lucares.pdbui; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; -@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Not Found") +@ResponseStatus(value = HttpStatus.NOT_FOUND) public class NotFoundException extends RuntimeException { private static final long serialVersionUID = 694206253376122420L; diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java b/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java index 643355a..c633335 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java @@ -143,7 +143,7 @@ public class PdbController implements HardcodedValues, PropertyKeys { return ResponseEntity.ok().body(plotResponse); } catch (final NoDataPointsException e) { - throw new NotFoundException(e); + throw new NotFoundException("No data was found. Try another query, or change the date range.",e); } finally { plotterLock.unlock(); } @@ -186,7 +186,7 @@ public class PdbController implements HardcodedValues, PropertyKeys { plotSettings.setLimitBy(limitBy); plotSettings.setDateRange(dateRange); plotSettings.setYAxisScale(axisScale); - plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(aggregate)); + plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(plotSettings.getYRangeUnit(), plotSettings.getYAxisScale(), aggregate)); plotSettings.setKeyOutside(keyOutside); plotSettings.setGenerateThumbnail(false); diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java b/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java index 3706123..f585b70 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java @@ -2,6 +2,7 @@ package org.lucares.pdbui; import org.lucares.pdb.plot.api.Aggregate; import org.lucares.pdb.plot.api.AggregateHandlerCollection; +import org.lucares.pdb.plot.api.AxisScale; import org.lucares.pdb.plot.api.CumulativeDistributionHandler; import org.lucares.pdb.plot.api.ParallelRequestsAggregate; import org.lucares.pdb.plot.api.PlotSettings; @@ -22,8 +23,7 @@ class PlotSettingsTransformer { result.setLimit(request.getLimit()); result.setLimitBy(request.getLimitBy()); result.setDateRange(request.getDateRange()); - result.setYAxisScale(request.getAxisScale()); - result.setAggregates(toAggregateInternal(request.getAggregates())); + result.setYAxisScale(request.getYAxisScale()); result.setKeyOutside(request.isKeyOutside()); result.setThumbnailMaxWidth(request.getThumbnailMaxWidth()); result.setThumbnailMaxHeight(request.getThumbnailMaxHeight()); @@ -31,6 +31,7 @@ class PlotSettingsTransformer { result.setYRangeMin(request.getyRangeMin()); result.setYRangeMax(request.getyRangeMax()); result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit())); + result.setAggregates(toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates())); return result; } @@ -53,7 +54,8 @@ class PlotSettingsTransformer { throw new IllegalStateException("unhandled enum value: " + yRangeUnit); } - static AggregateHandlerCollection toAggregateInternal(final Iterable aggregates) { + static AggregateHandlerCollection toAggregateInternal(TimeRangeUnitInternal yRangeUnit, AxisScale yAxisScale, + final Iterable aggregates) { final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection(); for (Aggregate aggregate : aggregates) { @@ -66,7 +68,12 @@ class PlotSettingsTransformer { aggregateHandlerCollection.add(new ParallelRequestsAggregate()); break; case SCATTER: - aggregateHandlerCollection.add(new ScatterAggregateHandler()); + if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) { + // TODO need a second ScatterAggregateHandler for YRangeUnit() == TimeRangeUnitInternal.AUTOMATIC + throw new UnsupportedOperationException("linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range"); + }else { + aggregateHandlerCollection.add(new ScatterAggregateHandler()); + } break; default: throw new IllegalStateException("unhandled enum: " + aggregate); diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java index a715d60..c7ab668 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotRequest.java @@ -22,7 +22,7 @@ public class PlotRequest { private Limit limitBy = Limit.NO_LIMIT; - private AxisScale yAxis = AxisScale.LINEAR; + private AxisScale yAxisScale = AxisScale.LINEAR; private int limit = Integer.MAX_VALUE; @@ -115,12 +115,12 @@ public class PlotRequest { this.dateRange = dateRange; } - public AxisScale getAxisScale() { - return yAxis; + public AxisScale getYAxisScale() { + return yAxisScale; } - public void setAxisScale(final AxisScale yAxis) { - this.yAxis = yAxis; + public void setYAxisScale(final AxisScale yAxis) { + this.yAxisScale = yAxis; } public void setAggregate(final List aggregates) {