Skip to content

Commit eb04a46

Browse files
author
Hoang Nguyen
authored
ui: Add clear all notification button (apache#5549)
* add clear all notification button * change position set count notify * get notification count * set label transliteration * add margin for notification * change position of clear notification button
1 parent 5eccbc9 commit eb04a46

File tree

82 files changed

+467
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+467
-168
lines changed

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@
577577
"label.cks.cluster.size": "Cluster size (Worker nodes)",
578578
"label.cleanup": "Clean up",
579579
"label.clear": "Clear",
580+
"label.clear.notification": "Clear notification",
580581
"label.clear.list": "Clear list",
581582
"label.close": "Close",
582583
"label.cloud.console": "Cloud Management Console",

ui/src/components/header/UserMenu.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,21 @@ export default {
8484
},
8585
data () {
8686
return {
87-
image: ''
87+
image: '',
88+
countNotify: 0
8889
}
8990
},
9091
created () {
9192
this.getIcon()
9293
eventBus.$on('refresh-header', () => {
9394
this.getIcon()
9495
})
96+
this.$store.watch(
97+
(state, getters) => getters.countNotify,
98+
(newValue, oldValue) => {
99+
this.countNotify = newValue
100+
}
101+
)
95102
},
96103
watch: {
97104
image () {
@@ -137,6 +144,10 @@ export default {
137144
description: err.message
138145
})
139146
})
147+
},
148+
clearAllNotify () {
149+
this.$store.commit('SET_COUNT_NOTIFY', 0)
150+
this.$notification.destroy()
140151
}
141152
}
142153
}

ui/src/components/page/GlobalLayout.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@
9191
/>
9292
</a-affix>
9393

94+
<a-button
95+
v-if="showClear"
96+
type="default"
97+
size="small"
98+
class="button-clear-notification"
99+
@click="onClearNotification">{{ $t('label.clear.notification') }}</a-button>
100+
94101
<!-- layout content -->
95102
<a-layout-content class="layout-content" :class="{'is-header-fixed': fixedHeader}">
96103
<slot></slot>
@@ -128,7 +135,8 @@ export default {
128135
return {
129136
collapsed: false,
130137
menus: [],
131-
showSetting: false
138+
showSetting: false,
139+
showClear: false
132140
}
133141
},
134142
computed: {
@@ -161,6 +169,12 @@ export default {
161169
} else {
162170
document.body.classList.remove('dark-mode')
163171
}
172+
},
173+
'$store.getters.countNotify' (countNotify) {
174+
this.showClear = false
175+
if (countNotify && countNotify > 0) {
176+
this.showClear = true
177+
}
164178
}
165179
},
166180
provide: function () {
@@ -212,6 +226,10 @@ export default {
212226
},
213227
toggleSetting (showSetting) {
214228
this.showSetting = showSetting
229+
},
230+
onClearNotification () {
231+
this.$notification.destroy()
232+
this.$store.commit('SET_COUNT_NOTIFY', 0)
215233
}
216234
}
217235
}

ui/src/components/view/DetailSettings.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ export default {
219219
apiName = 'updateTemplate'
220220
}
221221
if (!(apiName in this.$store.getters.apis)) {
222-
this.$notification.error({
222+
this.$showNotification({
223+
type: 'error',
223224
message: this.$t('error.execute.api.failed') + ' ' + apiName,
224225
description: this.$t('message.user.not.permitted.api')
225226
})

ui/src/components/view/ListView.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ export default {
514514
json.updateconfigurationresponse.configuration &&
515515
!json.updateconfigurationresponse.configuration.isdynamic &&
516516
['Admin'].includes(this.$store.getters.userInfo.roletype)) {
517-
this.$notification.warning({
517+
this.$showNotification({
518+
type: 'warning',
518519
message: this.$t('label.status'),
519520
description: this.$t('message.restart.mgmt.server')
520521
})

ui/src/components/view/ResourceLimitTab.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export default {
107107
this.dataResource = await this.listResourceLimits(params)
108108
this.formLoading = false
109109
} catch (e) {
110-
this.$notification.error({
110+
this.$showNotification({
111+
type: 'error',
111112
message: this.$t('message.request.failed'),
112113
description: e
113114
})

ui/src/components/view/SettingsTab.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export default {
164164
}).catch(error => {
165165
console.error(error)
166166
this.$message.error(this.$t('message.error.save.setting'))
167-
this.$notification.error({
167+
this.$showNotification({
168+
type: 'error',
168169
message: this.$t('label.error'),
169170
description: this.$t('message.error.try.save.setting')
170171
})

ui/src/components/view/UploadResourceIcon.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ export default {
234234
}).then(json => {
235235
console.log(this.resource)
236236
if (json?.uploadresourceiconresponse?.success) {
237-
this.$notification.success({
237+
this.$showNotification({
238+
type: 'success',
238239
message: this.$t('label.upload.icon'),
239240
description: `${this.$t('message.success.upload.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid)
240241
})
241242
}
242243
}).catch((error) => {
243-
this.$notification.error({
244+
this.$showNotification({
245+
type: 'error',
244246
message: this.$t('label.upload.icon'),
245247
description: error?.response?.data?.uploadresourceiconresponse?.errortext || '',
246248
duration: 0
@@ -264,13 +266,15 @@ export default {
264266
resourceids: resourceid
265267
}).then(json => {
266268
if (json?.deleteresourceiconresponse?.success) {
267-
this.$notification.success({
269+
this.$showNotification({
270+
type: 'success',
268271
message: this.$t('label.delete.icon'),
269272
description: `${this.$t('message.success.delete.icon')} ${resourceType}: ` + (this.resource.name || this.resource.username || resourceid)
270273
})
271274
}
272275
}).catch((error) => {
273-
this.$notification.error({
276+
this.$showNotification({
277+
type: 'error',
274278
message: this.$t('label.delete.icon'),
275279
description: error?.response?.data?.deleteresourceiconresponse?.errortext || '',
276280
duration: 0

ui/src/config/section/compute.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ export default {
152152
const vm = result.jobresult.virtualmachine || {}
153153
if (result.jobstatus === 1 && vm.password) {
154154
const name = vm.displayname || vm.name || vm.id
155-
obj.$notification.success({
155+
obj.$showNotification({
156+
type: 'success',
156157
message: `${obj.$t('label.reinstall.vm')}: ` + name,
157158
description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password,
158159
duration: 0
@@ -361,7 +362,8 @@ export default {
361362
const vm = result.jobresult.virtualmachine || {}
362363
if (result.jobstatus === 1 && vm.password) {
363364
const name = vm.displayname || vm.name || vm.id
364-
obj.$notification.success({
365+
obj.$showNotification({
366+
type: 'success',
365367
message: `${obj.$t('label.reset.ssh.key.pair.on.vm')}: ` + name,
366368
description: `${obj.$t('label.password.reset.confirm')}: ` + vm.password,
367369
duration: 0

ui/src/layouts/UserLayout.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717

1818
<template>
1919
<div id="userLayout" :class="['user-layout', device]">
20+
<a-button
21+
v-if="showClear"
22+
type="default"
23+
size="small"
24+
class="button-clear-notification"
25+
@click="onClearNotification">{{ $t('label.clear.notification') }}</a-button>
2026
<div class="user-layout-container">
2127
<div class="user-layout-header">
2228
<img
@@ -48,7 +54,9 @@ export default {
4854
components: { RouteView },
4955
mixins: [mixinDevice],
5056
data () {
51-
return {}
57+
return {
58+
showClear: false
59+
}
5260
},
5361
watch: {
5462
'$store.getters.darkMode' (darkMode) {
@@ -57,6 +65,12 @@ export default {
5765
} else {
5866
document.body.classList.remove('dark-mode')
5967
}
68+
},
69+
'$store.getters.countNotify' (countNotify) {
70+
this.showClear = false
71+
if (countNotify && countNotify > 0) {
72+
this.showClear = true
73+
}
6074
}
6175
},
6276
mounted () {
@@ -69,6 +83,12 @@ export default {
6983
beforeDestroy () {
7084
document.body.classList.remove('userLayout')
7185
document.body.classList.remove('dark-mode')
86+
},
87+
methods: {
88+
onClearNotification () {
89+
this.$notification.destroy()
90+
this.$store.commit('SET_COUNT_NOTIFY', 0)
91+
}
7292
}
7393
}
7494
</script>

0 commit comments

Comments
 (0)