diff --git a/plugins/hooks/frontend/public/javascripts/countly.models.js b/plugins/hooks/frontend/public/javascripts/countly.models.js index 3e9f0ea6922..30b42e5e05a 100644 --- a/plugins/hooks/frontend/public/javascripts/countly.models.js +++ b/plugins/hooks/frontend/public/javascripts/countly.models.js @@ -136,6 +136,64 @@ return triggerEffectDom; }; + hooksPlugin.generateTriggerActionsTreeForExport = function(row) { + var triggerNames = { + "APIEndPointTrigger": jQuery.i18n.map["hooks.trigger-api-endpoint-uri"], + "IncomingDataTrigger": jQuery.i18n.map["hooks.IncomingData"], + "InternalEventTrigger": jQuery.i18n.map["hooks.internal-event-selector-title"], + "ScheduledTrigger": jQuery.i18n.map["hooks.ScheduledTrigger"], + }; + var triggerText = triggerNames[row.trigger.type]; + var triggerDesc = ''; + try { + if (row.trigger.type === "IncomingDataTrigger") { + var event = row.trigger.configuration.event; + var parts = event[0].split("***"); + triggerDesc = ' ' + parts[1] + ' '; + } + + if (row.trigger.type === "APIEndPointTrigger") { + var path = row.trigger.configuration.path; + triggerDesc = ' ' + path + ' '; + } + + if (row.trigger.type === "InternalEventTrigger") { + var eventType = row.trigger.configuration.eventType; + triggerDesc = ' ' + eventType + ' '; + } + } + catch (e) { + //silent catch + } + + var effectNames = { + "EmailEffect": jQuery.i18n.map["hooks.EmailEffect"], + "HTTPEffect": jQuery.i18n.map["hooks.HTTPEffect"], + "CustomCodeEffect": jQuery.i18n.map["hooks.CustomCodeEffect"], + }; + var effectList = ""; + var arrow = ' -> '; + row.effects.forEach(function(effect) { + effectList += arrow + (effectNames[effect.type] && effectNames[effect.type].toUpperCase()) + ' '; + if (effect.type === "EmailEffect") { + effectList += ' ' + effect.configuration.address + ' '; + } + if (effect.type === "HTTPEffect") { + effectList += ' ' + effect.configuration.url + ' '; + } + if (effect.type === "CustomCodeEffect") { + effectList += ' ' + effect.configuration.code + ' '; + } + }); + + var triggerEffectDom = triggerText.toUpperCase() + ' '; + triggerEffectDom += triggerDesc; + triggerEffectDom += ' '; + triggerEffectDom += effectList; + triggerEffectDom += ' '; + return triggerEffectDom; + }; + hooksPlugin.getVuexModule = function() { var getEmptyState = function() { return { @@ -329,6 +387,7 @@ var triggerEffectDom = hooksPlugin.generateTriggerActionsTreeDom(row); + tableData.push({ _id: hookList[i]._id, name: hookList[i].name || '', diff --git a/plugins/hooks/frontend/public/javascripts/countly.views.js b/plugins/hooks/frontend/public/javascripts/countly.views.js index 07a8d752ab2..5ec7d5c697b 100644 --- a/plugins/hooks/frontend/public/javascripts/countly.views.js +++ b/plugins/hooks/frontend/public/javascripts/countly.views.js @@ -109,6 +109,23 @@ onRowClick: function(params) { app.navigate("/manage/hooks/" + params._id, true); }, + formatExportFunction: function() { + var tableData = this.tableRows; + var table = []; + for (var i = 0; i < tableData.length; i++) { + var item = {}; + item[CV.i18n('hooks.hook-name').toUpperCase()] = tableData[i].name; + item[CV.i18n('hooks.description').toUpperCase()] = tableData[i].description; + item[CV.i18n('hooks.trigger-and-actions').toUpperCase()] = hooksPlugin.generateTriggerActionsTreeForExport(tableData[i]); + item[CV.i18n('hooks.trigger-count').toUpperCase()] = tableData[i].triggerCount; + item[CV.i18n('hooks.trigger-last-time').toUpperCase()] = tableData[i].lastTriggerTimestampString === "-" ? "" : tableData[i].lastTriggerTimestampString; + item[CV.i18n('hooks.create-by').toUpperCase()] = tableData[i].createdByUser; + + table.push(item); + } + return table; + + }, } }); diff --git a/plugins/hooks/frontend/public/localization/hooks.properties b/plugins/hooks/frontend/public/localization/hooks.properties index d0319084100..6d997369251 100644 --- a/plugins/hooks/frontend/public/localization/hooks.properties +++ b/plugins/hooks/frontend/public/localization/hooks.properties @@ -49,7 +49,7 @@ hooks.trigger-instruction = TIPS hooks.trigger-copy-url = Copy URL hooks.test-hook=Test hook hooks.ScheduledTrigger = Scheduled Trigger - +hooks.trigger-and-actions = Trigger -> Actions #efffects hooks.CustomCodeEffect = Custom Code diff --git a/plugins/hooks/frontend/public/templates/vue-table.html b/plugins/hooks/frontend/public/templates/vue-table.html index 14132a924eb..59886c7a72c 100644 --- a/plugins/hooks/frontend/public/templates/vue-table.html +++ b/plugins/hooks/frontend/public/templates/vue-table.html @@ -5,6 +5,7 @@ class="cly-vue-hook-table is-clickable" :tracked-fields="localTableTrackedFields" :rows="tableRows" :resizable="false" + :exportFormat="formatExportFunction" :available-dynamic-cols="tableDynamicCols" > - +