1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-14 07:41:33 +08:00

fix: Run process notification without session (#413)

* fix: Show notification run process without session.

* close notification after response.
This commit is contained in:
Edwin Betancourt 2020-03-24 21:32:22 -04:00 committed by GitHub
parent 8258da6001
commit 1e837db9e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 221 additions and 175 deletions

View File

@ -176,15 +176,15 @@ export function getLookupList({
* @param {number} reportType * @param {number} reportType
* @param {number} tableName, table name of tab, used only window * @param {number} tableName, table name of tab, used only window
* @param {number} recordId, record identifier, used only window * @param {number} recordId, record identifier, used only window
* @param {array} parameters, parameters from process [{ columnName, value }] * @param {array} parametersList, parameters from process [{ columnName, value }]
* @param {array} selection, selection records, used only browser * @param {array} selectionsList, selection records, used only browser
[{ [{
selectionId, selectionId,
selectionValues: [{ columnName, value }] selectionValues: [{ columnName, value }]
}] }]
* @param {string} printFormatUuid * @param {string} printFormatUuid
*/ */
export function runProcess({ uuid, reportType, tableName, recordId, parameters: parametersList = [], selection: selectionsList = [], printFormatUuid }) { export function runProcess({ uuid, reportType, tableName, recordId, parametersList = [], selectionsList = [], printFormatUuid }) {
// Run Process // Run Process
return Instance.call(this).requestRunProcess({ return Instance.call(this).requestRunProcess({
uuid, uuid,

View File

@ -487,7 +487,7 @@ export const contextMixin = {
}) })
} }
} else if (action.type === 'updateReport') { } else if (action.type === 'updateReport') {
var updateReportParams = { const updateReportParams = {
instanceUuid: action.instanceUuid, instanceUuid: action.instanceUuid,
processUuid: action.processUuid, processUuid: action.processUuid,
tableName: action.tableName, tableName: action.tableName,
@ -526,8 +526,7 @@ export const contextMixin = {
response.url = link.href response.url = link.href
} }
this.$store.dispatch('finishProcess', { this.$store.dispatch('finishProcess', {
processOutput: response, processOutput: response
routeToDelete: this.$route
}) })
}) })
} }

View File

@ -6,6 +6,7 @@ import { showNotification } from '@/utils/ADempiere/notification'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils' import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
import language from '@/lang' import language from '@/lang'
import router from '@/router' import router from '@/router'
import { getToken } from '@/utils/auth'
const initStateProcessControl = { const initStateProcessControl = {
inExecution: [], // process not response from server inExecution: [], // process not response from server
@ -68,7 +69,7 @@ const processControl = {
setReportValues(state, payload) { setReportValues(state, payload) {
state.reportObject = payload state.reportObject = payload
if (state.reportList.some(report => report.instanceUuid === payload.instanceUuid)) { if (state.reportList.some(report => report.instanceUuid === payload.instanceUuid)) {
var reportIndex = state.reportList.findIndex(report => report.instanceUuid === payload.instanceUuid) const reportIndex = state.reportList.findIndex(report => report.instanceUuid === payload.instanceUuid)
state.reportList.splice(reportIndex, 1, payload) state.reportList.splice(reportIndex, 1, payload)
} else { } else {
state.reportList.push(payload) state.reportList.push(payload)
@ -101,12 +102,25 @@ const processControl = {
}, },
actions: { actions: {
// Supported Actions for it // Supported Actions for it
startProcess({ commit, state, dispatch, getters, rootGetters }, params) { startProcess({ commit, state, dispatch, getters, rootGetters }, {
parentUuid,
containerUuid,
panelType,
action,
parametersList,
reportFormat,
isProcessTableSelection,
isActionDocument,
tableNameUuidSelection,
recordUuidSelection,
menuParentUuid,
routeToDelete
}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// TODO: Add support to evaluate params to send // TODO: Add support to evaluate parameters list to send
// const samePocessInExecution = getters.getInExecution(params.containerUuid) // const samePocessInExecution = getters.getInExecution(containerUuid)
// exists some call to executed process with container uuid // exists some call to executed process with container uuid
// if (samePocessInExecution && !params.isProcessTableSelection) { // if (samePocessInExecution && !isProcessTableSelection) {
// return reject({ // return reject({
// error: 0, // error: 0,
// message: `In this process (${samePocessInExecution.name}) there is already an execution in progress.` // message: `In this process (${samePocessInExecution.name}) there is already an execution in progress.`
@ -117,11 +131,11 @@ const processControl = {
let selection = [] let selection = []
let allData = {} let allData = {}
let tab, tableName, recordId let tab, tableName, recordId
if (params.panelType) { if (panelType) {
if (params.panelType === 'browser') { if (panelType === 'browser') {
allData = getters.getDataRecordAndSelection(params.containerUuid) allData = getters.getDataRecordAndSelection(containerUuid)
selection = rootGetters.getSelectionToServer({ selection = rootGetters.getSelectionToServer({
containerUuid: params.containerUuid, containerUuid,
selection: allData.selection selection: allData.selection
}) })
if (selection.length < 1) { if (selection.length < 1) {
@ -131,26 +145,24 @@ const processControl = {
}) })
return reject({ return reject({
error: 0, error: 0,
message: `Required selection data record to run this process (${params.action.name})` message: `Required selection data record to run this process (${action.name})`
}) })
} }
} }
if (params.panelType === 'window') { if (panelType === 'window') {
const contextMenu = getters.getRecordUuidMenu const contextMenu = getters.getRecordUuidMenu
if (params.isProcessTableSelection) { tab = rootGetters.getTab(parentUuid, containerUuid)
tab = rootGetters.getTab(params.parentUuid, params.containerUuid) if (isProcessTableSelection) {
tableName = params.tableNameUuidSelection tableName = tableNameUuidSelection
recordId = params.recordUuidSelection recordId = recordUuidSelection
} else { } else {
if (contextMenu.processTable) { if (contextMenu.processTable) {
tab = rootGetters.getTab(params.parentUuid, params.containerUuid)
tableName = contextMenu.tableName tableName = contextMenu.tableName
recordId = contextMenu.valueRecord recordId = contextMenu.valueRecord
} else { } else {
tab = rootGetters.getTab(params.parentUuid, params.containerUuid)
tableName = tab.tableName tableName = tab.tableName
const field = rootGetters.getFieldFromColumnName({ const field = rootGetters.getFieldFromColumnName({
containerUuid: params.containerUuid, containerUuid,
columnName: `${tableName}_ID` columnName: `${tableName}_ID`
}) })
recordId = field.value recordId = field.value
@ -159,29 +171,36 @@ const processControl = {
} }
} }
// get info metadata process // get info metadata process
const processDefinition = !isEmptyValue(params.isActionDocument) ? params.action : rootGetters.getProcess(params.action.uuid) const processDefinition = !isEmptyValue(isActionDocument) ? action : rootGetters.getProcess(action.uuid)
let reportType = params.reportFormat let reportType = reportFormat
const finalParameters = rootGetters.getParametersToServer({ containerUuid: processDefinition.uuid }) const finalParameters = rootGetters.getParametersToServer({ containerUuid: processDefinition.uuid })
showNotification({ const isSession = !isEmptyValue(getToken())
let procesingMessage = {
close: () => false
}
if (isSession) {
procesingMessage = showNotification({
title: language.t('notifications.processing'), title: language.t('notifications.processing'),
message: processDefinition.name, message: processDefinition.name,
summary: processDefinition.description, summary: processDefinition.description,
type: 'info' type: 'info'
}) })
}
const timeInitialized = (new Date()).getTime() const timeInitialized = (new Date()).getTime()
let processResult let processResult
if (!isEmptyValue(params.isActionDocument)) { if (!isEmptyValue(isActionDocument)) {
processResult = { processResult = {
// panel attributes from where it was executed // panel attributes from where it was executed
parentUuid: params.parentUuid, parentUuid,
containerUuid: params.containerUuid, containerUuid,
panelType: params.panelType, panelType,
lastRun: timeInitialized, lastRun: timeInitialized,
processUuid: params.action.uuid, processUuid: action.uuid,
processId: params.action.id, processId: action.id,
processName: 'Procesar Orden', processName: 'Procesar Orden',
parameters: params.parametersList, parameters: parametersList,
parametersList,
isError: false, isError: false,
isProcessing: true, isProcessing: true,
summary: '', summary: '',
@ -203,12 +222,12 @@ const processControl = {
// uuid of process // uuid of process
processResult = { processResult = {
// panel attributes from where it was executed // panel attributes from where it was executed
parentUuid: params.parentUuid, parentUuid,
containerUuid: params.containerUuid, containerUuid,
panelType: params.panelType, panelType,
menuParentUuid: params.menuParentUuid, menuParentUuid,
processIdPath: params.routeToDelete.path, processIdPath: routeToDelete.path,
printFormatUuid: params.action.printFormatUuid, printFormatUuid: action.printFormatUuid,
// process attributes // process attributes
lastRun: timeInitialized, lastRun: timeInitialized,
action: processDefinition.name, action: processDefinition.name,
@ -237,25 +256,25 @@ const processControl = {
} }
} }
commit('addInExecution', processResult) commit('addInExecution', processResult)
if (params.panelType === 'window') { if (panelType === 'window') {
reportType = 'pdf' reportType = 'pdf'
} else if (params.panelType === 'browser') { } else if (panelType === 'browser') {
if (allData.record.length <= 100) { if (allData.record.length <= 100) {
// close view if is browser. // close view if is browser.
router.push({ path: '/dashboard' }) router.push({ path: '/dashboard' })
dispatch('tagsView/delView', params.routeToDelete) dispatch('tagsView/delView', routeToDelete)
// delete data associate to browser // delete data associate to browser
dispatch('deleteRecordContainer', { dispatch('deleteRecordContainer', {
viewUuid: params.containerUuid viewUuid: containerUuid
}) })
} }
} else { } else {
// close view if is process, report. // close view if is process, report.
router.push({ path: '/dashboard' }) router.push({ path: '/dashboard' })
dispatch('tagsView/delView', params.routeToDelete) dispatch('tagsView/delView', routeToDelete)
} }
if (params.isProcessTableSelection) { if (isProcessTableSelection) {
var windowSelectionProcess = getters.getProcessSelect const windowSelectionProcess = getters.getProcessSelect
windowSelectionProcess.selection.forEach(selection => { windowSelectionProcess.selection.forEach(selection => {
Object.assign(processResult, { Object.assign(processResult, {
selection: selection.UUID, selection: selection.UUID,
@ -267,9 +286,9 @@ const processControl = {
runProcess({ runProcess({
uuid: processDefinition.uuid, uuid: processDefinition.uuid,
id: processDefinition.id, id: processDefinition.id,
reportType: reportType, reportType,
parameters: isEmptyValue(finalParameters) ? params.parametersList : finalParameters, parametersList: isEmptyValue(finalParameters) ? parametersList : finalParameters,
selection: selection, selectionsList: selection,
tableName: windowSelectionProcess.tableName, tableName: windowSelectionProcess.tableName,
recordId: selection[windowSelectionProcess.tableName] recordId: selection[windowSelectionProcess.tableName]
}) })
@ -414,17 +433,14 @@ const processControl = {
const countResponse = state.totalResponse + 1 const countResponse = state.totalResponse + 1
commit('setTotalResponse', countResponse) commit('setTotalResponse', countResponse)
if (state.totalResponse === state.totalRequest) { if (state.totalResponse === state.totalRequest) {
// showNotification({ if (isSession) {
// title: language.t('notifications.succesful'), showNotification({
// message: language.t('notifications.totalProcess') + countResponse + language.t('notifications.error') + state.errorSelection + language.t('notifications.succesful') + state.successSelection + language.t('notifications.processExecuted'),
// type: 'success'
// })
const processMessage = {
title: language.t('notifications.succesful'), title: language.t('notifications.succesful'),
message: language.t('notifications.totalProcess') + countResponse + language.t('notifications.error') + state.errorSelection + language.t('notifications.succesful') + state.successSelection + language.t('notifications.processExecuted'), message: language.t('notifications.totalProcess') + countResponse + language.t('notifications.error') + state.errorSelection + language.t('notifications.succesful') + state.successSelection + language.t('notifications.processExecuted'),
type: 'success' type: 'success'
})
} }
showNotification(processMessage)
commit('setTotalRequest', 0) commit('setTotalRequest', 0)
commit('setTotalResponse', 0) commit('setTotalResponse', 0)
commit('setSuccessSelection', 0) commit('setSuccessSelection', 0)
@ -438,7 +454,7 @@ const processControl = {
commit('addNotificationProcess', processResult) commit('addNotificationProcess', processResult)
commit('addStartedProcess', processResult) commit('addStartedProcess', processResult)
commit('deleteInExecution', { commit('deleteInExecution', {
containerUuid: params.containerUuid containerUuid
}) })
}) })
} }
@ -448,15 +464,15 @@ const processControl = {
uuid: processDefinition.uuid, uuid: processDefinition.uuid,
id: processDefinition.id, id: processDefinition.id,
reportType, reportType,
parameters: isEmptyValue(finalParameters) ? params.parametersList : finalParameters, parametersList: isEmptyValue(finalParameters) ? parametersList : finalParameters,
selection, selectionsList: selection,
tableName, tableName,
recordId recordId
}) })
.then(runProcessResponse => { .then(runProcessResponse => {
const { instanceUuid, output } = runProcessResponse const { instanceUuid, output } = runProcessResponse
let logList = [] let logList = []
if (runProcessResponse.logsList) { if (!isEmptyValue(runProcessResponse.logsList)) {
logList = runProcessResponse.logsList logList = runProcessResponse.logsList
} }
@ -529,7 +545,7 @@ const processControl = {
} }
}) })
} else { } else {
var index = contextMenuMetadata.actions.findIndex(action => action.option === 'printFormat') const index = contextMenuMetadata.actions.findIndex(action => action.option === 'printFormat')
if (index !== -1) { if (index !== -1) {
contextMenuMetadata.actions[index] = printFormatList contextMenuMetadata.actions[index] = printFormatList
} }
@ -572,8 +588,8 @@ const processControl = {
logs: logList, logs: logList,
output output
}) })
dispatch('setReportTypeToShareLink', processResult.output.reportType)
resolve(processResult) resolve(processResult)
dispatch('setReportTypeToShareLink', processResult.output.reportType)
}) })
.catch(error => { .catch(error => {
Object.assign(processResult, { Object.assign(processResult, {
@ -586,17 +602,17 @@ const processControl = {
}) })
.finally(() => { .finally(() => {
if (!processResult.isError) { if (!processResult.isError) {
if (params.panelType === 'window') { if (panelType === 'window') {
// TODO: Add conditional to indicate when update record // TODO: Add conditional to indicate when update record
dispatch('updateRecordAfterRunProcess', { dispatch('updateRecordAfterRunProcess', {
parentUuid: params.parentUuid, parentUuid,
containerUuid: params.containerUuid, containerUuid,
tab: tab tab
}) })
} else if (params.panelType === 'browser') { } else if (panelType === 'browser') {
if (allData.record.length >= 100) { if (allData.record.length >= 100) {
dispatch('getBrowserSearch', { dispatch('getBrowserSearch', {
containerUuid: params.containerUuid containerUuid
}) })
} }
} }
@ -605,11 +621,11 @@ const processControl = {
commit('addNotificationProcess', processResult) commit('addNotificationProcess', processResult)
dispatch('finishProcess', { dispatch('finishProcess', {
processOutput: processResult, processOutput: processResult,
routeToDelete: params.routeToDelete procesingMessage
}) })
commit('deleteInExecution', { commit('deleteInExecution', {
containerUuid: params.containerUuid containerUuid
}) })
dispatch('setProcessTable', { dispatch('setProcessTable', {
@ -625,30 +641,40 @@ const processControl = {
}) })
}, },
// Supported to process selection // Supported to process selection
selectionProcess({ commit, state, dispatch, getters, rootGetters }, params) { selectionProcess({ commit, state, dispatch, getters, rootGetters }, {
parentUuid,
containerUuid,
panelType,
action,
isProcessTableSelection,
menuParentUuid,
routeToDelete
}) {
// get info metadata process // get info metadata process
const processDefinition = rootGetters.getProcess(params.action.uuid) const processDefinition = rootGetters.getProcess(action.uuid)
var reportType = 'pdf' const reportType = 'pdf'
const finalParameters = rootGetters.getParametersToServer({ containerUuid: processDefinition.uuid }) const finalParameters = rootGetters.getParametersToServer({ containerUuid: processDefinition.uuid })
const isSession = !isEmptyValue(getToken())
if (isSession) {
showNotification({ showNotification({
title: language.t('notifications.processing'), title: language.t('notifications.processing'),
message: processDefinition.name, message: processDefinition.name,
summary: processDefinition.description, summary: processDefinition.description,
type: 'info' type: 'info'
}) })
}
const timeInitialized = (new Date()).getTime() const timeInitialized = (new Date()).getTime()
// Run process on server and wait for it for notify // Run process on server and wait for it for notify
if (params.isProcessTableSelection) { if (isProcessTableSelection) {
var windowSelectionProcess = getters.getProcessSelect const windowSelectionProcess = getters.getProcessSelect
windowSelectionProcess.selection.forEach(selection => { windowSelectionProcess.selection.forEach(selection => {
var processResult = { const processResult = {
// panel attributes from where it was executed // panel attributes from where it was executed
parentUuid: params.parentUuid, parentUuid,
containerUuid: params.containerUuid, containerUuid,
panelType: params.panelType, panelType,
menuParentUuid: params.menuParentUuid, menuParentUuid,
processIdPath: params.routeToDelete.path, processIdPath: routeToDelete.path,
// process attributes // process attributes
lastRun: timeInitialized, lastRun: timeInitialized,
action: processDefinition.name, action: processDefinition.name,
@ -684,14 +710,14 @@ const processControl = {
return runProcess({ return runProcess({
uuid: processDefinition.uuid, uuid: processDefinition.uuid,
id: processDefinition.id, id: processDefinition.id,
reportType: reportType, reportType,
parameters: finalParameters, parametersList: finalParameters,
selection: selection, selectionsList: selection,
tableName: windowSelectionProcess.tableName, tableName: windowSelectionProcess.tableName,
recordId: selection[windowSelectionProcess.tableName] recordId: selection[windowSelectionProcess.tableName]
}) })
.then(response => { .then(response => {
var output = { let output = {
uuid: '', uuid: '',
name: '', name: '',
description: '', description: '',
@ -714,7 +740,7 @@ const processControl = {
reportType: responseOutput.reporttype reportType: responseOutput.reporttype
} }
} }
var logList = [] let logList = []
if (response.getLogsList) { if (response.getLogsList) {
logList = response.getLogsList.map(itemLog => { logList = response.getLogsList.map(itemLog => {
return { return {
@ -733,7 +759,7 @@ const processControl = {
ResultTableName: response.resulttablename, ResultTableName: response.resulttablename,
lastRun: response.lastRun, lastRun: response.lastRun,
logs: logList, logs: logList,
output: output output
}) })
dispatch('setReportTypeToShareLink', processResult.output.reportType) dispatch('setReportTypeToShareLink', processResult.output.reportType)
if (processResult.isError) { if (processResult.isError) {
@ -746,12 +772,13 @@ const processControl = {
const countResponse = state.totalResponse + 1 const countResponse = state.totalResponse + 1
commit('setTotalResponse', countResponse) commit('setTotalResponse', countResponse)
if (state.totalResponse === state.totalRequest) { if (state.totalResponse === state.totalRequest) {
var processMessage = { if (isSession) {
showNotification({
title: language.t('notifications.succesful'), title: language.t('notifications.succesful'),
message: language.t('notifications.totalProcess') + countResponse + language.t('notifications.error') + state.errorSelection + language.t('notifications.succesful') + state.successSelection + language.t('notifications.processExecuted'), message: language.t('notifications.totalProcess') + countResponse + language.t('notifications.error') + state.errorSelection + language.t('notifications.succesful') + state.successSelection + language.t('notifications.processExecuted'),
type: 'success' type: 'success'
})
} }
showNotification(processMessage)
commit('setTotalRequest', 0) commit('setTotalRequest', 0)
commit('setTotalResponse', 0) commit('setTotalResponse', 0)
commit('setSuccessSelection', 0) commit('setSuccessSelection', 0)
@ -765,7 +792,7 @@ const processControl = {
commit('addNotificationProcess', processResult) commit('addNotificationProcess', processResult)
commit('addStartedProcess', processResult) commit('addStartedProcess', processResult)
commit('deleteInExecution', { commit('deleteInExecution', {
containerUuid: params.containerUuid containerUuid
}) })
}) })
.catch(error => { .catch(error => {
@ -774,7 +801,7 @@ const processControl = {
message: error.message, message: error.message,
isProcessing: false isProcessing: false
}) })
console.warn(`Error running the process ${error}.`) console.warn(`Error running the process. Code ${error.code}: ${error.message}.`)
}) })
} }
}) })
@ -828,21 +855,24 @@ const processControl = {
* Show modal dialog with process/report, tab (sequence) metadata * Show modal dialog with process/report, tab (sequence) metadata
* @param {object} params * @param {object} params
*/ */
setShowDialog({ state, commit, dispatch, rootGetters }, params) { setShowDialog({ state, commit, dispatch, rootGetters }, {
type,
action
}) {
const panels = ['process', 'report', 'window'] const panels = ['process', 'report', 'window']
if (params.action && (panels.includes(params.type) || panels.includes(params.action.panelType))) { if (action && (panels.includes(type) || panels.includes(action.panelType))) {
// show some process loaded in store // show some process loaded in store
if (state.metadata && !isEmptyValue(state.metadata.containerUuid) && if (state.metadata && !isEmptyValue(state.metadata.containerUuid) &&
state.metadata.containerUuid === params.action.containerUuid) { state.metadata.containerUuid === action.containerUuid) {
commit('setShowDialog', true) commit('setShowDialog', true)
return return
} }
const panel = rootGetters.getPanel(params.action.containerUuid) const panel = rootGetters.getPanel(action.containerUuid)
if (panel === undefined) { if (panel === undefined) {
dispatch('getPanelAndFields', { dispatch('getPanelAndFields', {
parentUuid: params.action.parentUuid, parentUuid: action.parentUuid,
containerUuid: isEmptyValue(params.action.uuid) ? params.action.containerUuid : params.action.uuid, containerUuid: isEmptyValue(action.uuid) ? action.containerUuid : action.uuid,
panelType: params.action.panelType panelType: action.panelType
}) })
.then(response => { .then(response => {
commit('setMetadata', response) commit('setMetadata', response)
@ -856,53 +886,62 @@ const processControl = {
} }
commit('setShowDialog', false) commit('setShowDialog', false)
}, },
finishProcess({ commit }, parameters) { finishProcess({ commit }, {
var processMessage = { processOutput,
name: parameters.processOutput.processName, procesingMessage
}) {
const processMessage = {
name: processOutput.processName,
title: language.t('notifications.succesful'), title: language.t('notifications.succesful'),
message: language.t('notifications.processExecuted'), message: language.t('notifications.processExecuted'),
type: 'success', type: 'success',
logs: parameters.processOutput.logs, logs: processOutput.logs,
summary: parameters.processOutput.summary summary: processOutput.summary
} }
var errorMessage = !isEmptyValue(parameters.processOutput.message) ? parameters.processOutput.message : language.t('notifications.error') const errorMessage = !isEmptyValue(processOutput.message) ? processOutput.message : language.t('notifications.error')
// TODO: Add isReport to type always 'success' // TODO: Add isReport to type always 'success'
if (parameters.processOutput.isError || isEmptyValue(parameters.processOutput.processId) || isEmptyValue(parameters.processOutput.instanceUuid)) { if (processOutput.isError || isEmptyValue(processOutput.processId) || isEmptyValue(processOutput.instanceUuid)) {
processMessage.title = language.t('notifications.error') processMessage.title = language.t('notifications.error')
processMessage.message = errorMessage processMessage.message = errorMessage
processMessage.type = 'error' processMessage.type = 'error'
parameters.processOutput.isError = true processOutput.isError = true
} }
if (parameters.processOutput.isReport && !parameters.processOutput.isError) { if (processOutput.isReport && !processOutput.isError) {
// open report viewer with report response // open report viewer with report response
if (isEmptyValue(parameters.processOutput.menuParentUuid)) { if (isEmptyValue(processOutput.menuParentUuid)) {
parameters.processOutput.menuParentUuid = parameters.processOutput.processUuid processOutput.menuParentUuid = processOutput.processUuid
} }
let tableName let tableName
if (parameters.processOutput.option && !isEmptyValue(parameters.processOutput.option)) { if (processOutput.option && !isEmptyValue(processOutput.option)) {
if (parameters.processOutput.option === 'drillTable') { if (processOutput.option === 'drillTable') {
tableName = parameters.processOutput.tableName tableName = processOutput.tableName
} }
} }
router.push({ router.push({
name: 'Report Viewer', name: 'Report Viewer',
params: { params: {
processId: parameters.processOutput.processId, processId: processOutput.processId,
instanceUuid: parameters.processOutput.instanceUuid, instanceUuid: processOutput.instanceUuid,
fileName: isEmptyValue(parameters.processOutput.output.fileName) ? parameters.processOutput.fileName : parameters.processOutput.output.fileName, fileName: isEmptyValue(processOutput.output.fileName) ? processOutput.fileName : processOutput.output.fileName,
menuParentUuid: parameters.processOutput.menuParentUuid, menuParentUuid: processOutput.menuParentUuid,
tableName: tableName tableName
} }
}) })
} }
const isSession = !isEmptyValue(getToken())
if (isSession) {
showNotification(processMessage) showNotification(processMessage)
commit('addStartedProcess', parameters.processOutput) }
commit('setReportValues', parameters.processOutput) if (!isEmptyValue(procesingMessage)) {
procesingMessage.close()
}
commit('addStartedProcess', processOutput)
commit('setReportValues', processOutput)
}, },
changeFormatReport({ commit }, reportFormat) { changeFormatReport({ commit }, reportFormat) {
if (reportFormat !== undefined) { if (!isEmptyValue(reportFormat)) {
commit('changeFormatReport', reportFormat) commit('changeFormatReport', reportFormat)
} }
} }

View File

@ -6,7 +6,6 @@ export function hasTranslation(text) {
const hasKey = language.te('notifications.' + text) const hasKey = language.te('notifications.' + text)
if (hasKey) { if (hasKey) {
const translatedText = language.t('notifications.' + text) const translatedText = language.t('notifications.' + text)
return translatedText return translatedText
} }
return text return text
@ -14,61 +13,70 @@ export function hasTranslation(text) {
/** /**
* *
* @param {object} parameters * @param {string} type, required
* @param {object} parameters.type, required * @param {string} title, required
* @param {object} parameters.title, required * @param {object} message
* @param {object} parameters.message, required * @param {string} summary
* @param {object} parameters.summary, required * @param {string} name
* @param {object} parameters.name, required * @param {array} logs
*/ */
export function showNotification(parameters) { export function showNotification({ type, title, message, summary, name, logs = [] }) {
var title = hasTranslation(parameters.title) title = hasTranslation(title)
var message = '' if (message) {
if (parameters.message) { message = hasTranslation(message)
message = hasTranslation(parameters.message)
} }
// For summary // For summary
if (parameters.summary) { if (summary) {
if (message) { if (message) {
message = message + '<br>' + parameters.summary message = `${message} <br> ${summary}`
} else { } else {
message = parameters.summary message = summary
} }
} }
// For logs // For logs
if (parameters.logs) { if (logs && logs.length) {
parameters.logs.forEach(logResult => { logs.forEach(logResult => {
if (logResult) { if (logResult) {
message = message + '<br>' + logResult.log message = `${message} <br> ${logResult.log}`
} }
}) })
} }
if (parameters.name) { if (name) {
message = parameters.name + message message = name + message
} }
Notification({
title: title, return Notification({
message: `<div style="max-height: 100px; overflow-y: auto;">` + message + `</div>`, title,
type: parameters.type, message: `<div style="max-height: 100px; overflow-y: auto;">${message}</div>`,
type,
position: 'bottom-right', position: 'bottom-right',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
onClick() { onClick() {
router.push({ name: 'ProcessActivity' }) router.push({
name: 'ProcessActivity'
})
} }
}) })
} }
export function showMessage(parameters) { /**
var delay = 3000 *
if (parameters.type === 'info') { * @param {string} type
* @param {string} message
* @param {number} duration
*/
export function showMessage({ type, message, duration = 0 }) {
let delay = 3000
if (type === 'info') {
delay = 2000 delay = 2000
} }
if (parameters.duration) { if (duration) {
delay = parameters.duration delay = duration
} }
Message({
message: parameters.message, return Message({
type: parameters.type, message,
type,
showClose: true, showClose: true,
duration: delay duration: delay
}) })