diff --git a/src/portal/lib/src/config/registry-config.component.spec.ts b/src/portal/lib/src/config/registry-config.component.spec.ts index 84ed549ce..83da015a9 100644 --- a/src/portal/lib/src/config/registry-config.component.spec.ts +++ b/src/portal/lib/src/config/registry-config.component.spec.ts @@ -102,7 +102,7 @@ describe('RegistryConfigComponent (inline template)', () => { fixture.detectChanges(); - let el3: HTMLInputElement = fixture.nativeElement.querySelector('input[type="time"]'); + let el3: HTMLInputElement = fixture.nativeElement.querySelector('.btn-scan'); expect(el3).toBeTruthy(); expect(el3).not.toBeFalsy(); }); diff --git a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.html b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.html index 22966e33c..5c823f569 100644 --- a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.html +++ b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.html @@ -21,25 +21,35 @@ - {{ updatedTimestamp | date:'MM/dd/y HH:mm:ss' }} + {{ updatedTimestamp | date:'MM/dd/y HH:mm:ss' }} -
+
+ {{ 'CONFIG.SCANNING.SCAN_ALL' | translate }} + {{ (scanningType ? 'SCHEDULE.'+ scanningType.toUpperCase(): "") | translate }} + {{'SCHEDULE.AT' | translate}} + {{ dailyTime | translate }} + +
+
+ {{'SCHEDULE.AT' | translate}} {{'CONFIG.TOOLTIP.SCANNING_POLICY' | translate}} -
-
- {{ 'CONFIG.SCANNING.NEXT_SCAN' | translate }} {{ nextScanTimestamp | date:'y/MM/dd HH:mm' }} -
+ +
+
+
+ {{ 'CONFIG.SCANNING.NEXT_SCAN' | translate }} {{ nextScanTimestamp | date:'y/MM/dd HH:mm' }} +
\ No newline at end of file diff --git a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.scss b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.scss index e9f4fd65b..13e8c0e9f 100644 --- a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.scss +++ b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.scss @@ -2,6 +2,17 @@ padding-left: 0px !important; } +.vertical-center { + display: flex; + align-items: center; +} + +.normal-wrapper { + > span:not(:first-child) { + margin-right: 18px; + } +} + .section-title { font-size: 14px !important; font-weight: 600 !important; @@ -18,9 +29,7 @@ .clr-dropdown-override { margin-top: -8px; } -.btn-scan-right{ - margin-left: 10px; -} + .btn-scan-right button{ width: 160px; margin-bottom: 0px; diff --git a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.ts b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.ts index 3a09083a9..4425fcc9c 100644 --- a/src/portal/lib/src/config/vulnerability/vulnerability-config.component.ts +++ b/src/portal/lib/src/config/vulnerability/vulnerability-config.component.ts @@ -5,24 +5,29 @@ import { Configuration } from '../config'; import { ScanningResultService, SystemInfo, - SystemInfoService + SystemInfoService, + ConfigurationService } from '../../service/index'; import { ErrorHandler } from '../../error-handler/index'; -import { toPromise } from '../../utils'; +import { toPromise, isEmptyObject } from '../../utils'; import { TranslateService } from '@ngx-translate/core'; import { ClairDetail } from '../../service/interface'; - const ONE_HOUR_SECONDS: number = 3600; const ONE_DAY_SECONDS: number = 24 * ONE_HOUR_SECONDS; - +const SCHEDULE_TYPE = { + NONE: "none", + DAILY: "daily" +}; @Component({ selector: 'vulnerability-config', templateUrl: './vulnerability-config.component.html', - styles: ['./vulnerability-config.component.scss', '../registry-config.component.scss'] + styleUrls: ['./vulnerability-config.component.scss', '../registry-config.component.scss'] }) export class VulnerabilityConfigComponent implements OnInit { _localTime: Date = new Date(); - + isEditMode: boolean = false; + SCHEDULE_TYPE = SCHEDULE_TYPE; + configCopy: Configuration; onSubmitting: boolean = false; config: Configuration; openState: boolean = false; @@ -101,7 +106,6 @@ export class VulnerabilityConfigComponent implements OnInit { timeOffset = +daily_time; } } - // Convert to current time let timezoneOffset: number = this._localTime.getTimezoneOffset(); // Local time @@ -184,6 +188,7 @@ export class VulnerabilityConfigComponent implements OnInit { } } + set scanningType(v: string) { if (this.config && this.config.scan_all_policy && @@ -235,13 +240,30 @@ export class VulnerabilityConfigComponent implements OnInit { private scanningService: ScanningResultService, private errorHandler: ErrorHandler, private translate: TranslateService, - private systemInfoService: SystemInfoService + private systemInfoService: SystemInfoService, + private configService: ConfigurationService ) { } ngOnInit(): void { this.getSystemInfo(); + this.getConfigurations(); } + getConfigurations(): void { + toPromise(this.configService.getConfigurations()) + .then((config: Configuration) => { + this.configCopy = Object.assign({}, config); + this.config = config; + }) + .catch(error => { + this.errorHandler.error(error); + }); + } + + editSchedule() { + this.isEditMode = true; + } + convertToLocalTime(utcTime: number): Date { let dt: Date = new Date(); dt.setTime(utcTime * 1000); @@ -289,4 +311,42 @@ export class VulnerabilityConfigComponent implements OnInit { .then((info: SystemInfo) => this.systemInfo = info) .catch(error => this.errorHandler.error(error)); } + + save(): void { + let getchanges = this.config.scan_all_policy.value; + let changes = {"scan_all_policy": getchanges}; + + if (isEmptyObject(changes)) { + return; + } + + toPromise(this.configService.saveConfigurations(changes)) + .then(() => { + this.translate.get("CONFIG.SAVE_SUCCESS").subscribe((res: string) => { + this.errorHandler.info(res); + }); + this.getConfigurations(); + this.isEditMode = false; + }, () => { + this.reset(); + }) + .catch(error => { + this.errorHandler.error(error); + this.reset(); + }); + } + + cancel(): void { + this.reset(); + this.isEditMode = false; + } + + reset(): void { + // Reset to the values of copy + let getchanges = this.config.scan_all_policy.value; + let changes = {"scan_all_policy": getchanges}; + for (let prop of Object.keys(changes)) { + this.config[prop] = Object.assign({}, this.configCopy[prop]); + } + } } diff --git a/src/portal/src/app/config/config.component.ts b/src/portal/src/app/config/config.component.ts index 5d04d8e35..dca254166 100644 --- a/src/portal/src/app/config/config.component.ts +++ b/src/portal/src/app/config/config.component.ts @@ -204,7 +204,7 @@ export class ConfigurationComponent implements OnInit, OnDestroy { } public get hideBtn(): boolean { - return this.currentTabId === 'config-label' || this.currentTabId === 'config-gc'; + return this.currentTabId === 'config-label' || this.currentTabId === 'config-gc' || this.currentTabId === 'config-vulnerability'; } public get hideMailTestingSpinner(): boolean { diff --git a/src/portal/src/app/config/gc/gc.component.html b/src/portal/src/app/config/gc/gc.component.html index a0b900793..99a1a9176 100644 --- a/src/portal/src/app/config/gc/gc.component.html +++ b/src/portal/src/app/config/gc/gc.component.html @@ -1,12 +1,14 @@
- {{'GC.CURRENT_SCHEDULE' | translate}} + {{'GC.CURRENT_SCHEDULE' | translate}} {{(originScheduleType ? 'SCHEDULE.'+ originScheduleType.toUpperCase(): "") | translate}} - {{'GC.ON' | translate}} {{originWeekDay.text | translate}} - {{'GC.AT' | translate}} {{originOffTime.text}} + {{'SCHEDULE.ON' | translate}} + {{originWeekDay.text | translate}} + {{'SCHEDULE.AT' | translate}} + {{originOffTime.text}}
- +
- {{'GC.ON' | translate}} + {{'SCHEDULE.ON' | translate}}
- {{'GC.AT' | translate}} + {{'SCHEDULE.AT' | translate}}
-
{{'GC.JOB_LIST' | translate}}
+
{{'GC.JOB_LIST' | translate}}
{{'GC.JOB_ID' | translate}} {{'GC.TRIGGER_TYPE' | translate}} diff --git a/src/portal/src/app/config/gc/gc.component.scss b/src/portal/src/app/config/gc/gc.component.scss index e9dbd0620..b560ccc6a 100644 --- a/src/portal/src/app/config/gc/gc.component.scss +++ b/src/portal/src/app/config/gc/gc.component.scss @@ -2,17 +2,29 @@ display: flex; align-items: center; margin:20px 0; + font-size: .541667rem; +} + +.font-style { + color: #000; + font-size: .541667rem; } .setting-wrapper { - > * { - margin-right:35px; + label { + width: 228px; + } + *:not(:first-child), span { + margin-right: 18px; } } .normal-wrapper { - > * { - margin-right: 90px; + > span:first-child { + width: 228px; + } + > span:not(:first-child){ + margin-right: 18px; } } diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index 89b796199..128e6b8eb 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -828,12 +828,12 @@ "NONE": "None", "DAILY": "Daily", "WEEKLY": "Weekly", - "MANUAL": "Manual" + "MANUAL": "Manual", + "ON": "on", + "AT": "at" }, "GC": { "CURRENT_SCHEDULE": "Current Schedule", - "ON": "on", - "AT": "at", "GC_NOW": "GC NOW", "JOB_LIST":"GC Jobs List", "JOB_ID":"Job ID", diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index e6655d7f5..9a3385206 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -825,12 +825,12 @@ "NONE": "None", "DAILY": "Daily", "WEEKLY": "Weekly", - "MANUAL": "Manual" + "MANUAL": "Manual", + "ON": "on", + "AT": "at" }, "GC": { "CURRENT_SCHEDULE": "Current Schedule", - "ON": "on", - "AT": "at", "GC_NOW": "GC NOW", "JOB_LIST":"GC Jobs List", "JOB_ID":"Job ID", diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 5e2b891f0..3b54e539a 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -788,12 +788,12 @@ "NONE": "None", "DAILY": "Daily", "WEEKLY": "Weekly", - "MANUAL": "Manual" + "MANUAL": "Manual", + "ON": "on", + "AT": "at" }, "GC": { "CURRENT_SCHEDULE": "Current Schedule", - "ON": "on", - "AT": "at", "GC_NOW": "GC NOW", "JOB_LIST":"GC Jobs List", "JOB_ID":"Job ID", diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index f02074430..bb5bc6bee 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -824,12 +824,12 @@ "NONE": "无", "DAILY": "每天", "WEEKLY": "每周", - "MANUAL": "手动" + "MANUAL": "手动", + "ON": " ", + "AT": " " }, "GC": { "CURRENT_SCHEDULE": "当前定时任务", - "ON": " ", - "AT": " ", "GC_NOW": "立即清理垃圾", "JOB_LIST":"任务列表", "JOB_ID":"任务ID",