mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 09:38:09 +01:00
Merge pull request #12592 from AllForNothing/improve-p2p
Improve p2p-preheat ui
This commit is contained in:
commit
0598b3f712
@ -50,7 +50,7 @@ export class AddP2pPolicyComponent implements OnInit {
|
|||||||
repos: string;
|
repos: string;
|
||||||
tags: string;
|
tags: string;
|
||||||
onlySignedImages: boolean = false;
|
onlySignedImages: boolean = false;
|
||||||
severity: number = 0;
|
severity: number;
|
||||||
labels: string;
|
labels: string;
|
||||||
triggerType: string = TRIGGER.MANUAL;
|
triggerType: string = TRIGGER.MANUAL;
|
||||||
cron: string ;
|
cron: string ;
|
||||||
@ -96,7 +96,6 @@ export class AddP2pPolicyComponent implements OnInit {
|
|||||||
|
|
||||||
resetForAdd() {
|
resetForAdd() {
|
||||||
this.currentForm.reset({
|
this.currentForm.reset({
|
||||||
severity: 0,
|
|
||||||
triggerType: "manual"
|
triggerType: "manual"
|
||||||
});
|
});
|
||||||
this.inlineAlert.close();
|
this.inlineAlert.close();
|
||||||
@ -104,7 +103,7 @@ export class AddP2pPolicyComponent implements OnInit {
|
|||||||
this.repos = null;
|
this.repos = null;
|
||||||
this.tags = null;
|
this.tags = null;
|
||||||
this.onlySignedImages = false;
|
this.onlySignedImages = false;
|
||||||
this.severity = 0;
|
this.severity = null;
|
||||||
this.labels = null;
|
this.labels = null;
|
||||||
this.triggerType = "manual";
|
this.triggerType = "manual";
|
||||||
this.cron = null;
|
this.cron = null;
|
||||||
@ -173,7 +172,7 @@ export class AddP2pPolicyComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.severity === 0 || this.severity > 0) {
|
if (this.severity === 0 || this.severity > 0) {
|
||||||
filters.push({type: FILTER_TYPE.VULNERABILITY, value: this.severity});
|
filters.push({type: FILTER_TYPE.VULNERABILITY, value: +this.severity});
|
||||||
}
|
}
|
||||||
policy.filters = JSON.stringify(filters);
|
policy.filters = JSON.stringify(filters);
|
||||||
const trigger: any = {
|
const trigger: any = {
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
} from '../../../../lib/services';
|
} from '../../../../lib/services';
|
||||||
import { ClrLoadingState } from '@clr/angular';
|
import { ClrLoadingState } from '@clr/angular';
|
||||||
import {
|
import {
|
||||||
|
EXECUTION_STATUS,
|
||||||
FILTER_TYPE,
|
FILTER_TYPE,
|
||||||
P2pProviderService,
|
P2pProviderService,
|
||||||
PROJECT_SEVERITY_LEVEL_TO_TEXT_MAP,
|
PROJECT_SEVERITY_LEVEL_TO_TEXT_MAP,
|
||||||
@ -79,6 +80,7 @@ export class PolicyComponent implements OnInit, OnDestroy {
|
|||||||
private _searchSubscription: Subscription;
|
private _searchSubscription: Subscription;
|
||||||
project: Project;
|
project: Project;
|
||||||
severity_map: any = PROJECT_SEVERITY_LEVEL_TO_TEXT_MAP;
|
severity_map: any = PROJECT_SEVERITY_LEVEL_TO_TEXT_MAP;
|
||||||
|
timeout: any;
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@ -104,6 +106,10 @@ export class PolicyComponent implements OnInit, OnDestroy {
|
|||||||
this._searchSubscription.unsubscribe();
|
this._searchSubscription.unsubscribe();
|
||||||
this._searchSubscription = null;
|
this._searchSubscription = null;
|
||||||
}
|
}
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
const permissionsList: Observable<boolean>[] = [];
|
const permissionsList: Observable<boolean>[] = [];
|
||||||
@ -171,11 +177,13 @@ export class PolicyComponent implements OnInit, OnDestroy {
|
|||||||
if (message && message.source === ConfirmationTargets.P2P_PROVIDER_STOP &&
|
if (message && message.source === ConfirmationTargets.P2P_PROVIDER_STOP &&
|
||||||
message.state === ConfirmationState.CONFIRMED) {
|
message.state === ConfirmationState.CONFIRMED) {
|
||||||
this.stopLoading = true;
|
this.stopLoading = true;
|
||||||
|
const execution: Execution = clone(this.selectedExecutionRow);
|
||||||
|
execution.status = EXECUTION_STATUS.STOPPED;
|
||||||
this.preheatService.StopExecution({
|
this.preheatService.StopExecution({
|
||||||
projectName: this.projectName,
|
projectName: this.projectName,
|
||||||
preheatPolicyName: this.selectedRow.name,
|
preheatPolicyName: this.selectedRow.name,
|
||||||
executionId: this.selectedExecutionRow.id,
|
executionId: this.selectedExecutionRow.id,
|
||||||
execution: this.selectedExecutionRow
|
execution: execution
|
||||||
}).pipe(finalize(() => this.executing = false))
|
}).pipe(finalize(() => this.executing = false))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
this.messageHandlerService.showSuccess('P2P_PROVIDER.STOP_SUCCESSFULLY');
|
this.messageHandlerService.showSuccess('P2P_PROVIDER.STOP_SUCCESSFULLY');
|
||||||
@ -364,12 +372,14 @@ export class PolicyComponent implements OnInit, OnDestroy {
|
|||||||
if (this.executionList && this.executionList.length) {
|
if (this.executionList && this.executionList.length) {
|
||||||
for (let i = 0; i < this.executionList.length; i++) {
|
for (let i = 0; i < this.executionList.length; i++) {
|
||||||
if (this.p2pProviderService.willChangStatus(this.executionList[i].status)) {
|
if (this.p2pProviderService.willChangStatus(this.executionList[i].status)) {
|
||||||
setTimeout(() => {
|
if (!this.timeout) {
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
this.clrLoadJobs(null, false);
|
this.clrLoadJobs(null, false);
|
||||||
}, TIME_OUT);
|
}, TIME_OUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
this.messageHandlerService.handleError(error);
|
this.messageHandlerService.handleError(error);
|
||||||
});
|
});
|
||||||
|
@ -103,7 +103,11 @@
|
|||||||
</clr-tooltip-content>
|
</clr-tooltip-content>
|
||||||
</clr-tooltip>
|
</clr-tooltip>
|
||||||
</clr-dg-cell>
|
</clr-dg-cell>
|
||||||
<clr-dg-cell>{{toJsonString(t.extra_attrs)}}</clr-dg-cell>
|
<clr-dg-cell>
|
||||||
|
<span>{{t.extra_attrs?.artifact}}</span>,
|
||||||
|
<span>{{t.extra_attrs?.digest}}</span>,
|
||||||
|
<span>{{t.extra_attrs?.kind}}</span>
|
||||||
|
</clr-dg-cell>
|
||||||
<clr-dg-cell>{{t.start_time | date: 'short'}}</clr-dg-cell>
|
<clr-dg-cell>{{t.start_time | date: 'short'}}</clr-dg-cell>
|
||||||
<clr-dg-cell>{{getDuration(t)}}</clr-dg-cell>
|
<clr-dg-cell>{{getDuration(t)}}</clr-dg-cell>
|
||||||
<clr-dg-cell>
|
<clr-dg-cell>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { finalize } from 'rxjs/operators';
|
import { finalize } from 'rxjs/operators';
|
||||||
import { CustomComparator, DEFAULT_PAGE_SIZE, isEmptyObject } from '../../../../lib/utils/utils';
|
import { clone, CustomComparator, DEFAULT_PAGE_SIZE, isEmptyObject } from '../../../../lib/utils/utils';
|
||||||
import { Task } from '../../../../../ng-swagger-gen/models/task';
|
import { Task } from '../../../../../ng-swagger-gen/models/task';
|
||||||
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
|
import { MessageHandlerService } from '../../../shared/message-handler/message-handler.service';
|
||||||
import { Project } from '../../project';
|
import { Project } from '../../project';
|
||||||
@ -18,7 +18,7 @@ import { ClrLoadingState } from '@clr/angular';
|
|||||||
templateUrl: './task-list.component.html',
|
templateUrl: './task-list.component.html',
|
||||||
styleUrls: ['./task-list.component.scss']
|
styleUrls: ['./task-list.component.scss']
|
||||||
})
|
})
|
||||||
export class TaskListComponent implements OnInit {
|
export class TaskListComponent implements OnInit, OnDestroy {
|
||||||
projectId: number;
|
projectId: number;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
isOpenFilterTag: boolean;
|
isOpenFilterTag: boolean;
|
||||||
@ -35,6 +35,7 @@ export class TaskListComponent implements OnInit {
|
|||||||
execution: Execution;
|
execution: Execution;
|
||||||
hasUpdatePermission: boolean = false;
|
hasUpdatePermission: boolean = false;
|
||||||
btnState: ClrLoadingState = ClrLoadingState.DEFAULT;
|
btnState: ClrLoadingState = ClrLoadingState.DEFAULT;
|
||||||
|
timeout: any;
|
||||||
constructor(
|
constructor(
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
@ -59,6 +60,12 @@ export class TaskListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
this.getPermissions();
|
this.getPermissions();
|
||||||
}
|
}
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
const permissionsList: Observable<boolean>[] = [];
|
const permissionsList: Observable<boolean>[] = [];
|
||||||
permissionsList.push(this.userPermissionService.getPermission(this.projectId,
|
permissionsList.push(this.userPermissionService.getPermission(this.projectId,
|
||||||
@ -85,10 +92,12 @@ export class TaskListComponent implements OnInit {
|
|||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
this.execution = res;
|
this.execution = res;
|
||||||
if (!this.execution || this.p2pProviderService.willChangStatus(this.execution.status)) {
|
if (!this.execution || this.p2pProviderService.willChangStatus(this.execution.status)) {
|
||||||
setTimeout(() => {
|
if (!this.timeout) {
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
this.getExecutionDetail(false);
|
this.getExecutionDetail(false);
|
||||||
}, TIME_OUT);
|
}, TIME_OUT);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.messageHandlerService.error(error);
|
this.messageHandlerService.error(error);
|
||||||
@ -109,41 +118,44 @@ export class TaskListComponent implements OnInit {
|
|||||||
|
|
||||||
successNum(): number {
|
successNum(): number {
|
||||||
if (this.execution && this.execution.metrics) {
|
if (this.execution && this.execution.metrics) {
|
||||||
return this.execution.metrics.success_task_count;
|
return this.execution.metrics.success_task_count ? this.execution.metrics.success_task_count : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
failedNum(): number {
|
failedNum(): number {
|
||||||
if (this.execution && this.execution.metrics) {
|
if (this.execution && this.execution.metrics) {
|
||||||
return this.execution.metrics.error_task_count;
|
return this.execution.metrics.error_task_count ? this.execution.metrics.error_task_count : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
progressNum(): number {
|
progressNum(): number {
|
||||||
if (this.execution && this.execution.metrics) {
|
if (this.execution && this.execution.metrics) {
|
||||||
return (this.execution.metrics.pending_task_count ? this.execution.metrics.pending_task_count : 0)
|
const num: number = (this.execution.metrics.pending_task_count ? this.execution.metrics.pending_task_count : 0)
|
||||||
+ (this.execution.metrics.running_task_count ? this.execution.metrics.running_task_count : 0)
|
+ (this.execution.metrics.running_task_count ? this.execution.metrics.running_task_count : 0)
|
||||||
+ (this.execution.metrics.scheduled_task_count ? this.execution.metrics.scheduled_task_count : 0);
|
+ (this.execution.metrics.scheduled_task_count ? this.execution.metrics.scheduled_task_count : 0);
|
||||||
|
return num ? num : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
stoppedNum(): number {
|
stoppedNum(): number {
|
||||||
if (this.execution && this.execution.metrics) {
|
if (this.execution && this.execution.metrics) {
|
||||||
return this.execution.metrics.stopped_task_count;
|
return this.execution.metrics.stopped_task_count ? this.execution.metrics.stopped_task_count : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
stopJob() {
|
stopJob() {
|
||||||
this.stopOnGoing = true;
|
this.stopOnGoing = true;
|
||||||
|
const execution: Execution = clone(this.execution);
|
||||||
|
execution.status = EXECUTION_STATUS.STOPPED;
|
||||||
this.preheatService.StopExecution({
|
this.preheatService.StopExecution({
|
||||||
projectName: this.projectName,
|
projectName: this.projectName,
|
||||||
preheatPolicyName: this.preheatPolicyName,
|
preheatPolicyName: this.preheatPolicyName,
|
||||||
executionId: +this.executionId,
|
executionId: +this.executionId,
|
||||||
execution: this.execution
|
execution: execution
|
||||||
})
|
})
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
this.stopOnGoing = false;
|
this.stopOnGoing = false;
|
||||||
@ -199,12 +211,6 @@ export class TaskListComponent implements OnInit {
|
|||||||
this.totalCount = 0;
|
this.totalCount = 0;
|
||||||
this.clrLoadTasks(true);
|
this.clrLoadTasks(true);
|
||||||
}
|
}
|
||||||
toJsonString(obj: any) {
|
|
||||||
if (!isEmptyObject(obj)) {
|
|
||||||
return JSON.stringify(obj);
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
getDuration(t: Task): string {
|
getDuration(t: Task): string {
|
||||||
return this.p2pProviderService.getDuration(t.start_time, t.end_time);
|
return this.p2pProviderService.getDuration(t.start_time, t.end_time);
|
||||||
}
|
}
|
||||||
|
@ -1536,7 +1536,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
@ -1534,7 +1534,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
@ -1504,7 +1504,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
@ -1532,7 +1532,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
@ -1536,7 +1536,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
@ -1533,7 +1533,7 @@
|
|||||||
"PROVIDER_TYPE": "发起方",
|
"PROVIDER_TYPE": "发起方",
|
||||||
"ID": "执行 ID",
|
"ID": "执行 ID",
|
||||||
"NO_PROVIDER": "请先添加提供商",
|
"NO_PROVIDER": "请先添加提供商",
|
||||||
"EXTRA_ATTRS": "额外属性",
|
"EXTRA_ATTRS": "Artifact, 摘要和类型",
|
||||||
"TASKS": "任务",
|
"TASKS": "任务",
|
||||||
"TASKS_PLACEHOLDER": "暂无记录",
|
"TASKS_PLACEHOLDER": "暂无记录",
|
||||||
"SEVERITY_WARNING": "此处漏洞等级设置与项目设置冲突且将会被项目设置覆盖",
|
"SEVERITY_WARNING": "此处漏洞等级设置与项目设置冲突且将会被项目设置覆盖",
|
||||||
|
@ -1520,7 +1520,7 @@
|
|||||||
"PROVIDER_TYPE": "Vendor",
|
"PROVIDER_TYPE": "Vendor",
|
||||||
"ID": "Execution ID",
|
"ID": "Execution ID",
|
||||||
"NO_PROVIDER": "Please add a provider first",
|
"NO_PROVIDER": "Please add a provider first",
|
||||||
"EXTRA_ATTRS": "Extra Attrs",
|
"EXTRA_ATTRS": "Artifact, Digest and Kind",
|
||||||
"TASKS": "Tasks",
|
"TASKS": "Tasks",
|
||||||
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
"TASKS_PLACEHOLDER": "We couldn't find any task",
|
||||||
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
"SEVERITY_WARNING": "Vulnerability settings here conflicts with the relevant project configuration that will override the settings here",
|
||||||
|
Loading…
Reference in New Issue
Block a user