mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-01 06:47:33 +02:00
Force refresh user list view
This commit is contained in:
parent
9057f751e3
commit
056b15c74b
@ -6,8 +6,8 @@
|
||||
<button [class.hide-create]="!canCreateUser" type="submit" class="btn btn-link custom-add-button" (click)="addNewUser()"><clr-icon shape="add"></clr-icon> {{'USER.ADD_ACTION' | translate}}</button>
|
||||
</span>
|
||||
<hbr-filter [withDivider]="true" class="filter-pos" filterPlaceholder='{{"USER.FILTER_PLACEHOLDER" | translate}}' (filter)="doFilter($event)" [currentValue]="currentTerm"></hbr-filter>
|
||||
<span class="refresh-btn" (click)="refresh()">
|
||||
<clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress"></clr-icon>
|
||||
<span class="refresh-btn">
|
||||
<clr-icon shape="refresh" [hidden]="inProgress" ng-disabled="inProgress" (click)="refresh()"></clr-icon>
|
||||
<span class="spinner spinner-inline" [hidden]="inProgress === false"></span>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -60,6 +60,8 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(NewUserModalComponent)
|
||||
newUserDialog: NewUserModalComponent;
|
||||
|
||||
timerHandler: any;
|
||||
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private translate: TranslateService,
|
||||
@ -75,8 +77,6 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
this.delUser(confirmed.data);
|
||||
}
|
||||
});
|
||||
let hnd = setInterval(() => ref.markForCheck(), 100);
|
||||
setTimeout(() => clearInterval(hnd), 1000);
|
||||
}
|
||||
|
||||
isMySelf(uid: number): boolean {
|
||||
@ -126,12 +126,18 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.forceRefreshView(5000);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.deletionSubscription) {
|
||||
this.deletionSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
if (this.timerHandler) {
|
||||
clearInterval(this.timerHandler);
|
||||
this.timerHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
//Filter items by keywords
|
||||
@ -143,11 +149,10 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
} else {
|
||||
this.users = users.filter(user => {
|
||||
return this.isMatchFilterTerm(terms, user.username);
|
||||
})
|
||||
});
|
||||
this.forceRefreshView(5000);
|
||||
}
|
||||
});
|
||||
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
||||
setTimeout(() => clearInterval(hnd), 1000);
|
||||
}
|
||||
|
||||
//Disable the admin role for the specified user
|
||||
@ -175,8 +180,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
.then(() => {
|
||||
//Change view now
|
||||
user.has_admin_role = updatedUser.has_admin_role;
|
||||
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
||||
setTimeout(() => clearInterval(hnd), 1000);
|
||||
this.forceRefreshView(5000);
|
||||
})
|
||||
.catch(error => {
|
||||
this.msgHandler.handleError(error);
|
||||
@ -233,14 +237,15 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
this.totalCount = users.length;
|
||||
this.users = users.slice(from, to);//First page
|
||||
|
||||
this.forceRefreshView(5000);
|
||||
|
||||
return users;
|
||||
})
|
||||
.catch(error => {
|
||||
this.onGoing = false;
|
||||
this.msgHandler.handleError(error);
|
||||
this.forceRefreshView(5000);
|
||||
});
|
||||
let hnd = setInterval(() => this.ref.markForCheck(), 100);
|
||||
setTimeout(() => clearInterval(hnd), 1000);
|
||||
}
|
||||
|
||||
//Add new user
|
||||
@ -264,6 +269,7 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
this.originalUsers.then(users => {
|
||||
this.users = users.slice(state.page.from, state.page.to + 1);
|
||||
});
|
||||
this.forceRefreshView(5000);
|
||||
} else {
|
||||
this.refreshUser(state.page.from, state.page.to + 1);
|
||||
}
|
||||
@ -278,4 +284,18 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
this.refreshUser(0, 15);
|
||||
}
|
||||
|
||||
forceRefreshView(duration: number): void {
|
||||
//Reset timer
|
||||
if (this.timerHandler) {
|
||||
clearInterval(this.timerHandler);
|
||||
}
|
||||
this.timerHandler = setInterval(() => this.ref.markForCheck(), 100);
|
||||
setTimeout(() => {
|
||||
if (this.timerHandler) {
|
||||
clearInterval(this.timerHandler);
|
||||
this.timerHandler = null;
|
||||
}
|
||||
}, duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user