Fix ui issues found on testing day (#16444)

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
孙世军 2022-03-03 10:06:28 +08:00 committed by GitHub
parent eca5f48adb
commit 75bc82e5f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 23 deletions

View File

@ -52,7 +52,7 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
endTimeComparator: ClrDatagridComparatorInterface<ReplicationTask> = new CustomComparator< endTimeComparator: ClrDatagridComparatorInterface<ReplicationTask> = new CustomComparator<
ReplicationJob ReplicationJob
>("end_time", "date"); >("end_time", "date");
tasksTimeout: any;
constructor( constructor(
private translate: TranslateService, private translate: TranslateService,
private router: Router, private router: Router,
@ -90,16 +90,8 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
clrLoadPage(): void { clrLoadPage(): void {
if (!this.timerDelay) { if (!this.timerDelay) {
this.timerDelay = timer(REFRESH_TIME_DIFFERENCE, REFRESH_TIME_DIFFERENCE).subscribe(() => { this.timerDelay = timer(REFRESH_TIME_DIFFERENCE, REFRESH_TIME_DIFFERENCE).subscribe(() => {
let count: number = 0;
if (this.execution['status'] === executionStatus) { if (this.execution['status'] === executionStatus) {
count++;
}
if (count > 0) {
this.getExecutionDetail(); this.getExecutionDetail();
let state: ClrDatagridStateInterface = {
page: {}
};
this.clrLoadTasks(false, state);
} else { } else {
this.timerDelay.unsubscribe(); this.timerDelay.unsubscribe();
this.timerDelay = null; this.timerDelay = null;
@ -160,6 +152,10 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
if (this.timerDelay) { if (this.timerDelay) {
this.timerDelay.unsubscribe(); this.timerDelay.unsubscribe();
} }
if (this.tasksTimeout) {
clearTimeout(this.tasksTimeout);
this.tasksTimeout = null;
}
} }
clrLoadTasks(withLoading: boolean, state: ClrDatagridStateInterface): void { clrLoadTasks(withLoading: boolean, state: ClrDatagridStateInterface): void {
@ -200,6 +196,23 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
// Do customising filtering and sorting // Do customising filtering and sorting
this.tasks = doFiltering<ReplicationTask>(this.tasks, state); this.tasks = doFiltering<ReplicationTask>(this.tasks, state);
this.tasks = doSorting<ReplicationTask>(this.tasks, state); this.tasks = doSorting<ReplicationTask>(this.tasks, state);
let count: number = 0;
if (this.tasks?.length) {
this.tasks.forEach(item => {
if (item.status === executionStatus) {
count++;
}
});
}
if (count > 0 || this.execution?.status === executionStatus) {
if (!this.tasksTimeout) {
this.tasksTimeout = setTimeout(() => {
this.clrLoadTasks(false, {
page: {}
});
}, REFRESH_TIME_DIFFERENCE);
}
}
}, },
error => { error => {
this.errorHandler.error(error); this.errorHandler.error(error);

View File

@ -8,7 +8,7 @@ import { ErrorHandler } from "../../../../../../../../shared/units/error-handler
import { finalize } from "rxjs/operators"; import { finalize } from "rxjs/operators";
import { SafeUrl } from '@angular/platform-browser'; import { SafeUrl } from '@angular/platform-browser';
import { ArtifactService } from "../../../../artifact.service"; import { ArtifactService } from "../../../../artifact.service";
import { artifactDefault } from '../../../../artifact'; import { AccessoryQueryParams, artifactDefault } from '../../../../artifact';
export const ACCESSORY_PAGE_SIZE: number = 5; export const ACCESSORY_PAGE_SIZE: number = 5;
@ -64,9 +64,17 @@ export class SubAccessoriesComponent implements OnInit {
goIntoArtifactSummaryPage(accessory: Accessory): void { goIntoArtifactSummaryPage(accessory: Accessory): void {
const relativeRouterLink: string[] = ['artifacts', accessory.digest]; const relativeRouterLink: string[] = ['artifacts', accessory.digest];
if (this.activatedRoute.snapshot.queryParams[UN_LOGGED_PARAM] === YES) { if (this.activatedRoute.snapshot.queryParams[UN_LOGGED_PARAM] === YES) {
this.router.navigate(relativeRouterLink, {relativeTo: this.activatedRoute, queryParams: {[UN_LOGGED_PARAM]: YES}}); this.router.navigate(relativeRouterLink, {
relativeTo: this.activatedRoute, queryParams: {
[UN_LOGGED_PARAM]: YES, [AccessoryQueryParams.ACCESSORY_TYPE]: accessory.type
}
});
} else { } else {
this.router.navigate(relativeRouterLink, {relativeTo: this.activatedRoute}); this.router.navigate(relativeRouterLink, {
relativeTo: this.activatedRoute, queryParams: {
[AccessoryQueryParams.ACCESSORY_TYPE]: accessory.type
}
});
} }
} }

View File

@ -45,7 +45,9 @@
<clr-dg-column *ngIf="withNotary">{{'ACCESSORY.NOTARY_SIGNED' | translate}}</clr-dg-column> <clr-dg-column *ngIf="withNotary">{{'ACCESSORY.NOTARY_SIGNED' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'pull_time'">{{'TAG.PULL_TIME' | translate}}</clr-dg-column> <clr-dg-column [clrDgSortBy]="'pull_time'">{{'TAG.PULL_TIME' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'push_time'">{{'TAG.PUSH_TIME' | translate}}</clr-dg-column> <clr-dg-column [clrDgSortBy]="'push_time'">{{'TAG.PUSH_TIME' | translate}}</clr-dg-column>
<clr-dg-placeholder>
<span>{{'TAG.PLACEHOLDER' | translate}}</span>
</clr-dg-placeholder>
<clr-dg-row *ngFor="let tag of currentTags" [clrDgItem]="tag"> <clr-dg-row *ngFor="let tag of currentTags" [clrDgItem]="tag">
<clr-dg-cell> <clr-dg-cell>
<div class="cell white-normal" [class.immutable]="tag.immutable"> <div class="cell white-normal" [class.immutable]="tag.immutable">
@ -53,7 +55,7 @@
<span *ngIf="tag.immutable" class="label label-info ml-8">{{'REPOSITORY.IMMUTABLE' | translate}}</span> <span *ngIf="tag.immutable" class="label label-info ml-8">{{'REPOSITORY.IMMUTABLE' | translate}}</span>
</div> </div>
</clr-dg-cell> </clr-dg-cell>
<clr-dg-cell> <clr-dg-cell *ngIf="hasPullCommand()">
<hbr-copy-input [title]="getPullCommand(tag)" *ngIf="getPullCommand(tag)" [iconMode]="true" [defaultValue]="getPullCommand(tag)"></hbr-copy-input> <hbr-copy-input [title]="getPullCommand(tag)" *ngIf="getPullCommand(tag)" [iconMode]="true" [defaultValue]="getPullCommand(tag)"></hbr-copy-input>
</clr-dg-cell> </clr-dg-cell>
<clr-dg-cell *ngIf="withNotary" [ngSwitch]="tag.signed"> <clr-dg-cell *ngIf="withNotary" [ngSwitch]="tag.signed">

View File

@ -1,7 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ArtifactTagComponent } from './artifact-tag.component'; import { ArtifactTagComponent } from './artifact-tag.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { ErrorHandler } from "../../../../../shared/units/error-handler"; import { ErrorHandler } from "../../../../../shared/units/error-handler";
@ -54,8 +52,6 @@ describe('ArtifactTagComponent', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ imports: [
SharedTestingModule, SharedTestingModule,
BrowserAnimationsModule,
HttpClientTestingModule
], ],
schemas: [ schemas: [
CUSTOM_ELEMENTS_SCHEMA CUSTOM_ELEMENTS_SCHEMA

View File

@ -8,7 +8,7 @@ import { OperationService } from "../../../../../shared/components/operation/ope
import { ErrorHandler } from "../../../../../shared/units/error-handler"; import { ErrorHandler } from "../../../../../shared/units/error-handler";
import { ConfirmationButtons, ConfirmationState, ConfirmationTargets } from "../../../../../shared/entities/shared.const"; import { ConfirmationButtons, ConfirmationState, ConfirmationTargets } from "../../../../../shared/entities/shared.const";
import { operateChanges, OperateInfo, OperationState } from "../../../../../shared/components/operation/operate"; import { operateChanges, OperateInfo, OperationState } from "../../../../../shared/components/operation/operate";
import { ArtifactFront as Artifact, artifactImages, artifactPullCommands } from '../artifact'; import { AccessoryQueryParams, AccessoryType, ArtifactFront as Artifact, artifactImages, artifactPullCommands } from '../artifact';
import { ArtifactService } from '../../../../../../../ng-swagger-gen/services/artifact.service'; import { ArtifactService } from '../../../../../../../ng-swagger-gen/services/artifact.service';
import { Tag } from '../../../../../../../ng-swagger-gen/models/tag'; import { Tag } from '../../../../../../../ng-swagger-gen/models/tag';
import { SystemInfo, SystemInfoService, UserPermissionService, USERSTATICPERMISSION } from "../../../../../shared/services"; import { SystemInfo, SystemInfoService, UserPermissionService, USERSTATICPERMISSION } from "../../../../../shared/services";
@ -26,6 +26,7 @@ import { errorHandler } from "../../../../../shared/units/shared.utils";
import { ConfirmationDialogComponent } from "../../../../../shared/components/confirmation-dialog"; import { ConfirmationDialogComponent } from "../../../../../shared/components/confirmation-dialog";
import { ConfirmationMessage } from "../../../../global-confirmation-dialog/confirmation-message"; import { ConfirmationMessage } from "../../../../global-confirmation-dialog/confirmation-message";
import { ConfirmationAcknowledgement } from "../../../../global-confirmation-dialog/confirmation-state-message"; import { ConfirmationAcknowledgement } from "../../../../global-confirmation-dialog/confirmation-state-message";
import { ActivatedRoute } from '@angular/router';
class InitTag { class InitTag {
name = ""; name = "";
@ -66,6 +67,7 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
tagNameCheckSub: Subscription; tagNameCheckSub: Subscription;
tagNameCheckOnGoing = false; tagNameCheckOnGoing = false;
systemInfo: SystemInfo; systemInfo: SystemInfo;
accessoryType: string;
constructor( constructor(
private operationService: OperationService, private operationService: OperationService,
private artifactService: ArtifactService, private artifactService: ArtifactService,
@ -73,9 +75,12 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
private userPermissionService: UserPermissionService, private userPermissionService: UserPermissionService,
private systemInfoService: SystemInfoService, private systemInfoService: SystemInfoService,
private appConfigService: AppConfigService, private appConfigService: AppConfigService,
private errorHandlerService: ErrorHandler private errorHandlerService: ErrorHandler,
private activatedRoute: ActivatedRoute,
) { } ) {
this.accessoryType = this.activatedRoute.snapshot.queryParams[AccessoryQueryParams.ACCESSORY_TYPE];
}
ngOnInit() { ngOnInit() {
this.getImagePermissionRule(this.projectId); this.getImagePermissionRule(this.projectId);
this.invalidCreateTag(); this.invalidCreateTag();
@ -337,7 +342,8 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
return this.artifactDetails return this.artifactDetails
&& (this.artifactDetails.type === artifactImages[0] && (this.artifactDetails.type === artifactImages[0]
|| this.artifactDetails.type === artifactImages[1] || this.artifactDetails.type === artifactImages[1]
|| this.artifactDetails.type === artifactImages[2]); || this.artifactDetails.type === artifactImages[2])
&& this.accessoryType !== AccessoryType.COSIGN;
} }
getPullCommand(tag: Tag): string { getPullCommand(tag: Tag): string {
let pullCommand: string = ''; let pullCommand: string = '';

View File

@ -89,5 +89,7 @@ export const artifactPullCommands = [
]; ];
export const artifactDefault = "images/artifact-default.svg"; export const artifactDefault = "images/artifact-default.svg";
export enum AccessoryQueryParams {
ACCESSORY_TYPE = 'accessoryType'
}