Commit d2ec0280 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI Committed by Alex ORLUC
Browse files

FIX #16932 TIME 0:20 disable view menu if tile error

parent 17189d45
......@@ -20,9 +20,9 @@
<mat-divider *ngIf="menu==='delete'"></mat-divider>
<button *ngIf="['view', 'color'].indexOf(menu) === -1" mat-menu-item
(click)="launchAction(menu, tile)">{{'lang.'+ menu | translate}}</button>
<button *ngIf="menu==='view'" mat-menu-item
<button *ngIf="menu==='view' && !hasError(tile.id)" mat-menu-item
[matMenuTriggerFor]="toolMenuView">{{'lang.chartView' | translate}}</button>
<button *ngIf="menu==='color'" mat-menu-item
<button *ngIf="menu==='color' && !hasError(tile.id)" mat-menu-item
[matMenuTriggerFor]="toolMenuColors">{{'lang.'+ menu | translate}}</button>
</ng-container>
</mat-menu>
......@@ -66,7 +66,7 @@
</div>
</mat-menu>
</div>
<app-tile #tileComponent *ngIf="tile.id !== null" [tile]="tile" [view]="tile.view"
<app-tile #tileComponent (hasError)="tileErrors.push($event);" *ngIf="tile.id !== null" [tile]="tile" [view]="tile.view"
style="display: flex;height: 100%;flex-direction: column;width: 100%;">
</app-tile>
<button mat-button color="secondary" mat-icon-button [title]="'lang.addTile' | translate"
......
......@@ -25,6 +25,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
tiles: any = [];
hoveredTool: boolean = false;
tileErrors: any[] = [];
constructor(
......@@ -211,4 +212,9 @@ export class DashboardComponent implements OnInit, AfterViewInit {
emptyDashboard() {
return this.tiles.filter((item: any) => item.id !== null).length === 0;
}
hasError(idTile: any) {
const getTile: any = this.tileErrors.find((tile: any) => tile.id === idTile);
return getTile !== undefined ? getTile.error : false;
}
}
import { Component, OnInit, AfterViewInit, Input } from '@angular/core';
import { Component, OnInit, AfterViewInit, Input, EventEmitter, Output } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { AppService } from '@service/app.service';
......@@ -19,6 +19,8 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
@Input() tile: any = null;
@Output() hasError = new EventEmitter<any>();
loading: boolean = true;
onError: boolean = false;
errorMessage: string = '';
......@@ -81,6 +83,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors;
resolve(false);
return of(false);
......@@ -100,6 +103,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors;
resolve(false);
return of(false);
......@@ -122,6 +126,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors;
resolve(false);
return of(false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment