Merge pull request #2876 from steven-zou/master

fix issue #2811
This commit is contained in:
Steven Zou 2017-07-26 18:25:29 +08:00 committed by GitHub
commit 3820c91ef1
5 changed files with 17 additions and 4 deletions

View File

@ -55,7 +55,7 @@ export class VulnerabilityConfigComponent implements OnInit {
get scanAvailable(): boolean { get scanAvailable(): boolean {
let dt: Date = new Date(); 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 { get nextScanTimestamp(): Date {
@ -256,6 +256,10 @@ export class VulnerabilityConfigComponent implements OnInit {
return;//Aoid duplicated submitting return;//Aoid duplicated submitting
} }
if(!this.scanAvailable) {
return; //Aoid page hacking
}
this.onSubmitting = true; this.onSubmitting = true;
toPromise<any>(this.scanningService.startScanningAll()) toPromise<any>(this.scanningService.startScanningAll())
.then(() => { .then(() => {
@ -271,7 +275,13 @@ export class VulnerabilityConfigComponent implements OnInit {
}); });
}) })
.catch(error => { .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; this.onSubmitting = false;
}); });
} }

View File

@ -31,7 +31,7 @@
"clarity-icons": "^0.9.8", "clarity-icons": "^0.9.8",
"clarity-ui": "^0.9.8", "clarity-ui": "^0.9.8",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"harbor-ui": "0.3.49", "harbor-ui": "0.3.54",
"intl": "^1.2.5", "intl": "^1.2.5",
"mutationobserver-shim": "^0.3.2", "mutationobserver-shim": "^0.3.2",
"ngx-cookie": "^1.0.0", "ngx-cookie": "^1.0.0",

View File

@ -413,6 +413,7 @@
}, },
"SCANNING": { "SCANNING": {
"TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!", "TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!",
"TRIGGER_SCAN_ALL_FAIL": "Failed to trigger scan all with error: {{error}",
"TITLE": "Vulnerability Scanning", "TITLE": "Vulnerability Scanning",
"SCAN_ALL": "Scan All", "SCAN_ALL": "Scan All",
"SCAN_NOW": "SCAN NOW", "SCAN_NOW": "SCAN NOW",

View File

@ -414,6 +414,7 @@
}, },
"SCANNING": { "SCANNING": {
"TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!", "TRIGGER_SCAN_ALL_SUCCESS": "Trigger scan all successfully!",
"TRIGGER_SCAN_ALL_FAIL": "Failed to trigger scan all with error: {{error}",
"TITLE": "Vulnerability Scanning", "TITLE": "Vulnerability Scanning",
"SCAN_ALL": "Scan All", "SCAN_ALL": "Scan All",
"SCAN_NOW": "SCAN NOW", "SCAN_NOW": "SCAN NOW",

View File

@ -412,7 +412,8 @@
"SCOPE": "LDAP搜索范围" "SCOPE": "LDAP搜索范围"
}, },
"SCANNING": { "SCANNING": {
"TRIGGER_SCAN_ALL_SUCCESS": "成功启动扫描所有镜像任务!", "TRIGGER_SCAN_ALL_SUCCESS": "启动扫描所有镜像任务成功!",
"TRIGGER_SCAN_ALL_FAIL": "启动扫描所有镜像任务失败:{{error}",
"TITLE": "缺陷扫描", "TITLE": "缺陷扫描",
"SCAN_ALL": "扫描所有", "SCAN_ALL": "扫描所有",
"SCAN_NOW": "开始扫描", "SCAN_NOW": "开始扫描",