Skip to content

Commit

Permalink
Merge pull request goharbor#7559 from pureshine/add-loading
Browse files Browse the repository at this point in the history
Add loading to the vulnerability page and the gc page
  • Loading branch information
zhoumeina authored Apr 29, 2019
2 parents c9f2bf3 + 12737bf commit 8718000
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h5 class="history-header" id="history-header">{{'GC.JOB_HISTORY' | translate}}</h5>
<clr-datagrid>
<clr-datagrid [clrDgLoading]="loading">
<clr-dg-column>{{'GC.JOB_ID' | translate}}</clr-dg-column>
<clr-dg-column>{{'GC.TRIGGER_TYPE' | translate}}</clr-dg-column>
<clr-dg-column>{{'STATUS' | translate}}</clr-dg-column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { GcRepoService } from "../gc.service";
import { GcJobViewModel } from "../gcLog";
import { GcViewModelFactory } from "../gc.viewmodel.factory";
import { ErrorHandler } from "../../../error-handler/index";

@Component({
selector: 'gc-history',
Expand All @@ -10,18 +11,25 @@ import { GcViewModelFactory } from "../gc.viewmodel.factory";
})
export class GcHistoryComponent implements OnInit {
jobs: Array<GcJobViewModel> = [];
loading: boolean;
constructor(
private gcRepoService: GcRepoService,
private gcViewModelFactory: GcViewModelFactory,
private errorHandler: ErrorHandler
) {}

ngOnInit() {
this.getJobs();
}

getJobs() {
this.loading = true;
this.gcRepoService.getJobs().subscribe(jobs => {
this.jobs = this.gcViewModelFactory.createJobViewModel(jobs);
this.loading = false;
}, error => {
this.errorHandler.error(error);
this.loading = false;
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/portal/lib/src/config/gc/gc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class GcComponent implements OnInit {
disableGC: boolean = false;
getText = 'CONFIG.GC';
getLabelCurrent = 'GC.CURRENT_SCHEDULE';
@Output() loadingGcStatus = new EventEmitter<boolean>();
@ViewChild(CronScheduleComponent)
CronScheduleComponent: CronScheduleComponent;
constructor(
Expand All @@ -48,8 +49,10 @@ export class GcComponent implements OnInit {
}

getCurrentSchedule() {
this.loadingGcStatus.emit(true);
this.gcRepoService.getSchedule().subscribe(schedule => {
this.initSchedule(schedule);
this.loadingGcStatus.emit(false);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const SCHEDULE_TYPE_NONE = "None";
styleUrls: ['./vulnerability-config.component.scss', '../registry-config.component.scss']
})
export class VulnerabilityConfigComponent implements OnInit {
onGoing: boolean;
_localTime: Date = new Date();
originCron: OriginCron;
schedule: any;
Expand All @@ -40,6 +41,7 @@ export class VulnerabilityConfigComponent implements OnInit {

@Input() showSubTitle: boolean = false;
@Input() showScanningNamespaces: boolean = false;
@Output() loadingStatus = new EventEmitter<boolean>();
systemInfo: SystemInfo;

constructor(
Expand Down Expand Up @@ -83,8 +85,11 @@ export class VulnerabilityConfigComponent implements OnInit {
}

getSchedule() {
this.onGoing = true;
this.scanningService.getSchedule().subscribe(schedule => {
this.initSchedule(schedule);
this.onGoing = false;
this.loadingStatus.emit(this.onGoing);
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/portal/src/app/gc-page/gc-page.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h2 class="custom-h2 gc-title">{{'CONFIG.GC' | translate }}</h2>
<span class="spinner spinner-inline" [hidden]="!inProgress"></span>
<clr-tabs>
<clr-tab *ngIf="hasAdminRole">
<button id="config-gc" clrTabLink>{{'CONFIG.GC' | translate }}</button>
<ng-template [(clrIfActive)]="gcActive">
<clr-tab-content id="gc" *ngIf="hasAdminRole">
<gc-config></gc-config>
<gc-config (loadingGcStatus)="getGcStatus($event)"></gc-config>
</clr-tab-content>
</ng-template>
</clr-tab>
Expand Down
5 changes: 5 additions & 0 deletions src/portal/src/app/gc-page/gc-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SessionService } from "../shared/session.service";
styleUrls: ["./gc-page.component.scss"]
})
export class GcPageComponent implements OnInit {
inProgress: boolean;
constructor(private session: SessionService) {}

ngOnInit() {}
Expand All @@ -16,4 +17,8 @@ export class GcPageComponent implements OnInit {
this.session.getCurrentUser().has_admin_role
);
}

getGcStatus(status: boolean) {
this.inProgress = status;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h2 class="custom-h2 vul-title">{{'VULNERABILITY.SINGULAR' | translate }}</h2>
<span class="spinner spinner-inline" [hidden]="!inProgress"></span>
<clr-tabs>
<clr-tab *ngIf="withClair">
<clr-tab>
<button id="config-vulnerability" clrTabLink>{{'CONFIG.VULNERABILITY' | translate }}</button>
<ng-template [(clrIfActive)]="vulnerabilityActive">
<clr-tab-content id="vulnerability" *ngIf="withClair">
<vulnerability-config></vulnerability-config>
<clr-tab-content id="vulnerability">
<vulnerability-config (loadingStatus)="getStatus($event)"></vulnerability-config>
</clr-tab-content>
</ng-template>
</clr-tab>
</clr-tabs>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { AppConfigService } from "../app-config.service";
styleUrls: ["./vulnerability-page.component.scss"]
})
export class VulnerabilityPageComponent implements OnInit {
inProgress: boolean = true;
constructor(private appConfigService: AppConfigService) {}

ngOnInit() {}

public get withClair(): boolean {
return this.appConfigService.getConfig().with_clair;
getStatus(status: boolean) {
this.inProgress = false;
}
}

0 comments on commit 8718000

Please sign in to comment.