Fix some UI issues (#16979)

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2022-06-13 10:44:05 +08:00 committed by GitHub
parent 4d2d7fdb1a
commit c927a3cd52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 38 deletions

View File

@ -6,9 +6,17 @@
"stylelint-config-prettier-scss" "stylelint-config-prettier-scss"
], ],
"rules": { "rules": {
"selector-pseudo-element-no-unknown": [true, { "selector-pseudo-element-no-unknown": [
"ignorePseudoElements": ["ng-deep"] true,
}], {
"ignorePseudoElements": [
"ng-deep"
]
}
],
"no-empty-source": null "no-empty-source": null
} },
"ignoreFiles": [
"src/**/*.html"
]
} }

View File

@ -44,9 +44,7 @@
</div> </div>
<div class="cron-selection"> <div class="cron-selection">
<cron-selection <cron-selection
[externalValidation]=" [externalValidation]="isValid()"
!(purgeForm.invalid || !(selectedOperations?.length > 0))
"
[labelCurrent]="getLabelCurrent" [labelCurrent]="getLabelCurrent"
[labelEdit]="getLabelCurrent" [labelEdit]="getLabelCurrent"
[originCron]="originCron" [originCron]="originCron"

View File

@ -16,6 +16,7 @@ import {
} from '../../clearing-job-interfact'; } from '../../clearing-job-interfact';
import { clone } from '../../../../../shared/units/utils'; import { clone } from '../../../../../shared/units/utils';
import { PurgeHistoryComponent } from '../history/purge-history.component'; import { PurgeHistoryComponent } from '../history/purge-history.component';
import { NgForm } from '@angular/forms';
const ONE_MINUTE: number = 60000; const ONE_MINUTE: number = 60000;
const ONE_DAY: number = 24; const ONE_DAY: number = 24;
@ -31,7 +32,7 @@ export class SetJobComponent implements OnInit, OnDestroy {
getLabelCurrent = 'CLEARANCES.SCHEDULE_TO_PURGE'; getLabelCurrent = 'CLEARANCES.SCHEDULE_TO_PURGE';
loadingGcStatus = false; loadingGcStatus = false;
@ViewChild(CronScheduleComponent) @ViewChild(CronScheduleComponent)
CronScheduleComponent: CronScheduleComponent; cronScheduleComponent: CronScheduleComponent;
dryRunOnGoing: boolean = false; dryRunOnGoing: boolean = false;
lastCompletedTime: string; lastCompletedTime: string;
loadingLastCompletedTime: boolean = false; loadingLastCompletedTime: boolean = false;
@ -45,6 +46,8 @@ export class SetJobComponent implements OnInit, OnDestroy {
selectedOperations: string[] = clone(RETENTION_OPERATIONS); selectedOperations: string[] = clone(RETENTION_OPERATIONS);
@ViewChild(PurgeHistoryComponent) @ViewChild(PurgeHistoryComponent)
purgeHistoryComponent: PurgeHistoryComponent; purgeHistoryComponent: PurgeHistoryComponent;
@ViewChild('purgeForm')
purgeForm: NgForm;
constructor( constructor(
private purgeService: PurgeService, private purgeService: PurgeService,
private errorHandler: ErrorHandler private errorHandler: ErrorHandler
@ -80,10 +83,10 @@ export class SetJobComponent implements OnInit, OnDestroy {
this.statusTimeout = setTimeout(() => { this.statusTimeout = setTimeout(() => {
this.getStatus(); this.getStatus();
}, REFRESH_STATUS_TIME_DIFFERENCE); }, REFRESH_STATUS_TIME_DIFFERENCE);
} else { return;
}
}
this.loadingLastCompletedTime = false; this.loadingLastCompletedTime = false;
}
}
}); });
} }
getCurrentSchedule(withLoading: boolean) { getCurrentSchedule(withLoading: boolean) {
@ -108,11 +111,9 @@ export class SetJobComponent implements OnInit, OnDestroy {
} }
initSchedule(purgeHistory: ExecHistory) { initSchedule(purgeHistory: ExecHistory) {
if ((purgeHistory?.schedule as any)?.next_scheduled_time) { this.nextScheduledTime = purgeHistory?.schedule?.next_scheduled_time
this.nextScheduledTime = ( ? purgeHistory?.schedule?.next_scheduled_time
purgeHistory.schedule as any : null;
)?.next_scheduled_time;
}
if (purgeHistory && purgeHistory.schedule) { if (purgeHistory && purgeHistory.schedule) {
this.originCron = { this.originCron = {
type: purgeHistory.schedule.type, type: purgeHistory.schedule.type,
@ -244,7 +245,7 @@ export class SetJobComponent implements OnInit, OnDestroy {
this.errorHandler.info( this.errorHandler.info(
'CLEARANCES.PURGE_SCHEDULE_RESET' 'CLEARANCES.PURGE_SCHEDULE_RESET'
); );
this.CronScheduleComponent.resetSchedule(); this.cronScheduleComponent.resetSchedule();
this.getCurrentSchedule(false); // refresh schedule this.getCurrentSchedule(false); // refresh schedule
}, },
error: error => { error: error => {
@ -272,7 +273,7 @@ export class SetJobComponent implements OnInit, OnDestroy {
this.errorHandler.info( this.errorHandler.info(
'CLEARANCES.PURGE_SCHEDULE_RESET' 'CLEARANCES.PURGE_SCHEDULE_RESET'
); );
this.CronScheduleComponent.resetSchedule(); this.cronScheduleComponent.resetSchedule();
this.getCurrentSchedule(false); // refresh schedule this.getCurrentSchedule(false); // refresh schedule
}, },
error: error => { error: error => {
@ -304,4 +305,12 @@ export class SetJobComponent implements OnInit, OnDestroy {
this.getStatus(); this.getStatus();
this.purgeHistoryComponent?.refresh(); this.purgeHistoryComponent?.refresh();
} }
isValid(): boolean {
if (this.cronScheduleComponent?.scheduleType === ScheduleType.NONE) {
return true;
}
return !(
this.purgeForm?.invalid || !(this.selectedOperations?.length > 0)
);
}
} }

View File

@ -25,7 +25,7 @@ export class GcComponent implements OnInit, OnDestroy {
getLabelCurrent = 'GC.CURRENT_SCHEDULE'; getLabelCurrent = 'GC.CURRENT_SCHEDULE';
loadingGcStatus = false; loadingGcStatus = false;
@ViewChild(CronScheduleComponent) @ViewChild(CronScheduleComponent)
CronScheduleComponent: CronScheduleComponent; cronScheduleComponent: CronScheduleComponent;
shouldDeleteUntagged: boolean; shouldDeleteUntagged: boolean;
dryRunOnGoing: boolean = false; dryRunOnGoing: boolean = false;
@ -41,7 +41,7 @@ export class GcComponent implements OnInit, OnDestroy {
) {} ) {}
ngOnInit() { ngOnInit() {
this.getCurrentSchedule(); this.getCurrentSchedule(true);
this.getStatus(); this.getStatus();
} }
ngOnDestroy() { ngOnDestroy() {
@ -70,14 +70,16 @@ export class GcComponent implements OnInit, OnDestroy {
this.statusTimeout = setTimeout(() => { this.statusTimeout = setTimeout(() => {
this.getStatus(); this.getStatus();
}, REFRESH_STATUS_TIME_DIFFERENCE); }, REFRESH_STATUS_TIME_DIFFERENCE);
} else { return;
}
}
this.loadingLastCompletedTime = false; this.loadingLastCompletedTime = false;
}
}
}); });
} }
getCurrentSchedule() { getCurrentSchedule(withLoading: boolean) {
if (withLoading) {
this.loadingGcStatus = true; this.loadingGcStatus = true;
}
this.gcService this.gcService
.getGCSchedule() .getGCSchedule()
.pipe( .pipe(
@ -96,11 +98,9 @@ export class GcComponent implements OnInit, OnDestroy {
} }
private initSchedule(gcHistory: GCHistory) { private initSchedule(gcHistory: GCHistory) {
if ((gcHistory?.schedule as any)?.next_scheduled_time) { this.nextScheduledTime = gcHistory?.schedule?.next_scheduled_time
this.nextScheduledTime = ( ? gcHistory?.schedule?.next_scheduled_time
gcHistory.schedule as any : null;
)?.next_scheduled_time;
}
if (gcHistory && gcHistory.schedule) { if (gcHistory && gcHistory.schedule) {
this.originCron = { this.originCron = {
type: gcHistory.schedule.type, type: gcHistory.schedule.type,
@ -199,8 +199,8 @@ export class GcComponent implements OnInit, OnDestroy {
.subscribe( .subscribe(
response => { response => {
this.errorHandler.info('GC.MSG_SCHEDULE_RESET'); this.errorHandler.info('GC.MSG_SCHEDULE_RESET');
this.CronScheduleComponent.resetSchedule(); this.cronScheduleComponent.resetSchedule();
this.getCurrentSchedule(); // refresh schedule this.getCurrentSchedule(false); // refresh schedule
}, },
error => { error => {
this.errorHandler.error(error); this.errorHandler.error(error);
@ -223,8 +223,8 @@ export class GcComponent implements OnInit, OnDestroy {
.subscribe( .subscribe(
response => { response => {
this.errorHandler.info('GC.MSG_SCHEDULE_RESET'); this.errorHandler.info('GC.MSG_SCHEDULE_RESET');
this.CronScheduleComponent.resetSchedule(); this.cronScheduleComponent.resetSchedule();
this.getCurrentSchedule(); // refresh schedule this.getCurrentSchedule(false); // refresh schedule
}, },
error => { error => {
this.errorHandler.error(error); this.errorHandler.error(error);

View File

@ -122,6 +122,9 @@ export class SecurityComponent implements OnInit, OnDestroy {
this.systemInfoService.getSystemAllowlist().subscribe( this.systemInfoService.getSystemAllowlist().subscribe(
systemAllowlist => { systemAllowlist => {
this.onGoing = false; this.onGoing = false;
if (!systemAllowlist) {
systemAllowlist = {};
}
if (!systemAllowlist.items) { if (!systemAllowlist.items) {
systemAllowlist.items = []; systemAllowlist.items = [];
} }

View File

@ -306,6 +306,9 @@ export class CreateProjectComponent
+this.storageLimit === QuotaUnlimited +this.storageLimit === QuotaUnlimited
? this.storageLimit ? this.storageLimit
: getByte(+this.storageLimit, this.storageLimitUnit); : getByte(+this.storageLimit, this.storageLimitUnit);
const registryId: number = this.enableProxyCache
? +this.project.registry_id
: null;
this.projectService this.projectService
.createProject({ .createProject({
project: { project: {
@ -314,7 +317,7 @@ export class CreateProjectComponent
public: this.project.metadata.public ? 'true' : 'false', public: this.project.metadata.public ? 'true' : 'false',
}, },
storage_limit: +storageByte, storage_limit: +storageByte,
registry_id: +this.project.registry_id, registry_id: registryId,
}, },
}) })
.subscribe( .subscribe(

View File

@ -340,12 +340,13 @@ export class TagRetentionComponent implements OnInit, OnDestroy {
} }
} }
// data grid will be re-rendered if reassign "this.executionList" // data grid will be re-rendered if reassign "this.executionList"
// so only refresh the status property // so only refresh the status and the end_time property
if (res?.body?.length) { if (res?.body?.length) {
res.body.forEach(item => { res.body.forEach(item => {
this.executionList.forEach(item2 => { this.executionList.forEach(item2 => {
if (item2.id === item.id) { if (item2.id === item.id) {
item2.status = item.status; item2.status = item.status;
item2.end_time = item.end_time;
} }
}); });
}); });

View File

@ -434,10 +434,10 @@ export interface ProjectRootInterface {
LABEL: string; LABEL: string;
} }
export interface SystemCVEAllowlist { export interface SystemCVEAllowlist {
id: number; id?: number;
project_id: number; project_id?: number;
expires_at: number; expires_at?: number;
items: Array<{ cve_id: string }>; items?: Array<{ cve_id: string }>;
} }
export interface QuotaHardInterface { export interface QuotaHardInterface {
storage_per_project: number; storage_per_project: number;