(app)
| 26 | |
| 27 | export const pollJobPlugin = { |
| 28 | install (app) { |
| 29 | app.config.globalProperties.$pollJob = function (options) { |
| 30 | /** |
| 31 | * @param {String} jobId |
| 32 | * @param {String} [name=''] |
| 33 | * @param {String} [title=''] |
| 34 | * @param {String} [description=''] |
| 35 | * @param {Boolean} [showSuccessMessage=true] |
| 36 | * @param {String} [successMessage=Success] |
| 37 | * @param {Function} [successMethod=() => {}] |
| 38 | * @param {String} [errorMessage=Error] |
| 39 | * @param {Function} [errorMethod=() => {}] |
| 40 | * @param {Object} [showLoading=true] |
| 41 | * @param {String} [loadingMessage=Loading...] |
| 42 | * @param {String} [catchMessage=Error caught] |
| 43 | * @param {Function} [catchMethod=() => {}] |
| 44 | * @param {Object} [action=null] |
| 45 | * @param {Object} [bulkAction=false] |
| 46 | * @param {String} resourceId |
| 47 | */ |
| 48 | const { |
| 49 | jobId, |
| 50 | name = '', |
| 51 | title = '', |
| 52 | description = '', |
| 53 | showSuccessMessage = true, |
| 54 | successMessage = i18n.global.t('label.success'), |
| 55 | successMethod = () => {}, |
| 56 | errorMessage = i18n.global.t('label.error'), |
| 57 | errorMethod = () => {}, |
| 58 | loadingMessage = `${i18n.global.t('label.loading')}...`, |
| 59 | showLoading = true, |
| 60 | catchMessage = i18n.global.t('label.error.caught'), |
| 61 | catchMethod = () => {}, |
| 62 | action = null, |
| 63 | bulkAction = false, |
| 64 | resourceId = null |
| 65 | } = options |
| 66 | |
| 67 | store.dispatch('AddHeaderNotice', { |
| 68 | key: jobId, |
| 69 | title, |
| 70 | description, |
| 71 | status: 'progress', |
| 72 | timestamp: new Date() |
| 73 | }) |
| 74 | |
| 75 | eventBus.on('update-job-details', (args) => { |
| 76 | const { jobId, resourceId } = args |
| 77 | const fullPath = this.$route.fullPath |
| 78 | const path = this.$route.path |
| 79 | var jobs = this.$store.getters.headerNotices.map(job => { |
| 80 | if (job.key === jobId) { |
| 81 | if (resourceId && !path.includes(resourceId)) { |
| 82 | job.path = path + '/' + resourceId |
| 83 | } else { |
| 84 | job.path = fullPath |
| 85 | } |
nothing calls this directly
no test coverage detected