Merge pull request #34142 from rhcs-dashboard/wip-44667-fix-reload-issues

Reviewed-by: Tiago Melo <tmelo@suse.com>
Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
Lenz Grimmer 2020-04-24 15:58:17 +02:00 committed by GitHub
commit 88cb9f7adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 5 deletions

View File

@ -1,3 +1,7 @@
<cd-alert-panel *ngIf="isStale"
type="warning"
size="slim"
i18n>The bucket list data might be stale. If needed, you can manually reload it.</cd-alert-panel>
<cd-table #table
[autoReload]="false"
[data]="buckets"

View File

@ -1,4 +1,4 @@
import { Component, ViewChild } from '@angular/core';
import { Component, NgZone, ViewChild } from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalService } from 'ngx-bootstrap/modal';
@ -35,6 +35,8 @@ export class RgwBucketListComponent extends ListWithDetails {
columns: CdTableColumn[] = [];
buckets: object[] = [];
selection: CdTableSelection = new CdTableSelection();
isStale = false;
staleTimeout: number;
constructor(
private authStorageService: AuthStorageService,
@ -42,7 +44,8 @@ export class RgwBucketListComponent extends ListWithDetails {
private bsModalService: BsModalService,
private i18n: I18n,
private urlBuilder: URLBuilderService,
public actionLabels: ActionLabelsI18n
public actionLabels: ActionLabelsI18n,
private ngZone: NgZone
) {
super();
this.permission = this.authStorageService.getPermissions().rgw;
@ -82,9 +85,23 @@ export class RgwBucketListComponent extends ListWithDetails {
canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
};
this.tableActions = [addAction, editAction, deleteAction];
this.timeConditionReached();
}
timeConditionReached() {
clearTimeout(this.staleTimeout);
this.ngZone.runOutsideAngular(() => {
this.staleTimeout = window.setTimeout(() => {
this.ngZone.run(() => {
this.isStale = true;
});
}, 10000);
});
}
getBucketList(context: CdTableFetchDataContext) {
this.isStale = false;
this.timeConditionReached();
this.rgwBucketService.list().subscribe(
(resp: object[]) => {
this.buckets = resp;

View File

@ -1,3 +1,7 @@
<cd-alert-panel *ngIf="isStale"
type="warning"
size="slim"
i18n>The user list data might be stale. If needed, you can manually reload it.</cd-alert-panel>
<cd-table #table
[autoReload]="false"
[data]="users"

View File

@ -1,4 +1,4 @@
import { Component, ViewChild } from '@angular/core';
import { Component, NgZone, ViewChild } from '@angular/core';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalService } from 'ngx-bootstrap/modal';
@ -30,12 +30,13 @@ const BASE_URL = 'rgw/user';
export class RgwUserListComponent extends ListWithDetails {
@ViewChild(TableComponent, { static: true })
table: TableComponent;
permission: Permission;
tableActions: CdTableAction[];
columns: CdTableColumn[] = [];
users: object[] = [];
selection: CdTableSelection = new CdTableSelection();
isStale = false;
staleTimeout: number;
constructor(
private authStorageService: AuthStorageService,
@ -43,7 +44,8 @@ export class RgwUserListComponent extends ListWithDetails {
private bsModalService: BsModalService,
private i18n: I18n,
private urlBuilder: URLBuilderService,
public actionLabels: ActionLabelsI18n
public actionLabels: ActionLabelsI18n,
private ngZone: NgZone
) {
super();
this.permission = this.authStorageService.getPermissions().rgw;
@ -105,9 +107,23 @@ export class RgwUserListComponent extends ListWithDetails {
canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
};
this.tableActions = [addAction, editAction, deleteAction];
this.timeConditionReached();
}
timeConditionReached() {
clearTimeout(this.staleTimeout);
this.ngZone.runOutsideAngular(() => {
this.staleTimeout = window.setTimeout(() => {
this.ngZone.run(() => {
this.isStale = true;
});
}, 10000);
});
}
getUserList(context: CdTableFetchDataContext) {
this.isStale = false;
this.timeConditionReached();
this.rgwUserService.list().subscribe(
(resp: object[]) => {
this.users = resp;