From f3c1caeb3cc10fc5475a68ac9191c70ad1e49159 Mon Sep 17 00:00:00 2001 From: Steven Zou Date: Wed, 26 Jul 2017 17:58:43 +0800 Subject: [PATCH] fix issue #2811 --- .../vulnerability-config.component.ts | 14 ++++++++++++-- src/ui_ng/package.json | 2 +- src/ui_ng/src/i18n/lang/en-us-lang.json | 1 + src/ui_ng/src/i18n/lang/es-es-lang.json | 1 + src/ui_ng/src/i18n/lang/zh-cn-lang.json | 3 ++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts b/src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts index 625bffff4..6a724670f 100644 --- a/src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts +++ b/src/ui_ng/lib/src/config/vulnerability/vulnerability-config.component.ts @@ -55,7 +55,7 @@ export class VulnerabilityConfigComponent implements OnInit { get scanAvailable(): boolean { let dt: Date = new Date(); - return !this.onSubmitting && (this.nextScanTime <= 0 || dt.getTime() > ((this.nextScanTime + 30) * 1000)); + return !this.onSubmitting && (this.nextScanTime <= 0 || dt.getTime() > ((this.nextScanTime + 300) * 1000)); } get nextScanTimestamp(): Date { @@ -256,6 +256,10 @@ export class VulnerabilityConfigComponent implements OnInit { return;//Aoid duplicated submitting } + if(!this.scanAvailable) { + return; //Aoid page hacking + } + this.onSubmitting = true; toPromise(this.scanningService.startScanningAll()) .then(() => { @@ -271,7 +275,13 @@ export class VulnerabilityConfigComponent implements OnInit { }); }) .catch(error => { - this.errorHandler.error(error); + if (error && error.status && error.status === 412) { + this.translate.get("CONFIG.SCANNING.TRIGGER_SCAN_ALL_FAIL", { error: '' + error }).subscribe((res: string) => { + this.errorHandler.error(res); + }); + } else { + this.errorHandler.error(error); + } this.onSubmitting = false; }); } diff --git a/src/ui_ng/package.json b/src/ui_ng/package.json index 99107159a..5a27ca495 100644 --- a/src/ui_ng/package.json +++ b/src/ui_ng/package.json @@ -31,7 +31,7 @@ "clarity-icons": "^0.9.8", "clarity-ui": "^0.9.8", "core-js": "^2.4.1", - "harbor-ui": "0.3.49", + "harbor-ui": "0.3.54", "intl": "^1.2.5", "mutationobserver-shim": "^0.3.2", "ngx-cookie": "^1.0.0", diff --git a/src/ui_ng/src/i18n/lang/en-us-lang.json b/src/ui_ng/src/i18n/lang/en-us-lang.json index dfc1e9bec..dc6d95ae7 100644 --- a/src/ui_ng/src/i18n/lang/en-us-lang.json +++ b/src/ui_ng/src/i18n/lang/en-us-lang.json @@ -413,6 +413,7 @@ }, "SCANNING": { "TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!", + "TRIGGER_SCAN_ALL_FAIL": "Failed to trigger scan all with error: {{error}", "TITLE": "Vulnerability Scanning", "SCAN_ALL": "Scan All", "SCAN_NOW": "SCAN NOW", diff --git a/src/ui_ng/src/i18n/lang/es-es-lang.json b/src/ui_ng/src/i18n/lang/es-es-lang.json index 6d5a328d5..729ee939b 100644 --- a/src/ui_ng/src/i18n/lang/es-es-lang.json +++ b/src/ui_ng/src/i18n/lang/es-es-lang.json @@ -414,6 +414,7 @@ }, "SCANNING": { "TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!", + "TRIGGER_SCAN_ALL_FAIL": "Failed to trigger scan all with error: {{error}", "TITLE": "Vulnerability Scanning", "SCAN_ALL": "Scan All", "SCAN_NOW": "SCAN NOW", diff --git a/src/ui_ng/src/i18n/lang/zh-cn-lang.json b/src/ui_ng/src/i18n/lang/zh-cn-lang.json index 60e7a03bf..27fcc42ca 100644 --- a/src/ui_ng/src/i18n/lang/zh-cn-lang.json +++ b/src/ui_ng/src/i18n/lang/zh-cn-lang.json @@ -412,7 +412,8 @@ "SCOPE": "LDAP搜索范围" }, "SCANNING": { - "TRIGGER_SCAN_ALL_SUCCESS": "成功启动扫描所有镜像任务!", + "TRIGGER_SCAN_ALL_SUCCESS": "启动扫描所有镜像任务成功!", + "TRIGGER_SCAN_ALL_FAIL": "启动扫描所有镜像任务失败:{{error}", "TITLE": "缺陷扫描", "SCAN_ALL": "扫描所有", "SCAN_NOW": "开始扫描",