From b20cc474b31e36cab22ee1d5541832ef84096567 Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Fri, 18 Dec 2020 13:40:14 +0800 Subject: [PATCH] Fix robot account UI issues Signed-off-by: AllForNothing --- make/photon/portal/Dockerfile | 2 +- .../robot-account.component.html | 2 +- .../robot-account/robot-account.component.ts | 2 ++ .../statictics/statistics-panel.component.ts | 24 +++++++++++-- .../src/app/shared/statictics/volumes.ts | 4 +-- .../new-robot/new-robot.component.ts | 36 +++++++++++++------ .../system-robot-util.ts | 3 +- src/portal/src/i18n/lang/de-de-lang.json | 3 +- src/portal/src/i18n/lang/en-us-lang.json | 3 +- src/portal/src/i18n/lang/es-es-lang.json | 3 +- src/portal/src/i18n/lang/fr-fr-lang.json | 3 +- src/portal/src/i18n/lang/pt-br-lang.json | 3 +- src/portal/src/i18n/lang/tr-tr-lang.json | 3 +- src/portal/src/i18n/lang/zh-cn-lang.json | 3 +- src/portal/src/i18n/lang/zh-tw-lang.json | 3 +- .../cron-schedule.component.html | 6 ++-- 16 files changed, 74 insertions(+), 29 deletions(-) diff --git a/make/photon/portal/Dockerfile b/make/photon/portal/Dockerfile index 15ff2f3b2..608e4c04a 100644 --- a/make/photon/portal/Dockerfile +++ b/make/photon/portal/Dockerfile @@ -1,6 +1,6 @@ ARG harbor_base_image_version ARG harbor_base_namespace -FROM node:10.15.0 as nodeportal +FROM node:15.4.0 as nodeportal WORKDIR /build_dir diff --git a/src/portal/src/app/project/robot-account/robot-account.component.html b/src/portal/src/app/project/robot-account/robot-account.component.html index 28596bd24..c8bbcc4fa 100644 --- a/src/portal/src/app/project/robot-account/robot-account.component.html +++ b/src/portal/src/app/project/robot-account/robot-account.component.html @@ -59,7 +59,7 @@ {{'ROBOT_ACCOUNT.ENABLED_STATE' | translate}} {{"SYSTEM_ROBOT.PERMISSION_COLUMN" | translate}} {{'ROBOT_ACCOUNT.CREATETION' | translate}} - {{'SYSTEM_ROBOT.EXPIRED_AT' | translate}} + {{'SYSTEM_ROBOT.EXPIRES_AT' | translate}} {{'ROBOT_ACCOUNT.DESCRIPTION' | translate}} {{ 'SYSTEM_ROBOT.NOT_FOUND' | translate diff --git a/src/portal/src/app/project/robot-account/robot-account.component.ts b/src/portal/src/app/project/robot-account/robot-account.component.ts index 59cb54bed..2b5fdc7f9 100644 --- a/src/portal/src/app/project/robot-account/robot-account.component.ts +++ b/src/portal/src/app/project/robot-account/robot-account.component.ts @@ -102,6 +102,8 @@ export class RobotAccountComponent implements OnInit, OnDestroy { this.searchKey = robotSearchName; if (this.searchKey) { queryParam.q = encodeURIComponent(`Level=${PermissionsKinds.PROJECT},ProjectID=${this.projectId},name=~${this.searchKey}`); + } else { + queryParam.q = encodeURIComponent(`Level=${PermissionsKinds.PROJECT},ProjectID=${this.projectId}`); } this.loading = true; return this.robotService.ListRobotResponse(queryParam) diff --git a/src/portal/src/app/shared/statictics/statistics-panel.component.ts b/src/portal/src/app/shared/statictics/statistics-panel.component.ts index 5600a3f61..7df534cdb 100644 --- a/src/portal/src/app/shared/statictics/statistics-panel.component.ts +++ b/src/portal/src/app/shared/statictics/statistics-panel.component.ts @@ -69,11 +69,23 @@ export class StatisticsPanelComponent implements OnInit, OnDestroy { } public get totalStorage(): number { - return this.getGBFromBytes(this.volumesInfo.storage.total); + let count: number = 0; + if (this.volumesInfo && this.volumesInfo.storage && this.volumesInfo.storage.length) { + this.volumesInfo.storage.forEach(item => { + count += item.total; + }); + } + return this.getGBFromBytes(count); } public get freeStorage(): number { - return this.getGBFromBytes(this.volumesInfo.storage.free); + let count: number = 0; + if (this.volumesInfo && this.volumesInfo.storage && this.volumesInfo.storage.length) { + this.volumesInfo.storage.forEach(item => { + count += item.free; + }); + } + return this.getGBFromBytes(count); } public getStatistics(): void { @@ -98,7 +110,13 @@ export class StatisticsPanelComponent implements OnInit, OnDestroy { } public get isValidStorage(): boolean { - return this.volumesInfo.storage.total !== 0 && + let count: number = 0; + if (this.volumesInfo && this.volumesInfo.storage && this.volumesInfo.storage.length) { + this.volumesInfo.storage.forEach(item => { + count += item.total; + }); + } + return count !== 0 && this.appConfigService.getConfig().registry_storage_provider_name === "filesystem"; } diff --git a/src/portal/src/app/shared/statictics/volumes.ts b/src/portal/src/app/shared/statictics/volumes.ts index c9b8c0708..296bc6ad6 100644 --- a/src/portal/src/app/shared/statictics/volumes.ts +++ b/src/portal/src/app/shared/statictics/volumes.ts @@ -13,10 +13,10 @@ // limitations under the License. export class Volumes { constructor() { - this.storage = new Storage(); + this.storage = [new Storage()]; } - storage: Storage; + storage: Storage[]; } export class Storage { diff --git a/src/portal/src/app/system-robot-accounts/new-robot/new-robot.component.ts b/src/portal/src/app/system-robot-accounts/new-robot/new-robot.component.ts index 65431acf8..f4c7f0154 100644 --- a/src/portal/src/app/system-robot-accounts/new-robot/new-robot.component.ts +++ b/src/portal/src/app/system-robot-accounts/new-robot/new-robot.component.ts @@ -189,6 +189,9 @@ export class NewRobotComponent implements OnInit, OnDestroy { } }); } + if (!this.coverAll) { + this.defaultAccesses.forEach( item => item.checked = true); + } this.robotForm.reset({ name: this.systemRobot.name, expiration: this.systemRobot.duration, @@ -281,18 +284,31 @@ export class NewRobotComponent implements OnInit, OnDestroy { return true; } if (this.coverAll !== this.coverAllForEdit) { - return true; - } - if (this.coverAll) { - let flag = true; - this.defaultAccessesForEdit.forEach(item => { - this.defaultAccesses.forEach(item2 => { - if (item.resource === item2.resource && item.action === item2.action && item.checked !== item2.checked) { - flag = false; + if (this.coverAll) { + let flag = false; + this.defaultAccesses.forEach(item => { + if (item.checked) { + flag = true; } }); - }); - return !flag; + if (!flag) { + return false; + } + } + return true; + } + if (this.coverAll === this.coverAllForEdit) { + if (this.coverAll) { + let flag = true; + this.defaultAccessesForEdit.forEach(item => { + this.defaultAccesses.forEach(item2 => { + if (item.resource === item2.resource && item.action === item2.action && item.checked !== item2.checked) { + flag = false; + } + }); + }); + return !flag; + } } if (this.systemRobot.permissions.length !== this.listAllProjectsComponent.selectedRow.length) { return true; diff --git a/src/portal/src/app/system-robot-accounts/system-robot-util.ts b/src/portal/src/app/system-robot-accounts/system-robot-util.ts index fa851c3b5..54dcf4bb6 100644 --- a/src/portal/src/app/system-robot-accounts/system-robot-util.ts +++ b/src/portal/src/app/system-robot-accounts/system-robot-util.ts @@ -107,7 +107,8 @@ export const ACTION_RESOURCE_I18N_MAP = { 'helm-chart-version': 'SYSTEM_ROBOT.HELM_VERSION', 'tag': 'REPLICATION.TAG', 'artifact-label': 'SYSTEM_ROBOT.ARTIFACT_LABEL', - 'scan': 'SYSTEM_ROBOT.SCAN' + 'scan': 'SYSTEM_ROBOT.SCAN', + 'scanner-pull': 'SYSTEM_ROBOT.SCANNER_PULL' }; export enum ExpirationType { diff --git a/src/portal/src/i18n/lang/de-de-lang.json b/src/portal/src/i18n/lang/de-de-lang.json index 0e04e456b..67ebf2360 100644 --- a/src/portal/src/i18n/lang/de-de-lang.json +++ b/src/portal/src/i18n/lang/de-de-lang.json @@ -1659,6 +1659,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index fa2e3cbe2..05b18524b 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1659,6 +1659,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index 6df3ef405..295bf319d 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1657,6 +1657,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 8eea35cb2..48f24e94b 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1627,6 +1627,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index df9de30aa..6e6dae9d8 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1655,7 +1655,8 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index bc04b6b44..cd0fcd7f0 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -1659,6 +1659,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 4df722f8c..af0621e5a 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1656,6 +1656,7 @@ "ENABLE_NEW_SECRET": "开启此项以便手动指定新令牌", "DELETE": "删除", "ARTIFACT_LABEL": "Artifact 标签", - "SCAN": "扫描" + "SCAN": "扫描", + "SCANNER_PULL": "扫描器拉取" } } diff --git a/src/portal/src/i18n/lang/zh-tw-lang.json b/src/portal/src/i18n/lang/zh-tw-lang.json index 33ec943d8..3861fb50b 100644 --- a/src/portal/src/i18n/lang/zh-tw-lang.json +++ b/src/portal/src/i18n/lang/zh-tw-lang.json @@ -1643,6 +1643,7 @@ "ENABLE_NEW_SECRET": "Enable this option to manually specify a new secret", "DELETE": "Delete", "ARTIFACT_LABEL": "Artifact label", - "SCAN": "Scan" + "SCAN": "Scan", + "SCANNER_PULL": "Scanner Pull" } } diff --git a/src/portal/src/lib/components/cron-schedule/cron-schedule.component.html b/src/portal/src/lib/components/cron-schedule/cron-schedule.component.html index eb3e23b27..165623b6b 100644 --- a/src/portal/src/lib/components/cron-schedule/cron-schedule.component.html +++ b/src/portal/src/lib/components/cron-schedule/cron-schedule.component.html @@ -17,7 +17,7 @@ {{'CONFIG.TOOLTIP.DAILY_CRON' | translate}} - {{ "SCHEDULE.CRON" | translate }} : +  {{ "SCHEDULE.CRON" | translate }} : {{ oriCron }}