diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index ba60c9cdb1d1..33d7ba93d0f5 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -570,6 +570,7 @@ "label.cks.cluster.size": "Cluster size (Worker nodes)", "label.cleanup": "Clean up", "label.clear": "Clear", +"label.clear.notification": "Clear notification", "label.clear.list": "Clear list", "label.close": "Close", "label.cloud.console": "Cloud Management Console", diff --git a/ui/src/components/header/UserMenu.vue b/ui/src/components/header/UserMenu.vue index 782fab45c56a..24b63ead5d47 100644 --- a/ui/src/components/header/UserMenu.vue +++ b/ui/src/components/header/UserMenu.vue @@ -84,7 +84,8 @@ export default { }, data () { return { - image: '' + image: '', + countNotify: 0 } }, created () { @@ -92,6 +93,12 @@ export default { eventBus.$on('refresh-header', () => { this.getIcon() }) + this.$store.watch( + (state, getters) => getters.countNotify, + (newValue, oldValue) => { + this.countNotify = newValue + } + ) }, watch: { image () { @@ -137,6 +144,10 @@ export default { description: err.message }) }) + }, + clearAllNotify () { + this.$store.commit('SET_COUNT_NOTIFY', 0) + this.$notification.destroy() } } } diff --git a/ui/src/components/page/GlobalLayout.vue b/ui/src/components/page/GlobalLayout.vue index 3eac55a109c7..87c5ef8ebfb7 100644 --- a/ui/src/components/page/GlobalLayout.vue +++ b/ui/src/components/page/GlobalLayout.vue @@ -91,6 +91,13 @@ /> + {{ $t('label.clear.notification') }} + @@ -128,7 +135,8 @@ export default { return { collapsed: false, menus: [], - showSetting: false + showSetting: false, + showClear: false } }, computed: { @@ -161,6 +169,12 @@ export default { } else { document.body.classList.remove('dark-mode') } + }, + '$store.getters.countNotify' (countNotify) { + this.showClear = false + if (countNotify && countNotify > 0) { + this.showClear = true + } } }, provide: function () { @@ -212,6 +226,10 @@ export default { }, toggleSetting (showSetting) { this.showSetting = showSetting + }, + onClearNotification () { + this.$notification.destroy() + this.$store.commit('SET_COUNT_NOTIFY', 0) } } } diff --git a/ui/src/components/view/DetailSettings.vue b/ui/src/components/view/DetailSettings.vue index 2588c11fb2e4..07f0a49cefd6 100644 --- a/ui/src/components/view/DetailSettings.vue +++ b/ui/src/components/view/DetailSettings.vue @@ -219,7 +219,8 @@ export default { apiName = 'updateTemplate' } if (!(apiName in this.$store.getters.apis)) { - this.$notification.error({ + this.$showNotification({ + type: 'error', message: this.$t('error.execute.api.failed') + ' ' + apiName, description: this.$t('message.user.not.permitted.api') }) diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue index 335d53107e38..4333cc8f03c2 100644 --- a/ui/src/components/view/ListView.vue +++ b/ui/src/components/view/ListView.vue @@ -510,7 +510,8 @@ export default { json.updateconfigurationresponse.configuration && !json.updateconfigurationresponse.configuration.isdynamic && ['Admin'].includes(this.$store.getters.userInfo.roletype)) { - this.$notification.warning({ + this.$showNotification({ + type: 'warning', message: this.$t('label.status'), description: this.$t('message.restart.mgmt.server') }) diff --git a/ui/src/components/view/ResourceLimitTab.vue b/ui/src/components/view/ResourceLimitTab.vue index fefe93770f78..67a5f96a1e3f 100644 --- a/ui/src/components/view/ResourceLimitTab.vue +++ b/ui/src/components/view/ResourceLimitTab.vue @@ -107,7 +107,8 @@ export default { this.dataResource = await this.listResourceLimits(params) this.formLoading = false } catch (e) { - this.$notification.error({ + this.$showNotification({ + type: 'error', message: this.$t('message.request.failed'), description: e }) diff --git a/ui/src/components/view/SettingsTab.vue b/ui/src/components/view/SettingsTab.vue index 349d51691dd4..4f71e1957f32 100644 --- a/ui/src/components/view/SettingsTab.vue +++ b/ui/src/components/view/SettingsTab.vue @@ -164,7 +164,8 @@ export default { }).catch(error => { console.error(error) this.$message.error(this.$t('message.error.save.setting')) - this.$notification.error({ + this.$showNotification({ + type: 'error', message: this.$t('label.error'), description: this.$t('message.error.try.save.setting') }) diff --git a/ui/src/components/view/UploadResourceIcon.vue b/ui/src/components/view/UploadResourceIcon.vue index ecf6d6668e0a..cd8eb2f8902a 100644 --- a/ui/src/components/view/UploadResourceIcon.vue +++ b/ui/src/components/view/UploadResourceIcon.vue @@ -234,13 +234,15 @@ export default { }).then(json => { console.log(this.resource) if (json?.uploadresourceiconresponse?.success) { - this.$notification.success({ + this.$showNotification({ + type: 'success', message: this.$t('label.upload.icon'), description: `${this.$t('message.success.upload.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid) }) } }).catch((error) => { - this.$notification.error({ + this.$showNotification({ + type: 'error', message: this.$t('label.upload.icon'), description: error?.response?.data?.uploadresourceiconresponse?.errortext || '', duration: 0 @@ -264,13 +266,15 @@ export default { resourceids: resourceid }).then(json => { if (json?.deleteresourceiconresponse?.success) { - this.$notification.success({ + this.$showNotification({ + type: 'success', message: this.$t('label.delete.icon'), description: `${this.$t('message.success.delete.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid) }) } }).catch((error) => { - this.$notification.error({ + this.$showNotification({ + type: 'error', message: this.$t('label.delete.icon'), description: error?.response?.data?.deleteresourceiconresponse?.errortext || '', duration: 0 diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 8bd694e03712..9f7598840353 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -152,7 +152,8 @@ export default { const vm = result.jobresult.virtualmachine || {} if (result.jobstatus === 1 && vm.password) { const name = vm.displayname || vm.name || vm.id - obj.$notification.success({ + obj.$showNotification({ + type: 'success', message: `${obj.$t('label.reinstall.vm')}: ` + name, description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password, duration: 0 @@ -361,7 +362,8 @@ export default { const vm = result.jobresult.virtualmachine || {} if (result.jobstatus === 1 && vm.password) { const name = vm.displayname || vm.name || vm.id - obj.$notification.success({ + obj.$showNotification({ + type: 'success', message: `${obj.$t('label.reset.ssh.key.pair.on.vm')}: ` + name, description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password, duration: 0 diff --git a/ui/src/layouts/UserLayout.vue b/ui/src/layouts/UserLayout.vue index e25bab4c8cbb..12b93e2086a9 100644 --- a/ui/src/layouts/UserLayout.vue +++ b/ui/src/layouts/UserLayout.vue @@ -17,6 +17,12 @@