From 95c63a45b6f01bb6db4f3fce1e065b7a0576485d Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Mon, 23 Jul 2018 11:53:51 +0200 Subject: [PATCH] mgr/dashboard: Hide progress bar in case of an error - Enhance datatable to handle loading errors. - Add warning panel component - Modify the icon of the error panel component - Use cd-[info|warning|error]-panel in the cd-view-cache component Signed-off-by: Volker Theile --- .../block/rbd-list/rbd-list.component.html | 3 +- .../ceph/block/rbd-list/rbd-list.component.ts | 7 +++ .../cephfs-list/cephfs-list.component.html | 2 +- .../cephfs-list/cephfs-list.component.ts | 14 ++++-- .../configuration.component.html | 2 +- .../configuration/configuration.component.ts | 14 ++++-- .../ceph/cluster/hosts/hosts.component.html | 2 +- .../app/ceph/cluster/hosts/hosts.component.ts | 33 +++++++------ .../pool/pool-list/pool-list.component.html | 2 +- .../pool/pool-list/pool-list.component.ts | 19 ++++---- .../rgw-bucket-list.component.html | 2 +- .../rgw-bucket-list.component.ts | 7 ++- .../rgw-daemon-list.component.html | 2 +- .../rgw-daemon-list.component.ts | 7 ++- .../rgw-user-list.component.html | 2 +- .../rgw-user-list/rgw-user-list.component.ts | 7 ++- .../shared/components/components.module.ts | 7 ++- .../error-panel/error-panel.component.html | 2 +- .../view-cache/view-cache.component.html | 21 ++++----- .../view-cache/view-cache.component.spec.ts | 10 +++- .../warning-panel.component.html | 18 ++++++++ .../warning-panel.component.scss | 9 ++++ .../warning-panel.component.spec.ts | 26 +++++++++++ .../warning-panel/warning-panel.component.ts | 14 ++++++ .../datatable/table/table.component.html | 4 ++ .../datatable/table/table.component.spec.ts | 46 +++++++++++++++++++ .../shared/datatable/table/table.component.ts | 29 ++++++++++-- .../models/cd-table-fetch-data-context.ts | 17 +++++++ 28 files changed, 256 insertions(+), 72 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/warning-panel/warning-panel.component.html create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/warning-panel/warning-panel.component.scss create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/warning-panel/warning-panel.component.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/components/warning-panel/warning-panel.component.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-table-fetch-data-context.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html index 5d915a49feac1..2ca8b9c58569c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html @@ -12,7 +12,8 @@ [status]="viewCacheStatus.status" [statusFor]="viewCacheStatus.statusFor"> -; @ViewChild('parentTpl') parentTpl: TemplateRef; @ViewChild('nameTpl') nameTpl: TemplateRef; @@ -119,6 +121,10 @@ export class RbdListComponent implements OnInit, OnDestroy { this.summaryDataSubscription = this.summaryService.summaryData$.subscribe((data: any) => { this.loadImages(data.executing_tasks); }); + }, + () => { + this.table.reset(); // Disable loading indicator. + this.viewCacheStatusList = [{ status: ViewCacheStatus.ValueException }]; }); } @@ -166,6 +172,7 @@ export class RbdListComponent implements OnInit, OnDestroy { this.executingTasks = executingTasks; }, () => { + this.table.reset(); // Disable loading indicator. this.viewCacheStatusList = [{ status: ViewCacheStatus.ValueException }]; } ); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html index 6494b2f140589..726deba82d287 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html @@ -8,7 +8,7 @@ { - this.filesystems = resp; - }); + loadFilesystems(context: CdTableFetchDataContext) { + this.cephfsService.list().subscribe( + (resp: any[]) => { + this.filesystems = resp; + }, + () => { + context.error(); + } + ); } updateSelection(selection: CdTableSelection) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.html index 834a21479d04e..f0255f6a2f491 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.html @@ -6,7 +6,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts index 5a6dc0eac9e7b..ee6b16a311870 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { ConfigurationService } from '../../../shared/api/configuration.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; @Component({ @@ -114,10 +115,15 @@ export class ConfigurationComponent implements OnInit { this.selection = selection; } - getConfigurationList() { - this.configurationService.getConfigData().subscribe((data: any) => { - this.data = data; - }); + getConfigurationList(context: CdTableFetchDataContext) { + this.configurationService.getConfigData().subscribe( + (data: any) => { + this.data = data; + }, + () => { + context.error(); + } + ); } updateFilter() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html index 9948dded8c3f4..192f060329fed 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html @@ -10,7 +10,7 @@ + (fetchData)="getHosts($event)"> { - resp.map((host) => { - host.services.map((service) => { - service.cdLink = `/perf_counters/${service.type}/${service.id}`; - const permissionKey = typeToPermissionKey[service.type]; - service.canRead = this.permissions[permissionKey].read; - return service; - }); - return host; + this.hostService.list().then((resp) => { + resp.map((host) => { + host.services.map((service) => { + service.cdLink = `/perf_counters/${service.type}/${service.id}`; + const permissionKey = typeToPermissionKey[service.type]; + service.canRead = this.permissions[permissionKey].read; + return service; }); - this.hosts = resp; - this.isLoadingHosts = false; - }) - .catch(() => { - this.isLoadingHosts = false; + return host; }); + this.hosts = resp; + this.isLoadingHosts = false; + }).catch(() => { + this.isLoadingHosts = false; + context.error(); + }); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html index 5bda82ef1000d..96f4442bfe9e1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html @@ -4,7 +4,7 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts index 303eca25d29ff..0adbe9c19b65e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { PoolService } from '../../../shared/api/pool.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; @Component({ @@ -14,9 +15,7 @@ export class PoolListComponent { columns: CdTableColumn[]; selection = new CdTableSelection(); - constructor( - private poolService: PoolService, - ) { + constructor(private poolService: PoolService) { this.columns = [ { prop: 'pool_name', @@ -68,10 +67,14 @@ export class PoolListComponent { this.selection = selection; } - getPoolList() { - this.poolService.getList().subscribe((pools: any[]) => { - this.pools = pools; - }); + getPoolList(context: CdTableFetchDataContext) { + this.poolService.getList().subscribe( + (pools: any[]) => { + this.pools = pools; + }, + () => { + context.error(); + } + ); } - } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html index fd5388573844a..0f6afe3eff225 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html @@ -15,7 +15,7 @@ selectionType="multi" (updateSelection)="updateSelection($event)" identifier="bucket" - (fetchData)="getBucketList()"> + (fetchData)="getBucketList($event)">
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts index 4136225e5033e..d03ea84fd43bb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts @@ -7,6 +7,7 @@ import { RgwBucketService } from '../../../shared/api/rgw-bucket.service'; import { DeletionModalComponent } from '../../../shared/components/deletion-modal/deletion-modal.component'; import { TableComponent } from '../../../shared/datatable/table/table.component'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { Permission } from '../../../shared/models/permissions'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; @@ -44,15 +45,13 @@ export class RgwBucketListComponent { ]; } - getBucketList() { + getBucketList(context: CdTableFetchDataContext) { this.rgwBucketService.list().subscribe( (resp: object[]) => { this.buckets = resp; }, () => { - // Force datatable to hide the loading indicator in - // case of an error. - this.buckets = []; + context.error(); } ); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html index f480f5548d64e..c93bef352bd8d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.html @@ -13,7 +13,7 @@ columnMode="flex" selectionType="single" (updateSelection)="updateSelection($event)" - (fetchData)="getDaemonList()"> + (fetchData)="getDaemonList($event)"> diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts index 848d1b24c4913..281421f788650 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { RgwDaemonService } from '../../../shared/api/rgw-daemon.service'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; +import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe'; @@ -39,15 +40,13 @@ export class RgwDaemonListComponent { ]; } - getDaemonList() { + getDaemonList(context: CdTableFetchDataContext) { this.rgwDaemonService.list().subscribe( (resp: object[]) => { this.daemons = resp; }, () => { - // Force datatable to hide the loading indicator in - // case of an error. - this.daemons = []; + context.error(); } ); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.html index 85a1427b4920d..3cb0bfd83582a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.html @@ -15,7 +15,7 @@ selectionType="multi" (updateSelection)="updateSelection($event)" identifier="user_id" - (fetchData)="getUserList()"> + (fetchData)="getUserList($event)">