diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-04-08 15:45:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 15:45:34 +0300 |
commit | 821734c769fb012fc2ee5994b56937988150bc0f (patch) | |
tree | d5f7536f9507dd1def2cca0f2e7ff207771b1b26 /plugins | |
parent | 0087d178e516d16d3346c20f30685fd10d9fe84d (diff) |
[Vue] migrate scheduled reports management from twig/angularjs to vue (#19012)
* finish initial migration pass
* get changes to build
* delete angularjs and twig
* extract select phone numbers macro to vue and make sure angularjs directives are initialized in scheduled reports event content
* fixing several issues + getting report addition extending working
* fix UI tests
* possibly provide some BC for inline script use
* fix several bugs, use better approach for accessing report in event child vue components, provide backwards compatibility for angularjs/inline javascript potentially used by third party plugins
* apply review fixes
* decode scheduled report description as it is stored escaped in the DB + remove some vue warnings
Co-authored-by: sgiehl <stefan@matomo.org>
Diffstat (limited to 'plugins')
34 files changed, 3637 insertions, 779 deletions
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js index 9714c1ce19..8e5c88b308 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js @@ -2067,6 +2067,10 @@ var AjaxHelper_AjaxHelper = /*#__PURE__*/function () { helper.setErrorElement(options.errorElement); } + if (options.redirectOnSuccess) { + helper.redirectOnSuccess(options.redirectOnSuccess !== true ? options.redirectOnSuccess : undefined); + } + helper.setFormat(options.format || 'json'); if (Array.isArray(params)) { diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js index e6436e2409..e2b867cda6 100644 --- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js +++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js @@ -99,7 +99,7 @@ function Pe(){return S}function Ve(e,t){t.$oldEmit=t.$emit,t.$emit=function(e){f * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */function Ke(e,t){if("abort"!==t)if("undefined"!==typeof Piwik_Popover){var n=$("#loadingError");Piwik_Popover.isOpen()&&e&&500===e.status?e&&500===e.status&&$(document.body).html(piwikHelper.escape(e.responseText)):n.show()}else console.log("Request failed: ".concat(e.responseText))}Oe.updatePeriodParamsFromUrl=Ce.updatePeriodParamsFromUrl.bind(Ce),window.angular.module("piwikApp.service").service("piwikUrl",De),window.angular.module("piwikApp.service").run(["$location",function(){return null}]),window.angular.module("piwikApp.service").service("piwik",Pe),Ve.$inject=["piwik","$rootScope"],window.angular.module("piwikApp.service").run(Ve),window.globalAjaxQueue=[],window.globalAjaxQueue.active=0,window.globalAjaxQueue.clean=function(){for(var e=this.length;e>=0;e-=1)this[e]&&4!==this[e].readyState||this.splice(e,1)},window.globalAjaxQueue.push=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.active+=n.length,this.clean(),(e=Array.prototype.push).call.apply(e,[this].concat(n))},window.globalAjaxQueue.abort=function(){this.forEach((function(e){return e&&e.abort&&e.abort()})),this.splice(0,this.length),this.active=0};var Xe=function(e){$e(n,e);var t=He(n);function n(){return _e(this,n),t.apply(this,arguments)}return n}(We(Error)),Ze=function(){function e(){_e(this,e),Re(this,"format","json"),Re(this,"timeout",null),Re(this,"callback",null),Re(this,"useRegularCallbackInCaseOfError",!1),Re(this,"errorCallback",void 0),Re(this,"withToken",!1),Re(this,"completeCallback",void 0),Re(this,"getParams",{}),Re(this,"getUrl","?"),Re(this,"postParams",{}),Re(this,"loadingElement",null),Re(this,"errorElement","#ajaxError"),Re(this,"headers",void 0),Re(this,"requestHandle",null),Re(this,"abortController",null),Re(this,"defaultParams",["idSite","period","date","segment"]),Re(this,"resolveWithHelper",!1),this.errorCallback=Ke}return Fe(e,[{key:"addParams",value:function(e,t){var n=this,r="string"===typeof e?window.broadcast.getValuesFromUrl(e):e,i=["compareSegments","comparePeriods","compareDates"];Object.keys(r).forEach((function(e){var a=r[e];(-1===i.indexOf(e)||a)&&("get"===t.toLowerCase()?n.getParams[e]=a:"post"===t.toLowerCase()&&(n.postParams[e]=a))}))}},{key:"withTokenInUrl",value:function(){this.withToken=!0}},{key:"setUrl",value:function(e){this.addParams(broadcast.getValuesFromUrl(e),"GET")}},{key:"setBulkRequests",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.map((function(e){return"string"===typeof e?e:$.param(e)}));this.addParams({module:"API",method:"API.getBulkRequest",urls:r,format:"json"},"post")}},{key:"setTimeout",value:function(e){this.timeout=e}},{key:"setCallback",value:function(e){this.callback=e}},{key:"useCallbackInCaseOfError",value:function(){this.useRegularCallbackInCaseOfError=!0}},{key:"redirectOnSuccess",value:function(e){this.setCallback((function(){piwikHelper.redirect(e)}))}},{key:"setErrorCallback",value:function(e){this.errorCallback=e}},{key:"setCompleteCallback",value:function(e){this.completeCallback=e}},{key:"setFormat",value:function(e){this.format=e}},{key:"setLoadingElement",value:function(e){this.loadingElement=e||"#ajaxLoadingDiv"}},{key:"setErrorElement",value:function(e){e&&(this.errorElement=e)}},{key:"useGETDefaultParameter",value:function(e){if(e&&this.defaultParams)for(var t=0;t<this.defaultParams.length;t+=1)if(this.defaultParams[t]===e)return!0;return!1}},{key:"removeDefaultParameter",value:function(e){if(e&&this.defaultParams)for(var t=0;t<this.defaultParams.length;t+=1)this.defaultParams[t]===e&&this.defaultParams.splice(t,1)}},{key:"send",value:function(){var e=this;$(this.errorElement).length&&$(this.errorElement).hide(),this.loadingElement&&$(this.loadingElement).fadeIn(),this.requestHandle=this.buildAjaxCall(),window.globalAjaxQueue.push(this.requestHandle);var t=null;try{t=S.helper.getAngularDependency("$timeout")}catch(r){}this.abortController&&this.abortController.signal.addEventListener("abort",(function(){e.requestHandle&&e.requestHandle.abort()}));var n=new Promise((function(n,r){e.requestHandle.then((function(t){e.resolveWithHelper?n(e):n(t)})).fail((function(t){"abort"!==t.statusText&&(console.log("Warning: the ".concat($.param(e.getParams)," request failed!")),r(t))})).done((function(){t&&t()}))}));return n}},{key:"abort",value:function(){this.requestHandle&&"function"===typeof this.requestHandle.abort&&(this.requestHandle.abort(),this.requestHandle=null)}},{key:"buildAjaxCall",value:function(){var e=this,t=this,n=this.mixinDefaultGetParams(this.getParams),r=this.getUrl;"?"!==r[r.length-1]&&(r+="&"),n.segment&&(r="".concat(r,"segment=").concat(n.segment,"&"),delete n.segment),n.date&&(r="".concat(r,"date=").concat(decodeURIComponent(n.date.toString()),"&"),delete n.date),r+=$.param(n);var i={type:"POST",async:!0,url:r,dataType:this.format||"json",complete:this.completeCallback,headers:this.headers?this.headers:void 0,error:function(){if(window.globalAjaxQueue.active-=1,t.errorCallback){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.errorCallback.apply(this,n)}},success:function(t,n,r){if(e.loadingElement&&$(e.loadingElement).hide(),t&&"error"===t.result&&!e.useRegularCallbackInCaseOfError){var i=null,a="toast";$(e.errorElement).length&&t.message&&($(e.errorElement).show(),i=e.errorElement,a=null);var o=!document.querySelector("#login_form");if(t.message&&o){var l=window["require"]("piwik/UI"),c=new l.Notification;c.show(t.message,{placeat:i,context:"error",type:a,id:"ajaxHelper"}),c.scrollToNotification()}}else e.callback&&e.callback(t,n,r);window.globalAjaxQueue.active-=1,S.ajaxRequestFinished&&S.ajaxRequestFinished()},data:this.mixinDefaultPostParams(this.postParams),timeout:null!==this.timeout?this.timeout:void 0};return $.ajax(i)}},{key:"isRequestToApiMethod",value:function(){return this.getParams&&"API"===this.getParams.module&&this.getParams.method||this.postParams&&"API"===this.postParams.module&&this.postParams.method}},{key:"isWidgetizedRequest",value:function(){return"Widgetize"===broadcast.getValueFromUrl("module")}},{key:"getDefaultPostParams",value:function(){return this.withToken||this.isRequestToApiMethod()||S.shouldPropagateTokenAuth?{token_auth:S.token_auth,force_api_session:broadcast.isWidgetizeRequestWithoutSession()?0:1}:{}}},{key:"mixinDefaultPostParams",value:function(e){var t=this.getDefaultPostParams(),n=Object.assign(Object.assign({},t),e);return n}},{key:"mixinDefaultGetParams",value:function(e){var t=this,n=Ee.getSearchParam("segment"),r={idSite:S.idSite?S.idSite.toString():broadcast.getValueFromUrl("idSite"),period:S.period||broadcast.getValueFromUrl("period"),segment:n},i=e;return i.token_auth&&(i.token_auth=null,delete i.token_auth),Object.keys(r).forEach((function(e){t.useGETDefaultParameter(e)&&!i[e]&&!t.postParams[e]&&r[e]&&(i[e]=r[e])})),!this.useGETDefaultParameter("date")||i.date||this.postParams.date||(i.date=S.currentDateString),i}},{key:"getRequestHandle",value:function(){return this.requestHandle}}],[{key:"fetch",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new e;return n.withTokenInUrl&&r.withTokenInUrl(),n.errorElement&&r.setErrorElement(n.errorElement),r.setFormat(n.format||"json"),Array.isArray(t)?r.setBulkRequests.apply(r,Te(t)):r.addParams(Object.assign(Object.assign({module:"API",format:n.format||"json"},t),{},{segment:t.segment?encodeURIComponent(t.segment):void 0}),"get"),n.postParams&&r.addParams(n.postParams,"post"),n.headers&&(r.headers=n.headers),"undefined"===typeof n.createErrorNotification||n.createErrorNotification||r.useCallbackInCaseOfError(),n.abortController&&(r.abortController=n.abortController),n.returnResponseObject&&(r.resolveWithHelper=!0),r.send().then((function(t){var n=t instanceof e?t.requestHandle.responseJSON:t;if("error"===n.result)throw new Xe(n.message);return t}))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.fetch(e,Object.assign(Object.assign({},n),{},{postParams:t}))}}]),e}();function et(){return window.globalAjaxQueue}function tt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function rt(e,t,n){return t&&nt(e.prototype,t),n&&nt(e,n),e} + */function Ke(e,t){if("abort"!==t)if("undefined"!==typeof Piwik_Popover){var n=$("#loadingError");Piwik_Popover.isOpen()&&e&&500===e.status?e&&500===e.status&&$(document.body).html(piwikHelper.escape(e.responseText)):n.show()}else console.log("Request failed: ".concat(e.responseText))}Oe.updatePeriodParamsFromUrl=Ce.updatePeriodParamsFromUrl.bind(Ce),window.angular.module("piwikApp.service").service("piwikUrl",De),window.angular.module("piwikApp.service").run(["$location",function(){return null}]),window.angular.module("piwikApp.service").service("piwik",Pe),Ve.$inject=["piwik","$rootScope"],window.angular.module("piwikApp.service").run(Ve),window.globalAjaxQueue=[],window.globalAjaxQueue.active=0,window.globalAjaxQueue.clean=function(){for(var e=this.length;e>=0;e-=1)this[e]&&4!==this[e].readyState||this.splice(e,1)},window.globalAjaxQueue.push=function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.active+=n.length,this.clean(),(e=Array.prototype.push).call.apply(e,[this].concat(n))},window.globalAjaxQueue.abort=function(){this.forEach((function(e){return e&&e.abort&&e.abort()})),this.splice(0,this.length),this.active=0};var Xe=function(e){$e(n,e);var t=He(n);function n(){return _e(this,n),t.apply(this,arguments)}return n}(We(Error)),Ze=function(){function e(){_e(this,e),Re(this,"format","json"),Re(this,"timeout",null),Re(this,"callback",null),Re(this,"useRegularCallbackInCaseOfError",!1),Re(this,"errorCallback",void 0),Re(this,"withToken",!1),Re(this,"completeCallback",void 0),Re(this,"getParams",{}),Re(this,"getUrl","?"),Re(this,"postParams",{}),Re(this,"loadingElement",null),Re(this,"errorElement","#ajaxError"),Re(this,"headers",void 0),Re(this,"requestHandle",null),Re(this,"abortController",null),Re(this,"defaultParams",["idSite","period","date","segment"]),Re(this,"resolveWithHelper",!1),this.errorCallback=Ke}return Fe(e,[{key:"addParams",value:function(e,t){var n=this,r="string"===typeof e?window.broadcast.getValuesFromUrl(e):e,i=["compareSegments","comparePeriods","compareDates"];Object.keys(r).forEach((function(e){var a=r[e];(-1===i.indexOf(e)||a)&&("get"===t.toLowerCase()?n.getParams[e]=a:"post"===t.toLowerCase()&&(n.postParams[e]=a))}))}},{key:"withTokenInUrl",value:function(){this.withToken=!0}},{key:"setUrl",value:function(e){this.addParams(broadcast.getValuesFromUrl(e),"GET")}},{key:"setBulkRequests",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.map((function(e){return"string"===typeof e?e:$.param(e)}));this.addParams({module:"API",method:"API.getBulkRequest",urls:r,format:"json"},"post")}},{key:"setTimeout",value:function(e){this.timeout=e}},{key:"setCallback",value:function(e){this.callback=e}},{key:"useCallbackInCaseOfError",value:function(){this.useRegularCallbackInCaseOfError=!0}},{key:"redirectOnSuccess",value:function(e){this.setCallback((function(){piwikHelper.redirect(e)}))}},{key:"setErrorCallback",value:function(e){this.errorCallback=e}},{key:"setCompleteCallback",value:function(e){this.completeCallback=e}},{key:"setFormat",value:function(e){this.format=e}},{key:"setLoadingElement",value:function(e){this.loadingElement=e||"#ajaxLoadingDiv"}},{key:"setErrorElement",value:function(e){e&&(this.errorElement=e)}},{key:"useGETDefaultParameter",value:function(e){if(e&&this.defaultParams)for(var t=0;t<this.defaultParams.length;t+=1)if(this.defaultParams[t]===e)return!0;return!1}},{key:"removeDefaultParameter",value:function(e){if(e&&this.defaultParams)for(var t=0;t<this.defaultParams.length;t+=1)this.defaultParams[t]===e&&this.defaultParams.splice(t,1)}},{key:"send",value:function(){var e=this;$(this.errorElement).length&&$(this.errorElement).hide(),this.loadingElement&&$(this.loadingElement).fadeIn(),this.requestHandle=this.buildAjaxCall(),window.globalAjaxQueue.push(this.requestHandle);var t=null;try{t=S.helper.getAngularDependency("$timeout")}catch(r){}this.abortController&&this.abortController.signal.addEventListener("abort",(function(){e.requestHandle&&e.requestHandle.abort()}));var n=new Promise((function(n,r){e.requestHandle.then((function(t){e.resolveWithHelper?n(e):n(t)})).fail((function(t){"abort"!==t.statusText&&(console.log("Warning: the ".concat($.param(e.getParams)," request failed!")),r(t))})).done((function(){t&&t()}))}));return n}},{key:"abort",value:function(){this.requestHandle&&"function"===typeof this.requestHandle.abort&&(this.requestHandle.abort(),this.requestHandle=null)}},{key:"buildAjaxCall",value:function(){var e=this,t=this,n=this.mixinDefaultGetParams(this.getParams),r=this.getUrl;"?"!==r[r.length-1]&&(r+="&"),n.segment&&(r="".concat(r,"segment=").concat(n.segment,"&"),delete n.segment),n.date&&(r="".concat(r,"date=").concat(decodeURIComponent(n.date.toString()),"&"),delete n.date),r+=$.param(n);var i={type:"POST",async:!0,url:r,dataType:this.format||"json",complete:this.completeCallback,headers:this.headers?this.headers:void 0,error:function(){if(window.globalAjaxQueue.active-=1,t.errorCallback){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];t.errorCallback.apply(this,n)}},success:function(t,n,r){if(e.loadingElement&&$(e.loadingElement).hide(),t&&"error"===t.result&&!e.useRegularCallbackInCaseOfError){var i=null,a="toast";$(e.errorElement).length&&t.message&&($(e.errorElement).show(),i=e.errorElement,a=null);var o=!document.querySelector("#login_form");if(t.message&&o){var l=window["require"]("piwik/UI"),c=new l.Notification;c.show(t.message,{placeat:i,context:"error",type:a,id:"ajaxHelper"}),c.scrollToNotification()}}else e.callback&&e.callback(t,n,r);window.globalAjaxQueue.active-=1,S.ajaxRequestFinished&&S.ajaxRequestFinished()},data:this.mixinDefaultPostParams(this.postParams),timeout:null!==this.timeout?this.timeout:void 0};return $.ajax(i)}},{key:"isRequestToApiMethod",value:function(){return this.getParams&&"API"===this.getParams.module&&this.getParams.method||this.postParams&&"API"===this.postParams.module&&this.postParams.method}},{key:"isWidgetizedRequest",value:function(){return"Widgetize"===broadcast.getValueFromUrl("module")}},{key:"getDefaultPostParams",value:function(){return this.withToken||this.isRequestToApiMethod()||S.shouldPropagateTokenAuth?{token_auth:S.token_auth,force_api_session:broadcast.isWidgetizeRequestWithoutSession()?0:1}:{}}},{key:"mixinDefaultPostParams",value:function(e){var t=this.getDefaultPostParams(),n=Object.assign(Object.assign({},t),e);return n}},{key:"mixinDefaultGetParams",value:function(e){var t=this,n=Ee.getSearchParam("segment"),r={idSite:S.idSite?S.idSite.toString():broadcast.getValueFromUrl("idSite"),period:S.period||broadcast.getValueFromUrl("period"),segment:n},i=e;return i.token_auth&&(i.token_auth=null,delete i.token_auth),Object.keys(r).forEach((function(e){t.useGETDefaultParameter(e)&&!i[e]&&!t.postParams[e]&&r[e]&&(i[e]=r[e])})),!this.useGETDefaultParameter("date")||i.date||this.postParams.date||(i.date=S.currentDateString),i}},{key:"getRequestHandle",value:function(){return this.requestHandle}}],[{key:"fetch",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new e;return n.withTokenInUrl&&r.withTokenInUrl(),n.errorElement&&r.setErrorElement(n.errorElement),n.redirectOnSuccess&&r.redirectOnSuccess(!0!==n.redirectOnSuccess?n.redirectOnSuccess:void 0),r.setFormat(n.format||"json"),Array.isArray(t)?r.setBulkRequests.apply(r,Te(t)):r.addParams(Object.assign(Object.assign({module:"API",format:n.format||"json"},t),{},{segment:t.segment?encodeURIComponent(t.segment):void 0}),"get"),n.postParams&&r.addParams(n.postParams,"post"),n.headers&&(r.headers=n.headers),"undefined"===typeof n.createErrorNotification||n.createErrorNotification||r.useCallbackInCaseOfError(),n.abortController&&(r.abortController=n.abortController),n.returnResponseObject&&(r.resolveWithHelper=!0),r.send().then((function(t){var n=t instanceof e?t.requestHandle.responseJSON:t;if("error"===n.result)throw new Xe(n.message);return t}))}},{key:"post",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.fetch(e,Object.assign(Object.assign({},n),{},{postParams:t}))}}]),e}();function et(){return window.globalAjaxQueue}function tt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function rt(e,t,n){return t&&nt(e.prototype,t),n&&nt(e,n),e} /*! * Matomo - free/libre analytics platform * diff --git a/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts b/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts index 560bab3c1e..bd717d9b0f 100644 --- a/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts +++ b/plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts @@ -21,6 +21,7 @@ export interface AjaxOptions { abortController?: AbortController; returnResponseObject?: boolean; errorElement?: HTMLElement|JQuery|JQLite|string; + redirectOnSuccess?: QueryParameters|boolean; } interface ErrorResponse { @@ -189,6 +190,11 @@ export default class AjaxHelper<T = any> { // eslint-disable-line if (options.errorElement) { helper.setErrorElement(options.errorElement); } + if (options.redirectOnSuccess) { + helper.redirectOnSuccess( + options.redirectOnSuccess !== true ? options.redirectOnSuccess : undefined, + ); + } helper.setFormat(options.format || 'json'); if (Array.isArray(params)) { helper.setBulkRequests(...(params as QueryParameters[])); @@ -343,7 +349,7 @@ export default class AjaxHelper<T = any> { // eslint-disable-line * @param [params] to modify in redirect url * @return {void} */ - redirectOnSuccess(params: QueryParameters): void { + redirectOnSuccess(params?: QueryParameters): void { this.setCallback(() => { piwikHelper.redirect(params); }); diff --git a/plugins/CoreVue/types/index.d.ts b/plugins/CoreVue/types/index.d.ts index dcc0229382..2a454c6b78 100644 --- a/plugins/CoreVue/types/index.d.ts +++ b/plugins/CoreVue/types/index.d.ts @@ -88,11 +88,14 @@ declare global { lazyScrollToContent(): void; registerShortcut(key: string, description: string, callback: (event: ExtendedKeyboardEvent) => void): void; compileAngularComponents(selector: JQuery|JQLite|HTMLElement|string, options?: CompileAngularComponentsOptions): void; - compileVueEntryComponents(selector: JQuery|JQLite|HTMLElement|string): void; + compileVueEntryComponents(selector: JQuery|JQLite|HTMLElement|string, extraProps?: Record<string, unknown>): void; + destroyVueComponent(selector: JQuery|JQLite|HTMLElement|string): void; compileVueDirectives(selector: JQuery|JQLite|HTMLElement|string): void; calculateEvolution(currentValue: number, pastValue?: number|null): number; sendContentAsDownload(filename: string, content: any, mimeType?: string): void; showVisitorProfilePopup(visitorId: string, idSite: string|number): void; + hideAjaxError(): void; + refreshAfter(timeoutPeriod: number): void; } let piwikHelper: PiwikHelperGlobal; diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php index 7bce744459..1468cebb6f 100644 --- a/plugins/MobileMessaging/MobileMessaging.php +++ b/plugins/MobileMessaging/MobileMessaging.php @@ -76,7 +76,7 @@ class MobileMessaging extends \Piwik\Plugin 'ScheduledReports.allowMultipleReports' => 'allowMultipleReports', 'ScheduledReports.sendReport' => 'sendReport', 'Template.reportParametersScheduledReports' => 'template_reportParametersScheduledReports', - 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' + 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', ); } @@ -115,6 +115,11 @@ class MobileMessaging extends \Piwik\Plugin $translationKeys[] = 'MobileMessaging_Settings_ManagePhoneNumbers'; $translationKeys[] = 'MobileMessaging_Settings_VerificationCodeJustSent'; $translationKeys[] = 'MobileMessaging_Settings_ValidatePhoneNumber'; + $translationKeys[] = 'MobileMessaging_MobileReport_NoPhoneNumbers'; + $translationKeys[] = 'MobileMessaging_MobileReport_AdditionalPhoneNumbers'; + $translationKeys[] = 'MobileMessaging_MobileReport_MobileMessagingSettingsLink'; + $translationKeys[] = 'ScheduledReports_SendReportTo'; + $translationKeys[] = 'MobileMessaging_PhoneNumbers'; } public function validateReportParameters(&$parameters, $reportType) diff --git a/plugins/MobileMessaging/templates/macros.twig b/plugins/MobileMessaging/templates/macros.twig index a21f2f3be3..24f4dee65c 100644 --- a/plugins/MobileMessaging/templates/macros.twig +++ b/plugins/MobileMessaging/templates/macros.twig @@ -11,29 +11,10 @@ {% endmacro %} {% macro selectPhoneNumbers(phoneNumbers, angularContext, value, withIntroduction) %} - <div id="mobilePhoneNumbersHelp" class="inline-help-node"> - <span class="icon-info"></span> - - {% if phoneNumbers|length == 0 %} - {{ 'MobileMessaging_MobileReport_NoPhoneNumbers'|translate }} - {% else %} - {{ 'MobileMessaging_MobileReport_AdditionalPhoneNumbers'|translate|e('html_attr') }} - {% endif %} - <a href="{{ linkTo({'module':"MobileMessaging", 'action': 'index', 'updated':null}) }}">{{ 'MobileMessaging_MobileReport_MobileMessagingSettingsLink'|translate }}</a> - </div> - - <div class='mobile' - piwik-field uicontrol="checkbox" - var-type="array" - name="phoneNumbers" - ng-model="{{ angularContext }}.report.phoneNumbers" - {% if withIntroduction %} - introduction="{{ 'ScheduledReports_SendReportTo'|translate|e('html_attr') }}" - {% endif %} - data-title="{{ 'MobileMessaging_PhoneNumbers'|translate|e('html_attr') }}" - {% if phoneNumbers|length == 0 %}disabled="true"{% endif %} - options="{{ phoneNumbers|json_encode }}" - inline-help="#mobilePhoneNumbersHelp" - {% if value %}value="{{ value|json_encode }}"{% endif %}> - </div> + <div matomo-select-phone-numbers + phone-numbers="{{ phoneNumbers|json_encode|e('html_attr') }}" + ng-model="{{ angularContext }}.report.phoneNumbers" + with-introduction="{{ withIntroduction|json_encode|e('html_attr') }}" + {% if value %}value="{{ value|json_encode|e('html_attr') }}"{% endif %} + ></div> {% endmacro %}
\ No newline at end of file diff --git a/plugins/MobileMessaging/templates/reportParametersScheduledReports.twig b/plugins/MobileMessaging/templates/reportParametersScheduledReports.twig index 5ca96fa9fb..21c75099ed 100644 --- a/plugins/MobileMessaging/templates/reportParametersScheduledReports.twig +++ b/plugins/MobileMessaging/templates/reportParametersScheduledReports.twig @@ -1,30 +1,4 @@ -{% import '@MobileMessaging/macros.twig' as macro %} - -<div ng-show="manageScheduledReport.report.type == 'mobile'"> - {{ macro.selectPhoneNumbers(phoneNumbers, 'manageScheduledReport', '', true) }} -</div> - -<script> -$(function () { - resetReportParametersFunctions['mobile'] = function (report) { - report.phoneNumbers = []; - report.formatmobile = 'sms'; - }; - - updateReportParametersFunctions['mobile'] = function (report) { - if (report.parameters && report.parameters.phoneNumbers) { - report.phoneNumbers = report.parameters.phoneNumbers; - } - report.formatmobile = 'sms'; - }; - - getReportParametersFunctions['mobile'] = function (report) { - var parameters = {}; - - // returning [''] when no phone numbers are selected avoids the "please provide a value for 'parameters'" error message - parameters.phoneNumbers = report.phoneNumbers && report.phoneNumbers.length > 0 ? report.phoneNumbers : ['']; - - return parameters; - }; -}); -</script>
\ No newline at end of file +<div + vue-entry="MobileMessaging.ReportParameters" + phone-numbers="{{ phoneNumbers|default([])|json_encode|e('html_attr') }}" +></div> diff --git a/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.js b/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.js index ce80a64e2d..412aa834c5 100644 --- a/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.js +++ b/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.js @@ -125,10 +125,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_a5a2__; __webpack_require__.r(__webpack_exports__); // EXPORTS +__webpack_require__.d(__webpack_exports__, "ReportParameters", function() { return /* reexport */ ReportParameters; }); __webpack_require__.d(__webpack_exports__, "ManageSmsProvider", function() { return /* reexport */ ManageSmsProvider; }); __webpack_require__.d(__webpack_exports__, "SmsProviderCredentials", function() { return /* reexport */ SmsProviderCredentials; }); __webpack_require__.d(__webpack_exports__, "DelegateMobileMessagingSettings", function() { return /* reexport */ DelegateMobileMessagingSettings; }); __webpack_require__.d(__webpack_exports__, "ManageMobilePhoneNumbers", function() { return /* reexport */ ManageMobilePhoneNumbers; }); +__webpack_require__.d(__webpack_exports__, "SelectPhoneNumbers", function() { return /* reexport */ SelectPhoneNumbers; }); // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js // This file is imported into lib/wc client bundles. @@ -152,7 +154,7 @@ var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); // EXTERNAL MODULE: external "CoreHome" var external_CoreHome_ = __webpack_require__("19dc"); -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue?vue&type=template&id=71256e6a +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue?vue&type=template&id=e5a63bc6 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -177,7 +179,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) { }, null, 8, ["uicontrol", "name", "model-value", "onUpdate:modelValue", "title"]); }), 128))])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true); } -// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue?vue&type=template&id=71256e6a +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue?vue&type=template&id=e5a63bc6 // EXTERNAL MODULE: external "CorePluginsAdmin" var external_CorePluginsAdmin_ = __webpack_require__("a5a2"); @@ -193,10 +195,7 @@ var allFieldsByProvider = Object(external_commonjs_vue_commonjs2_vue_root_Vue_[" type: String, required: true }, - modelValue: { - type: Object, - required: true - } + modelValue: Object }, emits: ['update:modelValue'], components: { @@ -205,7 +204,7 @@ var allFieldsByProvider = Object(external_commonjs_vue_commonjs2_vue_root_Vue_[" watch: { provider: function provider() { // unset credentials when new provider is chosen - this.$emit('update:modelValue', {}); // fetch fields for provider + this.$emit('update:modelValue', null); // fetch fields for provider this.getCredentialFields(); } @@ -218,6 +217,9 @@ var allFieldsByProvider = Object(external_commonjs_vue_commonjs2_vue_root_Vue_[" var _this = this; if (allFieldsByProvider[this.provider]) { + this.$emit('update:modelValue', Object.fromEntries(allFieldsByProvider[this.provider].map(function (f) { + return [f.name, null]; + }))); return; } @@ -226,6 +228,10 @@ var allFieldsByProvider = Object(external_commonjs_vue_commonjs2_vue_root_Vue_[" action: 'getCredentialFields', provider: this.provider }).then(function (fields) { + _this.$emit('update:modelValue', Object.fromEntries(fields.map(function (f) { + return [f.name, null]; + }))); + allFieldsByProvider[_this.provider] = fields; }); } @@ -313,27 +319,262 @@ SmsProviderCredentialsvue_type_script_lang_ts.render = render } } })); -// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue?vue&type=template&id=d55b293c +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue?vue&type=template&id=12d83df9 + +var SelectPhoneNumbersvue_type_template_id_12d83df9_hoisted_1 = { + class: "mobile" +}; +var _hoisted_2 = { + id: "mobilePhoneNumbersHelp", + class: "inline-help-node" +}; + +var _hoisted_3 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-info", + style: { + "margin-right": "3.5px" + } +}, null, -1); + +var _hoisted_4 = { + key: 0, + style: { + "margin-right": "3.5px" + } +}; +var _hoisted_5 = { + key: 1, + style: { + "margin-right": "3.5px" + } +}; +var _hoisted_6 = ["href"]; +function SelectPhoneNumbersvue_type_template_id_12d83df9_render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field"); + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", SelectPhoneNumbersvue_type_template_id_12d83df9_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "checkbox", + "var-type": "array", + name: "phoneNumbers", + "model-value": _ctx.modelValue, + "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { + return _ctx.$emit('update:modelValue', $event); + }), + introduction: _ctx.withIntroduction ? _ctx.translate('ScheduledReports_SendReportTo') : undefined, + title: _ctx.translate('MobileMessaging_PhoneNumbers'), + disabled: _ctx.phoneNumbers.length === 0, + options: _ctx.phoneNumbers + }, { + "inline-help": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_2, [_hoisted_3, _ctx.phoneNumbers.length === 0 ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_MobileReport_NoPhoneNumbers')), 1)) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_5, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_MobileReport_AdditionalPhoneNumbers')), 1)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + href: _ctx.linkTo({ + module: 'MobileMessaging', + action: 'index', + updated: null + }) + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_MobileReport_MobileMessagingSettingsLink')), 9, _hoisted_6)])]; + }), + _: 1 + }, 8, ["model-value", "introduction", "title", "disabled", "options"])]); +} +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue?vue&type=template&id=12d83df9 + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue?vue&type=script&lang=ts -var ManageSmsProvidervue_type_template_id_d55b293c_hoisted_1 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + + +/* harmony default export */ var SelectPhoneNumbersvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + modelValue: Array, + phoneNumbers: { + type: [Array, Object], + required: true + }, + withIntroduction: Boolean + }, + emits: ['update:modelValue'], + components: { + Field: external_CorePluginsAdmin_["Field"] + }, + methods: { + linkTo: function linkTo(params) { + return "?".concat(external_CoreHome_["MatomoUrl"].stringify(Object.assign(Object.assign({}, external_CoreHome_["MatomoUrl"].urlParsed.value), params))); + } + } +})); +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue + + + +SelectPhoneNumbersvue_type_script_lang_ts.render = SelectPhoneNumbersvue_type_template_id_12d83df9_render + +/* harmony default export */ var SelectPhoneNumbers = (SelectPhoneNumbersvue_type_script_lang_ts); +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.adapter.ts +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + + + +/* harmony default export */ var SelectPhoneNumbers_adapter = (Object(external_CoreHome_["createAngularJsAdapter"])({ + component: SelectPhoneNumbers, + require: '?ngModel', + scope: { + phoneNumbers: { + angularJsBind: '<' + }, + withIntroduction: { + angularJsBind: '<' + }, + value: { + angularJsBind: '<', + vue: 'modelValue' + } + }, + $inject: ['$timeout'], + directiveName: 'matomoSelectPhoneNumbers', + events: { + 'update:modelValue': function updateModelValue(newValue, vm, scope, element, attrs, ngModel, $timeout) { + if (!ngModel) { + return; + } + + if (newValue !== ngModel.$viewValue) { + $timeout(function () { + ngModel.$setViewValue(newValue); + ngModel.$render(); // not detected by the watch for some reason + }); + } + } + }, + postCreate: function postCreate(vm, scope, element, attrs, controller) { + var ngModel = controller; // ngModel being used + + ngModel.$render = function () { + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(function () { + vm.modelValue = Object(external_CoreHome_["removeAngularJsSpecificProperties"])(ngModel.$viewValue); + }); + }; + + if (typeof scope.value !== 'undefined') { + ngModel.$setViewValue(scope.value); + } else { + ngModel.$setViewValue(vm.modelValue); + } + } +})); +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue?vue&type=template&id=5f520e2e + +var ReportParametersvue_type_template_id_5f520e2e_hoisted_1 = { + key: 0 +}; +function ReportParametersvue_type_template_id_5f520e2e_render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_SelectPhoneNumbers = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SelectPhoneNumbers"); + + return _ctx.report && _ctx.report.type === 'mobile' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", ReportParametersvue_type_template_id_5f520e2e_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SelectPhoneNumbers, { + "phone-numbers": _ctx.phoneNumbers, + "with-introduction": true, + "model-value": _ctx.report.phoneNumbers, + "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { + return _ctx.$emit('change', 'phoneNumbers', $event); + }) + }, null, 8, ["phone-numbers", "model-value"])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true); +} +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue?vue&type=template&id=5f520e2e + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue?vue&type=script&lang=ts + + +var REPORT_TYPE = 'mobile'; +/* harmony default export */ var ReportParametersvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + report: { + type: Object, + required: true + }, + phoneNumbers: { + type: [Array, Object], + required: true + } + }, + components: { + SelectPhoneNumbers: SelectPhoneNumbers + }, + emits: ['change'], + created: function created() { + var _window = window, + resetReportParametersFunctions = _window.resetReportParametersFunctions, + updateReportParametersFunctions = _window.updateReportParametersFunctions, + getReportParametersFunctions = _window.getReportParametersFunctions; + + if (!resetReportParametersFunctions[REPORT_TYPE]) { + resetReportParametersFunctions[REPORT_TYPE] = function (report) { + report.phoneNumbers = []; + report.formatmobile = 'sms'; + }; + } + + if (!updateReportParametersFunctions[REPORT_TYPE]) { + updateReportParametersFunctions[REPORT_TYPE] = function (report) { + if (!(report !== null && report !== void 0 && report.parameters)) { + return; + } + + if (report.parameters && report.parameters.phoneNumbers) { + report.phoneNumbers = report.parameters.phoneNumbers; + } + + report.formatmobile = 'sms'; + }; + } + + if (!getReportParametersFunctions[REPORT_TYPE]) { + getReportParametersFunctions[REPORT_TYPE] = function (report) { + // returning [''] when no phone numbers are selected avoids the "please provide a value + // for 'parameters'" error message + var phoneNumbers = report.phoneNumbers; + return { + phoneNumbers: phoneNumbers || [''] + }; + }; + } + } +})); +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue + + + +ReportParametersvue_type_script_lang_ts.render = ReportParametersvue_type_template_id_5f520e2e_render + +/* harmony default export */ var ReportParameters = (ReportParametersvue_type_script_lang_ts); +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue?vue&type=template&id=6fdded90 + + +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_1 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { id: "ajaxErrorManageSmsProviderSettings" }, null, -1); -var _hoisted_2 = { +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_2 = { key: 0 }; -var _hoisted_3 = { +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_3 = { key: 0 }; -var _hoisted_4 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_4 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); -var _hoisted_5 = { +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_5 = { key: 1 }; -var _hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); +var ManageSmsProvidervue_type_template_id_6fdded90_hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); var _hoisted_7 = ["innerHTML"]; var _hoisted_8 = { @@ -343,7 +584,7 @@ var _hoisted_9 = { id: "accountForm" }; var _hoisted_10 = ["innerHTML"]; -function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $props, $setup, $data, $options) { +function ManageSmsProvidervue_type_template_id_6fdded90_render(_ctx, _cache, $props, $setup, $data, $options) { var _component_ActivityIndicator = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ActivityIndicator"); var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field"); @@ -356,7 +597,7 @@ function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $pr return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ActivityIndicator, { loading: _ctx.isDeletingAccount - }, null, 8, ["loading"]), ManageSmsProvidervue_type_template_id_d55b293c_hoisted_1, _ctx.credentialSupplied ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("p", _hoisted_2, [_ctx.credentialError ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_3, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_Settings_CredentialInvalid', _ctx.provider)), 1), _hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.credentialError), 1)])) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", _hoisted_5, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_Settings_CredentialProvided', _ctx.provider)) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.creditLeft), 1)), _hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + }, null, 8, ["loading"]), ManageSmsProvidervue_type_template_id_6fdded90_hoisted_1, _ctx.credentialSupplied ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("p", ManageSmsProvidervue_type_template_id_6fdded90_hoisted_2, [_ctx.credentialError ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ManageSmsProvidervue_type_template_id_6fdded90_hoisted_3, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_Settings_CredentialInvalid', _ctx.provider)), 1), ManageSmsProvidervue_type_template_id_6fdded90_hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.credentialError), 1)])) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ManageSmsProvidervue_type_template_id_6fdded90_hoisted_5, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('MobileMessaging_Settings_CredentialProvided', _ctx.provider)) + " " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.creditLeft), 1)), ManageSmsProvidervue_type_template_id_6fdded90_hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { innerHTML: _ctx.$sanitize(_ctx.updateOrDeleteAccountText), onClick: _cache[0] || (_cache[0] = function ($event) { return _ctx.onUpdateOrDeleteClick($event); @@ -392,7 +633,7 @@ function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $pr innerHTML: _ctx.$sanitize(_ctx.currentProviderDescription) }, null, 8, _hoisted_10)], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.credentialSupplied || _ctx.showAccountForm], [_directive_form]])]); } -// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue?vue&type=template&id=d55b293c +// CONCATENATED MODULE: ./plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue?vue&type=template&id=6fdded90 // CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue?vue&type=script&lang=ts @@ -428,7 +669,7 @@ function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $pr isDeletingAccount: false, isUpdatingAccount: false, showAccountForm: false, - credentials: {}, + credentials: null, smsProvider: this.provider }; }, @@ -501,7 +742,7 @@ function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $pr computed: { isUpdateAccountPossible: function isUpdateAccountPossible() { // possible if smsProvider is set and all credential field values are set to something - return !!this.smsProvider && Object.keys(this.credentials).length > 0 && Object.values(this.credentials).every(function (v) { + return !!this.smsProvider && this.credentials !== null && Object.values(this.credentials).every(function (v) { return !!v; }); }, @@ -523,7 +764,7 @@ function ManageSmsProvidervue_type_template_id_d55b293c_render(_ctx, _cache, $pr -ManageSmsProvidervue_type_script_lang_ts.render = ManageSmsProvidervue_type_template_id_d55b293c_render +ManageSmsProvidervue_type_script_lang_ts.render = ManageSmsProvidervue_type_template_id_6fdded90_render /* harmony default export */ var ManageSmsProvider = (ManageSmsProvidervue_type_script_lang_ts); // CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/MobileMessaging/vue/src/DelegateMobileMessagingSettings/DelegateMobileMessagingSettings.vue?vue&type=template&id=8e4eafcc @@ -930,6 +1171,9 @@ ManageMobilePhoneNumbersvue_type_script_lang_ts.render = ManageMobilePhoneNumber + + + // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js diff --git a/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.min.js b/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.min.js index b023258275..f761c45737 100644 --- a/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.min.js +++ b/plugins/MobileMessaging/vue/dist/MobileMessaging.umd.min.js @@ -1,10 +1,16 @@ -(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):"function"===typeof define&&define.amd?define(["CoreHome",,"CorePluginsAdmin"],t):"object"===typeof exports?exports["MobileMessaging"]=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):e["MobileMessaging"]=t(e["CoreHome"],e["Vue"],e["CorePluginsAdmin"])})("undefined"!==typeof self?self:this,(function(e,t,n){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="plugins/MobileMessaging/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"8bbf":function(e,n){e.exports=t},a5a2:function(e,t){e.exports=n},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"ManageSmsProvider",(function(){return y})),n.d(t,"SmsProviderCredentials",(function(){return b})),n.d(t,"DelegateMobileMessagingSettings",(function(){return E})),n.d(t,"ManageMobilePhoneNumbers",(function(){return ee})),"undefined"!==typeof window){var o=window.document.currentScript,i=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);i&&(n.p=i[1])}var r=n("8bbf"),l=n("19dc");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c={key:0};function s(e,t,n,o,i,l){var s=Object(r["resolveComponent"])("Field");return e.fields?(Object(r["openBlock"])(),Object(r["createElementBlock"])("div",c,[(Object(r["openBlock"])(!0),Object(r["createElementBlock"])(r["Fragment"],null,Object(r["renderList"])(e.fields,(function(t){var n;return Object(r["openBlock"])(),Object(r["createBlock"])(s,{key:t.name,uicontrol:t.type,name:t.name,"model-value":null===(n=e.modelValue)||void 0===n?void 0:n[t.name],"onUpdate:modelValue":function(n){return e.$emit("update:modelValue",Object.assign(Object.assign({},e.modelValue),{},a({},t.name,n)))},title:e.translate(t.title)},null,8,["uicontrol","name","model-value","onUpdate:modelValue","title"])})),128))])):Object(r["createCommentVNode"])("",!0)}var d=n("a5a2"),u=Object(r["reactive"])({}),m=Object(r["defineComponent"])({props:{provider:{type:String,required:!0},modelValue:{type:Object,required:!0}},emits:["update:modelValue"],components:{Field:d["Field"]},watch:{provider:function(){this.$emit("update:modelValue",{}),this.getCredentialFields()}},created:function(){this.getCredentialFields()},methods:{getCredentialFields:function(){var e=this;u[this.provider]||l["AjaxHelper"].fetch({module:"MobileMessaging",action:"getCredentialFields",provider:this.provider}).then((function(t){u[e.provider]=t}))}},computed:{fields:function(){return u[this.provider]}}});m.render=s;var b=m,p=(Object(l["createAngularJsAdapter"])({component:b,scope:{provider:{angularJsBind:"="},credentials:{angularJsBind:"=value"}},directiveName:"smsProviderCredentials",transclude:!0,events:{"update:modelValue":function(e,t,n,o,i,r,l){var a=r?r.$viewValue:n.value;e!==a&&l((function(){r?(r.$setViewValue(e),r.$render()):n.value=e}))}},postCreate:function(e,t,n,o,i){var a=i;a?(a.$render=function(){Object(r["nextTick"])((function(){e.modelValue=Object(l["removeAngularJsSpecificProperties"])(a.$viewValue)}))},"undefined"!==typeof t.value?a.$setViewValue(t.value):a.$setViewValue(e.modelValue)):t.$watch("value",(function(t){t!==e.modelValue&&Object(r["nextTick"])((function(){e.modelValue=t}))}))}}),Object(r["createElementVNode"])("div",{id:"ajaxErrorManageSmsProviderSettings"},null,-1)),g={key:0},v={key:0},f=Object(r["createElementVNode"])("br",null,null,-1),h={key:1},j=Object(r["createElementVNode"])("br",null,null,-1),O=["innerHTML"],N={key:1},C={id:"accountForm"},M=["innerHTML"]; +(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):"function"===typeof define&&define.amd?define(["CoreHome",,"CorePluginsAdmin"],t):"object"===typeof exports?exports["MobileMessaging"]=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):e["MobileMessaging"]=t(e["CoreHome"],e["Vue"],e["CorePluginsAdmin"])})("undefined"!==typeof self?self:this,(function(e,t,n){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="plugins/MobileMessaging/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"8bbf":function(e,n){e.exports=t},a5a2:function(e,t){e.exports=n},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"ReportParameters",(function(){return P})),n.d(t,"ManageSmsProvider",(function(){return T})),n.d(t,"SmsProviderCredentials",(function(){return b})),n.d(t,"DelegateMobileMessagingSettings",(function(){return L})),n.d(t,"ManageMobilePhoneNumbers",(function(){return pe})),n.d(t,"SelectPhoneNumbers",(function(){return V})),"undefined"!==typeof window){var o=window.document.currentScript,r=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);r&&(n.p=r[1])}var i=n("8bbf"),l=n("19dc");function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c={key:0};function s(e,t,n,o,r,l){var s=Object(i["resolveComponent"])("Field");return e.fields?(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",c,[(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.fields,(function(t){var n;return Object(i["openBlock"])(),Object(i["createBlock"])(s,{key:t.name,uicontrol:t.type,name:t.name,"model-value":null===(n=e.modelValue)||void 0===n?void 0:n[t.name],"onUpdate:modelValue":function(n){return e.$emit("update:modelValue",Object.assign(Object.assign({},e.modelValue),{},a({},t.name,n)))},title:e.translate(t.title)},null,8,["uicontrol","name","model-value","onUpdate:modelValue","title"])})),128))])):Object(i["createCommentVNode"])("",!0)}var d=n("a5a2"),u=Object(i["reactive"])({}),m=Object(i["defineComponent"])({props:{provider:{type:String,required:!0},modelValue:Object},emits:["update:modelValue"],components:{Field:d["Field"]},watch:{provider:function(){this.$emit("update:modelValue",null),this.getCredentialFields()}},created:function(){this.getCredentialFields()},methods:{getCredentialFields:function(){var e=this;u[this.provider]?this.$emit("update:modelValue",Object.fromEntries(u[this.provider].map((function(e){return[e.name,null]})))):l["AjaxHelper"].fetch({module:"MobileMessaging",action:"getCredentialFields",provider:this.provider}).then((function(t){e.$emit("update:modelValue",Object.fromEntries(t.map((function(e){return[e.name,null]})))),u[e.provider]=t}))}},computed:{fields:function(){return u[this.provider]}}});m.render=s;var b=m,p=(Object(l["createAngularJsAdapter"])({component:b,scope:{provider:{angularJsBind:"="},credentials:{angularJsBind:"=value"}},directiveName:"smsProviderCredentials",transclude:!0,events:{"update:modelValue":function(e,t,n,o,r,i,l){var a=i?i.$viewValue:n.value;e!==a&&l((function(){i?(i.$setViewValue(e),i.$render()):n.value=e}))}},postCreate:function(e,t,n,o,r){var a=r;a?(a.$render=function(){Object(i["nextTick"])((function(){e.modelValue=Object(l["removeAngularJsSpecificProperties"])(a.$viewValue)}))},"undefined"!==typeof t.value?a.$setViewValue(t.value):a.$setViewValue(e.modelValue)):t.$watch("value",(function(t){t!==e.modelValue&&Object(i["nextTick"])((function(){e.modelValue=t}))}))}}),{class:"mobile"}),g={id:"mobilePhoneNumbersHelp",class:"inline-help-node"},v=Object(i["createElementVNode"])("span",{class:"icon-info",style:{"margin-right":"3.5px"}},null,-1),h={key:0,style:{"margin-right":"3.5px"}},f={key:1,style:{"margin-right":"3.5px"}},j=["href"]; /*! * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */function V(e,t,n,o,i,l){var a=Object(r["resolveComponent"])("ActivityIndicator"),c=Object(r["resolveComponent"])("Field"),s=Object(r["resolveComponent"])("SmsProviderCredentials"),d=Object(r["resolveComponent"])("SaveButton"),u=Object(r["resolveDirective"])("form");return Object(r["openBlock"])(),Object(r["createElementBlock"])("div",null,[Object(r["createVNode"])(a,{loading:e.isDeletingAccount},null,8,["loading"]),p,e.credentialSupplied?(Object(r["openBlock"])(),Object(r["createElementBlock"])("p",g,[e.credentialError?(Object(r["openBlock"])(),Object(r["createElementBlock"])("span",v,[Object(r["createTextVNode"])(Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_CredentialInvalid",e.provider)),1),f,Object(r["createTextVNode"])(" "+Object(r["toDisplayString"])(e.credentialError),1)])):(Object(r["openBlock"])(),Object(r["createElementBlock"])("span",h,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_CredentialProvided",e.provider))+" "+Object(r["toDisplayString"])(e.creditLeft),1)),j,Object(r["createElementVNode"])("span",{innerHTML:e.$sanitize(e.updateOrDeleteAccountText),onClick:t[0]||(t[0]=function(t){return e.onUpdateOrDeleteClick(t)})},null,8,O)])):(Object(r["openBlock"])(),Object(r["createElementBlock"])("p",N,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_PleaseSignUp")),1)),Object(r["withDirectives"])(Object(r["createElementVNode"])("div",C,[Object(r["createElementVNode"])("div",null,[Object(r["createVNode"])(c,{uicontrol:"select",name:"smsProviders",modelValue:e.smsProvider,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.smsProvider=t}),title:e.translate("MobileMessaging_Settings_SMSProvider"),options:e.smsProviderOptions,value:e.provider},null,8,["modelValue","title","options","value"])]),Object(r["createVNode"])(s,{provider:e.smsProvider,modelValue:e.credentials,"onUpdate:modelValue":[t[2]||(t[2]=function(t){return e.credentials=t}),t[3]||(t[3]=function(t){e.credentials=t})],"model-value":e.credentials},null,8,["provider","modelValue","model-value"]),Object(r["createVNode"])(d,{id:"apiAccountSubmit",disabled:!e.isUpdateAccountPossible,saving:e.isUpdatingAccount,onConfirm:t[4]||(t[4]=function(t){return e.updateAccount()})},null,8,["disabled","saving"]),Object(r["createElementVNode"])("div",{class:"providerDescription",innerHTML:e.$sanitize(e.currentProviderDescription)},null,8,M)],512),[[r["vShow"],!e.credentialSupplied||e.showAccountForm],[u]])])}var S=Object(r["defineComponent"])({props:{credentialSupplied:Boolean,credentialError:String,provider:String,creditLeft:[Number,String],smsProviderOptions:{type:Object,required:!0},smsProviders:{type:Object,required:!0}},components:{ActivityIndicator:l["ActivityIndicator"],Field:d["Field"],SaveButton:d["SaveButton"],SmsProviderCredentials:b},directives:{Form:d["Form"]},data:function(){return{isDeletingAccount:!1,isUpdatingAccount:!1,showAccountForm:!1,credentials:{},smsProvider:this.provider}},methods:{deleteApiAccount:function(){var e=this;this.isDeletingAccount=!0,l["AjaxHelper"].fetch({method:"MobileMessaging.deleteSMSAPICredential"},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){l["Matomo"].helper.redirect()})).finally((function(){e.isDeletingAccount=!1}))},showUpdateAccount:function(){this.showAccountForm=!0},updateAccount:function(){var e=this;this.isUpdateAccountPossible&&(this.isUpdatingAccount=!0,l["AjaxHelper"].post({method:"MobileMessaging.setSMSAPICredential"},{provider:this.smsProvider,credentials:this.credentials},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){l["Matomo"].helper.redirect()})).finally((function(){e.isUpdatingAccount=!1})))},deleteAccount:function(){var e=this;l["Matomo"].helper.modalConfirm("#confirmDeleteAccount",{yes:function(){e.isDeletingAccount=!0,l["AjaxHelper"].fetch({method:"MobileMessaging.deleteSMSAPICredential"},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){e.isDeletingAccount=!1,l["Matomo"].helper.redirect()})).finally((function(){e.isDeletingAccount=!1}))}})},onUpdateOrDeleteClick:function(e){var t=e.target;"displayAccountForm"===t.id?this.showUpdateAccount():"deleteAccount"===t.id&&this.deleteAccount()}},computed:{isUpdateAccountPossible:function(){return!!this.smsProvider&&Object.keys(this.credentials).length>0&&Object.values(this.credentials).every((function(e){return!!e}))},updateOrDeleteAccountText:function(){return Object(l["translate"])("MobileMessaging_Settings_UpdateOrDeleteAccount",'<a id="displayAccountForm">',"</a>",'<a id="deleteAccount">',"</a>")},currentProviderDescription:function(){return this.smsProvider&&this.smsProviders?this.smsProviders[this.smsProvider]:""}}});S.render=V;var y=S;function P(e,t,n,o,i,l){var a=Object(r["resolveComponent"])("Field"),c=Object(r["resolveComponent"])("SaveButton");return Object(r["openBlock"])(),Object(r["createElementBlock"])("div",null,[Object(r["createElementVNode"])("div",null,[Object(r["createVNode"])(a,{uicontrol:"radio",name:"delegatedManagement",title:e.translate("MobileMessaging_Settings_LetUsersManageAPICredential"),modelValue:e.enabled,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.enabled=t}),"full-width":!0,options:e.delegateManagementOptions},null,8,["title","modelValue","options"])]),Object(r["createVNode"])(c,{onConfirm:t[1]||(t[1]=function(t){return e.save()}),saving:e.isLoading},null,8,["saving"])])}var A=Object(r["defineComponent"])({props:{delegateManagementOptions:{type:Array,required:!0},delegatedManagement:[Number,Boolean]},components:{Field:d["Field"],SaveButton:d["SaveButton"]},data:function(){return{isLoading:!1,enabled:this.delegatedManagement?1:0}},methods:{save:function(){var e=this;this.isLoading=!0,l["AjaxHelper"].post({method:"MobileMessaging.setDelegatedManagement"},{delegatedManagement:this.enabled&&"0"!==this.enabled?"true":"false"}).then((function(){var e=l["NotificationsStore"].show({message:Object(l["translate"])("CoreAdminHome_SettingsSaveSuccess"),id:"mobileMessagingSettings",type:"transient",context:"success"});l["NotificationsStore"].scrollToNotification(e),l["Matomo"].helper.redirect()})).finally((function(){e.isLoading=!1}))}}});A.render=P;var E=A,_={key:0},k={class:"row"},x={class:"col s12"},B={class:"form-group row"},w={class:"col s12 m6"},D={class:"col s12 m6 form-help"},U={class:"form-group row addPhoneNumber"},F={class:"col s12 m6"},H={class:"countryCode left"},T=Object(r["createElementVNode"])("span",{class:"countryCodeSymbol"},"+",-1),q={class:"phoneNumber left"},I={class:"addNumber left valign-wrapper"},L={class:"col s12 m6 form-help"},$=Object(r["createElementVNode"])("div",{id:"ajaxErrorAddPhoneNumber"},null,-1),J={key:1,class:"row"},z={class:"col s12"},G={class:"col s12 m6"},R={class:"phoneNumber"},Y=["onUpdate:modelValue","placeholder"],K={key:0,class:"form-help col s12 m6"},Q=Object(r["createTextVNode"])(" Â "),W=Object(r["createElementVNode"])("div",{id:"invalidVerificationCodeAjaxError",style:{display:"none"}},null,-1);function X(e,t,n,o,i,l){var a=Object(r["resolveComponent"])("Field"),c=Object(r["resolveComponent"])("SaveButton"),s=Object(r["resolveComponent"])("Alert"),d=Object(r["resolveComponent"])("ActivityIndicator");return Object(r["openBlock"])(),Object(r["createElementBlock"])("div",null,[Object(r["createElementVNode"])("p",null,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_Help")),1),e.isSuperUser?(Object(r["openBlock"])(),Object(r["createElementBlock"])("p",_,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_DelegatedPhoneNumbersOnlyUsedByYou")),1)):Object(r["createCommentVNode"])("",!0),Object(r["createElementVNode"])("div",k,[Object(r["createElementVNode"])("h3",x,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_Add")),1)]),Object(r["createElementVNode"])("div",B,[Object(r["createElementVNode"])("div",w,[Object(r["createElementVNode"])("div",null,[Object(r["createVNode"])(a,{uicontrol:"select",name:"countryCodeSelect",title:e.translate("MobileMessaging_Settings_SelectCountry"),modelValue:e.countryCallingCode,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.countryCallingCode=t}),"full-width":!0,options:e.countries},null,8,["title","modelValue","options"])])]),Object(r["createElementVNode"])("div",D,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_CountryCode_Help")),1)]),Object(r["createElementVNode"])("div",U,[Object(r["createElementVNode"])("div",F,[Object(r["createElementVNode"])("div",H,[T,Object(r["createElementVNode"])("div",null,[Object(r["createVNode"])(a,{uicontrol:"text",name:"countryCallingCode",title:e.translate("MobileMessaging_Settings_CountryCode"),modelValue:e.countryCallingCode,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.countryCallingCode=t}),"full-width":!0,maxlength:4},null,8,["title","modelValue"])])]),Object(r["createElementVNode"])("div",q,[Object(r["createElementVNode"])("div",null,[Object(r["createVNode"])(a,{uicontrol:"text",name:"newPhoneNumber",modelValue:e.newPhoneNumber,"onUpdate:modelValue":t[2]||(t[2]=function(t){return e.newPhoneNumber=t}),title:e.translate("MobileMessaging_Settings_PhoneNumber"),"full-width":!0,maxlength:80},null,8,["modelValue","title"])])]),Object(r["createElementVNode"])("div",I,[Object(r["createVNode"])(c,{class:"valign",disabled:!e.canAddNumber||e.isAddingPhonenumber,onConfirm:t[3]||(t[3]=function(t){return e.addPhoneNumber()}),value:e.translate("General_Add")},null,8,["disabled","value"])]),Object(r["withDirectives"])(Object(r["createVNode"])(s,{severity:"warning",id:"suspiciousPhoneNumber"},{default:Object(r["withCtx"])((function(){return[Object(r["createTextVNode"])(Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_SuspiciousPhoneNumber","54184032")),1)]})),_:1},512),[[r["vShow"],e.showSuspiciousPhoneNumber]])]),Object(r["createElementVNode"])("div",L,Object(r["toDisplayString"])(e.strHelpAddPhone),1)]),$,Object(r["createVNode"])(d,{loading:e.isAddingPhonenumber},null,8,["loading"]),Object.keys(e.phoneNumbers||{}).length>0?(Object(r["openBlock"])(),Object(r["createElementBlock"])("div",J,[Object(r["createElementVNode"])("h3",z,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_ManagePhoneNumbers")),1)])):Object(r["createCommentVNode"])("",!0),(Object(r["openBlock"])(!0),Object(r["createElementBlock"])(r["Fragment"],null,Object(r["renderList"])(e.phoneNumbers||[],(function(t,n,o){return Object(r["openBlock"])(),Object(r["createElementBlock"])("div",{class:"form-group row",key:o},[Object(r["createElementVNode"])("div",G,[Object(r["createElementVNode"])("span",R,Object(r["toDisplayString"])(n),1),t||e.isActivated[o]?Object(r["createCommentVNode"])("",!0):Object(r["withDirectives"])((Object(r["openBlock"])(),Object(r["createElementBlock"])("input",{key:0,type:"text",class:"verificationCode","onUpdate:modelValue":function(t){return e.validationCode[o]=t},placeholder:e.translate("MobileMessaging_Settings_EnterActivationCode"),style:{"margin-right":"3.5px"}},null,8,Y)),[[r["vModelText"],e.validationCode[o]]]),t||e.isActivated[o]?Object(r["createCommentVNode"])("",!0):(Object(r["openBlock"])(),Object(r["createBlock"])(c,{key:1,disabled:!e.validationCode[o]||e.isChangingPhoneNumber,onConfirm:function(t){return e.validateActivationCode(n,o)},value:e.translate("MobileMessaging_Settings_ValidatePhoneNumber")},null,8,["disabled","onConfirm","value"])),Object(r["createVNode"])(c,{disabled:e.isChangingPhoneNumber,onConfirm:function(t){return e.removePhoneNumber(n)},value:e.translate("General_Remove"),style:{"margin-left":"3.5px"}},null,8,["disabled","onConfirm","value"])]),t||e.isActivated[o]?Object(r["createCommentVNode"])("",!0):(Object(r["openBlock"])(),Object(r["createElementBlock"])("div",K,[Object(r["createElementVNode"])("div",null,Object(r["toDisplayString"])(e.translate("MobileMessaging_Settings_VerificationCodeJustSent")),1),Q]))])})),128)),W,Object(r["createVNode"])(d,{loading:e.isChangingPhoneNumber},null,8,["loading"])])}var Z=Object(r["defineComponent"])({props:{isSuperUser:Boolean,defaultCallingCode:String,countries:{type:Array,required:!0},strHelpAddPhone:{type:String,required:!0},phoneNumbers:Object},components:{Field:d["Field"],SaveButton:d["SaveButton"],Alert:l["Alert"],ActivityIndicator:l["ActivityIndicator"]},data:function(){return{isAddingPhonenumber:!1,isChangingPhoneNumber:!1,isActivated:{},countryCallingCode:this.defaultCallingCode||"",newPhoneNumber:"",validationCode:{}}},methods:{validateActivationCode:function(e,t){var n=this;if(this.validationCode[t]){var o=this.validationCode[t];this.isChangingPhoneNumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.validatePhoneNumber"},{phoneNumber:e,verificationCode:o},{errorElement:"#invalidVerificationCodeAjaxError"}).then((function(e){var o;if(n.isChangingPhoneNumber=!1,e&&e.value){var i=Object(l["translate"])("MobileMessaging_Settings_PhoneActivated");o=l["NotificationsStore"].show({message:i,context:"success",id:"MobileMessaging_ValidatePhoneNumber",type:"transient"}),n.isActivated[t]=!0}else{var r=Object(l["translate"])("MobileMessaging_Settings_InvalidActivationCode");o=l["NotificationsStore"].show({message:r,context:"error",id:"MobileMessaging_ValidatePhoneNumber",type:"transient"})}l["NotificationsStore"].scrollToNotification(o)})).finally((function(){n.isChangingPhoneNumber=!1}))}},removePhoneNumber:function(e){var t=this;e&&(this.isChangingPhoneNumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.removePhoneNumber"},{phoneNumber:e},{errorElement:"#invalidVerificationCodeAjaxError"}).then((function(){t.isChangingPhoneNumber=!1,l["Matomo"].helper.redirect()})).finally((function(){t.isChangingPhoneNumber=!1})))},addPhoneNumber:function(){var e=this,t="+".concat(this.countryCallingCode).concat(this.newPhoneNumber);this.canAddNumber&&t.length>1&&(this.isAddingPhonenumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.addPhoneNumber"},{phoneNumber:t},{errorElement:"#ajaxErrorAddPhoneNumber"}).then((function(){e.isAddingPhonenumber=!1,l["Matomo"].helper.redirect()})).finally((function(){e.isAddingPhonenumber=!1})))}},computed:{showSuspiciousPhoneNumber:function(){return 0===this.newPhoneNumber.trim().lastIndexOf("0",0)},canAddNumber:function(){return!!this.newPhoneNumber&&""!==this.newPhoneNumber}}});Z.render=X;var ee=Z; + */function O(e,t,n,o,r,l){var a=Object(i["resolveComponent"])("Field");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",p,[Object(i["createVNode"])(a,{uicontrol:"checkbox","var-type":"array",name:"phoneNumbers","model-value":e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.$emit("update:modelValue",t)}),introduction:e.withIntroduction?e.translate("ScheduledReports_SendReportTo"):void 0,title:e.translate("MobileMessaging_PhoneNumbers"),disabled:0===e.phoneNumbers.length,options:e.phoneNumbers},{"inline-help":Object(i["withCtx"])((function(){return[Object(i["createElementVNode"])("div",g,[v,0===e.phoneNumbers.length?(Object(i["openBlock"])(),Object(i["createElementBlock"])("span",h,Object(i["toDisplayString"])(e.translate("MobileMessaging_MobileReport_NoPhoneNumbers")),1)):(Object(i["openBlock"])(),Object(i["createElementBlock"])("span",f,Object(i["toDisplayString"])(e.translate("MobileMessaging_MobileReport_AdditionalPhoneNumbers")),1)),Object(i["createElementVNode"])("a",{href:e.linkTo({module:"MobileMessaging",action:"index",updated:null})},Object(i["toDisplayString"])(e.translate("MobileMessaging_MobileReport_MobileMessagingSettingsLink")),9,j)])]})),_:1},8,["model-value","introduction","title","disabled","options"])])}var N=Object(i["defineComponent"])({props:{modelValue:Array,phoneNumbers:{type:[Array,Object],required:!0},withIntroduction:Boolean},emits:["update:modelValue"],components:{Field:d["Field"]},methods:{linkTo:function(e){return"?".concat(l["MatomoUrl"].stringify(Object.assign(Object.assign({},l["MatomoUrl"].urlParsed.value),e)))}}});N.render=O;var V=N,M=(Object(l["createAngularJsAdapter"])({component:V,require:"?ngModel",scope:{phoneNumbers:{angularJsBind:"<"},withIntroduction:{angularJsBind:"<"},value:{angularJsBind:"<",vue:"modelValue"}},$inject:["$timeout"],directiveName:"matomoSelectPhoneNumbers",events:{"update:modelValue":function(e,t,n,o,r,i,l){i&&e!==i.$viewValue&&l((function(){i.$setViewValue(e),i.$render()}))}},postCreate:function(e,t,n,o,r){var a=r;a.$render=function(){Object(i["nextTick"])((function(){e.modelValue=Object(l["removeAngularJsSpecificProperties"])(a.$viewValue)}))},"undefined"!==typeof t.value?a.$setViewValue(t.value):a.$setViewValue(e.modelValue)}}),{key:0}); +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */function y(e,t,n,o,r,l){var a=Object(i["resolveComponent"])("SelectPhoneNumbers");return e.report&&"mobile"===e.report.type?(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",M,[Object(i["createVNode"])(a,{"phone-numbers":e.phoneNumbers,"with-introduction":!0,"model-value":e.report.phoneNumbers,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.$emit("change","phoneNumbers",t)})},null,8,["phone-numbers","model-value"])])):Object(i["createCommentVNode"])("",!0)}var C="mobile",S=Object(i["defineComponent"])({props:{report:{type:Object,required:!0},phoneNumbers:{type:[Array,Object],required:!0}},components:{SelectPhoneNumbers:V},emits:["change"],created:function(){var e=window,t=e.resetReportParametersFunctions,n=e.updateReportParametersFunctions,o=e.getReportParametersFunctions;t[C]||(t[C]=function(e){e.phoneNumbers=[],e.formatmobile="sms"}),n[C]||(n[C]=function(e){null!==e&&void 0!==e&&e.parameters&&(e.parameters&&e.parameters.phoneNumbers&&(e.phoneNumbers=e.parameters.phoneNumbers),e.formatmobile="sms")}),o[C]||(o[C]=function(e){var t=e.phoneNumbers;return{phoneNumbers:t||[""]}})}});S.render=y;var P=S,A=Object(i["createElementVNode"])("div",{id:"ajaxErrorManageSmsProviderSettings"},null,-1),E={key:0},k={key:0},_=Object(i["createElementVNode"])("br",null,null,-1),B={key:1},w=Object(i["createElementVNode"])("br",null,null,-1),x=["innerHTML"],D={key:1},F={id:"accountForm"},U=["innerHTML"];function $(e,t,n,o,r,l){var a=Object(i["resolveComponent"])("ActivityIndicator"),c=Object(i["resolveComponent"])("Field"),s=Object(i["resolveComponent"])("SmsProviderCredentials"),d=Object(i["resolveComponent"])("SaveButton"),u=Object(i["resolveDirective"])("form");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",null,[Object(i["createVNode"])(a,{loading:e.isDeletingAccount},null,8,["loading"]),A,e.credentialSupplied?(Object(i["openBlock"])(),Object(i["createElementBlock"])("p",E,[e.credentialError?(Object(i["openBlock"])(),Object(i["createElementBlock"])("span",k,[Object(i["createTextVNode"])(Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_CredentialInvalid",e.provider)),1),_,Object(i["createTextVNode"])(" "+Object(i["toDisplayString"])(e.credentialError),1)])):(Object(i["openBlock"])(),Object(i["createElementBlock"])("span",B,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_CredentialProvided",e.provider))+" "+Object(i["toDisplayString"])(e.creditLeft),1)),w,Object(i["createElementVNode"])("span",{innerHTML:e.$sanitize(e.updateOrDeleteAccountText),onClick:t[0]||(t[0]=function(t){return e.onUpdateOrDeleteClick(t)})},null,8,x)])):(Object(i["openBlock"])(),Object(i["createElementBlock"])("p",D,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_PleaseSignUp")),1)),Object(i["withDirectives"])(Object(i["createElementVNode"])("div",F,[Object(i["createElementVNode"])("div",null,[Object(i["createVNode"])(c,{uicontrol:"select",name:"smsProviders",modelValue:e.smsProvider,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.smsProvider=t}),title:e.translate("MobileMessaging_Settings_SMSProvider"),options:e.smsProviderOptions,value:e.provider},null,8,["modelValue","title","options","value"])]),Object(i["createVNode"])(s,{provider:e.smsProvider,modelValue:e.credentials,"onUpdate:modelValue":[t[2]||(t[2]=function(t){return e.credentials=t}),t[3]||(t[3]=function(t){e.credentials=t})],"model-value":e.credentials},null,8,["provider","modelValue","model-value"]),Object(i["createVNode"])(d,{id:"apiAccountSubmit",disabled:!e.isUpdateAccountPossible,saving:e.isUpdatingAccount,onConfirm:t[4]||(t[4]=function(t){return e.updateAccount()})},null,8,["disabled","saving"]),Object(i["createElementVNode"])("div",{class:"providerDescription",innerHTML:e.$sanitize(e.currentProviderDescription)},null,8,U)],512),[[i["vShow"],!e.credentialSupplied||e.showAccountForm],[u]])])}var H=Object(i["defineComponent"])({props:{credentialSupplied:Boolean,credentialError:String,provider:String,creditLeft:[Number,String],smsProviderOptions:{type:Object,required:!0},smsProviders:{type:Object,required:!0}},components:{ActivityIndicator:l["ActivityIndicator"],Field:d["Field"],SaveButton:d["SaveButton"],SmsProviderCredentials:b},directives:{Form:d["Form"]},data:function(){return{isDeletingAccount:!1,isUpdatingAccount:!1,showAccountForm:!1,credentials:null,smsProvider:this.provider}},methods:{deleteApiAccount:function(){var e=this;this.isDeletingAccount=!0,l["AjaxHelper"].fetch({method:"MobileMessaging.deleteSMSAPICredential"},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){l["Matomo"].helper.redirect()})).finally((function(){e.isDeletingAccount=!1}))},showUpdateAccount:function(){this.showAccountForm=!0},updateAccount:function(){var e=this;this.isUpdateAccountPossible&&(this.isUpdatingAccount=!0,l["AjaxHelper"].post({method:"MobileMessaging.setSMSAPICredential"},{provider:this.smsProvider,credentials:this.credentials},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){l["Matomo"].helper.redirect()})).finally((function(){e.isUpdatingAccount=!1})))},deleteAccount:function(){var e=this;l["Matomo"].helper.modalConfirm("#confirmDeleteAccount",{yes:function(){e.isDeletingAccount=!0,l["AjaxHelper"].fetch({method:"MobileMessaging.deleteSMSAPICredential"},{errorElement:"#ajaxErrorManageSmsProviderSettings"}).then((function(){e.isDeletingAccount=!1,l["Matomo"].helper.redirect()})).finally((function(){e.isDeletingAccount=!1}))}})},onUpdateOrDeleteClick:function(e){var t=e.target;"displayAccountForm"===t.id?this.showUpdateAccount():"deleteAccount"===t.id&&this.deleteAccount()}},computed:{isUpdateAccountPossible:function(){return!!this.smsProvider&&null!==this.credentials&&Object.values(this.credentials).every((function(e){return!!e}))},updateOrDeleteAccountText:function(){return Object(l["translate"])("MobileMessaging_Settings_UpdateOrDeleteAccount",'<a id="displayAccountForm">',"</a>",'<a id="deleteAccount">',"</a>")},currentProviderDescription:function(){return this.smsProvider&&this.smsProviders?this.smsProviders[this.smsProvider]:""}}});H.render=$;var T=H;function q(e,t,n,o,r,l){var a=Object(i["resolveComponent"])("Field"),c=Object(i["resolveComponent"])("SaveButton");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",null,[Object(i["createElementVNode"])("div",null,[Object(i["createVNode"])(a,{uicontrol:"radio",name:"delegatedManagement",title:e.translate("MobileMessaging_Settings_LetUsersManageAPICredential"),modelValue:e.enabled,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.enabled=t}),"full-width":!0,options:e.delegateManagementOptions},null,8,["title","modelValue","options"])]),Object(i["createVNode"])(c,{onConfirm:t[1]||(t[1]=function(t){return e.save()}),saving:e.isLoading},null,8,["saving"])])}var I=Object(i["defineComponent"])({props:{delegateManagementOptions:{type:Array,required:!0},delegatedManagement:[Number,Boolean]},components:{Field:d["Field"],SaveButton:d["SaveButton"]},data:function(){return{isLoading:!1,enabled:this.delegatedManagement?1:0}},methods:{save:function(){var e=this;this.isLoading=!0,l["AjaxHelper"].post({method:"MobileMessaging.setDelegatedManagement"},{delegatedManagement:this.enabled&&"0"!==this.enabled?"true":"false"}).then((function(){var e=l["NotificationsStore"].show({message:Object(l["translate"])("CoreAdminHome_SettingsSaveSuccess"),id:"mobileMessagingSettings",type:"transient",context:"success"});l["NotificationsStore"].scrollToNotification(e),l["Matomo"].helper.redirect()})).finally((function(){e.isLoading=!1}))}}});I.render=q;var L=I,J={key:0},R={class:"row"},z={class:"col s12"},G={class:"form-group row"},Y={class:"col s12 m6"},K={class:"col s12 m6 form-help"},Q={class:"form-group row addPhoneNumber"},W={class:"col s12 m6"},X={class:"countryCode left"},Z=Object(i["createElementVNode"])("span",{class:"countryCodeSymbol"},"+",-1),ee={class:"phoneNumber left"},te={class:"addNumber left valign-wrapper"},ne={class:"col s12 m6 form-help"},oe=Object(i["createElementVNode"])("div",{id:"ajaxErrorAddPhoneNumber"},null,-1),re={key:1,class:"row"},ie={class:"col s12"},le={class:"col s12 m6"},ae={class:"phoneNumber"},ce=["onUpdate:modelValue","placeholder"],se={key:0,class:"form-help col s12 m6"},de=Object(i["createTextVNode"])(" Â "),ue=Object(i["createElementVNode"])("div",{id:"invalidVerificationCodeAjaxError",style:{display:"none"}},null,-1);function me(e,t,n,o,r,l){var a=Object(i["resolveComponent"])("Field"),c=Object(i["resolveComponent"])("SaveButton"),s=Object(i["resolveComponent"])("Alert"),d=Object(i["resolveComponent"])("ActivityIndicator");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",null,[Object(i["createElementVNode"])("p",null,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_Help")),1),e.isSuperUser?(Object(i["openBlock"])(),Object(i["createElementBlock"])("p",J,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_DelegatedPhoneNumbersOnlyUsedByYou")),1)):Object(i["createCommentVNode"])("",!0),Object(i["createElementVNode"])("div",R,[Object(i["createElementVNode"])("h3",z,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_Add")),1)]),Object(i["createElementVNode"])("div",G,[Object(i["createElementVNode"])("div",Y,[Object(i["createElementVNode"])("div",null,[Object(i["createVNode"])(a,{uicontrol:"select",name:"countryCodeSelect",title:e.translate("MobileMessaging_Settings_SelectCountry"),modelValue:e.countryCallingCode,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.countryCallingCode=t}),"full-width":!0,options:e.countries},null,8,["title","modelValue","options"])])]),Object(i["createElementVNode"])("div",K,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_PhoneNumbers_CountryCode_Help")),1)]),Object(i["createElementVNode"])("div",Q,[Object(i["createElementVNode"])("div",W,[Object(i["createElementVNode"])("div",X,[Z,Object(i["createElementVNode"])("div",null,[Object(i["createVNode"])(a,{uicontrol:"text",name:"countryCallingCode",title:e.translate("MobileMessaging_Settings_CountryCode"),modelValue:e.countryCallingCode,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.countryCallingCode=t}),"full-width":!0,maxlength:4},null,8,["title","modelValue"])])]),Object(i["createElementVNode"])("div",ee,[Object(i["createElementVNode"])("div",null,[Object(i["createVNode"])(a,{uicontrol:"text",name:"newPhoneNumber",modelValue:e.newPhoneNumber,"onUpdate:modelValue":t[2]||(t[2]=function(t){return e.newPhoneNumber=t}),title:e.translate("MobileMessaging_Settings_PhoneNumber"),"full-width":!0,maxlength:80},null,8,["modelValue","title"])])]),Object(i["createElementVNode"])("div",te,[Object(i["createVNode"])(c,{class:"valign",disabled:!e.canAddNumber||e.isAddingPhonenumber,onConfirm:t[3]||(t[3]=function(t){return e.addPhoneNumber()}),value:e.translate("General_Add")},null,8,["disabled","value"])]),Object(i["withDirectives"])(Object(i["createVNode"])(s,{severity:"warning",id:"suspiciousPhoneNumber"},{default:Object(i["withCtx"])((function(){return[Object(i["createTextVNode"])(Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_SuspiciousPhoneNumber","54184032")),1)]})),_:1},512),[[i["vShow"],e.showSuspiciousPhoneNumber]])]),Object(i["createElementVNode"])("div",ne,Object(i["toDisplayString"])(e.strHelpAddPhone),1)]),oe,Object(i["createVNode"])(d,{loading:e.isAddingPhonenumber},null,8,["loading"]),Object.keys(e.phoneNumbers||{}).length>0?(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",re,[Object(i["createElementVNode"])("h3",ie,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_ManagePhoneNumbers")),1)])):Object(i["createCommentVNode"])("",!0),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.phoneNumbers||[],(function(t,n,o){return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",{class:"form-group row",key:o},[Object(i["createElementVNode"])("div",le,[Object(i["createElementVNode"])("span",ae,Object(i["toDisplayString"])(n),1),t||e.isActivated[o]?Object(i["createCommentVNode"])("",!0):Object(i["withDirectives"])((Object(i["openBlock"])(),Object(i["createElementBlock"])("input",{key:0,type:"text",class:"verificationCode","onUpdate:modelValue":function(t){return e.validationCode[o]=t},placeholder:e.translate("MobileMessaging_Settings_EnterActivationCode"),style:{"margin-right":"3.5px"}},null,8,ce)),[[i["vModelText"],e.validationCode[o]]]),t||e.isActivated[o]?Object(i["createCommentVNode"])("",!0):(Object(i["openBlock"])(),Object(i["createBlock"])(c,{key:1,disabled:!e.validationCode[o]||e.isChangingPhoneNumber,onConfirm:function(t){return e.validateActivationCode(n,o)},value:e.translate("MobileMessaging_Settings_ValidatePhoneNumber")},null,8,["disabled","onConfirm","value"])),Object(i["createVNode"])(c,{disabled:e.isChangingPhoneNumber,onConfirm:function(t){return e.removePhoneNumber(n)},value:e.translate("General_Remove"),style:{"margin-left":"3.5px"}},null,8,["disabled","onConfirm","value"])]),t||e.isActivated[o]?Object(i["createCommentVNode"])("",!0):(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",se,[Object(i["createElementVNode"])("div",null,Object(i["toDisplayString"])(e.translate("MobileMessaging_Settings_VerificationCodeJustSent")),1),de]))])})),128)),ue,Object(i["createVNode"])(d,{loading:e.isChangingPhoneNumber},null,8,["loading"])])}var be=Object(i["defineComponent"])({props:{isSuperUser:Boolean,defaultCallingCode:String,countries:{type:Array,required:!0},strHelpAddPhone:{type:String,required:!0},phoneNumbers:Object},components:{Field:d["Field"],SaveButton:d["SaveButton"],Alert:l["Alert"],ActivityIndicator:l["ActivityIndicator"]},data:function(){return{isAddingPhonenumber:!1,isChangingPhoneNumber:!1,isActivated:{},countryCallingCode:this.defaultCallingCode||"",newPhoneNumber:"",validationCode:{}}},methods:{validateActivationCode:function(e,t){var n=this;if(this.validationCode[t]){var o=this.validationCode[t];this.isChangingPhoneNumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.validatePhoneNumber"},{phoneNumber:e,verificationCode:o},{errorElement:"#invalidVerificationCodeAjaxError"}).then((function(e){var o;if(n.isChangingPhoneNumber=!1,e&&e.value){var r=Object(l["translate"])("MobileMessaging_Settings_PhoneActivated");o=l["NotificationsStore"].show({message:r,context:"success",id:"MobileMessaging_ValidatePhoneNumber",type:"transient"}),n.isActivated[t]=!0}else{var i=Object(l["translate"])("MobileMessaging_Settings_InvalidActivationCode");o=l["NotificationsStore"].show({message:i,context:"error",id:"MobileMessaging_ValidatePhoneNumber",type:"transient"})}l["NotificationsStore"].scrollToNotification(o)})).finally((function(){n.isChangingPhoneNumber=!1}))}},removePhoneNumber:function(e){var t=this;e&&(this.isChangingPhoneNumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.removePhoneNumber"},{phoneNumber:e},{errorElement:"#invalidVerificationCodeAjaxError"}).then((function(){t.isChangingPhoneNumber=!1,l["Matomo"].helper.redirect()})).finally((function(){t.isChangingPhoneNumber=!1})))},addPhoneNumber:function(){var e=this,t="+".concat(this.countryCallingCode).concat(this.newPhoneNumber);this.canAddNumber&&t.length>1&&(this.isAddingPhonenumber=!0,l["AjaxHelper"].post({method:"MobileMessaging.addPhoneNumber"},{phoneNumber:t},{errorElement:"#ajaxErrorAddPhoneNumber"}).then((function(){e.isAddingPhonenumber=!1,l["Matomo"].helper.redirect()})).finally((function(){e.isAddingPhonenumber=!1})))}},computed:{showSuspiciousPhoneNumber:function(){return 0===this.newPhoneNumber.trim().lastIndexOf("0",0)},canAddNumber:function(){return!!this.newPhoneNumber&&""!==this.newPhoneNumber}}});be.render=me;var pe=be; /*! * Matomo - free/libre analytics platform * diff --git a/plugins/MobileMessaging/vue/dist/umd.metadata.json b/plugins/MobileMessaging/vue/dist/umd.metadata.json index dce4477a3c..b0a1ba0ec5 100644 --- a/plugins/MobileMessaging/vue/dist/umd.metadata.json +++ b/plugins/MobileMessaging/vue/dist/umd.metadata.json @@ -1,6 +1,7 @@ { "dependsOn": [ "CoreHome", - "CorePluginsAdmin" + "CorePluginsAdmin", + "ScheduledReports" ] }
\ No newline at end of file diff --git a/plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue b/plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue index d2c415575f..cdf62c5469 100644 --- a/plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue +++ b/plugins/MobileMessaging/vue/src/ManageSmsProvider/ManageSmsProvider.vue @@ -76,7 +76,7 @@ interface ManageSmsProviderState { isDeletingAccount: boolean; isUpdatingAccount: boolean; showAccountForm: boolean; - credentials: Record<string, unknown>; + credentials: Record<string, unknown>|null; smsProvider?: string; } @@ -109,7 +109,7 @@ export default defineComponent({ isDeletingAccount: false, isUpdatingAccount: false, showAccountForm: false, - credentials: {}, + credentials: null, smsProvider: this.provider, }; }, @@ -187,7 +187,7 @@ export default defineComponent({ isUpdateAccountPossible() { // possible if smsProvider is set and all credential field values are set to something return !!this.smsProvider - && Object.keys(this.credentials).length > 0 + && this.credentials !== null && Object.values(this.credentials as Record<string, string>).every((v) => !!v); }, updateOrDeleteAccountText() { diff --git a/plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue b/plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue new file mode 100644 index 0000000000..d0c067265d --- /dev/null +++ b/plugins/MobileMessaging/vue/src/ReportParameters/ReportParameters.vue @@ -0,0 +1,79 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <div v-if="report && report.type === 'mobile'"> + <SelectPhoneNumbers + :phone-numbers="phoneNumbers" + :with-introduction="true" + :model-value="report.phoneNumbers" + @update:model-value="$emit('change', 'phoneNumbers', $event)" + /> + </div> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { Report } from 'ScheduledReports'; +import SelectPhoneNumbers from '../SelectPhoneNumbers/SelectPhoneNumbers.vue'; + +const REPORT_TYPE = 'mobile'; + +export default defineComponent({ + props: { + report: { + type: Object, + required: true, + }, + phoneNumbers: { + type: [Array, Object], + required: true, + }, + }, + components: { + SelectPhoneNumbers, + }, + emits: ['change'], + created() { + const { + resetReportParametersFunctions, + updateReportParametersFunctions, + getReportParametersFunctions, + } = window; + + if (!resetReportParametersFunctions[REPORT_TYPE]) { + resetReportParametersFunctions[REPORT_TYPE] = (report: Report) => { + report.phoneNumbers = []; + report.formatmobile = 'sms'; + }; + } + + if (!updateReportParametersFunctions[REPORT_TYPE]) { + updateReportParametersFunctions[REPORT_TYPE] = (report: Report) => { + if (!report?.parameters) { + return; + } + + if (report.parameters && report.parameters.phoneNumbers) { + report.phoneNumbers = report.parameters.phoneNumbers; + } + report.formatmobile = 'sms'; + }; + } + + if (!getReportParametersFunctions[REPORT_TYPE]) { + getReportParametersFunctions[REPORT_TYPE] = (report: Report) => { + // returning [''] when no phone numbers are selected avoids the "please provide a value + // for 'parameters'" error message + const phoneNumbers: string[]|undefined = report.phoneNumbers as string[]|undefined; + return { + phoneNumbers: phoneNumbers || [''], + }; + }; + } + }, +}); +</script> diff --git a/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.adapter.ts b/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.adapter.ts new file mode 100644 index 0000000000..c1b79d5c56 --- /dev/null +++ b/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.adapter.ts @@ -0,0 +1,60 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +import { INgModelController, ITimeoutService } from 'angular'; +import { nextTick } from 'vue'; +import { createAngularJsAdapter, removeAngularJsSpecificProperties } from 'CoreHome'; +import SelectPhoneNumbers from './SelectPhoneNumbers.vue'; + +export default createAngularJsAdapter<[ITimeoutService]>({ + component: SelectPhoneNumbers, + require: '?ngModel', + scope: { + phoneNumbers: { + angularJsBind: '<', + }, + withIntroduction: { + angularJsBind: '<', + }, + value: { + angularJsBind: '<', + vue: 'modelValue', + }, + }, + $inject: ['$timeout'], + directiveName: 'matomoSelectPhoneNumbers', + events: { + 'update:modelValue': (newValue, vm, scope, element, attrs, ngModel, $timeout) => { + if (!ngModel) { + return; + } + + if (newValue !== (ngModel as INgModelController).$viewValue) { + $timeout(() => { + (ngModel as INgModelController).$setViewValue(newValue); + (ngModel as INgModelController).$render(); // not detected by the watch for some reason + }); + } + }, + }, + postCreate(vm, scope, element, attrs, controller) { + const ngModel = controller as INgModelController; + + // ngModel being used + ngModel.$render = () => { + nextTick(() => { + vm.modelValue = removeAngularJsSpecificProperties(ngModel.$viewValue); + }); + }; + + if (typeof scope.value !== 'undefined') { + (ngModel as INgModelController).$setViewValue(scope.value); + } else { + ngModel.$setViewValue(vm.modelValue); + } + }, +}); diff --git a/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue b/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue new file mode 100644 index 0000000000..15a34dcd7e --- /dev/null +++ b/plugins/MobileMessaging/vue/src/SelectPhoneNumbers/SelectPhoneNumbers.vue @@ -0,0 +1,66 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <div class='mobile'> + <Field + uicontrol="checkbox" + var-type="array" + name="phoneNumbers" + :model-value="modelValue" + @update:model-value="$emit('update:modelValue', $event)" + :introduction="withIntroduction ? translate('ScheduledReports_SendReportTo') : undefined" + :title="translate('MobileMessaging_PhoneNumbers')" + :disabled="phoneNumbers.length === 0" + :options="phoneNumbers" + > + <template v-slot:inline-help> + <div id="mobilePhoneNumbersHelp" class="inline-help-node"> + <span class="icon-info" style="margin-right:3.5px"></span> + + <span v-if="phoneNumbers.length === 0" style="margin-right:3.5px"> + {{ translate('MobileMessaging_MobileReport_NoPhoneNumbers') }} + </span> + <span v-else style="margin-right:3.5px"> + {{ translate('MobileMessaging_MobileReport_AdditionalPhoneNumbers') }} + </span> + <a :href="linkTo({ module: 'MobileMessaging', action: 'index', updated: null })"> + {{ translate('MobileMessaging_MobileReport_MobileMessagingSettingsLink') }} + </a> + </div> + </template> + </Field> + </div> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { MatomoUrl } from 'CoreHome'; +import { Field } from 'CorePluginsAdmin'; + +export default defineComponent({ + props: { + modelValue: Array, + phoneNumbers: { + type: [Array, Object], + required: true, + }, + withIntroduction: Boolean, + }, + emits: ['update:modelValue'], + components: { + Field, + }, + methods: { + linkTo(params: QueryParameters) { + return `?${MatomoUrl.stringify({ + ...MatomoUrl.urlParsed.value, + ...params, + })}`; + }, + }, +}); +</script> diff --git a/plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue b/plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue index 34a6d8b8ff..7762eaecd2 100644 --- a/plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue +++ b/plugins/MobileMessaging/vue/src/SmsProviderCredentials/SmsProviderCredentials.vue @@ -37,10 +37,7 @@ export default defineComponent({ type: String, required: true, }, - modelValue: { - type: Object, - required: true, - }, + modelValue: Object, }, emits: ['update:modelValue'], components: { @@ -49,7 +46,7 @@ export default defineComponent({ watch: { provider() { // unset credentials when new provider is chosen - this.$emit('update:modelValue', {}); + this.$emit('update:modelValue', null); // fetch fields for provider this.getCredentialFields(); @@ -61,14 +58,21 @@ export default defineComponent({ methods: { getCredentialFields() { if (allFieldsByProvider[this.provider]) { + this.$emit( + 'update:modelValue', + Object.fromEntries( + (allFieldsByProvider[this.provider] as FieldInfo[]).map((f) => [f.name, null]), + ), + ); return; } - AjaxHelper.fetch({ + AjaxHelper.fetch<FieldInfo[]>({ module: 'MobileMessaging', action: 'getCredentialFields', provider: this.provider, }).then((fields) => { + this.$emit('update:modelValue', Object.fromEntries(fields.map((f) => [f.name, null]))); allFieldsByProvider[this.provider] = fields; }); }, diff --git a/plugins/MobileMessaging/vue/src/index.ts b/plugins/MobileMessaging/vue/src/index.ts index a26a2b9526..335b7ee0fc 100644 --- a/plugins/MobileMessaging/vue/src/index.ts +++ b/plugins/MobileMessaging/vue/src/index.ts @@ -6,8 +6,11 @@ */ import './SmsProviderCredentials/SmsProviderCredentials.adapter'; +import './SelectPhoneNumbers/SelectPhoneNumbers.adapter'; +export { default as ReportParameters } from './ReportParameters/ReportParameters.vue'; export { default as ManageSmsProvider } from './ManageSmsProvider/ManageSmsProvider.vue'; export { default as SmsProviderCredentials } from './SmsProviderCredentials/SmsProviderCredentials.vue'; export { default as DelegateMobileMessagingSettings } from './DelegateMobileMessagingSettings/DelegateMobileMessagingSettings.vue'; export { default as ManageMobilePhoneNumbers } from './ManageMobilePhoneNumbers/ManageMobilePhoneNumbers.vue'; +export { default as SelectPhoneNumbers } from './SelectPhoneNumbers/SelectPhoneNumbers.vue'; diff --git a/plugins/Morpheus/javascripts/piwikHelper.js b/plugins/Morpheus/javascripts/piwikHelper.js index 3e59e44ef3..6897634b6c 100644 --- a/plugins/Morpheus/javascripts/piwikHelper.js +++ b/plugins/Morpheus/javascripts/piwikHelper.js @@ -153,7 +153,7 @@ window.piwikHelper = { }, // initial call for 'body' later in this file - compileVueEntryComponents: function (selector) { + compileVueEntryComponents: function (selector, extraProps) { function toCamelCase(arg) { return arg[0] + arg.substring(1) .replace(/-[a-z]/g, function (s) { return s[1].toUpperCase(); }); @@ -166,6 +166,10 @@ window.piwikHelper = { // process vue-entry attributes $('[vue-entry]', selector).add($(selector).filter('[vue-entry]')).each(function () { + if ($(this).closest('[vue-entry-ignore]').length) { + return; + } + var entry = $(this).attr('vue-entry'); var componentsToRegister = ($(this).attr('vue-components') || '').split(/\s+/).filter(function (s) { return !!s.length; @@ -191,25 +195,31 @@ window.piwikHelper = { $(this).attr('ng-non-bindable', ''); var paramsStr = ''; - var componentParams = {}; - $.each(this.attributes, function () { - if (this.name === 'vue-entry') { + + function handleProperty(name, value) { + if (name === 'vue-entry') { return; } // append with underscore so reserved javascripy keywords aren't accidentally used - var camelName = toCamelCase(this.name) + '_'; - paramsStr += ':' + this.name + '=' + JSON.stringify(camelName) + ' '; + var camelName = toCamelCase(name) + '_'; + paramsStr += ':' + name + '=' + JSON.stringify(camelName) + ' '; - var value = this.value; try { - value = JSON.parse(this.value); + value = JSON.parse(value); } catch (e) { // pass } componentParams[camelName] = value; + } + + $.each(this.attributes, function () { + handleProperty(this.name, this.value); + }); + Object.entries(extraProps || {}).forEach(([name, value]) => { + handleProperty(name, value); }); // NOTE: we could just do createVueApp(component, componentParams), but Vue will not allow diff --git a/plugins/ScheduledReports/ScheduledReports.php b/plugins/ScheduledReports/ScheduledReports.php index 1928940890..06f6da24f8 100644 --- a/plugins/ScheduledReports/ScheduledReports.php +++ b/plugins/ScheduledReports/ScheduledReports.php @@ -126,6 +126,36 @@ class ScheduledReports extends \Piwik\Plugin $translationKeys[] = "ScheduledReports_ReportHourWithUTC"; $translationKeys[] = "ScheduledReports_EvolutionGraphsShowForEachInPeriod"; $translationKeys[] = "ScheduledReports_EvolutionGraphsShowForPreviousN"; + $translationKeys[] = 'ScheduledReports_EmailSchedule'; + $translationKeys[] = 'ScheduledReports_ReportFormat'; + $translationKeys[] = 'ScheduledReports_SendReportTo'; + $translationKeys[] = 'ScheduledReports_MustBeLoggedIn'; + $translationKeys[] = 'Login_LogIn'; + $translationKeys[] = 'ScheduledReports_ThereIsNoReportToManage'; + $translationKeys[] = 'ScheduledReports_SegmentDeleted'; + $translationKeys[] = 'ScheduledReports_NoRecipients'; + $translationKeys[] = 'ScheduledReports_SendReportNow'; + $translationKeys[] = 'ScheduledReports_CreateAndScheduleReport'; + $translationKeys[] = 'ScheduledReports_DescriptionOnFirstPage'; + $translationKeys[] = 'SegmentEditor_ChooseASegment'; + $translationKeys[] = 'ScheduledReports_WeeklyScheduleHelp'; + $translationKeys[] = 'ScheduledReports_MonthlyScheduleHelp'; + $translationKeys[] = 'ScheduledReports_ReportPeriod'; + $translationKeys[] = 'ScheduledReports_ReportPeriodHelp'; + $translationKeys[] = 'ScheduledReports_ReportPeriodHelp2'; + $translationKeys[] = 'ScheduledReports_ReportHour'; + $translationKeys[] = 'ScheduledReports_ReportType'; + $translationKeys[] = 'ScheduledReports_AggregateReportsFormat'; + $translationKeys[] = 'ScheduledReports_EvolutionGraph'; + $translationKeys[] = 'ScheduledReports_EvolutionGraphsShowForPreviousN'; + $translationKeys[] = 'ScheduledReports_ReportsIncluded'; + $translationKeys[] = 'ScheduledReports_ReportIncludeNWebsites'; + $translationKeys[] = 'SegmentEditor_LoadingSegmentedDataMayTakeSomeTime'; + $translationKeys[] = 'General_Download'; + $translationKeys[] = 'ScheduledReports_Segment_Help'; + $translationKeys[] = 'SegmentEditor_AddNewSegment'; + $translationKeys[] = 'ScheduledReports_SentToMe'; + $translationKeys[] = 'ScheduledReports_AlsoSendReportToTheseEmails'; } /** @@ -143,8 +173,6 @@ class ScheduledReports extends \Piwik\Plugin public function getJsFiles(&$jsFiles) { - $jsFiles[] = "plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.controller.js"; - $jsFiles[] = "plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.directive.js"; } public function getStylesheetFiles(&$stylesheets) @@ -487,8 +515,8 @@ class ScheduledReports extends \Piwik\Plugin $view->currentUserEmail = Piwik::getCurrentUserEmail(); $view->reportType = self::EMAIL_TYPE; $view->defaultDisplayFormat = self::DEFAULT_DISPLAY_FORMAT; - $view->defaultEmailMe = self::EMAIL_ME_PARAMETER_DEFAULT_VALUE ? 'true' : 'false'; - $view->defaultEvolutionGraph = self::EVOLUTION_GRAPH_PARAMETER_DEFAULT_VALUE ? 'true' : 'false'; + $view->defaultEmailMe = self::EMAIL_ME_PARAMETER_DEFAULT_VALUE; + $view->defaultEvolutionGraph = self::EVOLUTION_GRAPH_PARAMETER_DEFAULT_VALUE; $out .= $view->render(); } diff --git a/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.controller.js b/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.controller.js deleted file mode 100644 index 4d584960a2..0000000000 --- a/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.controller.js +++ /dev/null @@ -1,265 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ -(function () { - angular.module('piwikApp').controller('ManageScheduledReportController', ManageScheduledReportController); - - ManageScheduledReportController.$inject = ['piwik']; - - function ManageScheduledReportController(piwik) { - // remember to keep controller very simple. Create a service/factory (model) if needed - - var self = this; - - function getTimeZoneDifferenceInHours() { - return piwik.timezoneOffset / 3600; - } - - this.reportHours = []; - for (var i = 0; i < 24; i++) { - if ((getTimeZoneDifferenceInHours()*2) % 2 != 0) { - this.reportHours.push({key: i + '.5', value: i + ':30'}); - } else { - this.reportHours.push({key: i + '', value: i + ''}); - } - } - - function scrollToTop() - { - piwikHelper.lazyScrollTo(".emailReports", 200); - } - - function updateParameters(reportType, report) - { - if (updateReportParametersFunctions && updateReportParametersFunctions[reportType]) { - updateReportParametersFunctions[reportType](report); - } - } - - function resetParameters(reportType, report) - { - if (resetReportParametersFunctions && resetReportParametersFunctions[reportType]) { - resetReportParametersFunctions[reportType](report) - } - } - - function adjustHourToTimezone(hour, difference) { - return '' + ((24 + parseFloat(hour) + difference) % 24); - } - - function updateReportHourUtc (report) { - var reportHour = adjustHourToTimezone(report.hour, -getTimeZoneDifferenceInHours()); - report.hourUtc = _pk_translate('ScheduledReports_ReportHourWithUTC', [reportHour]); - } - - function formSetEditReport(idReport) { - var report = { - 'type': ReportPlugin.defaultReportType, - 'format': ReportPlugin.defaultReportFormat, - 'description': '', - 'period': ReportPlugin.defaultPeriod, - 'hour': ReportPlugin.defaultHour, - 'reports': [], - 'idsegment': '', - 'evolutionPeriodFor': 'prev', - 'evolutionPeriodN': ReportPlugin.defaultEvolutionPeriodN, - 'periodParam': ReportPlugin.defaultPeriod, - }; - - if (idReport > 0) { - report = ReportPlugin.reportList[idReport]; - updateParameters(report.type, report); - self.saveButtonTitle = ReportPlugin.updateReportString; - } else { - self.saveButtonTitle = ReportPlugin.createReportString; - resetParameters(report.type, report); - } - - report.hour = adjustHourToTimezone(report.hour, getTimeZoneDifferenceInHours()); - updateReportHourUtc(report); - - setTimeout(function() { - $('[name=reportsList] input').prop('checked', false); - - var key; - for (key in report.reports) { - $('.' + report.type + ' [report-unique-id=' + report.reports[key] + ']').prop('checked', 'checked'); - } - }); - - report['format' + report.type] = report.format; - - if (!report.idsegment) { - report.idsegment = ''; - } - - self.report = report; - self.report.description = piwik.helper.htmlDecode(self.report.description); - self.editingReportId = idReport; - } - - function getReportAjaxRequest(idReport, defaultApiMethod) { - scrollToTop(); - - var ajaxHandler = new ajaxHelper(); - - var parameters = {module: 'API', method: defaultApiMethod, format: 'json'}; - if (idReport == 0) { - parameters.method = 'ScheduledReports.addReport'; - } - - ajaxHandler.addParams(parameters, 'GET'); - - return ajaxHandler; - } - - function fadeInOutSuccessMessage(selector, message) { - - var UI = require('piwik/UI'); - var notification = new UI.Notification(); - notification.show(message, { - placeat: selector, - context: 'success', - noclear: true, - type: 'toast', - style: {display: 'inline-block', marginTop: '10px'}, - id: 'scheduledReportSuccess' - }); - - piwikHelper.refreshAfter(2); - } - - this.updateReportHourUtc = function () { - updateReportHourUtc(this.report); - }; - - // Click Add/Update Submit - this.submitReport = function () { - var idReport = this.editingReportId; - var apiParameters = {}; - apiParameters.idReport = idReport; - apiParameters.description = this.report.description; - apiParameters.idSegment = this.report.idsegment; - apiParameters.reportType = this.report.type; - apiParameters.reportFormat = this.report['format' + this.report.type]; - apiParameters.periodParam = this.report.periodParam; - apiParameters.evolutionPeriodFor = this.report.evolutionPeriodFor; - if (apiParameters.evolutionPeriodFor !== 'each') { - apiParameters.evolutionPeriodN = this.report.evolutionPeriodN; - } - - var period = self.report.period; - var hour = adjustHourToTimezone(this.report.hour, -getTimeZoneDifferenceInHours()); - - var reports = []; - $('[name=reportsList].' + apiParameters.reportType + ' input:checked').each(function () { - reports.push($(this).attr('report-unique-id')); - }); - if (reports.length > 0) { - apiParameters.reports = reports; - } - - apiParameters.parameters = getReportParametersFunctions[this.report.type](this.report); - - var ajaxHandler = getReportAjaxRequest(idReport, 'ScheduledReports.updateReport'); - ajaxHandler.addParams(apiParameters, 'POST'); - ajaxHandler.addParams({period: period}, 'GET'); - ajaxHandler.addParams({hour: hour}, 'GET'); - ajaxHandler.redirectOnSuccess(); - ajaxHandler.setLoadingElement(); - if (idReport) { - ajaxHandler.setCallback(function (response) { - - fadeInOutSuccessMessage('#reportUpdatedSuccess', _pk_translate('ScheduledReports_ReportUpdated')); - }); - } - ajaxHandler.send(); - return false; - }; - - this.changedReportType = function () { - resetParameters(this.report.type, this.report); - }; - - this.displayReport = function (reportId) { - $('#downloadReportForm_' + reportId).submit(); - }; - - // Email now - this.sendReportNow = function (idReport) { - var ajaxHandler = getReportAjaxRequest(idReport, 'ScheduledReports.sendReport'); - ajaxHandler.addParams({idReport: idReport, force: true}, 'POST'); - ajaxHandler.setLoadingElement(); - ajaxHandler.setCallback(function (response) { - fadeInOutSuccessMessage('#reportSentSuccess', _pk_translate('ScheduledReports_ReportSent')); - }); - ajaxHandler.send(); - }; - - // Delete Report - this.deleteReport = function (idReport) { - function onDelete() { - var ajaxHandler = getReportAjaxRequest(idReport, 'ScheduledReports.deleteReport'); - ajaxHandler.addParams({idReport: idReport}, 'POST'); - ajaxHandler.redirectOnSuccess(); - ajaxHandler.setLoadingElement(); - ajaxHandler.send(); - } - - piwikHelper.modalConfirm('#confirm', {yes: onDelete}); - }; - - this.showListOfReports = function (shouldScrollToTop) { - this.showReportsList = true; - this.showReportForm = false; - piwik.helper.hideAjaxError(); - - if (typeof shouldScrollToTop === 'undefined' || !shouldScrollToTop) { - scrollToTop(); - } - }; - - this.showAddEditForm = function () { - this.showReportsList = false; - this.showReportForm = true; - }; - - this.createReport = function () { - this.showAddEditForm(); - formSetEditReport(/*idReport = */0); - } - - this.editReport = function (reportId) { - this.showAddEditForm(); - formSetEditReport(reportId); - }; - - this.getFrequencyPeriodSingle = function () { - if (!this.report || !this.report.period) { - return ''; - } - - var translation = ReportPlugin.periodTranslations[this.report.period]; - if (!translation) { - translation = ReportPlugin.periodTranslations.day; - } - return translation.single; - }; - this.getFrequencyPeriodPlural = function () { - if (!this.report || !this.report.period) { - return ''; - } - - var translation = ReportPlugin.periodTranslations[this.report.period]; - if (!translation) { - translation = ReportPlugin.periodTranslations.day; - } - return translation.plural; - }; - - this.showListOfReports(false); - } -})(); diff --git a/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.directive.js b/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.directive.js deleted file mode 100644 index f32289bac3..0000000000 --- a/plugins/ScheduledReports/angularjs/manage-scheduled-report/manage-scheduled-report.directive.js +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Matomo - free/libre analytics platform - * - * @link https://matomo.org - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -var getReportParametersFunctions = Object(); -var updateReportParametersFunctions = Object(); -var resetReportParametersFunctions = Object(); - -/** - * Usage: - * <div piwik-manage-scheduled-report> - */ -(function () { - angular.module('piwikApp').directive('piwikManageScheduledReport', piwikManageScheduledReport); - - piwikManageScheduledReport.$inject = ['piwik']; - - function piwikManageScheduledReport(piwik){ - - return { - restrict: 'A', - priority: 10, - controller: 'ManageScheduledReportController', - controllerAs: 'manageScheduledReport' - }; - } -})();
\ No newline at end of file diff --git a/plugins/ScheduledReports/templates/_addReport.twig b/plugins/ScheduledReports/templates/_addReport.twig deleted file mode 100644 index a8534bb152..0000000000 --- a/plugins/ScheduledReports/templates/_addReport.twig +++ /dev/null @@ -1,190 +0,0 @@ -<div piwik-content-block - content-title="{{ 'ScheduledReports_CreateAndScheduleReport'|translate|e('html_attr') }}" - class="entityAddContainer" - ng-if="manageScheduledReport.showReportForm"> - <div class='clear'></div> - <form id='addEditReport' piwik-form ng-submit="manageScheduledReport.submitReport()"> - - <div piwik-field uicontrol="text" name="website" - data-title="{{ 'General_Website'|translate|e('html_attr') }}" - data-disabled="true" - value="{{ siteName|rawSafeDecoded }}"> - </div> - - <div piwik-field uicontrol="textarea" name="report_description" - data-title="{{ 'General_Description'|translate|e('html_attr') }}" - ng-model="manageScheduledReport.report.description" - inline-help="{{ 'ScheduledReports_DescriptionOnFirstPage'|translate|e('html_attr') }}"> - </div> - - {% if segmentEditorActivated %} - <div id="reportSegmentInlineHelp" class="inline-help-node"> - {% set SegmentEditor_DefaultAllVisits %}{{ 'SegmentEditor_DefaultAllVisits'|translate }}{% endset %} - {% set SegmentEditor_AddNewSegment %}{{ 'SegmentEditor_AddNewSegment'|translate }}{% endset %} - {{ 'ScheduledReports_Segment_Help'|translate('<a href="./" rel="noreferrer noopener" target="_blank">','</a>',SegmentEditor_DefaultAllVisits,SegmentEditor_AddNewSegment)|raw }} - </div> - - <div piwik-field uicontrol="select" name="report_segment" - ng-model="manageScheduledReport.report.idsegment" - options="{{ savedSegmentsById|json_encode }}" - data-title="{{ 'SegmentEditor_ChooseASegment'|translate|e('html_attr') }}" - inline-help="#reportSegmentInlineHelp"> - </div> - {% endif %} - - <div id="emailScheduleInlineHelp" class="inline-help-node"> - {{ 'ScheduledReports_WeeklyScheduleHelp'|translate }} - <br/> - {{ 'ScheduledReports_MonthlyScheduleHelp'|translate }} - </div> - - <div piwik-field uicontrol="select" name="report_schedule" - options="{{ periods|json_encode }}" - ng-model="manageScheduledReport.report.period" - ng-change="manageScheduledReport.report.periodParam = manageScheduledReport.report.period === 'never' ? null : manageScheduledReport.report.period" - data-title="{{ 'ScheduledReports_EmailSchedule'|translate|e('html_attr') }}" - inline-help="#emailScheduleInlineHelp"> - </div> - - <div id="emailReportPeriodInlineHelp" class="inline-help-node"> - {{ 'ScheduledReports_ReportPeriodHelp'|translate }} - <br/><br/> - {{ 'ScheduledReports_ReportPeriodHelp2'|translate }} - </div> - - <div piwik-field uicontrol="select" name="report_period" - options="{{ paramPeriods|json_encode }}" - ng-model="manageScheduledReport.report.periodParam" - title="{{ 'ScheduledReports_ReportPeriod'|translate|e('html_attr') }}" - inline-help="#emailReportPeriodInlineHelp" - > - </div> - - <div piwik-field uicontrol="select" name="report_hour" - options="manageScheduledReport.reportHours" - ng-change="manageScheduledReport.updateReportHourUtc()" - ng-model="manageScheduledReport.report.hour" - {% if timezoneOffset != 0 %}inline-help="#reportHourHelpText"{% endif %} - data-title="{{ 'ScheduledReports_ReportHour'|translate('X')|e('html_attr') }}"> - </div> - - {% if timezoneOffset != 0 %} - <div id="reportHourHelpText" class="inline-help-node"> - <span ng-bind="manageScheduledReport.report.hourUtc"></span> - </div> - {% endif %} - - <div piwik-field uicontrol="select" name="report_type" - options="{{ reportTypeOptions|json_encode }}" - ng-model="manageScheduledReport.report.type" - ng-change="manageScheduledReport.changedReportType()" - {% if reportTypes|length == 1 %}disabled="true"{% endif %} - data-title="{{ 'ScheduledReports_ReportType'|translate|e('html_attr') }}"> - </div> - - {% for reportType, reportFormats in reportFormatsByReportTypeOptions %} - <div piwik-field uicontrol="select" name="report_format" - class="{{ reportType }}" - ng-model="manageScheduledReport.report.format{{ reportType }}" - ng-show="manageScheduledReport.report.type == '{{ reportType }}'" - options="{{ reportFormats|json_encode }}" - data-title="{{ 'ScheduledReports_ReportFormat'|translate|e('html_attr') }}"> - </div> - {% endfor %} - - {{ postEvent("Template.reportParametersScheduledReports") }} - - <div ng-show="manageScheduledReport.report.type == 'email' && manageScheduledReport.report.formatemail !== 'csv' && manageScheduledReport.report.formatemail !== 'tsv'"> - <div piwik-field uicontrol="select" name="display_format" class="email" - ng-model="manageScheduledReport.report.displayFormat" - options="{{ displayFormats|json_encode }}" - introduction="{{ 'ScheduledReports_AggregateReportsFormat'|translate|e('html_attr') }}"> - </div> - - <div piwik-field uicontrol="checkbox" name="report_evolution_graph" - class="report_evolution_graph" - ng-model="manageScheduledReport.report.evolutionGraph" - ng-show="manageScheduledReport.report.displayFormat == '2' || manageScheduledReport.report.displayFormat == '3'" - data-title="{{ 'ScheduledReports_EvolutionGraph'|translate(5)|e('html_attr') }}"> - </div> - - <div - class="row evolution-graph-period" - ng-show="manageScheduledReport.report.displayFormat == '1' || manageScheduledReport.report.displayFormat == '2' || manageScheduledReport.report.displayFormat == '3'" - > - <div class="col s12"> - <label for="report_evolution_period_for_each"> - <input id="report_evolution_period_for_each" name="report_evolution_period_for" type="radio" checked value="each" ng-model="manageScheduledReport.report.evolutionPeriodFor" /> - <span piwik-translate="ScheduledReports_EvolutionGraphsShowForEachInPeriod"><strong>::</strong>::{{ "{{ manageScheduledReport.getFrequencyPeriodSingle() }}" }}</span> - </label> - </div> - <div class="col s12"> - <label for="report_evolution_period_for_prev"> - <input id="report_evolution_period_for_prev" name="report_evolution_period_for" type="radio" value="prev" ng-model="manageScheduledReport.report.evolutionPeriodFor" /> - <span>{{ "{{ 'ScheduledReports_EvolutionGraphsShowForPreviousN'|translate:manageScheduledReport.getFrequencyPeriodPlural() }}" }}: - <input type="number" name="report_evolution_period_n" ng-model="manageScheduledReport.report.evolutionPeriodN" /></span> - </label> - </div> - </div> - </div> - - <div class="row"> - <h3 class="col s12">{{ 'ScheduledReports_ReportsIncluded'|translate }}</h3> - </div> - - {% for reportType, reportsByCategory in reportsByCategoryByReportType %} - <div name='reportsList' class='row {{ reportType }}' - ng-show="manageScheduledReport.report.type == '{{ reportType }}'"> - - {% if allowMultipleReportsByReportType[reportType] %} - {% set reportInputType='checkbox' %} - {% else %} - {% set reportInputType='radio' %} - {% endif %} - - {% set countCategory=0 %} - - {% set newColumnAfter=(reportsByCategory|length + 1)//2 %} - - <div class='col s12 m6'> - {% for category, reports in reportsByCategory %} - {% if countCategory >= newColumnAfter and newColumnAfter != 0 %} - {% set newColumnAfter=0 %} - </div> - <div class='col s12 m6'> - {% endif %} - <h3 class='reportCategory'>{{ category }}</h3> - <ul class='listReports'> - {% for report in reports %} - <li> - <label> - <input type='{{ reportInputType }}' id="{{ reportType }}{{ report.uniqueId }}" report-unique-id='{{ report.uniqueId }}' - name='{{ reportType }}Reports'/> - <span>{{ report.name|rawSafeDecoded }}</span> - {% if report.uniqueId=='MultiSites_getAll' %} - <div class="entityInlineHelp">{{ 'ScheduledReports_ReportIncludeNWebsites'|translate(countWebsites) - }}</div> - {% endif %} - </label> - </li> - {% endfor %} - {% set countCategory=countCategory+1 %} - </ul> - <br/> - {% endfor %} - </div> - </div> - {% endfor %} - - <input type="hidden" id="report_idreport" ng-model="manageScheduledReport.editingReportId"> - - <div ng-value="manageScheduledReport.saveButtonTitle" - onconfirm="manageScheduledReport.submitReport()" - piwik-save-button></div> - - <div class='entityCancel'> - {{ 'General_OrCancel'|translate("<a class='entityCancelLink' ng-click='manageScheduledReport.showListOfReports()'>","</a>")|raw }} - </div> - - </form> -</div> diff --git a/plugins/ScheduledReports/templates/_listReports.twig b/plugins/ScheduledReports/templates/_listReports.twig deleted file mode 100644 index 3985b02dc7..0000000000 --- a/plugins/ScheduledReports/templates/_listReports.twig +++ /dev/null @@ -1,126 +0,0 @@ -<div id='entityEditContainer' class="entityTableContainer" - piwik-content-block - content-title="{{ title|e('html_attr') }}" - help-url="https://matomo.org/docs/email-reports/" - feature="true" - ng-show="manageScheduledReport.showReportsList"> - - <table piwik-content-table> - <thead> - <tr> - <th class="first">{{ 'General_Description'|translate }}</th> - <th>{{ 'ScheduledReports_EmailSchedule'|translate }}</th> - <th>{{ 'ScheduledReports_ReportFormat'|translate }}</th> - <th>{{ 'ScheduledReports_SendReportTo'|translate }}</th> - <th>{{ 'General_Download'|translate }}</th> - <th>{{ 'General_Edit'|translate }}</th> - <th>{{ 'General_Delete'|translate }}</th> - </tr> - </thead> - - {% if userLogin == 'anonymous' %} - <tr> - <td colspan='7'> - <br/> - {{ 'ScheduledReports_MustBeLoggedIn'|translate }} - <br/>› <a href='index.php?module={{ loginModule }}'>{{ 'Login_LogIn'|translate }}</a> - <br/><br/> - </td> - </tr> - {% elseif reports is empty %} - <tr> - - <td colspan='7'> - <br/> - {{ 'ScheduledReports_ThereIsNoReportToManage'|translate(siteName)|rawSafeDecoded }}. - <br/><br/> - </td> - </tr> - {% else %} - {% for report in reports %} - <tr> - <td class="first"> - {{ report.description|rawSafeDecoded }} - {% if segmentEditorActivated and report.idsegment %} - <div class="entityInlineHelp" style="font-size: 9pt;"> - {% if savedSegmentsById[report.idsegment] is defined %} - {{ savedSegmentsById[report.idsegment] }} - {% else %} - {{ 'ScheduledReports_SegmentDeleted'|translate }} - {% endif %} - </div> - {% endif %} - </td> - <td>{{ periods[report.period] }} - <!-- Last sent on {{ report.ts_last_sent }} --> - </td> - <td> - {% if report.format is not empty %} - {{ report.format|upper }} - {% endif %} - </td> - <td> - {# report recipients #} - {% if report.recipients|length == 0 %} - {{ 'ScheduledReports_NoRecipients'|translate }} - {% else %} - {% for recipient in report.recipients %} - {{ recipient }} - <br/> - {% endfor %} - {# send now link #} - <a href="#" - ng-click="manageScheduledReport.sendReportNow({{ report.idreport }})" - name="linkSendNow" class="link_but withIcon" style="margin-top:3px;"> - <img border=0 src='{{ reportTypes[report.type] }}'/> - {{ 'ScheduledReports_SendReportNow'|translate }} - </a> - {% endif %} - </td> - <td> - {# download link #} - <form action="{{ linkTo({ 'module':'API', 'segment': null, - 'method':'ScheduledReports.generateReport', 'idReport':report.idreport, - 'outputType':downloadOutputType, 'language':language, - 'format': (report.format in ['html', 'csv', 'tsv']) ? report.format : false }) }}" - method="POST" - target="_blank" - id="downloadReportForm_{{ report.idreport|e('html_attr') }}" - > - <input type="hidden" name="token_auth" value="{{ token_auth|e('html_attr') }}"> - <input type="hidden" name="force_api_session" value="1"> - </form> - <a href="javascript:void(0)" - ng-click="manageScheduledReport.displayReport({{ report.idreport|json_encode }})" - rel="noreferrer noopener" name="linkDownloadReport" id="{{ report.idreport|e('html_attr') }}" class="link_but withIcon"> - <img src='{{ reportFormatsByReportType[report.type][report.format] }}' border="0" width="16px" height="16px"/> - {{ 'General_Download'|translate }} - </a> - </td> - <td style="text-align: center;padding-top:2px;"> - <button ng-click="manageScheduledReport.editReport({{ report.idreport|json_encode }})" - class="table-action" title="{{ 'General_Edit'|translate|e('html_attr') }}"> - <span class="icon-edit"></span> - </button> - </td> - <td style="text-align: center;padding-top:2px;"> - <button ng-click="manageScheduledReport.deleteReport({{ report.idreport|json_encode }})" - class="table-action" title="{{ 'General_Delete'|translate|e('html_attr') }}"> - <span class="icon-delete"></span> - </button> - </td> - </tr> - {% endfor %} - {% endif %} - </table> - - <div class="tableActionBar"> - {% if userLogin != 'anonymous' %} - <button id="add-report" ng-click="manageScheduledReport.createReport()" > - <span class="icon-add"></span> - {{ 'ScheduledReports_CreateAndScheduleReport'|translate }} - </button> - {% endif %} - </div> - -</div> diff --git a/plugins/ScheduledReports/templates/index.twig b/plugins/ScheduledReports/templates/index.twig index 191ca1c191..f6413840f1 100644 --- a/plugins/ScheduledReports/templates/index.twig +++ b/plugins/ScheduledReports/templates/index.twig @@ -9,19 +9,39 @@ {% block content %} -<div class="emailReports" piwik-manage-scheduled-report> - - <span id="reportSentSuccess"></span> - <span id="reportUpdatedSuccess"></span> - - <div> - {% import 'ajaxMacros.twig' as ajax %} - {{ ajax.errorDiv() }} - {{ ajax.loadingDiv() }} - {% include "@ScheduledReports/_listReports.twig" %} - {% include "@ScheduledReports/_addReport.twig" %} - <a id='bottom'></a> - </div> +{% set reportParametersScheduledReportsEvent %}{{ postEvent('Template.reportParametersScheduledReports') }}{% endset %} + +{# load the Template.reportParametersScheduledReports event twice, once here outside of vue so any inline scripts + will execute. then again in the vue slot so it will be used correctly. This is hack to provide some level of BC. #} +<div style="display:none" vue-entry-ignore ng-non-bindable> + {{ reportParametersScheduledReportsEvent|raw }} +</div> + +<div + vue-entry="ScheduledReports.ManageScheduledReport" + content-title="{{ title|default(null)|json_encode|e('html_attr') }}" + user-login="{{ userLogin|default(null)|json_encode|e('html_attr') }}" + login-module="{{ loginModule|default(null)|json_encode|e('html_attr') }}" + reports="{{ reports|default([])|json_encode|e('html_attr') }}" + site-name="{{ siteName|default(null)|json_encode|e('html_attr') }}" + segment-editor-activated="{{ segmentEditorActivated|default(null)|json_encode|e('html_attr') }}" + saved-segments-by-id="{{ savedSegmentsById|default(null)|json_encode|e('html_attr') }}" + periods="{{ periods|default(null)|json_encode|e('html_attr') }}" + download-output-type="{{ downloadOutputType|default(null)|json_encode|e('html_attr') }}" + language="{{ language|default(null)|json_encode|e('html_attr') }}" + report-formats-by-report-type="{{ reportFormatsByReportType|default(null)|json_encode|e('html_attr') }}" + param-periods="{{ paramPeriods|default(null)|json_encode|e('html_attr') }}" + report-type-options="{{ reportTypeOptions|default(null)|json_encode|e('html_attr') }}" + report-formats-by-report-type-options="{{ reportFormatsByReportTypeOptions|default(null)|json_encode|e('html_attr') }}" + display-formats="{{ displayFormats|default(null)|json_encode|e('html_attr') }}" + reports-by-category-by-report-type="{{ reportsByCategoryByReportType|default({})|json_encode|e('html_attr') }}" + allow-multiple-reports-by-report-type="{{ allowMultipleReportsByReportType|default(null)|json_encode|e('html_attr') }}" + count-websites="{{ countWebsites|default(null)|json_encode|e('html_attr') }}" + report-types="{{ reportTypes|default(null)|json_encode|e('html_attr') }}" +> + <template v-slot:report-parameters > + {{ reportParametersScheduledReportsEvent|raw }} + </template> </div> <div class="ui-confirm" id="confirm"> diff --git a/plugins/ScheduledReports/templates/reportParametersScheduledReports.twig b/plugins/ScheduledReports/templates/reportParametersScheduledReports.twig index 258f64dadb..49613eb9c0 100644 --- a/plugins/ScheduledReports/templates/reportParametersScheduledReports.twig +++ b/plugins/ScheduledReports/templates/reportParametersScheduledReports.twig @@ -1,52 +1,8 @@ -<div piwik-field uicontrol="checkbox" - name="report_email_me" - introduction="{{ 'ScheduledReports_SendReportTo'|translate|e('html_attr') }}" - ng-show="manageScheduledReport.report.type == 'email'" - ng-model="manageScheduledReport.report.emailMe" - data-title="{{ 'ScheduledReports_SentToMe'|translate|e('html_attr') }} ({{ currentUserEmail|e('html_attr') }})"> -</div> - -<div piwik-field uicontrol="textarea" var-type="array" - ng-show="manageScheduledReport.report.type == 'email'" - ng-model="manageScheduledReport.report.additionalEmails" - data-title="{{ 'ScheduledReports_AlsoSendReportToTheseEmails'|translate|e('html_attr') }}"> -</div> - -<script> - - $(function () { - - resetReportParametersFunctions ['{{ reportType }}'] = function (report) { - report.displayFormat = '{{ defaultDisplayFormat }}'; - report.emailMe = {{ defaultEmailMe }}; - report.evolutionGraph = {{ defaultEvolutionGraph }}; - report.additionalEmails = ''; - }; - - updateReportParametersFunctions['{{ reportType }}'] = function (report) { - if (report == null || report.parameters == null) { - return; - } - - var i, field, fields = ['displayFormat', 'emailMe', 'evolutionGraph', 'additionalEmails']; - for (i in fields) { - field = fields[i]; - if (field in report.parameters) { - report[field] = report.parameters[field]; - } - } - }; - - getReportParametersFunctions['{{ reportType }}'] = function (report) { - - var parameters = {}; - - parameters.displayFormat = report.displayFormat; - parameters.emailMe = report.emailMe; - parameters.evolutionGraph = report.evolutionGraph; - parameters.additionalEmails = report.additionalEmails ? report.additionalEmails : []; - - return parameters; - }; - }); -</script>
\ No newline at end of file +<div + vue-entry="ScheduledReports.ReportParameters" + report-type="{{ reportType|default(null)|json_encode|e('html_attr') }}" + default-display-format="{{ defaultDisplayFormat|default(null)|json_encode|e('html_attr') }}" + default-email-me="{{ defaultEmailMe|default(false)|json_encode|e('html_attr') }}" + default-evolution-graph="{{ defaultEvolutionGraph|default(false)|json_encode|e('html_attr') }}" + current-user-email="{{ currentUserEmail|default(null)|json_encode|e('html_attr') }}" +></div>
\ No newline at end of file diff --git a/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.js b/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.js new file mode 100644 index 0000000000..d59f8eb454 --- /dev/null +++ b/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.js @@ -0,0 +1,1607 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("CoreHome"), require("vue"), require("CorePluginsAdmin")); + else if(typeof define === 'function' && define.amd) + define(["CoreHome", , "CorePluginsAdmin"], factory); + else if(typeof exports === 'object') + exports["ScheduledReports"] = factory(require("CoreHome"), require("vue"), require("CorePluginsAdmin")); + else + root["ScheduledReports"] = factory(root["CoreHome"], root["Vue"], root["CorePluginsAdmin"]); +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__, __WEBPACK_EXTERNAL_MODULE__8bbf__, __WEBPACK_EXTERNAL_MODULE_a5a2__) { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "plugins/ScheduledReports/vue/dist/"; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "fae3"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "19dc": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__19dc__; + +/***/ }), + +/***/ "8bbf": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; + +/***/ }), + +/***/ "a5a2": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE_a5a2__; + +/***/ }), + +/***/ "fae3": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, "ReportParameters", function() { return /* reexport */ ReportParameters; }); +__webpack_require__.d(__webpack_exports__, "ManageScheduledReport", function() { return /* reexport */ ManageScheduledReport; }); + +// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js +// This file is imported into lib/wc client bundles. + +if (typeof window !== 'undefined') { + var currentScript = window.document.currentScript + if (false) { var getCurrentScript; } + + var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) + if (src) { + __webpack_require__.p = src[1] // eslint-disable-line + } +} + +// Indicate to webpack that this file can be concatenated +/* harmony default export */ var setPublicPath = (null); + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/types.ts +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} +var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue?vue&type=template&id=40badd5d + +var _hoisted_1 = { + key: 0 +}; +function render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field"); + + return _ctx.report ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "checkbox", + name: "report_email_me", + introduction: _ctx.translate('ScheduledReports_SendReportTo'), + "model-value": _ctx.report.emailMe, + "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { + return _ctx.$emit('change', 'emailMe', $event); + }), + title: "".concat(_ctx.translate('ScheduledReports_SentToMe'), " (").concat(_ctx.currentUserEmail, ")") + }, null, 8, ["introduction", "model-value", "title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.report.type === 'email']])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "textarea", + "var-type": "array", + "model-value": _ctx.report.additionalEmails, + "onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) { + return _ctx.$emit('change', 'additionalEmails', $event); + }), + title: _ctx.translate('ScheduledReports_AlsoSendReportToTheseEmails') + }, null, 8, ["model-value", "title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.report.type === 'email']])])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true); +} +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue?vue&type=template&id=40badd5d + +// EXTERNAL MODULE: external "CorePluginsAdmin" +var external_CorePluginsAdmin_ = __webpack_require__("a5a2"); + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue?vue&type=script&lang=ts + + +/* harmony default export */ var ReportParametersvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + report: { + type: Object, + required: true + }, + reportType: { + type: String, + required: true + }, + defaultDisplayFormat: { + type: Number, + required: true + }, + defaultEmailMe: { + type: Boolean, + required: true + }, + defaultEvolutionGraph: { + type: Boolean, + required: true + }, + currentUserEmail: { + type: String, + required: true + } + }, + emits: ['change'], + components: { + Field: external_CorePluginsAdmin_["Field"] + }, + setup: function setup(props) { + var _window = window, + resetReportParametersFunctions = _window.resetReportParametersFunctions, + updateReportParametersFunctions = _window.updateReportParametersFunctions, + getReportParametersFunctions = _window.getReportParametersFunctions; + + if (!resetReportParametersFunctions[props.reportType]) { + resetReportParametersFunctions[props.reportType] = function (theReport) { + theReport.displayFormat = props.defaultDisplayFormat; + theReport.emailMe = props.defaultEmailMe; + theReport.evolutionGraph = props.defaultEvolutionGraph; + theReport.additionalEmails = []; + }; + } + + if (!updateReportParametersFunctions[props.reportType]) { + updateReportParametersFunctions[props.reportType] = function (theReport) { + if (!(theReport !== null && theReport !== void 0 && theReport.parameters)) { + return; + } + + ['displayFormat', 'emailMe', 'evolutionGraph', 'additionalEmails'].forEach(function (field) { + if (field in theReport.parameters) { + theReport[field] = theReport.parameters[field]; + } + }); + }; + } + + if (!getReportParametersFunctions[props.reportType]) { + getReportParametersFunctions[props.reportType] = function (theReport) { + return { + displayFormat: theReport.displayFormat, + emailMe: theReport.emailMe, + evolutionGraph: theReport.evolutionGraph, + additionalEmails: theReport.additionalEmails || [] + }; + }; + } + } +})); +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue + + + +ReportParametersvue_type_script_lang_ts.render = render + +/* harmony default export */ var ReportParameters = (ReportParametersvue_type_script_lang_ts); +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue?vue&type=template&id=49678e2a + +var ManageScheduledReportvue_type_template_id_49678e2a_hoisted_1 = { + class: "emailReports", + ref: "root" +}; +var _hoisted_2 = { + ref: "reportSentSuccess" +}; +var _hoisted_3 = { + ref: "reportUpdatedSuccess" +}; + +var _hoisted_4 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + id: "ajaxError", + style: { + "display": "none" + } +}, null, -1); + +var _hoisted_5 = { + id: "ajaxLoadingDiv", + style: { + "display": "none" + } +}; +var _hoisted_6 = { + class: "loadingPiwik" +}; +var _hoisted_7 = ["alt"]; +var _hoisted_8 = { + class: "loadingSegment" +}; + +var _hoisted_9 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + id: "bottom" +}, null, -1); + +function ManageScheduledReportvue_type_template_id_49678e2a_render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_ListReports = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ListReports"); + + var _component_AddReport = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("AddReport"); + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", ManageScheduledReportvue_type_template_id_49678e2a_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_2, null, 512), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_3, null, 512), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [_hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_5, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_6, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("img", { + src: "plugins/Morpheus/images/loading-blue.gif", + alt: _ctx.translate('General_LoadingData') + }, null, 8, _hoisted_7), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_LoadingData')), 1)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_8, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('SegmentEditor_LoadingSegmentedDataMayTakeSomeTime')), 1)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ListReports, { + "content-title": _ctx.contentTitle, + "user-login": _ctx.userLogin, + "login-module": _ctx.loginModule, + reports: _ctx.reports, + "site-name": _ctx.decodedSiteName, + "segment-editor-activated": _ctx.segmentEditorActivated, + "saved-segments-by-id": _ctx.savedSegmentsById, + periods: _ctx.periods, + "report-types": _ctx.reportTypes, + "download-output-type": _ctx.downloadOutputType, + language: _ctx.language, + "report-formats-by-report-type": _ctx.reportFormatsByReportType, + onCreate: _cache[0] || (_cache[0] = function ($event) { + return _ctx.createReport(); + }), + onEdit: _cache[1] || (_cache[1] = function ($event) { + return _ctx.editReport($event); + }), + onDelete: _cache[2] || (_cache[2] = function ($event) { + return _ctx.deleteReport($event); + }), + onSendnow: _cache[3] || (_cache[3] = function ($event) { + return _ctx.sendReportNow($event); + }) + }, null, 8, ["content-title", "user-login", "login-module", "reports", "site-name", "segment-editor-activated", "saved-segments-by-id", "periods", "report-types", "download-output-type", "language", "report-formats-by-report-type"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.showReportsList]]), _ctx.showReportForm ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_AddReport, { + key: 0, + report: _ctx.report, + periods: _ctx.periods, + "param-periods": _ctx.paramPeriods, + "report-type-options": _ctx.reportTypeOptions, + "report-formats-by-report-type-options": _ctx.reportFormatsByReportTypeOptions, + "display-formats": _ctx.displayFormats, + "reports-by-category-by-report-type": _ctx.reportsByCategoryByReportType, + "allow-multiple-reports-by-report-type": _ctx.allowMultipleReportsByReportType, + "count-websites": _ctx.countWebsites, + "site-name": _ctx.decodedSiteName, + "selected-reports": _ctx.selectedReports, + "report-types": _ctx.reportTypes, + "segment-editor-activated": _ctx.segmentEditorActivated, + "saved-segments-by-id": _ctx.savedSegmentsById, + onToggleSelectedReport: _cache[4] || (_cache[4] = function ($event) { + return _ctx.toggleSelectedReport($event.reportType, $event.uniqueId); + }), + onChange: _cache[5] || (_cache[5] = function ($event) { + return _ctx.onChangeProperty($event.prop, $event.value); + }), + onSubmit: _cache[6] || (_cache[6] = function ($event) { + return _ctx.submitReport(); + }) + }, { + "report-parameters": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "report-parameters")]; + }), + _: 3 + }, 8, ["report", "periods", "param-periods", "report-type-options", "report-formats-by-report-type-options", "display-formats", "reports-by-category-by-report-type", "allow-multiple-reports-by-report-type", "count-websites", "site-name", "selected-reports", "report-types", "segment-editor-activated", "saved-segments-by-id"])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _hoisted_9])], 512); +} +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue?vue&type=template&id=49678e2a + +// EXTERNAL MODULE: external "CoreHome" +var external_CoreHome_ = __webpack_require__("19dc"); + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/AddReport/AddReport.vue?vue&type=template&id=3ae95bea + + +var AddReportvue_type_template_id_3ae95bea_hoisted_1 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + class: "clear" +}, null, -1); + +var AddReportvue_type_template_id_3ae95bea_hoisted_2 = { + key: 0 +}; +var AddReportvue_type_template_id_3ae95bea_hoisted_3 = ["innerHTML"]; +var AddReportvue_type_template_id_3ae95bea_hoisted_4 = { + id: "emailScheduleInlineHelp", + class: "inline-help-node" +}; + +var AddReportvue_type_template_id_3ae95bea_hoisted_5 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var AddReportvue_type_template_id_3ae95bea_hoisted_6 = { + id: "emailReportPeriodInlineHelp", + class: "inline-help-node" +}; + +var AddReportvue_type_template_id_3ae95bea_hoisted_7 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var AddReportvue_type_template_id_3ae95bea_hoisted_8 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var AddReportvue_type_template_id_3ae95bea_hoisted_9 = { + key: 0, + id: "reportHourHelpText", + class: "inline-help-node" +}; +var _hoisted_10 = ["textContent"]; +var _hoisted_11 = { + ref: "reportParameters" +}; +var _hoisted_12 = { + class: "email" +}; +var _hoisted_13 = { + class: "report_evolution_graph" +}; +var _hoisted_14 = { + class: "row evolution-graph-period" +}; +var _hoisted_15 = { + class: "col s12" +}; +var _hoisted_16 = { + for: "report_evolution_period_for_each" +}; +var _hoisted_17 = ["checked"]; +var _hoisted_18 = ["innerHTML"]; +var _hoisted_19 = { + class: "col s12" +}; +var _hoisted_20 = { + for: "report_evolution_period_for_prev" +}; +var _hoisted_21 = ["checked"]; +var _hoisted_22 = ["value"]; +var _hoisted_23 = { + class: "row" +}; +var _hoisted_24 = { + class: "col s12" +}; +var _hoisted_25 = { + class: "reportCategory" +}; +var _hoisted_26 = { + class: "listReports" +}; +var _hoisted_27 = ["name", "type", "id", "checked", "onChange"]; +var _hoisted_28 = { + key: 0, + class: "entityInlineHelp" +}; + +var _hoisted_29 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_30 = ["innerHTML"]; +function AddReportvue_type_template_id_3ae95bea_render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field"); + + var _component_SaveButton = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("SaveButton"); + + var _component_ContentBlock = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ContentBlock"); + + var _directive_form = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("form"); + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_ContentBlock, { + class: "entityAddContainer", + "content-title": _ctx.translate('ScheduledReports_CreateAndScheduleReport') + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [AddReportvue_type_template_id_3ae95bea_hoisted_1, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("form", { + id: "addEditReport", + onSubmit: _cache[13] || (_cache[13] = function ($event) { + return _ctx.$emit('submit'); + }) + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "text", + name: "website", + title: _ctx.translate('General_Website'), + disabled: true, + "model-value": _ctx.siteName + }, null, 8, ["title", "model-value"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "textarea", + name: "report_description", + title: _ctx.translate('General_Description'), + "model-value": _ctx.report.description, + "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) { + return _ctx.$emit('change', { + prop: 'description', + value: $event + }); + }), + "inline-help": _ctx.translate('ScheduledReports_DescriptionOnFirstPage') + }, null, 8, ["title", "model-value", "inline-help"])]), _ctx.segmentEditorActivated ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", AddReportvue_type_template_id_3ae95bea_hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_segment", + title: _ctx.translate('SegmentEditor_ChooseASegment'), + "model-value": _ctx.report.idsegment, + "onUpdate:modelValue": _cache[1] || (_cache[1] = function ($event) { + return _ctx.$emit('change', { + prop: 'idsegment', + value: $event + }); + }), + options: _ctx.savedSegmentsById + }, { + "inline-help": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [_ctx.segmentEditorActivated ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + key: 0, + id: "reportSegmentInlineHelp", + class: "inline-help-node", + innerHTML: _ctx.$sanitize(_ctx.reportSegmentInlineHelp) + }, null, 8, AddReportvue_type_template_id_3ae95bea_hoisted_3)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]; + }), + _: 1 + }, 8, ["title", "model-value", "options"])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_schedule", + "model-value": _ctx.report.period, + "onUpdate:modelValue": _cache[2] || (_cache[2] = function ($event) { + _ctx.$emit('change', { + prop: 'period', + value: $event + }); + + _ctx.$emit('change', { + prop: 'periodParam', + value: _ctx.report.period === 'never' ? null : _ctx.report.period + }); + }), + title: _ctx.translate('ScheduledReports_EmailSchedule'), + options: _ctx.periods + }, { + "inline-help": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", AddReportvue_type_template_id_3ae95bea_hoisted_4, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_WeeklyScheduleHelp')) + " ", 1), AddReportvue_type_template_id_3ae95bea_hoisted_5, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_MonthlyScheduleHelp')), 1)])]; + }), + _: 1 + }, 8, ["model-value", "title", "options"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_period", + "model-value": _ctx.report.periodParam, + "onUpdate:modelValue": _cache[3] || (_cache[3] = function ($event) { + return _ctx.$emit('change', { + prop: 'periodParam', + value: $event + }); + }), + options: _ctx.paramPeriods, + title: _ctx.translate('ScheduledReports_ReportPeriod') + }, { + "inline-help": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", AddReportvue_type_template_id_3ae95bea_hoisted_6, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ReportPeriodHelp')) + " ", 1), AddReportvue_type_template_id_3ae95bea_hoisted_7, AddReportvue_type_template_id_3ae95bea_hoisted_8, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ReportPeriodHelp2')), 1)])]; + }), + _: 1 + }, 8, ["model-value", "options", "title"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_hour", + "model-value": _ctx.report.hour, + "onUpdate:modelValue": _cache[4] || (_cache[4] = function ($event) { + return _ctx.$emit('change', { + prop: 'hour', + value: $event + }); + }), + title: _ctx.translate('ScheduledReports_ReportHour', 'X'), + options: _ctx.reportHours + }, { + "inline-help": Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [_ctx.timezoneOffset !== 0 && _ctx.timezoneOffset !== '0' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", AddReportvue_type_template_id_3ae95bea_hoisted_9, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + textContent: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.reportHourUtc) + }, null, 8, _hoisted_10)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]; + }), + _: 1 + }, 8, ["model-value", "title", "options"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_type", + disabled: _ctx.reportTypes.length === 1, + "model-value": _ctx.report.type, + "onUpdate:modelValue": _cache[5] || (_cache[5] = function ($event) { + return _ctx.$emit('change', { + prop: 'type', + value: $event + }); + }), + title: _ctx.translate('ScheduledReports_ReportType'), + options: _ctx.reportTypeOptions + }, null, 8, ["disabled", "model-value", "title", "options"])]), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.reportFormatsByReportTypeOptions, function (reportFormats, reportType) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + key: reportType + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "report_format", + title: _ctx.translate('ScheduledReports_ReportFormat'), + class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(reportType), + "model-value": _ctx.report["format".concat(reportType)], + "onUpdate:modelValue": function onUpdateModelValue($event) { + return _ctx.$emit('change', { + prop: "format".concat(reportType), + value: $event + }); + }, + options: reportFormats + }, null, 8, ["title", "class", "model-value", "onUpdate:modelValue", "options"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.report.type === reportType]])]); + }), 128)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_11, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "report-parameters")], 512), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_12, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "select", + name: "display_format", + "model-value": _ctx.report.displayFormat, + "onUpdate:modelValue": _cache[6] || (_cache[6] = function ($event) { + return _ctx.$emit('change', { + prop: 'displayFormat', + value: $event + }); + }), + options: _ctx.displayFormats, + introduction: _ctx.translate('ScheduledReports_AggregateReportsFormat') + }, null, 8, ["model-value", "options", "introduction"])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_13, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, { + uicontrol: "checkbox", + name: "report_evolution_graph", + title: _ctx.translate('ScheduledReports_EvolutionGraph', 5), + "model-value": _ctx.report.evolutionGraph, + "onUpdate:modelValue": _cache[7] || (_cache[7] = function ($event) { + return _ctx.$emit('change', { + prop: 'evolutionGraph', + value: $event + }); + }) + }, null, 8, ["title", "model-value"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], [2, '2', 3, '3'].indexOf(_ctx.report.displayFormat) !== -1]])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_14, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_15, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("label", _hoisted_16, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + id: "report_evolution_period_for_each", + name: "report_evolution_period_for", + type: "radio", + value: "each", + checked: _ctx.report.evolutionPeriodFor === 'each', + onChange: _cache[8] || (_cache[8] = function ($event) { + return _ctx.$emit('change', { + prop: 'evolutionPeriodFor', + value: $event.target.value + }); + }) + }, null, 40, _hoisted_17), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.$sanitize(_ctx.evolutionGraphsShowForEachInPeriod) + }, null, 8, _hoisted_18)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_19, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("label", _hoisted_20, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + id: "report_evolution_period_for_prev", + name: "report_evolution_period_for", + type: "radio", + value: "prev", + checked: _ctx.report.evolutionPeriodFor === 'prev', + onChange: _cache[9] || (_cache[9] = function ($event) { + return _ctx.$emit('change', { + prop: 'evolutionPeriodFor', + value: $event.target.value + }); + }) + }, null, 40, _hoisted_21), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_EvolutionGraphsShowForPreviousN', _ctx.frequencyPeriodPlural)) + ": ", 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + type: "number", + name: "report_evolution_period_n", + value: _ctx.report.evolutionPeriodN, + onKeydown: _cache[10] || (_cache[10] = function ($event) { + return _ctx.onEvolutionPeriodN($event); + }), + onChange: _cache[11] || (_cache[11] = function ($event) { + return _ctx.onEvolutionPeriodN($event); + }) + }, null, 40, _hoisted_22)])])])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], [1, '1', 2, '2', 3, '3'].indexOf(_ctx.report.displayFormat) !== -1]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.report.type === 'email' && _ctx.report.formatemail !== 'csv' && _ctx.report.formatemail !== 'tsv']]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_23, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h3", _hoisted_24, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ReportsIncluded')), 1)]), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.reportsByCategoryByReportTypeInColumns, function (reportColumns, reportType) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])((Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + name: "reportsList", + class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])("row ".concat(reportType)), + key: reportType + }, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(reportColumns, function (reportsByCategory, index) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + class: "col s12 m6", + key: index + }, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(reportsByCategory, function (reports, category) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + key: category + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h3", _hoisted_25, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(category), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", _hoisted_26, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(reports, function (report) { + var _ctx$selectedReports$; + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("li", { + key: report.uniqueId + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("label", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + name: "".concat(reportType, "Reports"), + type: _ctx.allowMultipleReportsByReportType[reportType] ? 'checkbox' : 'radio', + id: "".concat(reportType).concat(report.uniqueId), + checked: (_ctx$selectedReports$ = _ctx.selectedReports[reportType]) === null || _ctx$selectedReports$ === void 0 ? void 0 : _ctx$selectedReports$[report.uniqueId], + onChange: function onChange($event) { + return _ctx.$emit('toggleSelectedReport', { + reportType: reportType, + uniqueId: report.uniqueId + }); + } + }, null, 40, _hoisted_27), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.decode(report.name)), 1), report.uniqueId === 'MultiSites_getAll' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_28, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ReportIncludeNWebsites', _ctx.countWebsites)), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])]); + }), 128))]), _hoisted_29]); + }), 128))]); + }), 128))], 2)), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.report.type === reportType]]); + }), 128)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_SaveButton, { + value: _ctx.saveButtonTitle, + onConfirm: _cache[12] || (_cache[12] = function ($event) { + return _ctx.$emit('submit'); + }) + }, null, 8, ["value"]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + class: "entityCancel", + innerHTML: _ctx.$sanitize(_ctx.entityCancelText) + }, null, 8, _hoisted_30)], 544), [[_directive_form]])]; + }), + _: 3 + }, 8, ["content-title"]); +} +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/AddReport/AddReport.vue?vue&type=template&id=3ae95bea + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/utilities.ts +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +function adjustHourToTimezone(hour, difference) { + return "".concat((24 + parseFloat(hour) + difference) % 24); +} +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/AddReport/AddReport.vue?vue&type=script&lang=ts +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + +/* harmony default export */ var AddReportvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + report: { + type: Object, + required: true + }, + selectedReports: Object, + paramPeriods: { + type: Object, + required: true + }, + reportTypeOptions: { + type: Object, + required: true + }, + reportFormatsByReportTypeOptions: { + type: Object, + required: true + }, + displayFormats: { + type: Object, + required: true + }, + reportsByCategoryByReportType: { + type: Object, + required: true + }, + allowMultipleReportsByReportType: { + type: Object, + required: true + }, + countWebsites: { + type: Number, + required: true + }, + siteName: { + type: String, + required: true + }, + reportTypes: { + type: Object, + required: true + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true + } + }, + emits: ['submit', 'change', 'toggleSelectedReport'], + components: { + ContentBlock: external_CoreHome_["ContentBlock"], + Field: external_CorePluginsAdmin_["Field"], + SaveButton: external_CorePluginsAdmin_["SaveButton"] + }, + directives: { + Form: external_CorePluginsAdmin_["Form"] + }, + created: function created() { + this.onEvolutionPeriodN = Object(external_CoreHome_["debounce"])(this.onEvolutionPeriodN, 50); + }, + methods: { + onEvolutionPeriodN: function onEvolutionPeriodN(event) { + this.$emit('change', { + prop: 'evolutionPeriodN', + value: event.target.value + }); + }, + decode: function decode(s) { + // report names can be encoded (mainly goals) + return external_CoreHome_["Matomo"].helper.htmlDecode(s); + } + }, + setup: function setup(props, ctx) { + var reportParameters = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); + var angularControllerProxy = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({ + report: Object.assign({}, props.report) + }); + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])(function () { + return angularControllerProxy.report; + }, function (newValue) { + Object.keys(newValue).forEach(function (key) { + if (newValue[key] !== props.report[key]) { + ctx.emit('change', { + prop: key, + value: newValue[key] + }); + } + }); + }, { + deep: true + }); + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])(function () { + return props.report; + }, function (newValue) { + Object.assign(angularControllerProxy.report, newValue); + external_CoreHome_["Matomo"].helper.getAngularDependency('$timeout')(); + }, { + deep: true + }); + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["onMounted"])(function () { + var reportParametersElement = reportParameters.value; + external_CoreHome_["Matomo"].helper.compileAngularComponents(reportParametersElement, { + params: { + manageScheduledReport: angularControllerProxy + } + }); + external_CoreHome_["Matomo"].helper.compileVueEntryComponents(reportParametersElement, { + report: angularControllerProxy.report, + onChange: function onChange(prop, value) { + ctx.emit('change', { + prop: prop, + value: value + }); + } + }); + }); + return { + reportParameters: reportParameters + }; + }, + beforeUnmount: function beforeUnmount() { + var reportParameters = this.$refs.reportParameters; + external_CoreHome_["Matomo"].helper.destroyVueComponent(reportParameters); + }, + computed: { + reportsByCategoryByReportTypeInColumns: function reportsByCategoryByReportTypeInColumns() { + var reportsByCategoryByReportType = this.reportsByCategoryByReportType; + var inColumns = Object.entries(reportsByCategoryByReportType).map(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + key = _ref2[0], + reportsByCategory = _ref2[1]; + + var newColumnAfter = Math.floor((Object.keys(reportsByCategory).length + 1) / 2); + var column1 = {}; + var column2 = {}; + var currentColumn = column1; + Object.entries(reportsByCategory).forEach(function (_ref3) { + var _ref4 = _slicedToArray(_ref3, 2), + category = _ref4[0], + reports = _ref4[1]; + + currentColumn[category] = reports; + + if (Object.keys(currentColumn).length >= newColumnAfter) { + currentColumn = column2; + } + }); + return [key, [column1, column2]]; + }); + return Object.fromEntries(inColumns); + }, + entityCancelText: function entityCancelText() { + return Object(external_CoreHome_["translate"])('General_OrCancel', '<a class="entityCancelLink">', '</a>'); + }, + frequencyPeriodSingle: function frequencyPeriodSingle() { + if (!this.report || !this.report.period) { + return ''; + } + + var _window = window, + ReportPlugin = _window.ReportPlugin; + var translation = ReportPlugin.periodTranslations[this.report.period]; + + if (!translation) { + translation = ReportPlugin.periodTranslations.day; + } + + return translation.single; + }, + frequencyPeriodPlural: function frequencyPeriodPlural() { + if (!this.report || !this.report.period) { + return ''; + } + + var _window2 = window, + ReportPlugin = _window2.ReportPlugin; + var translation = ReportPlugin.periodTranslations[this.report.period]; + + if (!translation) { + translation = ReportPlugin.periodTranslations.day; + } + + return translation.plural; + }, + evolutionGraphsShowForEachInPeriod: function evolutionGraphsShowForEachInPeriod() { + return Object(external_CoreHome_["translate"])('ScheduledReports_EvolutionGraphsShowForEachInPeriod', '<strong>', '</strong>', this.frequencyPeriodSingle); + }, + reportSegmentInlineHelp: function reportSegmentInlineHelp() { + return Object(external_CoreHome_["translate"])('ScheduledReports_Segment_Help', '<a href="./" rel="noreferrer noopener" target="_blank">', '</a>', Object(external_CoreHome_["translate"])('SegmentEditor_DefaultAllVisits'), Object(external_CoreHome_["translate"])('SegmentEditor_AddNewSegment')); + }, + timezoneOffset: function timezoneOffset() { + return external_CoreHome_["Matomo"].timezoneOffset; + }, + timeZoneDifferenceInHours: function timeZoneDifferenceInHours() { + return external_CoreHome_["Matomo"].timezoneOffset / 3600; + }, + reportHours: function reportHours() { + var hours = []; + + for (var i = 0; i < 24; i += 1) { + if (this.timeZoneDifferenceInHours * 2 % 2 !== 0) { + hours.push({ + key: "".concat(i, ".5"), + value: "".concat(i, ":30") + }); + } else { + hours.push({ + key: "".concat(i), + value: "".concat(i) + }); + } + } + + return hours; + }, + reportHourUtc: function reportHourUtc() { + var reportHour = adjustHourToTimezone(this.report.hour, -this.timeZoneDifferenceInHours); + return Object(external_CoreHome_["translate"])('ScheduledReports_ReportHourWithUTC', [reportHour]); + }, + saveButtonTitle: function saveButtonTitle() { + var _window3 = window, + ReportPlugin = _window3.ReportPlugin; + var isCreate = this.report.idreport > 0; + return isCreate ? ReportPlugin.updateReportString : ReportPlugin.createReportString; + } + } +})); +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/AddReport/AddReport.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/AddReport/AddReport.vue + + + +AddReportvue_type_script_lang_ts.render = AddReportvue_type_template_id_3ae95bea_render + +/* harmony default export */ var AddReport = (AddReportvue_type_script_lang_ts); +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ListReports/ListReports.vue?vue&type=template&id=5753851b + +var ListReportsvue_type_template_id_5753851b_hoisted_1 = { + class: "first" +}; +var ListReportsvue_type_template_id_5753851b_hoisted_2 = { + key: 0 +}; +var ListReportsvue_type_template_id_5753851b_hoisted_3 = { + colspan: "7" +}; + +var ListReportsvue_type_template_id_5753851b_hoisted_4 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_5 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])("› "); + +var ListReportsvue_type_template_id_5753851b_hoisted_7 = ["href"]; + +var ListReportsvue_type_template_id_5753851b_hoisted_8 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_9 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_10 = { + key: 1 +}; +var ListReportsvue_type_template_id_5753851b_hoisted_11 = { + colspan: "7" +}; + +var ListReportsvue_type_template_id_5753851b_hoisted_12 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_13 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_14 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_15 = { + class: "first" +}; +var ListReportsvue_type_template_id_5753851b_hoisted_16 = { + key: 0, + class: "entityInlineHelp", + style: { + "font-size": "9pt" + } +}; +var ListReportsvue_type_template_id_5753851b_hoisted_17 = { + key: 0 +}; +var ListReportsvue_type_template_id_5753851b_hoisted_18 = { + key: 1 +}; +var ListReportsvue_type_template_id_5753851b_hoisted_19 = { + key: 0 +}; +var ListReportsvue_type_template_id_5753851b_hoisted_20 = { + key: 0 +}; + +var ListReportsvue_type_template_id_5753851b_hoisted_21 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_22 = ["onClick"]; +var ListReportsvue_type_template_id_5753851b_hoisted_23 = ["src"]; +var ListReportsvue_type_template_id_5753851b_hoisted_24 = ["id", "action"]; +var ListReportsvue_type_template_id_5753851b_hoisted_25 = ["value"]; + +var ListReportsvue_type_template_id_5753851b_hoisted_26 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + type: "hidden", + name: "force_api_session", + value: "1" +}, null, -1); + +var ListReportsvue_type_template_id_5753851b_hoisted_27 = ["onClick", "id"]; +var ListReportsvue_type_template_id_5753851b_hoisted_28 = ["src"]; +var ListReportsvue_type_template_id_5753851b_hoisted_29 = { + style: { + "text-align": "center", + "padding-top": "2px" + } +}; +var ListReportsvue_type_template_id_5753851b_hoisted_30 = ["onClick", "title"]; + +var _hoisted_31 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-edit" +}, null, -1); + +var _hoisted_32 = [_hoisted_31]; +var _hoisted_33 = { + style: { + "text-align": "center", + "padding-top": "2px" + } +}; +var _hoisted_34 = ["onClick", "title"]; + +var _hoisted_35 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-delete" +}, null, -1); + +var _hoisted_36 = [_hoisted_35]; +var _hoisted_37 = { + class: "tableActionBar" +}; + +var _hoisted_38 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "icon-add" +}, null, -1); + +function ListReportsvue_type_template_id_5753851b_render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_ContentBlock = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ContentBlock"); + + var _directive_content_table = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-table"); + + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_ContentBlock, { + id: "entityEditContainer", + class: "entityTableContainer", + "help-url": "https://matomo.org/docs/email-reports/", + feature: 'true', + "content-title": _ctx.contentTitle + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + var _ctx$reports; + + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("table", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("thead", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tr", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", ListReportsvue_type_template_id_5753851b_hoisted_1, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Description')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_EmailSchedule')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ReportFormat')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_SendReportTo')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Download')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Edit')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Delete')), 1)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tbody", null, [_ctx.userLogin === 'anonymous' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", ListReportsvue_type_template_id_5753851b_hoisted_2, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", ListReportsvue_type_template_id_5753851b_hoisted_3, [ListReportsvue_type_template_id_5753851b_hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_MustBeLoggedIn')) + " ", 1), ListReportsvue_type_template_id_5753851b_hoisted_5, ListReportsvue_type_template_id_5753851b_hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + href: "index.php?module=".concat(_ctx.loginModule) + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Login_LogIn')), 9, ListReportsvue_type_template_id_5753851b_hoisted_7), ListReportsvue_type_template_id_5753851b_hoisted_8, ListReportsvue_type_template_id_5753851b_hoisted_9])])) : !((_ctx$reports = _ctx.reports) !== null && _ctx$reports !== void 0 && _ctx$reports.length) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", ListReportsvue_type_template_id_5753851b_hoisted_10, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", ListReportsvue_type_template_id_5753851b_hoisted_11, [ListReportsvue_type_template_id_5753851b_hoisted_12, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_ThereIsNoReportToManage', _ctx.siteName)) + ". ", 1), ListReportsvue_type_template_id_5753851b_hoisted_13, ListReportsvue_type_template_id_5753851b_hoisted_14])])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.decodedReports, function (report) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", { + key: report.idreport + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", ListReportsvue_type_template_id_5753851b_hoisted_15, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(report.description) + " ", 1), _ctx.segmentEditorActivated && report.idsegment ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", ListReportsvue_type_template_id_5753851b_hoisted_16, [_ctx.savedSegmentsById[report.idsegment] ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ListReportsvue_type_template_id_5753851b_hoisted_17, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.savedSegmentsById[report.idsegment]), 1)) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ListReportsvue_type_template_id_5753851b_hoisted_18, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_SegmentDeleted')), 1))])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.periods[report.period]), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [report.format ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ListReportsvue_type_template_id_5753851b_hoisted_19, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(report.format.toUpperCase()), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [report.recipients.length === 0 ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", ListReportsvue_type_template_id_5753851b_hoisted_20, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_NoRecipients')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(report.recipients, function (recipient, index) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", { + key: index + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(recipient) + " ", 1), ListReportsvue_type_template_id_5753851b_hoisted_21]); + }), 128)), report.recipients.length !== 0 ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", { + key: 1, + href: "#", + name: "linkSendNow", + class: "link_but withIcon", + style: { + "margin-top": "3px" + }, + onClick: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withModifiers"])(function ($event) { + return _ctx.$emit('sendnow', report.idreport); + }, ["prevent"]) + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("img", { + border: "0", + src: _ctx.reportTypes[report.type] + }, null, 8, ListReportsvue_type_template_id_5753851b_hoisted_23), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_SendReportNow')), 1)], 8, ListReportsvue_type_template_id_5753851b_hoisted_22)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("form", { + method: "POST", + target: "_blank", + id: "downloadReportForm_".concat(report.idreport), + action: _ctx.linkTo({ + module: 'API', + segment: null, + method: 'ScheduledReports.generateReport', + idReport: report.idreport, + outputType: _ctx.downloadOutputType, + language: _ctx.language, + format: ['html', 'csv', 'tsv'].indexOf(report.format) !== -1 ? report.format : 'original' + }) + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("input", { + type: "hidden", + name: "token_auth", + value: _ctx.token_auth + }, null, 8, ListReportsvue_type_template_id_5753851b_hoisted_25), ListReportsvue_type_template_id_5753851b_hoisted_26], 8, ListReportsvue_type_template_id_5753851b_hoisted_24), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("a", { + href: "", + rel: "noreferrer noopener", + name: "linkDownloadReport", + class: "link_but withIcon", + onClick: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withModifiers"])(function ($event) { + return _ctx.displayReport(report.idreport); + }, ["prevent"]), + id: report.idreport + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("img", { + border: "0", + width: 16, + height: 16, + src: _ctx.reportFormatsByReportType[report.type][report.format] + }, null, 8, ListReportsvue_type_template_id_5753851b_hoisted_28), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Download')), 1)], 8, ListReportsvue_type_template_id_5753851b_hoisted_27)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", ListReportsvue_type_template_id_5753851b_hoisted_29, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", { + class: "table-action", + onClick: function onClick($event) { + return _ctx.$emit('edit', report.idreport); + }, + title: _ctx.translate('General_Edit') + }, _hoisted_32, 8, ListReportsvue_type_template_id_5753851b_hoisted_30)]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", _hoisted_33, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", { + class: "table-action", + onClick: function onClick($event) { + return _ctx.$emit('delete', report.idreport); + }, + title: _ctx.translate('General_Delete') + }, _hoisted_36, 8, _hoisted_34)])]); + }), 128))])], 512), [[_directive_content_table]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", _hoisted_37, [_ctx.userLogin !== 'anonymous' ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("button", { + key: 0, + id: "add-report", + onClick: _cache[0] || (_cache[0] = function ($event) { + return _ctx.$emit('create'); + }) + }, [_hoisted_38, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('ScheduledReports_CreateAndScheduleReport')), 1)])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)])]; + }), + _: 1 + }, 8, ["content-title"]); +} +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ListReports/ListReports.vue?vue&type=template&id=5753851b + +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ListReports/ListReports.vue?vue&type=script&lang=ts + + +/* harmony default export */ var ListReportsvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + contentTitle: { + type: String, + required: true + }, + userLogin: { + type: String, + required: true + }, + loginModule: { + type: String, + required: true + }, + reports: { + type: Array, + required: true + }, + siteName: { + type: String, + required: true + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true + }, + downloadOutputType: { + type: Number, + required: true + }, + language: { + type: String, + required: true + }, + reportFormatsByReportType: { + type: Object, + required: true + }, + reportTypes: { + type: Object, + required: true + } + }, + components: { + ContentBlock: external_CoreHome_["ContentBlock"] + }, + directives: { + ContentTable: external_CoreHome_["ContentTable"] + }, + emits: ['create', 'edit', 'delete', 'sendnow'], + methods: { + linkTo: function linkTo(params) { + return "?".concat(external_CoreHome_["MatomoUrl"].stringify(Object.assign(Object.assign({}, external_CoreHome_["MatomoUrl"].urlParsed.value), params))); + }, + displayReport: function displayReport(reportId) { + $("#downloadReportForm_".concat(reportId)).submit(); + } + }, + computed: { + token_auth: function token_auth() { + return external_CoreHome_["Matomo"].token_auth; + }, + decodedReports: function decodedReports() { + return this.reports.map(function (r) { + return Object.assign(Object.assign({}, r), {}, { + description: external_CoreHome_["Matomo"].helper.htmlDecode(r.description) + }); + }); + } + } +})); +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ListReports/ListReports.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ListReports/ListReports.vue + + + +ListReportsvue_type_script_lang_ts.render = ListReportsvue_type_template_id_5753851b_render + +/* harmony default export */ var ListReports = (ListReportsvue_type_script_lang_ts); +// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue?vue&type=script&lang=ts + + + + + + + +function scrollToTop() { + external_CoreHome_["Matomo"].helper.lazyScrollTo('.emailReports', 200); +} + +function updateParameters(reportType, report) { + var _window$updateReportP; + + if ((_window$updateReportP = window.updateReportParametersFunctions) !== null && _window$updateReportP !== void 0 && _window$updateReportP[reportType]) { + window.updateReportParametersFunctions[reportType](report); + } +} + +function resetParameters(reportType, report) { + var _window$resetReportPa; + + if ((_window$resetReportPa = window.resetReportParametersFunctions) !== null && _window$resetReportPa !== void 0 && _window$resetReportPa[reportType]) { + window.resetReportParametersFunctions[reportType](report); + } +} + +window.resetReportParametersFunctions = window.resetReportParametersFunctions || {}; +window.updateReportParametersFunctions = window.updateReportParametersFunctions || {}; +window.getReportParametersFunctions = window.getReportParametersFunctions || {}; +var _window = window, + ManageScheduledReportvue_type_script_lang_ts_$ = _window.$; +var ManageScheduledReportvue_type_script_lang_ts_timeZoneDifferenceInHours = external_CoreHome_["Matomo"].timezoneOffset / 3600; +/* harmony default export */ var ManageScheduledReportvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + props: { + contentTitle: { + type: String, + required: true + }, + userLogin: { + type: String, + required: true + }, + loginModule: { + type: String, + required: true + }, + reports: { + type: Array, + required: true + }, + siteName: { + type: String, + required: true + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true + }, + downloadOutputType: { + type: Number, + required: true + }, + language: { + type: String, + required: true + }, + reportFormatsByReportType: { + type: Object, + required: true + }, + paramPeriods: { + type: Object, + required: true + }, + reportTypeOptions: { + type: Object, + required: true + }, + reportFormatsByReportTypeOptions: { + type: Object, + required: true + }, + displayFormats: { + type: Object, + required: true + }, + reportsByCategoryByReportType: { + type: Object, + required: true + }, + allowMultipleReportsByReportType: { + type: Object, + required: true + }, + countWebsites: { + type: Number, + required: true + }, + reportTypes: { + type: Object, + required: true + } + }, + components: { + AddReport: AddReport, + ListReports: ListReports + }, + directives: { + ContentTable: external_CoreHome_["ContentTable"], + Form: external_CorePluginsAdmin_["Form"] + }, + mounted: function mounted() { + var _this = this; + + ManageScheduledReportvue_type_script_lang_ts_$(this.$refs.root).on('click', 'a.entityCancelLink', function () { + _this.showListOfReports(); + }); + }, + data: function data() { + return { + showReportsList: true, + report: {}, + selectedReports: {} + }; + }, + methods: { + sendReportNow: function sendReportNow(idReport) { + var _this2 = this; + + scrollToTop(); + external_CoreHome_["AjaxHelper"].post({ + method: 'ScheduledReports.sendReport' + }, { + idReport: idReport, + force: true + }).then(function () { + _this2.fadeInOutSuccessMessage(_this2.$refs.reportSentSuccess, Object(external_CoreHome_["translate"])('ScheduledReports_ReportSent'), false); + }); + }, + formSetEditReport: function formSetEditReport(idReport) { + var _this3 = this; + + var _window2 = window, + ReportPlugin = _window2.ReportPlugin; + var report = { + idreport: idReport, + type: ReportPlugin.defaultReportType, + format: ReportPlugin.defaultReportFormat, + description: '', + period: ReportPlugin.defaultPeriod, + hour: ReportPlugin.defaultHour, + reports: [], + idsegment: '', + evolutionPeriodFor: 'prev', + evolutionPeriodN: ReportPlugin.defaultEvolutionPeriodN, + periodParam: ReportPlugin.defaultPeriod + }; + + if (idReport > 0) { + report = ReportPlugin.reportList[idReport]; + updateParameters(report.type, report); + } else { + resetParameters(report.type, report); + } + + report.hour = adjustHourToTimezone(report.hour, ManageScheduledReportvue_type_script_lang_ts_timeZoneDifferenceInHours); + this.selectedReports = {}; + Object.values(report.reports).forEach(function (reportId) { + _this3.selectedReports[report.type] = _this3.selectedReports[report.type] || {}; + _this3.selectedReports[report.type][reportId] = true; + }); + report["format".concat(report.type)] = report.format; + + if (!report.idsegment) { + report.idsegment = ''; + } + + this.report = report; + this.report.description = external_CoreHome_["Matomo"].helper.htmlDecode(report.description); + }, + fadeInOutSuccessMessage: function fadeInOutSuccessMessage(selector, message) { + var reload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; + external_CoreHome_["NotificationsStore"].show({ + message: message, + placeat: selector, + context: 'success', + noclear: true, + type: 'toast', + style: { + display: 'inline-block', + marginTop: '10px' + }, + id: 'scheduledReportSuccess' + }); + + if (reload) { + external_CoreHome_["Matomo"].helper.refreshAfter(2); + } + }, + changedReportType: function changedReportType() { + resetParameters(this.report.type, this.report); + }, + deleteReport: function deleteReport(idReport) { + external_CoreHome_["Matomo"].helper.modalConfirm('#confirm', { + yes: function yes() { + external_CoreHome_["AjaxHelper"].post({ + method: 'ScheduledReports.deleteReport' + }, { + idReport: idReport + }, { + redirectOnSuccess: true + }); + } + }); + }, + showListOfReports: function showListOfReports(shouldScrollToTop) { + this.showReportsList = true; + external_CoreHome_["Matomo"].helper.hideAjaxError(); + + if (typeof shouldScrollToTop === 'undefined' || shouldScrollToTop) { + scrollToTop(); + } + }, + createReport: function createReport() { + var _this4 = this; + + this.showReportsList = false; // in nextTick so global report function records get manipulated before individual + // entries are used + + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(function () { + _this4.formSetEditReport(0); + }); + }, + editReport: function editReport(reportId) { + var _this5 = this; + + this.showReportsList = false; // in nextTick so global report function records get manipulated before individual + // entries are used + + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(function () { + _this5.formSetEditReport(reportId); + }); + }, + submitReport: function submitReport() { + var _this6 = this; + + var apiParameters = { + idReport: this.report.idreport, + description: this.report.description, + idSegment: this.report.idsegment, + reportType: this.report.type, + reportFormat: this.report["format".concat(this.report.type)], + periodParam: this.report.periodParam, + evolutionPeriodFor: this.report.evolutionPeriodFor + }; + + if (apiParameters.evolutionPeriodFor !== 'each') { + apiParameters.evolutionPeriodN = this.report.evolutionPeriodN; + } + + var period = this.report.period; + var hour = adjustHourToTimezone(this.report.hour, -ManageScheduledReportvue_type_script_lang_ts_timeZoneDifferenceInHours); + var selectedReports = this.selectedReports[apiParameters.reportType] || {}; + var reports = Object.keys(selectedReports).filter(function (name) { + return _this6.selectedReports[apiParameters.reportType][name]; + }); + + if (reports.length > 0) { + apiParameters.reports = reports; + } + + var reportParams = window.getReportParametersFunctions[this.report.type](this.report); + apiParameters.parameters = reportParams; + var isCreate = this.report.idreport > 0; + external_CoreHome_["AjaxHelper"].post({ + method: isCreate ? 'ScheduledReports.updateReport' : 'ScheduledReports.addReport', + period: period, + hour: hour + }, apiParameters).then(function () { + _this6.fadeInOutSuccessMessage(_this6.$refs.reportUpdatedSuccess, Object(external_CoreHome_["translate"])('ScheduledReports_ReportUpdated')); + }); + return false; + }, + onChangeProperty: function onChangeProperty(propName, value) { + this.report[propName] = value; + + if (propName === 'type') { + this.changedReportType(); + } + }, + toggleSelectedReport: function toggleSelectedReport(reportType, uniqueId) { + this.selectedReports[reportType] = this.selectedReports[reportType] || {}; + this.selectedReports[reportType][uniqueId] = !this.selectedReports[reportType][uniqueId]; + } + }, + computed: { + showReportForm: function showReportForm() { + return !this.showReportsList; + }, + decodedSiteName: function decodedSiteName() { + return external_CoreHome_["Matomo"].helper.htmlDecode(this.siteName); + } + } +})); +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue?vue&type=script&lang=ts + +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue + + + +ManageScheduledReportvue_type_script_lang_ts.render = ManageScheduledReportvue_type_template_id_49678e2a_render + +/* harmony default export */ var ManageScheduledReport = (ManageScheduledReportvue_type_script_lang_ts); +// CONCATENATED MODULE: ./plugins/ScheduledReports/vue/src/index.ts +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + + + +// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js + + + + +/***/ }) + +/******/ }); +}); +//# sourceMappingURL=ScheduledReports.umd.js.map
\ No newline at end of file diff --git a/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.min.js b/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.min.js new file mode 100644 index 0000000000..351616fdb5 --- /dev/null +++ b/plugins/ScheduledReports/vue/dist/ScheduledReports.umd.min.js @@ -0,0 +1,20 @@ +(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):"function"===typeof define&&define.amd?define(["CoreHome",,"CorePluginsAdmin"],t):"object"===typeof exports?exports["ScheduledReports"]=t(require("CoreHome"),require("vue"),require("CorePluginsAdmin")):e["ScheduledReports"]=t(e["CoreHome"],e["Vue"],e["CorePluginsAdmin"])})("undefined"!==typeof self?self:this,(function(e,t,r){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="plugins/ScheduledReports/vue/dist/",r(r.s="fae3")}({"19dc":function(t,r){t.exports=e},"8bbf":function(e,r){e.exports=t},a5a2:function(e,t){e.exports=r},fae3:function(e,t,r){"use strict";if(r.r(t),r.d(t,"ReportParameters",(function(){return d})),r.d(t,"ManageScheduledReport",(function(){return ot})),"undefined"!==typeof window){var o=window.document.currentScript,n=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);n&&(r.p=n[1])}var l=r("8bbf"),i={key:0}; +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */function c(e,t,r,o,n,c){var a=Object(l["resolveComponent"])("Field");return e.report?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",i,[Object(l["createElementVNode"])("div",null,[Object(l["withDirectives"])(Object(l["createVNode"])(a,{uicontrol:"checkbox",name:"report_email_me",introduction:e.translate("ScheduledReports_SendReportTo"),"model-value":e.report.emailMe,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.$emit("change","emailMe",t)}),title:"".concat(e.translate("ScheduledReports_SentToMe")," (").concat(e.currentUserEmail,")")},null,8,["introduction","model-value","title"]),[[l["vShow"],"email"===e.report.type]])]),Object(l["createElementVNode"])("div",null,[Object(l["withDirectives"])(Object(l["createVNode"])(a,{uicontrol:"textarea","var-type":"array","model-value":e.report.additionalEmails,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.$emit("change","additionalEmails",t)}),title:e.translate("ScheduledReports_AlsoSendReportToTheseEmails")},null,8,["model-value","title"]),[[l["vShow"],"email"===e.report.type]])])])):Object(l["createCommentVNode"])("",!0)}var a=r("a5a2"),p=Object(l["defineComponent"])({props:{report:{type:Object,required:!0},reportType:{type:String,required:!0},defaultDisplayFormat:{type:Number,required:!0},defaultEmailMe:{type:Boolean,required:!0},defaultEvolutionGraph:{type:Boolean,required:!0},currentUserEmail:{type:String,required:!0}},emits:["change"],components:{Field:a["Field"]},setup:function(e){var t=window,r=t.resetReportParametersFunctions,o=t.updateReportParametersFunctions,n=t.getReportParametersFunctions;r[e.reportType]||(r[e.reportType]=function(t){t.displayFormat=e.defaultDisplayFormat,t.emailMe=e.defaultEmailMe,t.evolutionGraph=e.defaultEvolutionGraph,t.additionalEmails=[]}),o[e.reportType]||(o[e.reportType]=function(e){null!==e&&void 0!==e&&e.parameters&&["displayFormat","emailMe","evolutionGraph","additionalEmails"].forEach((function(t){t in e.parameters&&(e[t]=e.parameters[t])}))}),n[e.reportType]||(n[e.reportType]=function(e){return{displayFormat:e.displayFormat,emailMe:e.emailMe,evolutionGraph:e.evolutionGraph,additionalEmails:e.additionalEmails||[]}})}});p.render=c;var d=p,s={class:"emailReports",ref:"root"},u={ref:"reportSentSuccess"},m={ref:"reportUpdatedSuccess"},b=Object(l["createElementVNode"])("div",{id:"ajaxError",style:{display:"none"}},null,-1),O={id:"ajaxLoadingDiv",style:{display:"none"}},y={class:"loadingPiwik"},j=["alt"],h={class:"loadingSegment"},f=Object(l["createElementVNode"])("a",{id:"bottom"},null,-1);function v(e,t,r,o,n,i){var c=Object(l["resolveComponent"])("ListReports"),a=Object(l["resolveComponent"])("AddReport");return Object(l["openBlock"])(),Object(l["createElementBlock"])("div",s,[Object(l["createElementVNode"])("div",u,null,512),Object(l["createElementVNode"])("div",m,null,512),Object(l["createElementVNode"])("div",null,[b,Object(l["createElementVNode"])("div",O,[Object(l["createElementVNode"])("div",y,[Object(l["createElementVNode"])("img",{src:"plugins/Morpheus/images/loading-blue.gif",alt:e.translate("General_LoadingData")},null,8,j),Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("General_LoadingData")),1)]),Object(l["createElementVNode"])("div",h,Object(l["toDisplayString"])(e.translate("SegmentEditor_LoadingSegmentedDataMayTakeSomeTime")),1)]),Object(l["withDirectives"])(Object(l["createVNode"])(c,{"content-title":e.contentTitle,"user-login":e.userLogin,"login-module":e.loginModule,reports:e.reports,"site-name":e.decodedSiteName,"segment-editor-activated":e.segmentEditorActivated,"saved-segments-by-id":e.savedSegmentsById,periods:e.periods,"report-types":e.reportTypes,"download-output-type":e.downloadOutputType,language:e.language,"report-formats-by-report-type":e.reportFormatsByReportType,onCreate:t[0]||(t[0]=function(t){return e.createReport()}),onEdit:t[1]||(t[1]=function(t){return e.editReport(t)}),onDelete:t[2]||(t[2]=function(t){return e.deleteReport(t)}),onSendnow:t[3]||(t[3]=function(t){return e.sendReportNow(t)})},null,8,["content-title","user-login","login-module","reports","site-name","segment-editor-activated","saved-segments-by-id","periods","report-types","download-output-type","language","report-formats-by-report-type"]),[[l["vShow"],e.showReportsList]]),e.showReportForm?(Object(l["openBlock"])(),Object(l["createBlock"])(a,{key:0,report:e.report,periods:e.periods,"param-periods":e.paramPeriods,"report-type-options":e.reportTypeOptions,"report-formats-by-report-type-options":e.reportFormatsByReportTypeOptions,"display-formats":e.displayFormats,"reports-by-category-by-report-type":e.reportsByCategoryByReportType,"allow-multiple-reports-by-report-type":e.allowMultipleReportsByReportType,"count-websites":e.countWebsites,"site-name":e.decodedSiteName,"selected-reports":e.selectedReports,"report-types":e.reportTypes,"segment-editor-activated":e.segmentEditorActivated,"saved-segments-by-id":e.savedSegmentsById,onToggleSelectedReport:t[4]||(t[4]=function(t){return e.toggleSelectedReport(t.reportType,t.uniqueId)}),onChange:t[5]||(t[5]=function(t){return e.onChangeProperty(t.prop,t.value)}),onSubmit:t[6]||(t[6]=function(t){return e.submitReport()})},{"report-parameters":Object(l["withCtx"])((function(){return[Object(l["renderSlot"])(e.$slots,"report-parameters")]})),_:3},8,["report","periods","param-periods","report-type-options","report-formats-by-report-type-options","display-formats","reports-by-category-by-report-type","allow-multiple-reports-by-report-type","count-websites","site-name","selected-reports","report-types","segment-editor-activated","saved-segments-by-id"])):Object(l["createCommentVNode"])("",!0),f])],512)}var g=r("19dc"),S=Object(l["createElementVNode"])("div",{class:"clear"},null,-1),R={key:0},E=["innerHTML"],N={id:"emailScheduleInlineHelp",class:"inline-help-node"},V=Object(l["createElementVNode"])("br",null,null,-1),k={id:"emailReportPeriodInlineHelp",class:"inline-help-node"},w=Object(l["createElementVNode"])("br",null,null,-1),_=Object(l["createElementVNode"])("br",null,null,-1),B={key:0,id:"reportHourHelpText",class:"inline-help-node"},T=["textContent"],C={ref:"reportParameters"},P={class:"email"},F={class:"report_evolution_graph"},D={class:"row evolution-graph-period"},x={class:"col s12"},q={for:"report_evolution_period_for_each"},M=["checked"],I=["innerHTML"],A={class:"col s12"},L={for:"report_evolution_period_for_prev"},H=["checked"],G=["value"],U={class:"row"},z={class:"col s12"},W={class:"reportCategory"},Z={class:"listReports"},K=["name","type","id","checked","onChange"],X={key:0,class:"entityInlineHelp"},J=Object(l["createElementVNode"])("br",null,null,-1),Q=["innerHTML"];function Y(e,t,r,o,n,i){var c=Object(l["resolveComponent"])("Field"),a=Object(l["resolveComponent"])("SaveButton"),p=Object(l["resolveComponent"])("ContentBlock"),d=Object(l["resolveDirective"])("form");return Object(l["openBlock"])(),Object(l["createBlock"])(p,{class:"entityAddContainer","content-title":e.translate("ScheduledReports_CreateAndScheduleReport")},{default:Object(l["withCtx"])((function(){return[S,Object(l["withDirectives"])(Object(l["createElementVNode"])("form",{id:"addEditReport",onSubmit:t[13]||(t[13]=function(t){return e.$emit("submit")})},[Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"text",name:"website",title:e.translate("General_Website"),disabled:!0,"model-value":e.siteName},null,8,["title","model-value"])]),Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"textarea",name:"report_description",title:e.translate("General_Description"),"model-value":e.report.description,"onUpdate:modelValue":t[0]||(t[0]=function(t){return e.$emit("change",{prop:"description",value:t})}),"inline-help":e.translate("ScheduledReports_DescriptionOnFirstPage")},null,8,["title","model-value","inline-help"])]),e.segmentEditorActivated?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",R,[Object(l["createVNode"])(c,{uicontrol:"select",name:"report_segment",title:e.translate("SegmentEditor_ChooseASegment"),"model-value":e.report.idsegment,"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.$emit("change",{prop:"idsegment",value:t})}),options:e.savedSegmentsById},{"inline-help":Object(l["withCtx"])((function(){return[e.segmentEditorActivated?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",{key:0,id:"reportSegmentInlineHelp",class:"inline-help-node",innerHTML:e.$sanitize(e.reportSegmentInlineHelp)},null,8,E)):Object(l["createCommentVNode"])("",!0)]})),_:1},8,["title","model-value","options"])])):Object(l["createCommentVNode"])("",!0),Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"select",name:"report_schedule","model-value":e.report.period,"onUpdate:modelValue":t[2]||(t[2]=function(t){e.$emit("change",{prop:"period",value:t}),e.$emit("change",{prop:"periodParam",value:"never"===e.report.period?null:e.report.period})}),title:e.translate("ScheduledReports_EmailSchedule"),options:e.periods},{"inline-help":Object(l["withCtx"])((function(){return[Object(l["createElementVNode"])("div",N,[Object(l["createTextVNode"])(Object(l["toDisplayString"])(e.translate("ScheduledReports_WeeklyScheduleHelp"))+" ",1),V,Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_MonthlyScheduleHelp")),1)])]})),_:1},8,["model-value","title","options"])]),Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"select",name:"report_period","model-value":e.report.periodParam,"onUpdate:modelValue":t[3]||(t[3]=function(t){return e.$emit("change",{prop:"periodParam",value:t})}),options:e.paramPeriods,title:e.translate("ScheduledReports_ReportPeriod")},{"inline-help":Object(l["withCtx"])((function(){return[Object(l["createElementVNode"])("div",k,[Object(l["createTextVNode"])(Object(l["toDisplayString"])(e.translate("ScheduledReports_ReportPeriodHelp"))+" ",1),w,_,Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_ReportPeriodHelp2")),1)])]})),_:1},8,["model-value","options","title"])]),Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"select",name:"report_hour","model-value":e.report.hour,"onUpdate:modelValue":t[4]||(t[4]=function(t){return e.$emit("change",{prop:"hour",value:t})}),title:e.translate("ScheduledReports_ReportHour","X"),options:e.reportHours},{"inline-help":Object(l["withCtx"])((function(){return[0!==e.timezoneOffset&&"0"!==e.timezoneOffset?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",B,[Object(l["createElementVNode"])("span",{textContent:Object(l["toDisplayString"])(e.reportHourUtc)},null,8,T)])):Object(l["createCommentVNode"])("",!0)]})),_:1},8,["model-value","title","options"])]),Object(l["createElementVNode"])("div",null,[Object(l["createVNode"])(c,{uicontrol:"select",name:"report_type",disabled:1===e.reportTypes.length,"model-value":e.report.type,"onUpdate:modelValue":t[5]||(t[5]=function(t){return e.$emit("change",{prop:"type",value:t})}),title:e.translate("ScheduledReports_ReportType"),options:e.reportTypeOptions},null,8,["disabled","model-value","title","options"])]),(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(e.reportFormatsByReportTypeOptions,(function(t,r){return Object(l["openBlock"])(),Object(l["createElementBlock"])("div",{key:r},[Object(l["withDirectives"])(Object(l["createVNode"])(c,{uicontrol:"select",name:"report_format",title:e.translate("ScheduledReports_ReportFormat"),class:Object(l["normalizeClass"])(r),"model-value":e.report["format".concat(r)],"onUpdate:modelValue":function(t){return e.$emit("change",{prop:"format".concat(r),value:t})},options:t},null,8,["title","class","model-value","onUpdate:modelValue","options"]),[[l["vShow"],e.report.type===r]])])})),128)),Object(l["createElementVNode"])("div",C,[Object(l["renderSlot"])(e.$slots,"report-parameters")],512),Object(l["withDirectives"])(Object(l["createElementVNode"])("div",null,[Object(l["createElementVNode"])("div",P,[Object(l["createVNode"])(c,{uicontrol:"select",name:"display_format","model-value":e.report.displayFormat,"onUpdate:modelValue":t[6]||(t[6]=function(t){return e.$emit("change",{prop:"displayFormat",value:t})}),options:e.displayFormats,introduction:e.translate("ScheduledReports_AggregateReportsFormat")},null,8,["model-value","options","introduction"])]),Object(l["createElementVNode"])("div",F,[Object(l["withDirectives"])(Object(l["createVNode"])(c,{uicontrol:"checkbox",name:"report_evolution_graph",title:e.translate("ScheduledReports_EvolutionGraph",5),"model-value":e.report.evolutionGraph,"onUpdate:modelValue":t[7]||(t[7]=function(t){return e.$emit("change",{prop:"evolutionGraph",value:t})})},null,8,["title","model-value"]),[[l["vShow"],-1!==[2,"2",3,"3"].indexOf(e.report.displayFormat)]])]),Object(l["withDirectives"])(Object(l["createElementVNode"])("div",D,[Object(l["createElementVNode"])("div",x,[Object(l["createElementVNode"])("label",q,[Object(l["createElementVNode"])("input",{id:"report_evolution_period_for_each",name:"report_evolution_period_for",type:"radio",value:"each",checked:"each"===e.report.evolutionPeriodFor,onChange:t[8]||(t[8]=function(t){return e.$emit("change",{prop:"evolutionPeriodFor",value:t.target.value})})},null,40,M),Object(l["createElementVNode"])("span",{innerHTML:e.$sanitize(e.evolutionGraphsShowForEachInPeriod)},null,8,I)])]),Object(l["createElementVNode"])("div",A,[Object(l["createElementVNode"])("label",L,[Object(l["createElementVNode"])("input",{id:"report_evolution_period_for_prev",name:"report_evolution_period_for",type:"radio",value:"prev",checked:"prev"===e.report.evolutionPeriodFor,onChange:t[9]||(t[9]=function(t){return e.$emit("change",{prop:"evolutionPeriodFor",value:t.target.value})})},null,40,H),Object(l["createElementVNode"])("span",null,[Object(l["createTextVNode"])(Object(l["toDisplayString"])(e.translate("ScheduledReports_EvolutionGraphsShowForPreviousN",e.frequencyPeriodPlural))+": ",1),Object(l["createElementVNode"])("input",{type:"number",name:"report_evolution_period_n",value:e.report.evolutionPeriodN,onKeydown:t[10]||(t[10]=function(t){return e.onEvolutionPeriodN(t)}),onChange:t[11]||(t[11]=function(t){return e.onEvolutionPeriodN(t)})},null,40,G)])])])],512),[[l["vShow"],-1!==[1,"1",2,"2",3,"3"].indexOf(e.report.displayFormat)]])],512),[[l["vShow"],"email"===e.report.type&&"csv"!==e.report.formatemail&&"tsv"!==e.report.formatemail]]),Object(l["createElementVNode"])("div",U,[Object(l["createElementVNode"])("h3",z,Object(l["toDisplayString"])(e.translate("ScheduledReports_ReportsIncluded")),1)]),(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(e.reportsByCategoryByReportTypeInColumns,(function(t,r){return Object(l["withDirectives"])((Object(l["openBlock"])(),Object(l["createElementBlock"])("div",{name:"reportsList",class:Object(l["normalizeClass"])("row ".concat(r)),key:r},[(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(t,(function(t,o){return Object(l["openBlock"])(),Object(l["createElementBlock"])("div",{class:"col s12 m6",key:o},[(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(t,(function(t,o){return Object(l["openBlock"])(),Object(l["createElementBlock"])("div",{key:o},[Object(l["createElementVNode"])("h3",W,Object(l["toDisplayString"])(o),1),Object(l["createElementVNode"])("ul",Z,[(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(t,(function(t){var o;return Object(l["openBlock"])(),Object(l["createElementBlock"])("li",{key:t.uniqueId},[Object(l["createElementVNode"])("label",null,[Object(l["createElementVNode"])("input",{name:"".concat(r,"Reports"),type:e.allowMultipleReportsByReportType[r]?"checkbox":"radio",id:"".concat(r).concat(t.uniqueId),checked:null===(o=e.selectedReports[r])||void 0===o?void 0:o[t.uniqueId],onChange:function(o){return e.$emit("toggleSelectedReport",{reportType:r,uniqueId:t.uniqueId})}},null,40,K),Object(l["createElementVNode"])("span",null,Object(l["toDisplayString"])(e.decode(t.name)),1),"MultiSites_getAll"===t.uniqueId?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",X,Object(l["toDisplayString"])(e.translate("ScheduledReports_ReportIncludeNWebsites",e.countWebsites)),1)):Object(l["createCommentVNode"])("",!0)])])})),128))]),J])})),128))])})),128))],2)),[[l["vShow"],e.report.type===r]])})),128)),Object(l["createVNode"])(a,{value:e.saveButtonTitle,onConfirm:t[12]||(t[12]=function(t){return e.$emit("submit")})},null,8,["value"]),Object(l["createElementVNode"])("div",{class:"entityCancel",innerHTML:e.$sanitize(e.entityCancelText)},null,8,Q)],544),[[d]])]})),_:3},8,["content-title"])} +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */function ee(e,t){return"".concat((24+parseFloat(e)+t)%24)}function te(e,t){return ie(e)||le(e,t)||oe(e,t)||re()}function re(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function oe(e,t){if(e){if("string"===typeof e)return ne(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ne(e,t):void 0}}function ne(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function le(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,l=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(o=r.next()).done);i=!0)if(l.push(o.value),t&&l.length===t)break}catch(a){c=!0,n=a}finally{try{i||null==r["return"]||r["return"]()}finally{if(c)throw n}}return l}}function ie(e){if(Array.isArray(e))return e}var ce=Object(l["defineComponent"])({props:{report:{type:Object,required:!0},selectedReports:Object,paramPeriods:{type:Object,required:!0},reportTypeOptions:{type:Object,required:!0},reportFormatsByReportTypeOptions:{type:Object,required:!0},displayFormats:{type:Object,required:!0},reportsByCategoryByReportType:{type:Object,required:!0},allowMultipleReportsByReportType:{type:Object,required:!0},countWebsites:{type:Number,required:!0},siteName:{type:String,required:!0},reportTypes:{type:Object,required:!0},segmentEditorActivated:Boolean,savedSegmentsById:Object,periods:{type:Object,required:!0}},emits:["submit","change","toggleSelectedReport"],components:{ContentBlock:g["ContentBlock"],Field:a["Field"],SaveButton:a["SaveButton"]},directives:{Form:a["Form"]},created:function(){this.onEvolutionPeriodN=Object(g["debounce"])(this.onEvolutionPeriodN,50)},methods:{onEvolutionPeriodN:function(e){this.$emit("change",{prop:"evolutionPeriodN",value:e.target.value})},decode:function(e){return g["Matomo"].helper.htmlDecode(e)}},setup:function(e,t){var r=Object(l["ref"])(null),o=Object(l["reactive"])({report:Object.assign({},e.report)});return Object(l["watch"])((function(){return o.report}),(function(r){Object.keys(r).forEach((function(o){r[o]!==e.report[o]&&t.emit("change",{prop:o,value:r[o]})}))}),{deep:!0}),Object(l["watch"])((function(){return e.report}),(function(e){Object.assign(o.report,e),g["Matomo"].helper.getAngularDependency("$timeout")()}),{deep:!0}),Object(l["onMounted"])((function(){var e=r.value;g["Matomo"].helper.compileAngularComponents(e,{params:{manageScheduledReport:o}}),g["Matomo"].helper.compileVueEntryComponents(e,{report:o.report,onChange:function(e,r){t.emit("change",{prop:e,value:r})}})})),{reportParameters:r}},beforeUnmount:function(){var e=this.$refs.reportParameters;g["Matomo"].helper.destroyVueComponent(e)},computed:{reportsByCategoryByReportTypeInColumns:function(){var e=this.reportsByCategoryByReportType,t=Object.entries(e).map((function(e){var t=te(e,2),r=t[0],o=t[1],n=Math.floor((Object.keys(o).length+1)/2),l={},i={},c=l;return Object.entries(o).forEach((function(e){var t=te(e,2),r=t[0],o=t[1];c[r]=o,Object.keys(c).length>=n&&(c=i)})),[r,[l,i]]}));return Object.fromEntries(t)},entityCancelText:function(){return Object(g["translate"])("General_OrCancel",'<a class="entityCancelLink">',"</a>")},frequencyPeriodSingle:function(){if(!this.report||!this.report.period)return"";var e=window,t=e.ReportPlugin,r=t.periodTranslations[this.report.period];return r||(r=t.periodTranslations.day),r.single},frequencyPeriodPlural:function(){if(!this.report||!this.report.period)return"";var e=window,t=e.ReportPlugin,r=t.periodTranslations[this.report.period];return r||(r=t.periodTranslations.day),r.plural},evolutionGraphsShowForEachInPeriod:function(){return Object(g["translate"])("ScheduledReports_EvolutionGraphsShowForEachInPeriod","<strong>","</strong>",this.frequencyPeriodSingle)},reportSegmentInlineHelp:function(){return Object(g["translate"])("ScheduledReports_Segment_Help",'<a href="./" rel="noreferrer noopener" target="_blank">',"</a>",Object(g["translate"])("SegmentEditor_DefaultAllVisits"),Object(g["translate"])("SegmentEditor_AddNewSegment"))},timezoneOffset:function(){return g["Matomo"].timezoneOffset},timeZoneDifferenceInHours:function(){return g["Matomo"].timezoneOffset/3600},reportHours:function(){for(var e=[],t=0;t<24;t+=1)2*this.timeZoneDifferenceInHours%2!==0?e.push({key:"".concat(t,".5"),value:"".concat(t,":30")}):e.push({key:"".concat(t),value:"".concat(t)});return e},reportHourUtc:function(){var e=ee(this.report.hour,-this.timeZoneDifferenceInHours);return Object(g["translate"])("ScheduledReports_ReportHourWithUTC",[e])},saveButtonTitle:function(){var e=window,t=e.ReportPlugin,r=this.report.idreport>0;return r?t.updateReportString:t.createReportString}}});ce.render=Y;var ae=ce,pe={class:"first"},de={key:0},se={colspan:"7"},ue=Object(l["createElementVNode"])("br",null,null,-1),me=Object(l["createElementVNode"])("br",null,null,-1),be=Object(l["createTextVNode"])("› "),Oe=["href"],ye=Object(l["createElementVNode"])("br",null,null,-1),je=Object(l["createElementVNode"])("br",null,null,-1),he={key:1},fe={colspan:"7"},ve=Object(l["createElementVNode"])("br",null,null,-1),ge=Object(l["createElementVNode"])("br",null,null,-1),Se=Object(l["createElementVNode"])("br",null,null,-1),Re={class:"first"},Ee={key:0,class:"entityInlineHelp",style:{"font-size":"9pt"}},Ne={key:0},Ve={key:1},ke={key:0},we={key:0},_e=Object(l["createElementVNode"])("br",null,null,-1),Be=["onClick"],Te=["src"],Ce=["id","action"],Pe=["value"],Fe=Object(l["createElementVNode"])("input",{type:"hidden",name:"force_api_session",value:"1"},null,-1),De=["onClick","id"],xe=["src"],qe={style:{"text-align":"center","padding-top":"2px"}},Me=["onClick","title"],Ie=Object(l["createElementVNode"])("span",{class:"icon-edit"},null,-1),Ae=[Ie],Le={style:{"text-align":"center","padding-top":"2px"}},He=["onClick","title"],$e=Object(l["createElementVNode"])("span",{class:"icon-delete"},null,-1),Ge=[$e],Ue={class:"tableActionBar"},ze=Object(l["createElementVNode"])("span",{class:"icon-add"},null,-1);function We(e,t,r,o,n,i){var c=Object(l["resolveComponent"])("ContentBlock"),a=Object(l["resolveDirective"])("content-table");return Object(l["openBlock"])(),Object(l["createBlock"])(c,{id:"entityEditContainer",class:"entityTableContainer","help-url":"https://matomo.org/docs/email-reports/",feature:"true","content-title":e.contentTitle},{default:Object(l["withCtx"])((function(){var r;return[Object(l["withDirectives"])(Object(l["createElementVNode"])("table",null,[Object(l["createElementVNode"])("thead",null,[Object(l["createElementVNode"])("tr",null,[Object(l["createElementVNode"])("th",pe,Object(l["toDisplayString"])(e.translate("General_Description")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("ScheduledReports_EmailSchedule")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("ScheduledReports_ReportFormat")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("ScheduledReports_SendReportTo")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("General_Download")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("General_Edit")),1),Object(l["createElementVNode"])("th",null,Object(l["toDisplayString"])(e.translate("General_Delete")),1)])]),Object(l["createElementVNode"])("tbody",null,["anonymous"===e.userLogin?(Object(l["openBlock"])(),Object(l["createElementBlock"])("tr",de,[Object(l["createElementVNode"])("td",se,[ue,Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_MustBeLoggedIn"))+" ",1),me,be,Object(l["createElementVNode"])("a",{href:"index.php?module=".concat(e.loginModule)},Object(l["toDisplayString"])(e.translate("Login_LogIn")),9,Oe),ye,je])])):null!==(r=e.reports)&&void 0!==r&&r.length?Object(l["createCommentVNode"])("",!0):(Object(l["openBlock"])(),Object(l["createElementBlock"])("tr",he,[Object(l["createElementVNode"])("td",fe,[ve,Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_ThereIsNoReportToManage",e.siteName))+". ",1),ge,Se])])),(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(e.decodedReports,(function(t){return Object(l["openBlock"])(),Object(l["createElementBlock"])("tr",{key:t.idreport},[Object(l["createElementVNode"])("td",Re,[Object(l["createTextVNode"])(Object(l["toDisplayString"])(t.description)+" ",1),e.segmentEditorActivated&&t.idsegment?(Object(l["openBlock"])(),Object(l["createElementBlock"])("div",Ee,[e.savedSegmentsById[t.idsegment]?(Object(l["openBlock"])(),Object(l["createElementBlock"])("span",Ne,Object(l["toDisplayString"])(e.savedSegmentsById[t.idsegment]),1)):(Object(l["openBlock"])(),Object(l["createElementBlock"])("span",Ve,Object(l["toDisplayString"])(e.translate("ScheduledReports_SegmentDeleted")),1))])):Object(l["createCommentVNode"])("",!0)]),Object(l["createElementVNode"])("td",null,Object(l["toDisplayString"])(e.periods[t.period]),1),Object(l["createElementVNode"])("td",null,[t.format?(Object(l["openBlock"])(),Object(l["createElementBlock"])("span",ke,Object(l["toDisplayString"])(t.format.toUpperCase()),1)):Object(l["createCommentVNode"])("",!0)]),Object(l["createElementVNode"])("td",null,[0===t.recipients.length?(Object(l["openBlock"])(),Object(l["createElementBlock"])("span",we,Object(l["toDisplayString"])(e.translate("ScheduledReports_NoRecipients")),1)):Object(l["createCommentVNode"])("",!0),(Object(l["openBlock"])(!0),Object(l["createElementBlock"])(l["Fragment"],null,Object(l["renderList"])(t.recipients,(function(e,t){return Object(l["openBlock"])(),Object(l["createElementBlock"])("span",{key:t},[Object(l["createTextVNode"])(Object(l["toDisplayString"])(e)+" ",1),_e])})),128)),0!==t.recipients.length?(Object(l["openBlock"])(),Object(l["createElementBlock"])("a",{key:1,href:"#",name:"linkSendNow",class:"link_but withIcon",style:{"margin-top":"3px"},onClick:Object(l["withModifiers"])((function(r){return e.$emit("sendnow",t.idreport)}),["prevent"])},[Object(l["createElementVNode"])("img",{border:"0",src:e.reportTypes[t.type]},null,8,Te),Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_SendReportNow")),1)],8,Be)):Object(l["createCommentVNode"])("",!0)]),Object(l["createElementVNode"])("td",null,[Object(l["createElementVNode"])("form",{method:"POST",target:"_blank",id:"downloadReportForm_".concat(t.idreport),action:e.linkTo({module:"API",segment:null,method:"ScheduledReports.generateReport",idReport:t.idreport,outputType:e.downloadOutputType,language:e.language,format:-1!==["html","csv","tsv"].indexOf(t.format)?t.format:"original"})},[Object(l["createElementVNode"])("input",{type:"hidden",name:"token_auth",value:e.token_auth},null,8,Pe),Fe],8,Ce),Object(l["createElementVNode"])("a",{href:"",rel:"noreferrer noopener",name:"linkDownloadReport",class:"link_but withIcon",onClick:Object(l["withModifiers"])((function(r){return e.displayReport(t.idreport)}),["prevent"]),id:t.idreport},[Object(l["createElementVNode"])("img",{border:"0",width:16,height:16,src:e.reportFormatsByReportType[t.type][t.format]},null,8,xe),Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("General_Download")),1)],8,De)]),Object(l["createElementVNode"])("td",qe,[Object(l["createElementVNode"])("button",{class:"table-action",onClick:function(r){return e.$emit("edit",t.idreport)},title:e.translate("General_Edit")},Ae,8,Me)]),Object(l["createElementVNode"])("td",Le,[Object(l["createElementVNode"])("button",{class:"table-action",onClick:function(r){return e.$emit("delete",t.idreport)},title:e.translate("General_Delete")},Ge,8,He)])])})),128))])],512),[[a]]),Object(l["createElementVNode"])("div",Ue,["anonymous"!==e.userLogin?(Object(l["openBlock"])(),Object(l["createElementBlock"])("button",{key:0,id:"add-report",onClick:t[0]||(t[0]=function(t){return e.$emit("create")})},[ze,Object(l["createTextVNode"])(" "+Object(l["toDisplayString"])(e.translate("ScheduledReports_CreateAndScheduleReport")),1)])):Object(l["createCommentVNode"])("",!0)])]})),_:1},8,["content-title"])}var Ze=Object(l["defineComponent"])({props:{contentTitle:{type:String,required:!0},userLogin:{type:String,required:!0},loginModule:{type:String,required:!0},reports:{type:Array,required:!0},siteName:{type:String,required:!0},segmentEditorActivated:Boolean,savedSegmentsById:Object,periods:{type:Object,required:!0},downloadOutputType:{type:Number,required:!0},language:{type:String,required:!0},reportFormatsByReportType:{type:Object,required:!0},reportTypes:{type:Object,required:!0}},components:{ContentBlock:g["ContentBlock"]},directives:{ContentTable:g["ContentTable"]},emits:["create","edit","delete","sendnow"],methods:{linkTo:function(e){return"?".concat(g["MatomoUrl"].stringify(Object.assign(Object.assign({},g["MatomoUrl"].urlParsed.value),e)))},displayReport:function(e){$("#downloadReportForm_".concat(e)).submit()}},computed:{token_auth:function(){return g["Matomo"].token_auth},decodedReports:function(){return this.reports.map((function(e){return Object.assign(Object.assign({},e),{},{description:g["Matomo"].helper.htmlDecode(e.description)})}))}}});Ze.render=We;var Ke=Ze;function Xe(){g["Matomo"].helper.lazyScrollTo(".emailReports",200)}function Je(e,t){var r;null!==(r=window.updateReportParametersFunctions)&&void 0!==r&&r[e]&&window.updateReportParametersFunctions[e](t)}function Qe(e,t){var r;null!==(r=window.resetReportParametersFunctions)&&void 0!==r&&r[e]&&window.resetReportParametersFunctions[e](t)}window.resetReportParametersFunctions=window.resetReportParametersFunctions||{},window.updateReportParametersFunctions=window.updateReportParametersFunctions||{},window.getReportParametersFunctions=window.getReportParametersFunctions||{};var Ye=window,et=Ye.$,tt=g["Matomo"].timezoneOffset/3600,rt=Object(l["defineComponent"])({props:{contentTitle:{type:String,required:!0},userLogin:{type:String,required:!0},loginModule:{type:String,required:!0},reports:{type:Array,required:!0},siteName:{type:String,required:!0},segmentEditorActivated:Boolean,savedSegmentsById:Object,periods:{type:Object,required:!0},downloadOutputType:{type:Number,required:!0},language:{type:String,required:!0},reportFormatsByReportType:{type:Object,required:!0},paramPeriods:{type:Object,required:!0},reportTypeOptions:{type:Object,required:!0},reportFormatsByReportTypeOptions:{type:Object,required:!0},displayFormats:{type:Object,required:!0},reportsByCategoryByReportType:{type:Object,required:!0},allowMultipleReportsByReportType:{type:Object,required:!0},countWebsites:{type:Number,required:!0},reportTypes:{type:Object,required:!0}},components:{AddReport:ae,ListReports:Ke},directives:{ContentTable:g["ContentTable"],Form:a["Form"]},mounted:function(){var e=this;et(this.$refs.root).on("click","a.entityCancelLink",(function(){e.showListOfReports()}))},data:function(){return{showReportsList:!0,report:{},selectedReports:{}}},methods:{sendReportNow:function(e){var t=this;Xe(),g["AjaxHelper"].post({method:"ScheduledReports.sendReport"},{idReport:e,force:!0}).then((function(){t.fadeInOutSuccessMessage(t.$refs.reportSentSuccess,Object(g["translate"])("ScheduledReports_ReportSent"),!1)}))},formSetEditReport:function(e){var t=this,r=window,o=r.ReportPlugin,n={idreport:e,type:o.defaultReportType,format:o.defaultReportFormat,description:"",period:o.defaultPeriod,hour:o.defaultHour,reports:[],idsegment:"",evolutionPeriodFor:"prev",evolutionPeriodN:o.defaultEvolutionPeriodN,periodParam:o.defaultPeriod};e>0?(n=o.reportList[e],Je(n.type,n)):Qe(n.type,n),n.hour=ee(n.hour,tt),this.selectedReports={},Object.values(n.reports).forEach((function(e){t.selectedReports[n.type]=t.selectedReports[n.type]||{},t.selectedReports[n.type][e]=!0})),n["format".concat(n.type)]=n.format,n.idsegment||(n.idsegment=""),this.report=n,this.report.description=g["Matomo"].helper.htmlDecode(n.description)},fadeInOutSuccessMessage:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];g["NotificationsStore"].show({message:t,placeat:e,context:"success",noclear:!0,type:"toast",style:{display:"inline-block",marginTop:"10px"},id:"scheduledReportSuccess"}),r&&g["Matomo"].helper.refreshAfter(2)},changedReportType:function(){Qe(this.report.type,this.report)},deleteReport:function(e){g["Matomo"].helper.modalConfirm("#confirm",{yes:function(){g["AjaxHelper"].post({method:"ScheduledReports.deleteReport"},{idReport:e},{redirectOnSuccess:!0})}})},showListOfReports:function(e){this.showReportsList=!0,g["Matomo"].helper.hideAjaxError(),("undefined"===typeof e||e)&&Xe()},createReport:function(){var e=this;this.showReportsList=!1,Object(l["nextTick"])((function(){e.formSetEditReport(0)}))},editReport:function(e){var t=this;this.showReportsList=!1,Object(l["nextTick"])((function(){t.formSetEditReport(e)}))},submitReport:function(){var e=this,t={idReport:this.report.idreport,description:this.report.description,idSegment:this.report.idsegment,reportType:this.report.type,reportFormat:this.report["format".concat(this.report.type)],periodParam:this.report.periodParam,evolutionPeriodFor:this.report.evolutionPeriodFor};"each"!==t.evolutionPeriodFor&&(t.evolutionPeriodN=this.report.evolutionPeriodN);var r=this.report.period,o=ee(this.report.hour,-tt),n=this.selectedReports[t.reportType]||{},l=Object.keys(n).filter((function(r){return e.selectedReports[t.reportType][r]}));l.length>0&&(t.reports=l);var i=window.getReportParametersFunctions[this.report.type](this.report);t.parameters=i;var c=this.report.idreport>0;return g["AjaxHelper"].post({method:c?"ScheduledReports.updateReport":"ScheduledReports.addReport",period:r,hour:o},t).then((function(){e.fadeInOutSuccessMessage(e.$refs.reportUpdatedSuccess,Object(g["translate"])("ScheduledReports_ReportUpdated"))})),!1},onChangeProperty:function(e,t){this.report[e]=t,"type"===e&&this.changedReportType()},toggleSelectedReport:function(e,t){this.selectedReports[e]=this.selectedReports[e]||{},this.selectedReports[e][t]=!this.selectedReports[e][t]}},computed:{showReportForm:function(){return!this.showReportsList},decodedSiteName:function(){return g["Matomo"].helper.htmlDecode(this.siteName)}}});rt.render=v;var ot=rt; +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */}})})); +//# sourceMappingURL=ScheduledReports.umd.min.js.map
\ No newline at end of file diff --git a/plugins/ScheduledReports/vue/dist/umd.metadata.json b/plugins/ScheduledReports/vue/dist/umd.metadata.json new file mode 100644 index 0000000000..6eb1c55162 --- /dev/null +++ b/plugins/ScheduledReports/vue/dist/umd.metadata.json @@ -0,0 +1,6 @@ +{ + "dependsOn": [ + "CorePluginsAdmin", + "CoreHome" + ] +}
\ No newline at end of file diff --git a/plugins/ScheduledReports/vue/src/AddReport/AddReport.vue b/plugins/ScheduledReports/vue/src/AddReport/AddReport.vue new file mode 100644 index 0000000000..23bc88e052 --- /dev/null +++ b/plugins/ScheduledReports/vue/src/AddReport/AddReport.vue @@ -0,0 +1,546 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <ContentBlock + class="entityAddContainer" + :content-title="translate('ScheduledReports_CreateAndScheduleReport')" + > + <div class="clear" /> + <form + id="addEditReport" + @submit="$emit('submit')" + v-form + > + <div> + <Field + uicontrol="text" + name="website" + :title="translate('General_Website')" + :disabled="true" + :model-value="siteName" + > + </Field> + </div> + <div> + <Field + uicontrol="textarea" + name="report_description" + :title="translate('General_Description')" + :model-value="report.description" + @update:model-value="$emit('change', { prop: 'description', value: $event })" + :inline-help="translate('ScheduledReports_DescriptionOnFirstPage')" + > + </Field> + </div> + <div v-if="segmentEditorActivated"> + <Field + uicontrol="select" + name="report_segment" + :title="translate('SegmentEditor_ChooseASegment')" + :model-value="report.idsegment" + @update:model-value="$emit('change', { prop: 'idsegment', value: $event })" + :options="savedSegmentsById" + > + <template v-slot:inline-help> + <div + id="reportSegmentInlineHelp" + class="inline-help-node" + v-if="segmentEditorActivated" + v-html="$sanitize(reportSegmentInlineHelp)" + /> + </template> + </Field> + </div> + <div> + <Field + uicontrol="select" + name="report_schedule" + :model-value="report.period" + @update:model-value="$emit('change', { prop: 'period', value: $event }); + $emit('change', { + prop: 'periodParam', + value: report.period === 'never' ? null : report.period, + })" + :title="translate('ScheduledReports_EmailSchedule')" + :options="periods" + > + <template v-slot:inline-help> + <div + id="emailScheduleInlineHelp" + class="inline-help-node" + > + {{ translate('ScheduledReports_WeeklyScheduleHelp') }} + <br /> + {{ translate('ScheduledReports_MonthlyScheduleHelp') }} + </div> + </template> + </Field> + </div> + <div> + <Field + uicontrol="select" + name="report_period" + :model-value="report.periodParam" + @update:model-value="$emit('change', { prop: 'periodParam', value: $event })" + :options="paramPeriods" + :title="translate('ScheduledReports_ReportPeriod')" + > + <template v-slot:inline-help> + <div + id="emailReportPeriodInlineHelp" + class="inline-help-node" + > + {{ translate('ScheduledReports_ReportPeriodHelp') }} + <br /><br /> + {{ translate('ScheduledReports_ReportPeriodHelp2') }} + </div> + </template> + </Field> + </div> + <div> + <Field + uicontrol="select" + name="report_hour" + :model-value="report.hour" + @update:model-value="$emit('change', { prop: 'hour', value: $event })" + :title="translate('ScheduledReports_ReportHour', 'X')" + :options="reportHours" + > + <template v-slot:inline-help> + <div + id="reportHourHelpText" + class="inline-help-node" + v-if="timezoneOffset !== 0 && timezoneOffset !== '0'" + > + <span v-text="reportHourUtc" /> + </div> + </template> + </Field> + </div> + <div> + <Field + uicontrol="select" + name="report_type" + :disabled="reportTypes.length === 1" + :model-value="report.type" + @update:model-value="$emit('change', { prop: 'type', value: $event })" + :title="translate('ScheduledReports_ReportType')" + :options="reportTypeOptions" + > + </Field> + </div> + <div + v-for="(reportFormats, reportType) in reportFormatsByReportTypeOptions" + :key="reportType" + > + <Field + uicontrol="select" + name="report_format" + :title="translate('ScheduledReports_ReportFormat')" + :class="reportType" + v-show="report.type === reportType" + :model-value="report[`format${reportType}`]" + @update:model-value="$emit('change', { prop: `format${reportType}`, value: $event })" + :options="reportFormats" + > + </Field> + </div> + <div ref="reportParameters"> + <slot name="report-parameters"></slot> + </div> + <div + v-show="report.type === 'email' + && report.formatemail !== 'csv' + && report.formatemail !== 'tsv'" + > + <div class="email"> + <Field + uicontrol="select" + name="display_format" + :model-value="report.displayFormat" + @update:model-value="$emit('change', { prop: 'displayFormat', value: $event })" + :options="displayFormats" + :introduction="translate('ScheduledReports_AggregateReportsFormat')" + > + </Field> + </div> + <div class="report_evolution_graph"> + <Field + uicontrol="checkbox" + name="report_evolution_graph" + :title="translate('ScheduledReports_EvolutionGraph', 5)" + v-show="[2, '2', 3, '3'].indexOf(report.displayFormat) !== -1" + :model-value="report.evolutionGraph" + @update:model-value="$emit('change', { prop: 'evolutionGraph', value: $event })" + > + </Field> + </div> + <div + class="row evolution-graph-period" + v-show="[1, '1', 2, '2', 3, '3'].indexOf(report.displayFormat) !== -1" + > + <div class="col s12"> + <label for="report_evolution_period_for_each"> + <input + id="report_evolution_period_for_each" + name="report_evolution_period_for" + type="radio" + value="each" + :checked="report.evolutionPeriodFor === 'each'" + @change="$emit( + 'change', + { prop: 'evolutionPeriodFor', value: $event.target.value }, + )" + /> + <span v-html="$sanitize(evolutionGraphsShowForEachInPeriod)"></span> + </label> + </div> + <div class="col s12"> + <label for="report_evolution_period_for_prev"> + <input + id="report_evolution_period_for_prev" + name="report_evolution_period_for" + type="radio" + value="prev" + :checked="report.evolutionPeriodFor === 'prev'" + @change="$emit( + 'change', + { prop: 'evolutionPeriodFor', value: $event.target.value }, + )" + /> + <span>{{ translate( + 'ScheduledReports_EvolutionGraphsShowForPreviousN', + frequencyPeriodPlural, + ) }}: + <input + type="number" + name="report_evolution_period_n" + :value="report.evolutionPeriodN" + @keydown="onEvolutionPeriodN($event)" + @change="onEvolutionPeriodN($event)" + /> + </span> + </label> + </div> + </div> + </div> + <div class="row"> + <h3 class="col s12">{{ translate('ScheduledReports_ReportsIncluded') }}</h3> + </div> + <div + name="reportsList" + :class="`row ${reportType}`" + v-show="report.type === reportType" + v-for="(reportColumns, reportType) in reportsByCategoryByReportTypeInColumns" + :key="reportType" + > + <div class="col s12 m6" v-for="(reportsByCategory, index) in reportColumns" :key="index"> + <div v-for="(reports, category) in reportsByCategory" :key="category"> + <h3 class="reportCategory">{{ category }}</h3> + <ul class="listReports"> + <li v-for="report in reports" :key="report.uniqueId"> + <label> + <input + :name="`${reportType}Reports`" + :type="allowMultipleReportsByReportType[reportType] ? 'checkbox' : 'radio'" + :id="`${reportType}${report.uniqueId}`" + :checked="selectedReports[reportType]?.[report.uniqueId]" + @change="$emit('toggleSelectedReport', { + reportType, + uniqueId: report.uniqueId, + })" + /> + <span>{{ decode(report.name) }}</span> + <div class="entityInlineHelp" v-if="report.uniqueId === 'MultiSites_getAll'"> + {{ translate('ScheduledReports_ReportIncludeNWebsites', countWebsites) }} + </div> + </label> + </li> + </ul> + <br /> + </div> + </div> + </div> + <SaveButton + :value="saveButtonTitle" + @confirm="$emit('submit')" + /> + <div + class="entityCancel" + v-html="$sanitize(entityCancelText)" + > + </div> + </form> + </ContentBlock> +</template> + +<script lang="ts"> +import { + defineComponent, + onMounted, + reactive, + ref, + watch, +} from 'vue'; +import { + ContentBlock, + Matomo, + translate, + debounce, +} from 'CoreHome'; +import { Field, Form, SaveButton } from 'CorePluginsAdmin'; +import { adjustHourToTimezone } from '../utilities'; + +interface Option { + key: string; + value: string; +} + +export default defineComponent({ + props: { + report: { + type: Object, + required: true, + }, + selectedReports: Object, + paramPeriods: { + type: Object, + required: true, + }, + reportTypeOptions: { + type: Object, + required: true, + }, + reportFormatsByReportTypeOptions: { + type: Object, + required: true, + }, + displayFormats: { + type: Object, + required: true, + }, + reportsByCategoryByReportType: { + type: Object, + required: true, + }, + allowMultipleReportsByReportType: { + type: Object, + required: true, + }, + countWebsites: { + type: Number, + required: true, + }, + siteName: { + type: String, + required: true, + }, + reportTypes: { + type: Object, + required: true, + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true, + }, + }, + emits: ['submit', 'change', 'toggleSelectedReport'], + components: { + ContentBlock, + Field, + SaveButton, + }, + directives: { + Form, + }, + created() { + this.onEvolutionPeriodN = debounce(this.onEvolutionPeriodN, 50); + }, + methods: { + onEvolutionPeriodN(event: Event) { + this.$emit('change', { + prop: 'evolutionPeriodN', + value: (event.target as HTMLInputElement).value, + }); + }, + decode(s: string) { + // report names can be encoded (mainly goals) + return Matomo.helper.htmlDecode(s); + }, + }, + setup(props, ctx) { + const reportParameters = ref<HTMLElement|null>(null); + + const angularControllerProxy = reactive({ + report: { + ...props.report, + }, + }); + + watch( + () => angularControllerProxy.report, + (newValue) => { + Object.keys(newValue).forEach((key) => { + if (newValue[key] !== props.report[key]) { + ctx.emit('change', { prop: key, value: newValue[key] }); + } + }); + }, + { deep: true }, + ); + + watch( + () => props.report, + (newValue) => { + Object.assign(angularControllerProxy.report, newValue); + Matomo.helper.getAngularDependency('$timeout')(); + }, + { deep: true }, + ); + + onMounted(() => { + const reportParametersElement = reportParameters.value as HTMLElement; + Matomo.helper.compileAngularComponents(reportParametersElement, { + params: { + manageScheduledReport: angularControllerProxy, + }, + }); + + Matomo.helper.compileVueEntryComponents(reportParametersElement, { + report: angularControllerProxy.report, + onChange(prop: string, value: unknown) { + ctx.emit('change', { prop, value }); + }, + }); + }); + + return { + reportParameters, + }; + }, + beforeUnmount() { + const reportParameters = this.$refs.reportParameters as HTMLElement; + Matomo.helper.destroyVueComponent(reportParameters); + }, + computed: { + reportsByCategoryByReportTypeInColumns() { + const reportsByCategoryByReportType = this.reportsByCategoryByReportType as + Record<string, Record<string, unknown[]>>; + + const inColumns = Object.entries(reportsByCategoryByReportType).map( + ([key, reportsByCategory]) => { + const newColumnAfter = Math.floor((Object.keys(reportsByCategory).length + 1) / 2); + + const column1: Record<string, unknown[]> = {}; + const column2: Record<string, unknown[]> = {}; + + let currentColumn = column1; + Object.entries(reportsByCategory).forEach(([category, reports]) => { + currentColumn[category] = reports; + + if (Object.keys(currentColumn).length >= newColumnAfter) { + currentColumn = column2; + } + }); + + return [key, [column1, column2]]; + }, + ); + + return Object.fromEntries(inColumns); + }, + entityCancelText() { + return translate( + 'General_OrCancel', + '<a class="entityCancelLink">', + '</a>', + ); + }, + frequencyPeriodSingle() { + if (!this.report || !this.report.period) { + return ''; + } + + const { ReportPlugin } = window; + + let translation = ReportPlugin.periodTranslations[this.report.period]; + if (!translation) { + translation = ReportPlugin.periodTranslations.day; + } + return translation.single; + }, + frequencyPeriodPlural() { + if (!this.report || !this.report.period) { + return ''; + } + + const { ReportPlugin } = window; + + let translation = ReportPlugin.periodTranslations[this.report.period]; + if (!translation) { + translation = ReportPlugin.periodTranslations.day; + } + return translation.plural; + }, + evolutionGraphsShowForEachInPeriod() { + return translate( + 'ScheduledReports_EvolutionGraphsShowForEachInPeriod', + '<strong>', + '</strong>', + this.frequencyPeriodSingle, + ); + }, + reportSegmentInlineHelp() { + return translate( + 'ScheduledReports_Segment_Help', + '<a href="./" rel="noreferrer noopener" target="_blank">', + '</a>', + translate('SegmentEditor_DefaultAllVisits'), + translate('SegmentEditor_AddNewSegment'), + ); + }, + timezoneOffset() { + return Matomo.timezoneOffset; + }, + timeZoneDifferenceInHours() { + return Matomo.timezoneOffset / 3600; + }, + reportHours() { + const hours: Option[] = []; + for (let i = 0; i < 24; i += 1) { + if ((this.timeZoneDifferenceInHours * 2) % 2 !== 0) { + hours.push({ + key: `${i}.5`, + value: `${i}:30`, + }); + } else { + hours.push({ + key: `${i}`, + value: `${i}`, + }); + } + } + return hours; + }, + reportHourUtc() { + const reportHour = adjustHourToTimezone( + this.report.hour as string, + -this.timeZoneDifferenceInHours, + ); + return translate('ScheduledReports_ReportHourWithUTC', [reportHour]); + }, + saveButtonTitle() { + const { ReportPlugin } = window; + + const isCreate = this.report.idreport > 0; + return isCreate ? ReportPlugin.updateReportString : ReportPlugin.createReportString; + }, + }, +}); +</script> diff --git a/plugins/ScheduledReports/vue/src/ListReports/ListReports.vue b/plugins/ScheduledReports/vue/src/ListReports/ListReports.vue new file mode 100644 index 0000000000..4d021ada6b --- /dev/null +++ b/plugins/ScheduledReports/vue/src/ListReports/ListReports.vue @@ -0,0 +1,252 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <ContentBlock + id="entityEditContainer" + class="entityTableContainer" + help-url="https://matomo.org/docs/email-reports/" + :feature="'true'" + :content-title="contentTitle" + > + <table v-content-table> + <thead> + <tr> + <th class="first">{{ translate('General_Description') }}</th> + <th>{{ translate('ScheduledReports_EmailSchedule') }}</th> + <th>{{ translate('ScheduledReports_ReportFormat') }}</th> + <th>{{ translate('ScheduledReports_SendReportTo') }}</th> + <th>{{ translate('General_Download') }}</th> + <th>{{ translate('General_Edit') }}</th> + <th>{{ translate('General_Delete') }}</th> + </tr> + </thead> + <tbody> + <tr v-if="userLogin === 'anonymous'"> + <td colspan="7"> + <br /> + {{ translate('ScheduledReports_MustBeLoggedIn') }} + <br />› <a :href="`index.php?module=${loginModule}`"> + {{ translate('Login_LogIn') }} + </a> + <br /><br /> + </td> + </tr> + <tr v-else-if="!reports?.length"> + <td colspan="7"> + <br /> + {{ translate('ScheduledReports_ThereIsNoReportToManage', siteName) }}. + <br /><br /> + </td> + </tr> + <tr v-for="report in decodedReports" :key="report.idreport"> + <td class="first"> + {{ report.description }} + <div + class="entityInlineHelp" + style="font-size: 9pt;" + v-if="segmentEditorActivated && report.idsegment" + > + <span v-if="savedSegmentsById[report.idsegment]"> + {{ savedSegmentsById[report.idsegment] }} + </span> + <span v-else> + {{ translate('ScheduledReports_SegmentDeleted') }} + </span> + </div> + </td> + <td>{{ periods[report.period] }} + <!-- Last sent on {{ report.ts_last_sent }} --> + </td> + <td> + <span v-if="report.format">{{ report.format.toUpperCase() }}</span> + </td> + <td> + <span v-if="report.recipients.length === 0"> + {{ translate('ScheduledReports_NoRecipients') }} + </span> + <span v-for="(recipient, index) in report.recipients" :key="index"> + {{ recipient }} + <br /> + </span> + + <a + v-if="report.recipients.length !== 0" + href="#" + name="linkSendNow" + class="link_but withIcon" + style="margin-top:3px;" + @click.prevent="$emit('sendnow', report.idreport)" + > + <img + border="0" + :src="reportTypes[report.type]" + /> + {{ translate('ScheduledReports_SendReportNow') }} + </a> + </td> + <td> + <form + method="POST" + target="_blank" + :id="`downloadReportForm_${report.idreport}`" + :action="linkTo({ + module: 'API', + segment: null, + method: 'ScheduledReports.generateReport', + idReport: report.idreport, + outputType: downloadOutputType, + language: language, + format: ['html', 'csv', 'tsv'].indexOf(report.format) !== -1 + ? report.format : 'original', + })" + > + <input + type="hidden" + name="token_auth" + :value="token_auth" + /> + <input + type="hidden" + name="force_api_session" + value="1" + /> + </form> + <a + href="" + rel="noreferrer noopener" + name="linkDownloadReport" + class="link_but withIcon" + @click.prevent="displayReport(report.idreport)" + :id="report.idreport" + > + <img + border="0" + :width="16" + :height="16" + :src="reportFormatsByReportType[report.type][report.format]" + /> {{ translate('General_Download') }} + </a> + </td> + <td style="text-align: center;padding-top:2px;"> + <button + class="table-action" + @click="$emit('edit', report.idreport)" + :title="translate('General_Edit')" + > + <span class="icon-edit" /> + </button> + </td> + <td style="text-align: center;padding-top:2px;"> + <button + class="table-action" + @click="$emit('delete', report.idreport)" + :title="translate('General_Delete')" + > + <span class="icon-delete" /> + </button> + </td> + </tr> + </tbody> + </table> + <div class="tableActionBar"> + <button + id="add-report" + @click="$emit('create')" + v-if="userLogin !== 'anonymous'" + > + <span class="icon-add" /> + {{ translate('ScheduledReports_CreateAndScheduleReport') }} + </button> + </div> + </ContentBlock> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { + ContentBlock, + ContentTable, + MatomoUrl, + Matomo, +} from 'CoreHome'; +import { Report } from '../types'; + +export default defineComponent({ + props: { + contentTitle: { + type: String, + required: true, + }, + userLogin: { + type: String, + required: true, + }, + loginModule: { + type: String, + required: true, + }, + reports: { + type: Array, + required: true, + }, + siteName: { + type: String, + required: true, + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true, + }, + downloadOutputType: { + type: Number, + required: true, + }, + language: { + type: String, + required: true, + }, + reportFormatsByReportType: { + type: Object, + required: true, + }, + reportTypes: { + type: Object, + required: true, + }, + }, + components: { + ContentBlock, + }, + directives: { + ContentTable, + }, + emits: ['create', 'edit', 'delete', 'sendnow'], + methods: { + linkTo(params: QueryParameters) { + return `?${MatomoUrl.stringify({ + ...MatomoUrl.urlParsed.value, + ...params, + })}`; + }, + displayReport(reportId: number|string) { + $(`#downloadReportForm_${reportId}`).submit(); + }, + }, + computed: { + token_auth() { + return Matomo.token_auth; + }, + decodedReports() { + return (this.reports as Report[]).map( + (r) => ({ ...r, description: Matomo.helper.htmlDecode(r.description) }), + ); + }, + }, +}); +</script> diff --git a/plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue b/plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue new file mode 100644 index 0000000000..7aa6a1846a --- /dev/null +++ b/plugins/ScheduledReports/vue/src/ManageScheduledReport/ManageScheduledReport.vue @@ -0,0 +1,406 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <div class="emailReports" ref="root"> + <div ref="reportSentSuccess" /> + <div ref="reportUpdatedSuccess" /> + <div> + <div id="ajaxError" style="display:none"></div> + + <div id="ajaxLoadingDiv" style="display:none;"> + <div class="loadingPiwik"> + <img + src="plugins/Morpheus/images/loading-blue.gif" + :alt="translate('General_LoadingData')" + /> + {{ translate('General_LoadingData') }} + </div> + <div class="loadingSegment"> + {{ translate('SegmentEditor_LoadingSegmentedDataMayTakeSomeTime') }} + </div> + </div> + <ListReports + v-show="showReportsList" + :content-title="contentTitle" + :user-login="userLogin" + :login-module="loginModule" + :reports="reports" + :site-name="decodedSiteName" + :segment-editor-activated="segmentEditorActivated" + :saved-segments-by-id="savedSegmentsById" + :periods="periods" + :report-types="reportTypes" + :download-output-type="downloadOutputType" + :language="language" + :report-formats-by-report-type="reportFormatsByReportType" + @create="createReport()" + @edit="editReport($event)" + @delete="deleteReport($event)" + @sendnow="sendReportNow($event)" + /> + <AddReport + v-if="showReportForm" + :report="report" + :periods="periods" + :param-periods="paramPeriods" + :report-type-options="reportTypeOptions" + :report-formats-by-report-type-options="reportFormatsByReportTypeOptions" + :display-formats="displayFormats" + :reports-by-category-by-report-type="reportsByCategoryByReportType" + :allow-multiple-reports-by-report-type="allowMultipleReportsByReportType" + :count-websites="countWebsites" + :site-name="decodedSiteName" + :selected-reports="selectedReports" + :report-types="reportTypes" + :segment-editor-activated="segmentEditorActivated" + :saved-segments-by-id="savedSegmentsById" + @toggle-selected-report="toggleSelectedReport($event.reportType, $event.uniqueId)" + @change="onChangeProperty($event.prop, $event.value)" + @submit="submitReport()" + > + <template v-slot:report-parameters> + <slot name="report-parameters"></slot> + </template> + </AddReport> + + <a id="bottom" /> + </div> + </div> +</template> + +<script lang="ts"> +import { defineComponent, nextTick } from 'vue'; +import { + translate, + Matomo, + NotificationsStore, + ContentTable, + AjaxHelper, +} from 'CoreHome'; +import { Form } from 'CorePluginsAdmin'; +import AddReport from '../AddReport/AddReport.vue'; +import ListReports from '../ListReports/ListReports.vue'; +import { Report } from '../types'; +import { adjustHourToTimezone } from '../utilities'; + +interface ManageScheduledReportState { + showReportsList: boolean; + report: Report; + selectedReports: Record<string, Record<string, boolean>>; +} + +function scrollToTop() { + Matomo.helper.lazyScrollTo('.emailReports', 200); +} + +function updateParameters(reportType: string, report: Report) { + if (window.updateReportParametersFunctions?.[reportType]) { + window.updateReportParametersFunctions[reportType](report); + } +} + +function resetParameters(reportType: string, report: Report) { + if (window.resetReportParametersFunctions?.[reportType]) { + window.resetReportParametersFunctions[reportType](report); + } +} + +window.resetReportParametersFunctions = window.resetReportParametersFunctions || {}; +window.updateReportParametersFunctions = window.updateReportParametersFunctions || {}; +window.getReportParametersFunctions = window.getReportParametersFunctions || {}; + +const { $ } = window; + +const timeZoneDifferenceInHours = Matomo.timezoneOffset / 3600; + +export default defineComponent({ + props: { + contentTitle: { + type: String, + required: true, + }, + userLogin: { + type: String, + required: true, + }, + loginModule: { + type: String, + required: true, + }, + reports: { + type: Array, + required: true, + }, + siteName: { + type: String, + required: true, + }, + segmentEditorActivated: Boolean, + savedSegmentsById: Object, + periods: { + type: Object, + required: true, + }, + downloadOutputType: { + type: Number, + required: true, + }, + language: { + type: String, + required: true, + }, + reportFormatsByReportType: { + type: Object, + required: true, + }, + paramPeriods: { + type: Object, + required: true, + }, + reportTypeOptions: { + type: Object, + required: true, + }, + reportFormatsByReportTypeOptions: { + type: Object, + required: true, + }, + displayFormats: { + type: Object, + required: true, + }, + reportsByCategoryByReportType: { + type: Object, + required: true, + }, + allowMultipleReportsByReportType: { + type: Object, + required: true, + }, + countWebsites: { + type: Number, + required: true, + }, + reportTypes: { + type: Object, + required: true, + }, + }, + components: { + AddReport, + ListReports, + }, + directives: { + ContentTable, + Form, + }, + mounted() { + $(this.$refs.root as HTMLElement).on('click', 'a.entityCancelLink', () => { + this.showListOfReports(); + }); + }, + data(): ManageScheduledReportState { + return { + showReportsList: true, + report: {} as unknown as Report, + selectedReports: {}, + }; + }, + methods: { + sendReportNow(idReport: string|number) { + scrollToTop(); + + AjaxHelper.post( + { + method: 'ScheduledReports.sendReport', + }, + { + idReport, + force: true, + }, + ).then(() => { + this.fadeInOutSuccessMessage( + this.$refs.reportSentSuccess as HTMLElement, + translate('ScheduledReports_ReportSent'), + false, + ); + }); + }, + formSetEditReport(idReport: number) { + const { ReportPlugin } = window; + + let report: Report = { + idreport: idReport, + type: ReportPlugin.defaultReportType, + format: ReportPlugin.defaultReportFormat, + description: '', + period: ReportPlugin.defaultPeriod, + hour: ReportPlugin.defaultHour, + reports: [], + idsegment: '', + evolutionPeriodFor: 'prev', + evolutionPeriodN: ReportPlugin.defaultEvolutionPeriodN, + periodParam: ReportPlugin.defaultPeriod, + } as unknown as Report; + + if (idReport > 0) { + report = ReportPlugin.reportList[idReport]; + updateParameters(report.type, report); + } else { + resetParameters(report.type, report); + } + + report.hour = adjustHourToTimezone(report.hour as string, timeZoneDifferenceInHours); + + this.selectedReports = {}; + Object.values(report.reports).forEach((reportId) => { + this.selectedReports[report.type] = this.selectedReports[report.type] || {}; + this.selectedReports[report.type][reportId] = true; + }); + + report[`format${report.type}`] = report.format; + + if (!report.idsegment) { + report.idsegment = ''; + } + + this.report = report; + this.report.description = Matomo.helper.htmlDecode(report.description); + }, + fadeInOutSuccessMessage(selector: HTMLElement, message: string, reload = true) { + NotificationsStore.show({ + message, + placeat: selector, + context: 'success', + noclear: true, + type: 'toast', + style: { + display: 'inline-block', + marginTop: '10px', + }, + id: 'scheduledReportSuccess', + }); + + if (reload) { + Matomo.helper.refreshAfter(2); + } + }, + changedReportType() { + resetParameters(this.report.type, this.report); + }, + deleteReport(idReport: string|number) { + Matomo.helper.modalConfirm('#confirm', { + yes: () => { + AjaxHelper.post( + { + method: 'ScheduledReports.deleteReport', + }, + { + idReport, + }, + { + redirectOnSuccess: true, + }, + ); + }, + }); + }, + showListOfReports(shouldScrollToTop?: boolean) { + this.showReportsList = true; + + Matomo.helper.hideAjaxError(); + + if (typeof shouldScrollToTop === 'undefined' || shouldScrollToTop) { + scrollToTop(); + } + }, + createReport() { + this.showReportsList = false; + + // in nextTick so global report function records get manipulated before individual + // entries are used + nextTick(() => { + this.formSetEditReport(0); + }); + }, + editReport(reportId: number) { + this.showReportsList = false; + + // in nextTick so global report function records get manipulated before individual + // entries are used + nextTick(() => { + this.formSetEditReport(reportId); + }); + }, + submitReport() { + const apiParameters: QueryParameters = { + idReport: this.report.idreport, + description: this.report.description, + idSegment: this.report.idsegment, + reportType: this.report.type, + reportFormat: this.report[`format${this.report.type}`] as string, + periodParam: this.report.periodParam, + evolutionPeriodFor: this.report.evolutionPeriodFor, + }; + + if (apiParameters.evolutionPeriodFor !== 'each') { + apiParameters.evolutionPeriodN = this.report.evolutionPeriodN; + } + + const { period } = this.report; + const hour = adjustHourToTimezone(this.report.hour as string, -timeZoneDifferenceInHours); + + const selectedReports = this.selectedReports[apiParameters.reportType as string] || {}; + const reports = Object.keys(selectedReports).filter( + (name) => this.selectedReports[apiParameters.reportType as string][name], + ); + + if (reports.length > 0) { + apiParameters.reports = reports; + } + + const reportParams = window.getReportParametersFunctions[this.report.type](this.report); + apiParameters.parameters = reportParams as unknown as QueryParameters; + + const isCreate = this.report.idreport > 0; + AjaxHelper.post( + { + method: isCreate ? 'ScheduledReports.updateReport' : 'ScheduledReports.addReport', + period, + hour, + }, + apiParameters, + ).then(() => { + this.fadeInOutSuccessMessage( + this.$refs.reportUpdatedSuccess as HTMLElement, + translate('ScheduledReports_ReportUpdated'), + ); + }); + return false; + }, + onChangeProperty(propName: string, value: unknown) { + this.report[propName] = value; + + if (propName === 'type') { + this.changedReportType(); + } + }, + toggleSelectedReport(reportType: string, uniqueId: string) { + this.selectedReports[reportType] = this.selectedReports[reportType] || {}; + this.selectedReports[reportType][uniqueId] = !this.selectedReports[reportType][uniqueId]; + }, + }, + computed: { + showReportForm() { + return !this.showReportsList; + }, + decodedSiteName() { + return Matomo.helper.htmlDecode(this.siteName); + }, + }, +}); +</script> diff --git a/plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue b/plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue new file mode 100644 index 0000000000..ebbea65df1 --- /dev/null +++ b/plugins/ScheduledReports/vue/src/ReportParameters/ReportParameters.vue @@ -0,0 +1,109 @@ +<!-- + Matomo - free/libre analytics platform + @link https://matomo.org + @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later +--> + +<template> + <div v-if="report"> + <div> + <Field + uicontrol="checkbox" + name="report_email_me" + :introduction="translate('ScheduledReports_SendReportTo')" + v-show="report.type === 'email'" + :model-value="report.emailMe" + @update:model-value="$emit('change', 'emailMe', $event)" + :title="`${translate('ScheduledReports_SentToMe')} (${currentUserEmail})`" + /> + </div> + + <div> + <Field + uicontrol="textarea" + var-type="array" + v-show="report.type === 'email'" + :model-value="report.additionalEmails" + @update:model-value="$emit('change', 'additionalEmails', $event)" + :title="translate('ScheduledReports_AlsoSendReportToTheseEmails')"> + </Field> + </div> + </div> +</template> + +<script lang="ts"> +import { defineComponent } from 'vue'; +import { Field } from 'CorePluginsAdmin'; + +export default defineComponent({ + props: { + report: { + type: Object, + required: true, + }, + reportType: { + type: String, + required: true, + }, + defaultDisplayFormat: { + type: Number, + required: true, + }, + defaultEmailMe: { + type: Boolean, + required: true, + }, + defaultEvolutionGraph: { + type: Boolean, + required: true, + }, + currentUserEmail: { + type: String, + required: true, + }, + }, + emits: ['change'], + components: { + Field, + }, + setup(props) { + const { + resetReportParametersFunctions, + updateReportParametersFunctions, + getReportParametersFunctions, + } = window; + + if (!resetReportParametersFunctions[props.reportType]) { + resetReportParametersFunctions[props.reportType] = (theReport) => { + theReport.displayFormat = props.defaultDisplayFormat; + theReport.emailMe = props.defaultEmailMe; + theReport.evolutionGraph = props.defaultEvolutionGraph; + theReport.additionalEmails = []; + }; + } + + if (!updateReportParametersFunctions[props.reportType]) { + updateReportParametersFunctions[props.reportType] = (theReport) => { + if (!theReport?.parameters) { + return; + } + + ['displayFormat', 'emailMe', 'evolutionGraph', 'additionalEmails'].forEach((field) => { + if (field in theReport.parameters) { + theReport[field] = theReport.parameters[field]; + } + }); + }; + } + + if (!getReportParametersFunctions[props.reportType]) { + getReportParametersFunctions[props.reportType] = (theReport) => ({ + displayFormat: theReport.displayFormat, + emailMe: theReport.emailMe, + evolutionGraph: theReport.evolutionGraph, + additionalEmails: (theReport.additionalEmails || []), + }); + } + }, +}); +</script> diff --git a/plugins/ScheduledReports/vue/src/index.ts b/plugins/ScheduledReports/vue/src/index.ts new file mode 100644 index 0000000000..c24b56ad96 --- /dev/null +++ b/plugins/ScheduledReports/vue/src/index.ts @@ -0,0 +1,10 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +export * from './types'; +export { default as ReportParameters } from './ReportParameters/ReportParameters.vue'; +export { default as ManageScheduledReport } from './ManageScheduledReport/ManageScheduledReport.vue'; diff --git a/plugins/ScheduledReports/vue/src/types.ts b/plugins/ScheduledReports/vue/src/types.ts new file mode 100644 index 0000000000..69bece2cc6 --- /dev/null +++ b/plugins/ScheduledReports/vue/src/types.ts @@ -0,0 +1,53 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +export interface Report { + [name: string]: unknown; + + idreport: string|number; + idsite: string|number; + login: string; + description: string; + idsegment: string|number|null; + period: string; + hour: string|number; + type: string; + format: string; + reports: string[]; + parameters: Record<string, unknown>; // QueryParameters + ts_created: string; + ts_last_sent: string|null; + deleted: string|number; + evolution_graph_within_period: string|number; + evolution_graph_period_n: string|number; + period_param: string; + evolutionPeriodFor: string; + evolutionPeriodN: number; + periodParam: string; + recipients: string[]; +} + +interface ReportPluginGlobal { + defaultPeriod: string; + defaultHour: string; + defaultReportType: string; + defaultReportFormat: string; + reportList: Report[]; + createReportString: string; + updateReportString: string; + defaultEvolutionPeriodN: number; + periodTranslations: Record<string, { single: string, plural: string }>; +} + +declare global { + interface Window { + ReportPlugin: ReportPluginGlobal; + getReportParametersFunctions: Record<string, (report: Report) => Record<string, unknown>>; + resetReportParametersFunctions: Record<string, (report: Report) => void>; + updateReportParametersFunctions: Record<string, (report: Report) => void>; + } +} diff --git a/plugins/ScheduledReports/vue/src/utilities.ts b/plugins/ScheduledReports/vue/src/utilities.ts new file mode 100644 index 0000000000..d1f3577b9b --- /dev/null +++ b/plugins/ScheduledReports/vue/src/utilities.ts @@ -0,0 +1,10 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +export function adjustHourToTimezone(hour: string, difference: number): string { + return `${(24 + parseFloat(hour) + difference) % 24}`; +} |