Skip to content

Commit ff4b49b

Browse files
authored
UI: Add router links to notifications and show error description (apache#5402)
1 parent d1db7f4 commit ff4b49b

4 files changed

Lines changed: 30 additions & 27 deletions

File tree

ui/src/components/header/HeaderNotice.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
</a-list-item-meta>
3434
</a-list-item>
3535
<a-list-item v-for="(notice, index) in notices" :key="index">
36-
<a-list-item-meta :title="notice.title" :description="notice.description">
36+
<div slot="title"> {{ notice.path }} </div>
37+
<a-list-item-meta :title="notice.title">
3738
<a-avatar :style="notificationAvatar[notice.status].style" :icon="notificationAvatar[notice.status].icon" slot="avatar"/>
38-
<span v-if="getResourceName(notice.description, 'name') && notice.path" slot="description"><router-link :to="{ path: notice.path}"> {{ getResourceName(notice.description, "name") + ' - ' }}</router-link></span>
39-
<span v-if="getResourceName(notice.description, 'name') && notice.path" slot="description"> {{ getResourceName(notice.description, "msg") }}</span>
40-
<span v-else slot="description"> {{ notice.description }} </span>
39+
<span slot="description" v-if="getResourceName(notice.description, 'name') && notice.path"><router-link :to="{ path: notice.path}"> {{ getResourceName(notice.description, "name") + ' - ' }}</router-link></span>
40+
<span slot="description" v-if="getResourceName(notice.description, 'name') && notice.path"> {{ getResourceName(notice.description, "msg") }}</span>
41+
<span slot="description" v-else> {{ notice.description }} </span>
4142
</a-list-item-meta>
4243
</a-list-item>
4344
</a-list>

ui/src/utils/plugins.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const pollJobPlugin = {
4040
* @param {Function} [catchMethod=() => {}]
4141
* @param {Object} [action=null]
4242
* @param {Object} [bulkAction=false]
43+
* @param {String} resourceId
4344
*/
4445
const {
4546
jobId,
@@ -55,7 +56,8 @@ export const pollJobPlugin = {
5556
catchMessage = i18n.t('label.error.caught'),
5657
catchMethod = () => {},
5758
action = null,
58-
bulkAction = false
59+
bulkAction = false,
60+
resourceId = null
5961
} = options
6062

6163
store.dispatch('AddHeaderNotice', {
@@ -65,9 +67,26 @@ export const pollJobPlugin = {
6567
status: 'progress'
6668
})
6769

70+
eventBus.$on('update-job-details', (jobId, resourceId) => {
71+
const fullPath = this.$route.fullPath
72+
const path = this.$route.path
73+
var jobs = this.$store.getters.headerNotices.map(job => {
74+
if (job.key === jobId) {
75+
if (resourceId && !path.includes(resourceId)) {
76+
job.path = path + '/' + resourceId
77+
} else {
78+
job.path = fullPath
79+
}
80+
}
81+
return job
82+
})
83+
this.$store.commit('SET_HEADER_NOTICES', jobs)
84+
})
85+
6886
options.originalPage = options.originalPage || this.$router.currentRoute.path
6987
api('queryAsyncJobResult', { jobId }).then(json => {
7088
const result = json.queryasyncjobresultresponse
89+
eventBus.$emit('update-job-details', jobId, resourceId)
7190
if (result.jobstatus === 1) {
7291
var content = successMessage
7392
if (successMessage === 'Success' && action && action.label) {
@@ -88,7 +107,7 @@ export const pollJobPlugin = {
88107
status: 'done',
89108
duration: 2
90109
})
91-
110+
eventBus.$emit('update-job-details', jobId, resourceId)
92111
// Ensure we refresh on the same / parent page
93112
const currentPage = this.$router.currentRoute.path
94113
const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')
@@ -123,11 +142,11 @@ export const pollJobPlugin = {
123142
store.dispatch('AddHeaderNotice', {
124143
key: jobId,
125144
title: title,
126-
description: description,
145+
description: desc,
127146
status: 'failed',
128147
duration: 2
129148
})
130-
149+
eventBus.$emit('update-job-details', jobId, resourceId)
131150
// Ensure we refresh on the same / parent page
132151
const currentPage = this.$router.currentRoute.path
133152
const samePage = options.originalPage === currentPage || options.originalPage.startsWith(currentPage + '/')

ui/src/views/AutogenView.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -500,21 +500,6 @@ export default {
500500
})
501501
}
502502
})
503-
eventBus.$on('update-job-details', (jobId, resourceId) => {
504-
const fullPath = this.$route.fullPath
505-
const path = this.$route.path
506-
var jobs = this.$store.getters.headerNotices.map(job => {
507-
if (job.jobid === jobId) {
508-
if (resourceId && !path.includes(resourceId)) {
509-
job.path = path + '/' + resourceId
510-
} else {
511-
job.path = fullPath
512-
}
513-
}
514-
return job
515-
})
516-
this.$store.commit('SET_HEADER_NOTICES', jobs)
517-
})
518503
519504
eventBus.$on('update-resource-state', (selectedItems, resource, state, jobid) => {
520505
if (selectedItems.length === 0) {
@@ -1064,7 +1049,8 @@ export default {
10641049
showLoading: showLoading,
10651050
catchMessage: this.$t('error.fetching.async.job.result'),
10661051
action,
1067-
bulkAction: `${this.selectedItems.length > 0}` && this.showGroupActionModal
1052+
bulkAction: `${this.selectedItems.length > 0}` && this.showGroupActionModal,
1053+
resourceId: resource
10681054
})
10691055
})
10701056
},

ui/src/views/compute/StartVirtualMachine.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100

101101
<script>
102102
import { api } from '@/api'
103-
import eventBus from '@/config/eventBus'
104103
import TooltipLabel from '@/components/widgets/TooltipLabel'
105104
106105
export default {
@@ -232,8 +231,6 @@ export default {
232231
successMessage: `${this.$t('label.action.start.instance')} ${this.resource.name}`,
233232
response: (result) => { return result.virtualmachine && result.virtualmachine.password ? `The password of VM <b>${result.virtualmachine.displayname}</b> is <b>${result.virtualmachine.password}</b>` : null }
234233
})
235-
const resourceId = this.resource.id
236-
eventBus.$emit('update-job-details', jobId, resourceId)
237234
this.closeAction()
238235
}).catch(error => {
239236
this.$notifyError(error)

0 commit comments

Comments
 (0)