Commit 0b93d03b authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #16932 TIME 0:10 hide view and color menus if tile error

parent 45c5a3de
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
<mat-divider *ngIf="menu==='delete'"></mat-divider> <mat-divider *ngIf="menu==='delete'"></mat-divider>
<button *ngIf="['view', 'color'].indexOf(menu) === -1" mat-menu-item <button *ngIf="['view', 'color'].indexOf(menu) === -1" mat-menu-item
(click)="launchAction(menu, tile)">{{'lang.'+ menu | translate}}</button> (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> [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> [matMenuTriggerFor]="toolMenuColors">{{'lang.'+ menu | translate}}</button>
</ng-container> </ng-container>
</mat-menu> </mat-menu>
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</div> </div>
</mat-menu> </mat-menu>
</div> </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%;"> style="display: flex;height: 100%;flex-direction: column;width: 100%;">
</app-tile> </app-tile>
<button mat-button color="secondary" mat-icon-button [title]="'lang.addTile' | translate" <button mat-button color="secondary" mat-icon-button [title]="'lang.addTile' | translate"
......
...@@ -23,6 +23,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { ...@@ -23,6 +23,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
tiles: any = []; tiles: any = [];
hoveredTool: boolean = false; hoveredTool: boolean = false;
tileErrors: any[] = [];
@ViewChildren('tileComponent') tileComponent: QueryList<any>; @ViewChildren('tileComponent') tileComponent: QueryList<any>;
...@@ -210,4 +211,10 @@ export class DashboardComponent implements OnInit, AfterViewInit { ...@@ -210,4 +211,10 @@ export class DashboardComponent implements OnInit, AfterViewInit {
emptyDashboard() { emptyDashboard() {
return this.tiles.filter((item: any) => item.id !== null).length === 0; 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 { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { AppService } from '@service/app.service'; import { AppService } from '@service/app.service';
...@@ -19,6 +19,8 @@ export class TileDashboardComponent implements OnInit, AfterViewInit { ...@@ -19,6 +19,8 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
@Input() tile: any = null; @Input() tile: any = null;
@Output() hasError = new EventEmitter<any>();
loading: boolean = true; loading: boolean = true;
onError: boolean = false; onError: boolean = false;
errorMessage: string = ''; errorMessage: string = '';
...@@ -81,6 +83,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit { ...@@ -81,6 +83,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err); console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) })); this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true; this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors; this.errorMessage = err.error.errors;
resolve(false); resolve(false);
return of(false); return of(false);
...@@ -100,6 +103,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit { ...@@ -100,6 +103,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err); console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) })); this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true; this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors; this.errorMessage = err.error.errors;
resolve(false); resolve(false);
return of(false); return of(false);
...@@ -122,6 +126,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit { ...@@ -122,6 +126,7 @@ export class TileDashboardComponent implements OnInit, AfterViewInit {
console.log(err); console.log(err);
this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) })); this.notify.error(this.translate.instant('lang.tileLoadError', { 0: (this.tile.position + 1) }));
this.onError = true; this.onError = true;
this.hasError.emit({id: this.tile.id, error: this.onError});
this.errorMessage = err.error.errors; this.errorMessage = err.error.errors;
resolve(false); resolve(false);
return of(false); return of(false);
......
Supports Markdown
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