diff --git a/src/api/ADempiere/reportManagement/index.ts b/src/api/ADempiere/reportManagement/index.ts index 09a5aada4a..69f9c1d7b9 100644 --- a/src/api/ADempiere/reportManagement/index.ts +++ b/src/api/ADempiere/reportManagement/index.ts @@ -180,3 +180,39 @@ export function runExport({ method: 'post' }) } + +export function ListNotificationsTypes() { + return request({ + url: '/send_notifications/notifications_types', + method: 'get' + }) +} + +export function ListUsers() { + return request({ + url: '/send_notifications/user', + method: 'get' + }) +} + +export function SendNotification({ + user_id, + title, + recipients, + subject, + notification_type, + attachments +}) { + return request({ + url: '/send_notifications/notification', + method: 'post', + params: { + user_id, + title, + recipients, + subject, + notification_type, + attachments + } + }) +} diff --git a/src/lang/ADempiere/en/report.js b/src/lang/ADempiere/en/report.js index 5e74806992..1fbe8ca084 100644 --- a/src/lang/ADempiere/en/report.js +++ b/src/lang/ADempiere/en/report.js @@ -105,7 +105,10 @@ const report = { viewReport: 'Report View', Detail: 'View Detailed', summary: 'View Summary', - exportFormat: 'Export Format' + exportFormat: 'Export Format', + download: 'Generated Download Link', + sharedReport: 'Shared Report', + mesajeDownload: 'Click on the Following lLnk to go to Download ' } } diff --git a/src/lang/ADempiere/es/report.js b/src/lang/ADempiere/es/report.js index d37d68f5f2..2b0e0c5931 100644 --- a/src/lang/ADempiere/es/report.js +++ b/src/lang/ADempiere/es/report.js @@ -105,7 +105,10 @@ const report = { viewReport: 'Vista del Informe', Detail: 'Ver Detallado', summary: 'Ver Resumido', - exportFormat: 'Formato de Exportación' + exportFormat: 'Formato de Exportación', + download: 'Link de Descarga Generado', + sharedReport: 'Reporte Compartido', + mesajeDownload: 'Haga clic en el Siguiente Enlace para ir a la Descarga ' } } diff --git a/src/store/modules/ADempiere/reportManager.js b/src/store/modules/ADempiere/reportManager.js index 5ff36636cc..07ab93f6e4 100644 --- a/src/store/modules/ADempiere/reportManager.js +++ b/src/store/modules/ADempiere/reportManager.js @@ -27,7 +27,10 @@ import { runExport, generateReport, generateReportRequest, - getReportOutputRequest + getReportOutputRequest, + ListNotificationsTypes, + ListUsers, + SendNotification } from '@/api/ADempiere/reportManagement/index.ts' import { listPrintFormatsRequest } from '@/api/ADempiere/reportManagement/printFormat.ts' import { listReportViewsRequest } from '@/api/ADempiere/reportManagement/reportView.ts' @@ -63,12 +66,24 @@ const initState = { pageSize: 15, isLoading: false, showDialog: false, - expandedAll: true + expandedAll: true, + exportReport: {}, + contactSend: '', + typeNotify: '' } const reportManager = { state: initState, mutations: { + setContactSend(state, contactSend) { + state.contactSend = contactSend + }, + setTypeNotify(state, typeNotify) { + state.typeNotify = typeNotify + }, + setExportReport(state, exportReport) { + state.exportReport = exportReport + }, setShowDialog(state, showDialog) { state.showDialog = showDialog }, @@ -676,7 +691,7 @@ const reportManager = { * @returns {files} */ exportReport({ - getters + commit }, { reportId, reportName @@ -689,8 +704,69 @@ const reportManager = { const { file_name } = response const file = document.createElement('a') file.href = `${config.adempiere.resource.url}${file_name}` - file.download = `${reportName}` // name of the file to be downloaded - file.click() + file.download = `${reportName}` + commit('setExportReport', response) + resolve(response) + }) + .catch(error => { + showNotification({ + title: language.t('notifications.error'), + message: error.message, + type: 'error' + }) + console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`) + }) + }) + }, + ListNotifications() { + return new Promise(resolve => { + ListNotificationsTypes() + .then(response => { + resolve(response) + }) + .catch(error => { + showNotification({ + title: language.t('notifications.error'), + message: error.message, + type: 'error' + }) + console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`) + }) + }) + }, + ListUser() { + return new Promise(resolve => { + ListUsers() + .then(response => { + resolve(response) + }) + .catch(error => { + showNotification({ + title: language.t('notifications.error'), + message: error.message, + type: 'error' + }) + console.warn(`Error exporting report: ${error.message}. Code: ${error.code}.`) + }) + }) + }, + getSendNotification({ commit }, { + user_id, + title, + recipients, + notification_type, + attachments + }) { + return new Promise(resolve => { + SendNotification({ + user_id, + title, + recipients, + notification_type, + attachments + }) + .then(response => { + commit('setSendNotification', response) resolve(response) }) .catch(error => { @@ -706,6 +782,15 @@ const reportManager = { }, getters: { + getContactSend: (state) => { + return state.contactSend + }, + getTypeNotify: (state) => { + return state.typeNotify + }, + getExportReport: (state) => { + return state.exportReport + }, getExpandedAll: (state) => { return state.expandedAll }, diff --git a/src/utils/ADempiere/notification.js b/src/utils/ADempiere/notification.js index 9489aa58b5..6c58ccd212 100644 --- a/src/utils/ADempiere/notification.js +++ b/src/utils/ADempiere/notification.js @@ -81,22 +81,22 @@ export function showNotification({ type = 'success', title, message = '', summar }) } export function showNotificationReport({ type = 'success', title, message, link }) { + title = hasTranslation(title) + if (message) { + message = hasTranslation(message) + } return Notification({ title, message: `
${message} +

+ Link
`, type, position: 'bottom-right', - dangerouslyUseHTMLString: true, - onClick() { - router.push({ - name: title, - path: link - }, () => {}) - } + dangerouslyUseHTMLString: true }) } /** diff --git a/src/views/ADempiere/ReportViewerEngine/dialog/contactSend.vue b/src/views/ADempiere/ReportViewerEngine/dialog/contactSend.vue new file mode 100644 index 0000000000..5329d14e70 --- /dev/null +++ b/src/views/ADempiere/ReportViewerEngine/dialog/contactSend.vue @@ -0,0 +1,56 @@ + + diff --git a/src/views/ADempiere/ReportViewerEngine/dialog/copyLink.vue b/src/views/ADempiere/ReportViewerEngine/dialog/copyLink.vue new file mode 100644 index 0000000000..77c6e7a29f --- /dev/null +++ b/src/views/ADempiere/ReportViewerEngine/dialog/copyLink.vue @@ -0,0 +1,93 @@ + + diff --git a/src/views/ADempiere/ReportViewerEngine/dialog/index.vue b/src/views/ADempiere/ReportViewerEngine/dialog/index.vue index 1f29ccace9..7c475691ab 100644 --- a/src/views/ADempiere/ReportViewerEngine/dialog/index.vue +++ b/src/views/ADempiere/ReportViewerEngine/dialog/index.vue @@ -94,71 +94,18 @@ - - - - + - - - - + -

- {{ $t('component.attachment.share.description') }} -

-

- - {{ $t('component.attachment.share.timeText') }} - -

- - 1 {{ ' ' + $t('component.attachment.share.time.hour') }} - 6 {{ ' ' + $t('component.attachment.share.time.hours') }} - 1 {{ ' ' + $t('component.attachment.share.time.day') }} - 3 {{ ' ' + $t('component.attachment.share.time.days') }} - 7 {{ ' ' + $t('component.attachment.share.time.days') }} - - - - - -
@@ -169,7 +116,8 @@ icon="el-icon-check" style="float: right;" type="primary" - @click="checkedItemGeneral === 0 ? handleDownload() : viewShowDialog()" + :disabled="disableButtom" + @click="sendNotify" /> import store from '@/store' -import { defineComponent, ref } from '@vue/composition-api' +import { defineComponent, computed, ref } from '@vue/composition-api' import { isEmptyValue } from '@/utils/ADempiere/valueUtils' -import { - requestShareResources -} from '@/api/ADempiere/file-management/resource-reference.ts' -import { copyToClipboard } from '@/utils/ADempiere/coreUtils.js' import { config } from '@/utils/ADempiere/config' import { REPORT_EXPORT_TYPES } from '@/utils/ADempiere/constants/report' +import { showNotificationReport } from '@/utils/ADempiere/notification.js' +import contactSend from './contactSend' +import typeNotify from './typeNotify' +import copyLink from './copyLink' export default defineComponent({ name: 'dialogShareReport', + components: { + contactSend, + copyLink, + typeNotify + }, props: { containerUuid: { type: String, @@ -208,13 +161,9 @@ export default defineComponent({ setup(props) { const checkedItemGeneral = ref(0) const checkedItem = ref(0) - const validTime = ref(3600) - const linkShare = ref('') - const isLoading = ref(false) const printFormat = ref([]) const printFormatValue = ref('') const typeNotification = ref('') - const contactSend = ref('') function setCheckedItemGeneral(check) { checkedItemGeneral.value = check } @@ -230,28 +179,29 @@ export default defineComponent({ function viewShowDialog() { store.commit('setShowDialog', false) } - function loadData() { - isLoading.value = true - requestShareResources({ - fileName: props.reportOutput.name, - seconds: validTime.value - }) - .then(response => { - linkShare.value = response - }) - .finally(() => { - isLoading.value = false - }) - } - function copyValue() { - let textToCopy = linkShare.value - if (isEmptyValue(textToCopy)) { - textToCopy = '' + function sendNotify() { + let link = 'https://www.google.com' + let title = '' + let message = 'Documento procesado' + if (!isEmptyValue(exportData.value)) { + link = exportData.value.file_name } - copyToClipboard({ - text: textToCopy, - isShowMessage: true + switch (checkedItemGeneral.value) { + case 1: + sendLink() + title = this.$t('report.reportEnginer.sharedReport') + message = this.$t('report.reportEnginer.mesajeDownload') + break + default: + title = this.$t('report.reportEnginer.download') + break + } + showNotificationReport({ + title, + message, + link }) + store.commit('setShowDialog', false) } function handleDownload() { const link = document.createElement('a') @@ -264,24 +214,45 @@ export default defineComponent({ const xlsTypes = REPORT_EXPORT_TYPES.filter(type => type.type === 'xls') printFormat.value = xlsTypes } - loadData() + const exportData = computed(() => { + return store.getters.getExportReport + }) + const typeNotify = computed(() => { + return store.getters.getTypeNotify + }) + const contactSend = computed(() => { + return store.getters.getContactSend + }) + const disableButtom = computed(() => { + return checkedItemGeneral.value === 1 && (isEmptyValue(typeNotify.value) || isEmptyValue(contactSend.value)) + }) + function sendLink() { + const user_id = store.getters['user/userInfo'].id + store.dispatch('getSendNotification', { + user_id, + title: props.reportOutput.name, + recipients: contactSend.value, + notification_type: typeNotify.value, + attachments: exportData.file_name + }) + } return { checkedItemGeneral, checkedItem, - validTime, - linkShare, - isLoading, printFormat, printFormatValue, typeNotification, + exportData, + disableButtom, + typeNotify, contactSend, handleDownload, getOptionFormat, viewShowDialog, setCheckedItemGeneral, - loadData, - copyValue, - optionPrintFormat + optionPrintFormat, + sendNotify, + sendLink } } }) diff --git a/src/views/ADempiere/ReportViewerEngine/dialog/typeNotify.vue b/src/views/ADempiere/ReportViewerEngine/dialog/typeNotify.vue new file mode 100644 index 0000000000..4cc0de6bc2 --- /dev/null +++ b/src/views/ADempiere/ReportViewerEngine/dialog/typeNotify.vue @@ -0,0 +1,57 @@ + + +