use snackbar to show error messages
This commit is contained in:
@@ -16,11 +16,13 @@ import {MatButtonModule} from '@angular/material/button';
|
|||||||
import {MatCheckboxModule} from '@angular/material/checkbox';
|
import {MatCheckboxModule} from '@angular/material/checkbox';
|
||||||
import {MatSelectModule} from '@angular/material/select';
|
import {MatSelectModule} from '@angular/material/select';
|
||||||
import {MatFormFieldModule, MatInputModule} from '@angular/material';
|
import {MatFormFieldModule, MatInputModule} from '@angular/material';
|
||||||
|
import {MatSnackBarModule} from '@angular/material/snack-bar';
|
||||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||||
import { YAxisRangeComponent } from './y-axis-range/y-axis-range.component';
|
import { YAxisRangeComponent } from './y-axis-range/y-axis-range.component';
|
||||||
import { QueryAutocompleteComponent } from './query-autocomplete/query-autocomplete.component';
|
import { QueryAutocompleteComponent } from './query-autocomplete/query-autocomplete.component';
|
||||||
import { LimitByComponent } from './limit-by/limit-by.component';
|
import { LimitByComponent } from './limit-by/limit-by.component';
|
||||||
import { PlotViewComponent } from './plot-view/plot-view.component';
|
import { PlotViewComponent } from './plot-view/plot-view.component';
|
||||||
|
import { GalleryViewComponent } from './gallery-view/gallery-view.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@@ -45,6 +47,7 @@ import { PlotViewComponent } from './plot-view/plot-view.component';
|
|||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
|
MatSnackBarModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
HttpClientModule
|
HttpClientModule
|
||||||
|
|||||||
@@ -19,4 +19,3 @@
|
|||||||
[style.width]="zoomInSliderStyleWidth"
|
[style.width]="zoomInSliderStyleWidth"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="errorMessage" class="errorPanel">{{errorMessage}}</div>
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ export class PlotViewComponent implements OnInit {
|
|||||||
|
|
||||||
imageUrl : string;
|
imageUrl : string;
|
||||||
|
|
||||||
errorMessage: string;
|
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
zoomRange : EventEmitter<SelectionRange> = new EventEmitter<SelectionRange>();
|
zoomRange : EventEmitter<SelectionRange> = new EventEmitter<SelectionRange>();
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,8 @@
|
|||||||
#plotView
|
#plotView
|
||||||
(zoomRange)="zoomRange($event)"
|
(zoomRange)="zoomRange($event)"
|
||||||
(zoomWithDateAnchor)="zoomWithDateAnchor($event)"></pdb-plot-view>
|
(zoomWithDateAnchor)="zoomWithDateAnchor($event)"></pdb-plot-view>
|
||||||
|
<pdb-gallery-view>
|
||||||
|
</pdb-gallery-view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import { Component, OnInit, ViewChild } from '@angular/core';
|
|||||||
import { PlotService, PlotType, PlotRequest, PlotResponse, TagField, FilterDefaults } from '../plot.service';
|
import { PlotService, PlotType, PlotRequest, PlotResponse, TagField, FilterDefaults } from '../plot.service';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { FormControl, Validators } from '@angular/forms';
|
import { FormControl, Validators } from '@angular/forms';
|
||||||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { LimitByComponent } from '../limit-by/limit-by.component';
|
import { LimitByComponent } from '../limit-by/limit-by.component';
|
||||||
import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component';
|
import { YAxisRangeComponent } from '../y-axis-range/y-axis-range.component';
|
||||||
import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomplete.component';
|
import { QueryAutocompleteComponent } from '../query-autocomplete/query-autocomplete.component';
|
||||||
import {PlotViewComponent, SelectionRange, DateAnchor} from '../plot-view/plot-view.component'
|
import { PlotViewComponent, SelectionRange, DateAnchor } from '../plot-view/plot-view.component';
|
||||||
|
import { GalleryViewComponent } from '../gallery-view/gallery-view.component';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -48,7 +50,14 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
enableGallery = false;
|
enableGallery = false;
|
||||||
splitBy = null;
|
splitBy = null;
|
||||||
|
|
||||||
constructor(private plotService: PlotService) {
|
constructor(private plotService: PlotService, private snackBar: MatSnackBar) {
|
||||||
|
}
|
||||||
|
|
||||||
|
showError(message) {
|
||||||
|
this.snackBar.open(message, "", {
|
||||||
|
duration: 5000,
|
||||||
|
verticalPosition: 'top'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -64,6 +73,9 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
|
|
||||||
filterDefaults.fields.forEach(function(name) {
|
filterDefaults.fields.forEach(function(name) {
|
||||||
that.tagFields.push(new TagField(name));
|
that.tagFields.push(new TagField(name));
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
that.showError(error.error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
that.groupBy = that.tagFields.filter(val => filterDefaults.groupBy.includes(val.name));
|
that.groupBy = that.tagFields.filter(val => filterDefaults.groupBy.includes(val.name));
|
||||||
@@ -76,6 +88,9 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
if (!that.combinePlotTypes.includes(that.selectedCombinePlotType.value)){
|
if (!that.combinePlotTypes.includes(that.selectedCombinePlotType.value)){
|
||||||
that.selectedCombinePlotType.setValue('');
|
that.selectedCombinePlotType.setValue('');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
that.showError(error.error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,18 +110,16 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
const that = this;
|
const that = this;
|
||||||
this.plotService.splitQuery(this.query.query, this.splitBy.name).subscribe(function(valuesForSplitBy){
|
this.plotService.splitQuery(this.query.query, this.splitBy.name).subscribe(function(valuesForSplitBy){
|
||||||
console.log("valuesForSplitBy: " + JSON.stringify(valuesForSplitBy));
|
console.log("valuesForSplitBy: " + JSON.stringify(valuesForSplitBy));
|
||||||
that.plotView.errorMessage = '';
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
that.plotView.imageUrl = '';
|
that.plotView.imageUrl = '';
|
||||||
that.plotView.errorMessage = error.error.message;
|
that.showError(error.error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
plot(){
|
plot(){
|
||||||
const that = this;
|
const that = this;
|
||||||
|
|
||||||
that.plotView.errorMessage = '';
|
|
||||||
that.plotView.imageUrl = '';
|
that.plotView.imageUrl = '';
|
||||||
|
|
||||||
|
|
||||||
@@ -136,11 +149,10 @@ export class VisualizationPageComponent implements OnInit {
|
|||||||
this.plotService.sendPlotRequest(request).subscribe(function(plotResponse){
|
this.plotService.sendPlotRequest(request).subscribe(function(plotResponse){
|
||||||
console.log("response: " + JSON.stringify(plotResponse));
|
console.log("response: " + JSON.stringify(plotResponse));
|
||||||
that.plotView.imageUrl = "http://"+window.location.hostname+':8080/'+plotResponse.imageUrl;
|
that.plotView.imageUrl = "http://"+window.location.hostname+':8080/'+plotResponse.imageUrl;
|
||||||
that.plotView.errorMessage = '';
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
that.plotView.imageUrl = '';
|
that.plotView.imageUrl = '';
|
||||||
that.plotView.errorMessage = error.error.message;
|
that.showError(error.error.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user