From 0472b16ec19710b8d68c71d606d2ba1b9f5b3b1e Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 1 Apr 2022 11:51:31 -0700 Subject: [PATCH 1/5] migrate manage custom vars model to store --- .../ManageCustomVars.store.ts | 87 +++++++++++++++++++ vue/src/types.ts | 6 ++ 2 files changed, 93 insertions(+) create mode 100644 vue/src/ManageCustomVars/ManageCustomVars.store.ts create mode 100644 vue/src/types.ts diff --git a/vue/src/ManageCustomVars/ManageCustomVars.store.ts b/vue/src/ManageCustomVars/ManageCustomVars.store.ts new file mode 100644 index 0000000..677fded --- /dev/null +++ b/vue/src/ManageCustomVars/ManageCustomVars.store.ts @@ -0,0 +1,87 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +// TODO: +// - state property types +// - method signatures +// - method code + +import { + reactive, + computed, + readonly, +} from 'vue'; +import { AjaxHelper } from 'CoreHome'; + +interface CustomVarsStoreState { + customVariables: unknown[]; + extractions: unknown[]; + isLoading: boolean; + hasCustomVariablesInGeneral: boolean; + hasAtLeastOneUsage: boolean; + numSlotsAvailable: number; +} + +interface CustomVariableUsage { + index: number; + scope: string; + usages: unknown[]; +} + +class ManageCustomVarsStore { + private privateState = reactive({ + customVariables: [], + extractions: [], + isLoading: false, + hasCustomVariablesInGeneral: false, + hasAtLeastOneUsage: false, + numSlotsAvailable: 5, + }); + + readonly state = computed(() => readonly(this.privateState)); + + init() { + return this.fetchUsages(); + } + + fetchCustomVariables() { + return AjaxHelper.fetch({ + method: 'CustomVariables.getCustomVariables', + period: 'year', + date: 'today', + filter_limit: 1, + }).then((customVariables) => { + this.privateState.hasCustomVariablesInGeneral = customVariables?.length > 0; + }); + } + + fetchUsages() { + this.privateState.isLoading = true; + Promise.all([ + this.fetchCustomVariables(), + AjaxHelper.fetch({ + method: 'CustomVariables.getUsagesOfSlots', + filter_limit: '-1', + }), + ]).then(([, customVariableUsages]) => { + this.privateState.customVariables = customVariableUsages as CustomVariableUsage[]; + (customVariableUsages as CustomVariableUsage[]).forEach((customVar) => { + if (customVar.index > this.state.value.numSlotsAvailable) { + this.privateState.numSlotsAvailable = customVar.index; + } + + if (customVar.usages && customVar.usages.length > 0) { + this.privateState.hasAtLeastOneUsage = true; + } + }); + }).finally(() => { + this.privateState.isLoading = false; + }); + } +} + +export default new ManageCustomVarsStore(); diff --git a/vue/src/types.ts b/vue/src/types.ts new file mode 100644 index 0000000..2592e68 --- /dev/null +++ b/vue/src/types.ts @@ -0,0 +1,6 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ From 9e51e6b7545001c2398fcc6a3a908e93548f029c Mon Sep 17 00:00:00 2001 From: diosmosis Date: Fri, 1 Apr 2022 12:43:59 -0700 Subject: [PATCH 2/5] migrate manage custom vars store and directive to vue --- .gitignore | 7 +- CustomVariables.php | 10 +- .../manage-custom-vars.controller.js | 22 - .../manage-custom-vars.directive.html | 63 --- .../manage-custom-vars.directive.js | 26 - .../manage-custom-vars.model.js | 59 --- templates/manage.twig | 2 +- vue/dist/CustomVariables.umd.js | 475 ++++++++++++++++++ vue/dist/CustomVariables.umd.min.js | 14 + vue/dist/umd.metadata.json | 5 + .../ManageCustomVars.adapter.ts | 14 + .../ManageCustomVars/ManageCustomVars.less | 0 .../ManageCustomVars.store.ts | 24 +- vue/src/ManageCustomVars/ManageCustomVars.vue | 189 +++++++ vue/src/index.ts | 11 + vue/src/types.ts | 14 + 16 files changed, 736 insertions(+), 199 deletions(-) delete mode 100644 angularjs/manage-custom-vars/manage-custom-vars.controller.js delete mode 100644 angularjs/manage-custom-vars/manage-custom-vars.directive.html delete mode 100644 angularjs/manage-custom-vars/manage-custom-vars.directive.js delete mode 100644 angularjs/manage-custom-vars/manage-custom-vars.model.js create mode 100644 vue/dist/CustomVariables.umd.js create mode 100644 vue/dist/CustomVariables.umd.min.js create mode 100644 vue/dist/umd.metadata.json create mode 100644 vue/src/ManageCustomVars/ManageCustomVars.adapter.ts rename angularjs/manage-custom-vars/manage-custom-vars.directive.less => vue/src/ManageCustomVars/ManageCustomVars.less (100%) create mode 100644 vue/src/ManageCustomVars/ManageCustomVars.vue create mode 100644 vue/src/index.ts diff --git a/.gitignore b/.gitignore index c8c9480..71f2693 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ -tests/System/processed/*xml \ No newline at end of file +tests/System/processed/*xml +tests/System/processed/*text +/vue/dist/demo.html +/vue/dist/*.common.js +/vue/dist/*.map +/vue/dist/*.development.* diff --git a/CustomVariables.php b/CustomVariables.php index fcf1c10..6debed8 100644 --- a/CustomVariables.php +++ b/CustomVariables.php @@ -20,7 +20,6 @@ class CustomVariables extends \Piwik\Plugin public function registerEvents() { return array( - 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'Dimension.addDimensions' => 'addDimensions', @@ -137,14 +136,7 @@ public function getClientSideTranslationKeys(&$translationKeys) public function getStylesheetFiles(&$stylesheets) { - $stylesheets[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.less"; - } - - public function getJsFiles(&$jsFiles) - { - $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.model.js"; - $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.controller.js"; - $jsFiles[] = "plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.js"; + $stylesheets[] = "plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.less"; } public function provideActionDimensionFields(&$fields, &$joins) diff --git a/angularjs/manage-custom-vars/manage-custom-vars.controller.js b/angularjs/manage-custom-vars/manage-custom-vars.controller.js deleted file mode 100644 index b6c9983..0000000 --- a/angularjs/manage-custom-vars/manage-custom-vars.controller.js +++ /dev/null @@ -1,22 +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('ManageCustomVarsController', ManageCustomVarsController); - - ManageCustomVarsController.$inject = ['manageCustomVarsModel', 'piwik', '$filter']; - - function ManageCustomVarsController(manageCustomVarsModel, piwik, $filter) { - manageCustomVarsModel.fetchUsages(); - - this.model = manageCustomVarsModel; - this.siteName = piwik.siteName; - this.scopes = [ - {value: 'visit', name: _pk_translate('General_TrackingScopeVisit')}, - {value: 'page', name: _pk_translate('General_TrackingScopePage')} - ]; - } -})(); \ No newline at end of file diff --git a/angularjs/manage-custom-vars/manage-custom-vars.directive.html b/angularjs/manage-custom-vars/manage-custom-vars.directive.html deleted file mode 100644 index aaeb4ad..0000000 --- a/angularjs/manage-custom-vars/manage-custom-vars.directive.html +++ /dev/null @@ -1,63 +0,0 @@ -
-
-

- {{ 'CustomVariables_CustomVariables'|translate }} -

- -

- -

-
- -
- {{ 'CustomVariables_SlotsReportIsGeneratedOverTime'|translate }} -
- -
-
- - - - - - - - - - - - - - - - -
{{'CustomVariables_Index'|translate }}{{'CustomVariables_Usages'|translate }}
{{ 'General_Loading'|translate }}
{{ customVariables.index }} - {{'CustomVariables_Unused'|translate }} - - {{ cvar.name }}, - -
-
-
- -
- -

- {{ 'CustomVariables_CreatingCustomVariableTakesTime'|translate }} -

- -
-
- {{ 'CustomVariables_ToCreateCustomVarExecute'|translate }} -
-

./console customvariables:set-max-custom-variables {{ manageCustomVars.model.numSlotsAvailable + 1 }}
-

- -
- -
diff --git a/angularjs/manage-custom-vars/manage-custom-vars.directive.js b/angularjs/manage-custom-vars/manage-custom-vars.directive.js deleted file mode 100644 index adbf957..0000000 --- a/angularjs/manage-custom-vars/manage-custom-vars.directive.js +++ /dev/null @@ -1,26 +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 - */ - -/** - * Usage: - *
- */ -(function () { - angular.module('piwikApp').directive('piwikManageCustomVars', piwikManageCustomVars); - - piwikManageCustomVars.$inject = ['piwik']; - - function piwikManageCustomVars(piwik){ - return { - restrict: 'A', - scope: {}, - templateUrl: 'plugins/CustomVariables/angularjs/manage-custom-vars/manage-custom-vars.directive.html?cb=' + piwik.cacheBuster, - controller: 'ManageCustomVarsController', - controllerAs: 'manageCustomVars' - }; - } -})(); \ No newline at end of file diff --git a/angularjs/manage-custom-vars/manage-custom-vars.model.js b/angularjs/manage-custom-vars/manage-custom-vars.model.js deleted file mode 100644 index 6ce717b..0000000 --- a/angularjs/manage-custom-vars/manage-custom-vars.model.js +++ /dev/null @@ -1,59 +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').factory('manageCustomVarsModel', manageCustomVarsModel); - - manageCustomVarsModel.$inject = ['piwikApi']; - - function manageCustomVarsModel(piwikApi) { - - var model = { - customVariables : [], - extractions : [], - isLoading: false, - fetchUsages: fetchUsages, - hasCustomVariablesInGeneral: false, - hasAtLeastOneUsage: false, - numSlotsAvailable: 5, - }; - - return model; - - function fetchCustomVariables() { - return piwikApi.fetch({method: 'CustomVariables.getCustomVariables', period: 'year', date: 'today', filter_limit: 1}) - .then(function (customVariables) { - model.hasCustomVariablesInGeneral = (customVariables && customVariables.length > 0); - }); - } - - function fetchUsages() { - - model.isLoading = true; - - fetchCustomVariables().then(function () { - return piwikApi.fetch({method: 'CustomVariables.getUsagesOfSlots', filter_limit: '-1'}); - - }).then(function (customVariables) { - model.customVariables = customVariables; - - angular.forEach(customVariables, function (customVar) { - if (customVar.index > model.numSlotsAvailable) { - model.numSlotsAvailable = customVar.index; - } - - if (customVar.usages && customVar.usages.length > 0) { - model.hasAtLeastOneUsage = true; - } - }); - - })['finally'](function () { // .finally() is not IE8 compatible see https://github.com/angular/angular.js/commit/f078762d48d0d5d9796dcdf2cb0241198677582c - model.isLoading = false; - }); - } - - } -})(); \ No newline at end of file diff --git a/templates/manage.twig b/templates/manage.twig index e10e1ee..397e693 100644 --- a/templates/manage.twig +++ b/templates/manage.twig @@ -7,5 +7,5 @@ {% endblock %} {% block content %} -
+
{% endblock %} \ No newline at end of file diff --git a/vue/dist/CustomVariables.umd.js b/vue/dist/CustomVariables.umd.js new file mode 100644 index 0000000..0b16cd6 --- /dev/null +++ b/vue/dist/CustomVariables.umd.js @@ -0,0 +1,475 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("CoreHome"), require("vue")); + else if(typeof define === 'function' && define.amd) + define(["CoreHome", ], factory); + else if(typeof exports === 'object') + exports["CustomVariables"] = factory(require("CoreHome"), require("vue")); + else + root["CustomVariables"] = factory(root["CoreHome"], root["Vue"]); +})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__, __WEBPACK_EXTERNAL_MODULE__8bbf__) { +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/CustomVariables/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__; + +/***/ }), + +/***/ "65ae": +/***/ (function(module, exports) { + + + +/***/ }), + +/***/ "8bbf": +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; + +/***/ }), + +/***/ "fae3": +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, "ManageCustomVarsStore", function() { return /* reexport */ ManageCustomVars_store; }); +__webpack_require__.d(__webpack_exports__, "ManageCustomVars", function() { return /* reexport */ ManageCustomVars; }); + +// 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); + +// EXTERNAL MODULE: external "CoreHome" +var external_CoreHome_ = __webpack_require__("19dc"); + +// 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/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=0b948dfb + +var _hoisted_1 = { + class: "manageCustomVars" +}; +var _hoisted_2 = ["innerHTML"]; +var _hoisted_3 = { + class: "index" +}; +var _hoisted_4 = ["title"]; +var _hoisted_5 = { + key: 0 +}; + +var _hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_7 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_8 = ["innerHTML"]; + +var _hoisted_9 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_10 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_11 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1); + +var _hoisted_12 = ["textContent"]; +function render(_ctx, _cache, $props, $setup, $data, $options) { + var _component_EnrichedHeadline = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("EnrichedHeadline"); + + var _component_ContentBlock = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ContentBlock"); + + var _directive_content_intro = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-intro"); + + var _directive_content_table = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("content-table"); + + var _directive_select_on_focus = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("select-on-focus"); + + return 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_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h2", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_EnrichedHeadline, { + "help-url": "https://matomo.org/docs/custom-variables/" + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_CustomVariables')), 1)]; + }), + _: 1 + })]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.$sanitize(_ctx.translate('CustomVariables_ManageDescription', _ctx.siteName)) + }, null, 8, _hoisted_2)])], 512), [[_directive_content_intro]]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", { + class: "alert alert-info" + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_SlotsReportIsGeneratedOverTime')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading && _ctx.hasCustomVariablesInGeneral && !_ctx.hasAtLeastOneUsage]]), (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.scopes, function (scope) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", { + key: scope.name + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { + "content-title": _ctx.translate('CustomVariables_ScopeX', scope.name) + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + 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", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Index')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("th", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Usages')), 1)])]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tbody", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("tr", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", { + colspan: "3" + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Loading')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], _ctx.isLoading]])]), (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.customVariablesByScope[scope.value], function (customVariables, index) { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("tr", { + key: index + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", _hoisted_3, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(customVariables.index), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("td", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + class: "unused" + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_Unused')), 513), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], customVariables.usages.length === 0]]), (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.sortUsages(customVariables), function (cvar, cvarIndex) { + 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"])("span", { + key: cvarIndex + }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + title: _ctx.translate('CustomVariables_UsageDetails', cvar.nb_visits ? cvar.nb_visits : 0, cvar.nb_actions ? cvar.nb_actions : 0) + }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(cvar.name), 9, _hoisted_4), cvarIndex < customVariables.usages.length - 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_["createCommentVNode"])("", true)], 512)), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], customVariables.usages.length]]); + }), 128))])]); + }), 128))])], 512), [[_directive_content_table]])]; + }), + _: 2 + }, 1032, ["content-title"])]); + }), 128)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_ContentBlock, { + id: "CustomVariablesCreateNewSlot", + "content-title": _ctx.translate('CustomVariables_CreateNewSlot') + }, { + default: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () { + return [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"])("p", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_CreatingCustomVariableTakesTime')) + " ", 1), _hoisted_6, _hoisted_7, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { + innerHTML: _ctx.$sanitize(_ctx.currentAvailableCustomVariablesText) + }, null, 8, _hoisted_8), _hoisted_9, _hoisted_10, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('CustomVariables_ToCreateCustomVarExecute')) + " ", 1), _hoisted_11]), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("pre", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("code", { + textContent: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.setMaxCustomVariablesCmd) + }, null, 8, _hoisted_12)], 512), [[_directive_select_on_focus, {}]])], 512), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading]])]; + }), + _: 1 + }, 8, ["content-title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading]])]); +} +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=0b948dfb + +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.store.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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +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; } + +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + + + +var ManageCustomVars_store_ManageCustomVarsStore = /*#__PURE__*/function () { + function ManageCustomVarsStore() { + var _this = this; + + _classCallCheck(this, ManageCustomVarsStore); + + _defineProperty(this, "privateState", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({ + customVariables: [], + isLoading: false, + hasCustomVariablesInGeneral: false, + hasAtLeastOneUsage: false, + numSlotsAvailable: 5 + })); + + _defineProperty(this, "state", Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(function () { + return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["readonly"])(_this.privateState); + })); + } + + _createClass(ManageCustomVarsStore, [{ + key: "init", + value: function init() { + return this.fetchUsages(); + } + }, { + key: "fetchCustomVariables", + value: function fetchCustomVariables() { + var _this2 = this; + + return external_CoreHome_["AjaxHelper"].fetch({ + method: 'CustomVariables.getCustomVariables', + period: 'year', + date: 'today', + filter_limit: 1 + }).then(function (customVariables) { + _this2.privateState.hasCustomVariablesInGeneral = (customVariables === null || customVariables === void 0 ? void 0 : customVariables.length) > 0; + }); + } + }, { + key: "fetchUsages", + value: function fetchUsages() { + var _this3 = this; + + this.privateState.isLoading = true; + return Promise.all([this.fetchCustomVariables(), external_CoreHome_["AjaxHelper"].fetch({ + method: 'CustomVariables.getUsagesOfSlots', + filter_limit: '-1' + })]).then(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + customVariableUsages = _ref2[1]; + + _this3.privateState.customVariables = customVariableUsages; + customVariableUsages.forEach(function (customVar) { + if (customVar.index > _this3.state.value.numSlotsAvailable) { + _this3.privateState.numSlotsAvailable = customVar.index; + } + + if (customVar.usages && customVar.usages.length > 0) { + _this3.privateState.hasAtLeastOneUsage = true; + } + }); + }).finally(function () { + _this3.privateState.isLoading = false; + }); + } + }]); + + return ManageCustomVarsStore; +}(); + +/* harmony default export */ var ManageCustomVars_store = (new ManageCustomVars_store_ManageCustomVarsStore()); +// 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/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=script&lang=ts +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || ManageCustomVarsvue_type_script_lang_ts_unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function ManageCustomVarsvue_type_script_lang_ts_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return ManageCustomVarsvue_type_script_lang_ts_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 ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(arr); } + +function ManageCustomVarsvue_type_script_lang_ts_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; } + + + + +/* harmony default export */ var ManageCustomVarsvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ + components: { + EnrichedHeadline: external_CoreHome_["EnrichedHeadline"], + ContentBlock: external_CoreHome_["ContentBlock"] + }, + directives: { + ContentIntro: external_CoreHome_["ContentIntro"], + ContentTable: external_CoreHome_["ContentTable"], + SelectOnFocus: external_CoreHome_["SelectOnFocus"] + }, + data: function data() { + return { + siteName: external_CoreHome_["Matomo"].siteName, + scopes: [{ + value: 'visit', + name: Object(external_CoreHome_["translate"])('General_TrackingScopeVisit') + }, { + value: 'page', + name: Object(external_CoreHome_["translate"])('General_TrackingScopePage') + }] + }; + }, + created: function created() { + ManageCustomVars_store.init(); + }, + methods: { + sortUsages: function sortUsages(customVar) { + var result = _toConsumableArray(customVar.usages); + + result.sort(function (lhs, rhs) { + var rhsActions = "".concat(rhs.nb_actions); + var lhsActions = "".concat(lhs.nb_actions); + return parseInt(rhsActions, 10) - parseInt(lhsActions, 10); + }); + return result; + } + }, + computed: { + isLoading: function isLoading() { + return ManageCustomVars_store.state.value.isLoading; + }, + hasCustomVariablesInGeneral: function hasCustomVariablesInGeneral() { + return ManageCustomVars_store.state.value.hasCustomVariablesInGeneral; + }, + hasAtLeastOneUsage: function hasAtLeastOneUsage() { + return ManageCustomVars_store.state.value.hasAtLeastOneUsage; + }, + numSlotsAvailable: function numSlotsAvailable() { + return ManageCustomVars_store.state.value.numSlotsAvailable; + }, + customVariablesByScope: function customVariablesByScope() { + var result = {}; + ManageCustomVars_store.state.value.customVariables.forEach(function (customVar) { + result[customVar.scope] = result[customVar.scope] || []; + result[customVar.scope].push(customVar); + }); + return result; + }, + currentAvailableCustomVariablesText: function currentAvailableCustomVariablesText() { + return Object(external_CoreHome_["translate"])('CustomVariables_CurrentAvailableCustomVariables', "".concat(this.numSlotsAvailable, "")); + }, + setMaxCustomVariablesCmd: function setMaxCustomVariablesCmd() { + return "./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable + 1); + } + } +})); +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=script&lang=ts + +// EXTERNAL MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=custom&index=0&blockType=todo +var ManageCustomVarsvue_type_custom_index_0_blockType_todo = __webpack_require__("65ae"); +var ManageCustomVarsvue_type_custom_index_0_blockType_todo_default = /*#__PURE__*/__webpack_require__.n(ManageCustomVarsvue_type_custom_index_0_blockType_todo); + +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue + + + +ManageCustomVarsvue_type_script_lang_ts.render = render +/* custom blocks */ + +if (typeof ManageCustomVarsvue_type_custom_index_0_blockType_todo_default.a === 'function') ManageCustomVarsvue_type_custom_index_0_blockType_todo_default()(ManageCustomVarsvue_type_script_lang_ts) + + +/* harmony default export */ var ManageCustomVars = (ManageCustomVarsvue_type_script_lang_ts); +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.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 ManageCustomVars_adapter = (Object(external_CoreHome_["createAngularJsAdapter"])({ + component: ManageCustomVars, + directiveName: 'piwikManageCustomVars' +})); +// CONCATENATED MODULE: ./plugins/CustomVariables/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=CustomVariables.umd.js.map \ No newline at end of file diff --git a/vue/dist/CustomVariables.umd.min.js b/vue/dist/CustomVariables.umd.min.js new file mode 100644 index 0000000..c65871d --- /dev/null +++ b/vue/dist/CustomVariables.umd.min.js @@ -0,0 +1,14 @@ +(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue")):"function"===typeof define&&define.amd?define(["CoreHome"],t):"object"===typeof exports?exports["CustomVariables"]=t(require("CoreHome"),require("vue")):e["CustomVariables"]=t(e["CoreHome"],e["Vue"])})("undefined"!==typeof self?self:this,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},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/CustomVariables/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"65ae":function(e,t){},"8bbf":function(e,n){e.exports=t},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"ManageCustomVarsStore",(function(){return _})),n.d(t,"ManageCustomVars",(function(){return P})),"undefined"!==typeof window){var r=window.document.currentScript,a=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);a&&(n.p=a[1])}var o=n("19dc"),i=n("8bbf"),l={class:"manageCustomVars"},c=["innerHTML"],s={class:"index"},u=["title"],b={key:0},m=Object(i["createElementVNode"])("br",null,null,-1),d=Object(i["createElementVNode"])("br",null,null,-1),f=["innerHTML"],p=Object(i["createElementVNode"])("br",null,null,-1),v=Object(i["createElementVNode"])("br",null,null,-1),O=Object(i["createElementVNode"])("br",null,null,-1),j=["textContent"];function h(e,t,n,r,a,o){var h=Object(i["resolveComponent"])("EnrichedHeadline"),g=Object(i["resolveComponent"])("ContentBlock"),y=Object(i["resolveDirective"])("content-intro"),V=Object(i["resolveDirective"])("content-table"),C=Object(i["resolveDirective"])("select-on-focus");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",l,[Object(i["withDirectives"])(Object(i["createElementVNode"])("div",null,[Object(i["createElementVNode"])("h2",null,[Object(i["createVNode"])(h,{"help-url":"https://matomo.org/docs/custom-variables/"},{default:Object(i["withCtx"])((function(){return[Object(i["createTextVNode"])(Object(i["toDisplayString"])(e.translate("CustomVariables_CustomVariables")),1)]})),_:1})]),Object(i["createElementVNode"])("p",null,[Object(i["createElementVNode"])("span",{innerHTML:e.$sanitize(e.translate("CustomVariables_ManageDescription",e.siteName))},null,8,c)])],512),[[y]]),Object(i["withDirectives"])(Object(i["createElementVNode"])("div",{class:"alert alert-info"},Object(i["toDisplayString"])(e.translate("CustomVariables_SlotsReportIsGeneratedOverTime")),513),[[i["vShow"],!e.isLoading&&e.hasCustomVariablesInGeneral&&!e.hasAtLeastOneUsage]]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.scopes,(function(t){return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",{key:t.name},[Object(i["createVNode"])(g,{"content-title":e.translate("CustomVariables_ScopeX",t.name)},{default:Object(i["withCtx"])((function(){return[Object(i["withDirectives"])(Object(i["createElementVNode"])("table",null,[Object(i["createElementVNode"])("thead",null,[Object(i["createElementVNode"])("tr",null,[Object(i["createElementVNode"])("th",null,Object(i["toDisplayString"])(e.translate("CustomVariables_Index")),1),Object(i["createElementVNode"])("th",null,Object(i["toDisplayString"])(e.translate("CustomVariables_Usages")),1)])]),Object(i["createElementVNode"])("tbody",null,[Object(i["createElementVNode"])("tr",null,[Object(i["withDirectives"])(Object(i["createElementVNode"])("td",{colspan:"3"},Object(i["toDisplayString"])(e.translate("General_Loading")),513),[[i["vShow"],e.isLoading]])]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.customVariablesByScope[t.value],(function(t,n){return Object(i["openBlock"])(),Object(i["createElementBlock"])("tr",{key:n},[Object(i["createElementVNode"])("td",s,Object(i["toDisplayString"])(t.index),1),Object(i["createElementVNode"])("td",null,[Object(i["withDirectives"])(Object(i["createElementVNode"])("span",{class:"unused"},Object(i["toDisplayString"])(e.translate("CustomVariables_Unused")),513),[[i["vShow"],0===t.usages.length]]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.sortUsages(t),(function(n,r){return Object(i["withDirectives"])((Object(i["openBlock"])(),Object(i["createElementBlock"])("span",{key:r},[Object(i["createElementVNode"])("span",{title:e.translate("CustomVariables_UsageDetails",n.nb_visits?n.nb_visits:0,n.nb_actions?n.nb_actions:0)},Object(i["toDisplayString"])(n.name),9,u),re.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}))}},{key:"fetchUsages",value:function(){var e=this;return this.privateState.isLoading=!0,Promise.all([this.fetchCustomVariables(),o["AjaxHelper"].fetch({method:"CustomVariables.getUsagesOfSlots",filter_limit:"-1"})]).then((function(t){var n=g(t,2),r=n[1];e.privateState.customVariables=r,r.forEach((function(t){t.index>e.state.value.numSlotsAvailable&&(e.privateState.numSlotsAvailable=t.index),t.usages&&t.usages.length>0&&(e.privateState.hasAtLeastOneUsage=!0)}))})).finally((function(){e.privateState.isLoading=!1}))}}]),e}(),_=new A;function D(e){return I(e)||B(e)||T(e)||L()}function L(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){if(e){if("string"===typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function B(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e){if(Array.isArray(e))return M(e)}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n".concat(this.numSlotsAvailable,""))},setMaxCustomVariablesCmd:function(){return"./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable+1)}}}),H=n("65ae"),G=n.n(H);U.render=h,"function"===typeof G.a&&G()(U);var P=U; +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */Object(o["createAngularJsAdapter"])({component:P,directiveName:"piwikManageCustomVars"})}})})); +//# sourceMappingURL=CustomVariables.umd.min.js.map \ No newline at end of file diff --git a/vue/dist/umd.metadata.json b/vue/dist/umd.metadata.json new file mode 100644 index 0000000..9ecfcc0 --- /dev/null +++ b/vue/dist/umd.metadata.json @@ -0,0 +1,5 @@ +{ + "dependsOn": [ + "CoreHome" + ] +} \ No newline at end of file diff --git a/vue/src/ManageCustomVars/ManageCustomVars.adapter.ts b/vue/src/ManageCustomVars/ManageCustomVars.adapter.ts new file mode 100644 index 0000000..fd1c5d4 --- /dev/null +++ b/vue/src/ManageCustomVars/ManageCustomVars.adapter.ts @@ -0,0 +1,14 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +import { createAngularJsAdapter } from 'CoreHome'; +import ManageCustomVars from './ManageCustomVars.vue'; + +export default createAngularJsAdapter({ + component: ManageCustomVars, + directiveName: 'piwikManageCustomVars', +}); diff --git a/angularjs/manage-custom-vars/manage-custom-vars.directive.less b/vue/src/ManageCustomVars/ManageCustomVars.less similarity index 100% rename from angularjs/manage-custom-vars/manage-custom-vars.directive.less rename to vue/src/ManageCustomVars/ManageCustomVars.less diff --git a/vue/src/ManageCustomVars/ManageCustomVars.store.ts b/vue/src/ManageCustomVars/ManageCustomVars.store.ts index 677fded..596cf62 100644 --- a/vue/src/ManageCustomVars/ManageCustomVars.store.ts +++ b/vue/src/ManageCustomVars/ManageCustomVars.store.ts @@ -5,37 +5,25 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -// TODO: -// - state property types -// - method signatures -// - method code - import { reactive, computed, readonly, } from 'vue'; import { AjaxHelper } from 'CoreHome'; +import { CustomVariableUsage } from '../types'; interface CustomVarsStoreState { - customVariables: unknown[]; - extractions: unknown[]; + customVariables: CustomVariableUsage[]; isLoading: boolean; hasCustomVariablesInGeneral: boolean; hasAtLeastOneUsage: boolean; numSlotsAvailable: number; } -interface CustomVariableUsage { - index: number; - scope: string; - usages: unknown[]; -} - class ManageCustomVarsStore { private privateState = reactive({ customVariables: [], - extractions: [], isLoading: false, hasCustomVariablesInGeneral: false, hasAtLeastOneUsage: false, @@ -44,11 +32,11 @@ class ManageCustomVarsStore { readonly state = computed(() => readonly(this.privateState)); - init() { + init(): Promise { return this.fetchUsages(); } - fetchCustomVariables() { + fetchCustomVariables(): Promise { return AjaxHelper.fetch({ method: 'CustomVariables.getCustomVariables', period: 'year', @@ -59,9 +47,9 @@ class ManageCustomVarsStore { }); } - fetchUsages() { + fetchUsages(): Promise { this.privateState.isLoading = true; - Promise.all([ + return Promise.all([ this.fetchCustomVariables(), AjaxHelper.fetch({ method: 'CustomVariables.getUsagesOfSlots', diff --git a/vue/src/ManageCustomVars/ManageCustomVars.vue b/vue/src/ManageCustomVars/ManageCustomVars.vue new file mode 100644 index 0000000..439a8e4 --- /dev/null +++ b/vue/src/ManageCustomVars/ManageCustomVars.vue @@ -0,0 +1,189 @@ + + + +- test in UI + + + + + diff --git a/vue/src/index.ts b/vue/src/index.ts new file mode 100644 index 0000000..410da49 --- /dev/null +++ b/vue/src/index.ts @@ -0,0 +1,11 @@ +/*! + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +import './ManageCustomVars/ManageCustomVars.adapter'; + +export { default as ManageCustomVarsStore } from './ManageCustomVars/ManageCustomVars.store'; +export { default as ManageCustomVars } from './ManageCustomVars/ManageCustomVars.vue'; diff --git a/vue/src/types.ts b/vue/src/types.ts index 2592e68..c5f9abb 100644 --- a/vue/src/types.ts +++ b/vue/src/types.ts @@ -4,3 +4,17 @@ * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ + +interface CustomVariableUsageRow { + name: string; + nb_actions: number|string; + nb_visits: number|string; +} + +interface CustomVariableUsage { + index: number; + scope: string; + usages: CustomVariableUsageRow[]; +} + +export { CustomVariableUsage }; From e6098f4b5b40479ad8c04887b0dd826a16949bf2 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 6 Apr 2022 16:22:00 -0700 Subject: [PATCH 3/5] update expected screenshot --- .../CustomVariables_manage.png | Bin 104492 -> 104398 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/UI/expected-ui-screenshots/CustomVariables_manage.png b/tests/UI/expected-ui-screenshots/CustomVariables_manage.png index 5def12aa3b265468c1df777b9d7d6d6c4b6865bf..7a970267530d3fa6fe55065902908db1c94b9faf 100644 GIT binary patch delta 388 zcmZ3pf$iLSwh7`~x*Ti_3=I9A5v7faTNN4SH!z9)*nX&iF+sF`GPlqf3z9=+2!xpGV6;%yQK?HxJi59{jY#>U{RGp3gPfj~+f$)YsR4`s7K*^L2N% zG&Jf10s|-Z7(S0SfoeJWu;9ey%fWGRai6|_55K#s^y$OE-SJwpjoF+uYU6X-aVj( zlx#REL~*yUKcI9w9*D_4#V`#mu#NY)K7i6r+Mb3Qy(_p1Ped# zDpD+(01T)pN;4onU$O7=znwV{Jy-aqE4DI*i2ak_{lLr5@d6KbtYG{z(&yF<<** zClO|#G6seMPs{s0PxdrRwjXvhfC#Pgcs{#(PPjqvuEh4k3pb~qpXVP4R?9Gb3Xr!e zMR{wXW7-*uxqeG!{6q8d-u)C~hnRKo^x3nar#^;Q&OP^emf>TY`&|_k6(>%g_O`UN zytOlXI~NyMeMm@%O7fYXV!RM7frS<_pT2yVGJX2=KY#y*ZqJLYthiEl?{p=r@zSY< zR&zgn{yMe2y`77jJ2WPy#O^2)SX;~%8yl}p0`mF!mUI0otE#S5T{}~Geg?>_PoK1Y z?%%#0s9~lq#6Nn`OShM5&RvuAdZ`beOZ(wnb5@pU@q^7d@N|s{zvcb-RIB$1%eEN( z$uR>9@0b+RAp;7ir5tHs0ftrY_tfi2L)crLr+;W;bet|QjZs+aKl`j`ucVjPu6+SX Ndb;|#taD0e0stJkn^XV* From 0b9cf9b15fe02061f9dde61f82d8f3124c7fdc8c Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 6 Apr 2022 16:23:49 -0700 Subject: [PATCH 4/5] remove todo --- vue/dist/CustomVariables.umd.js | 19 ++----------------- vue/dist/CustomVariables.umd.min.js | 6 +++--- vue/src/ManageCustomVars/ManageCustomVars.vue | 4 ---- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/vue/dist/CustomVariables.umd.js b/vue/dist/CustomVariables.umd.js index 0b16cd6..e7c0d43 100644 --- a/vue/dist/CustomVariables.umd.js +++ b/vue/dist/CustomVariables.umd.js @@ -101,13 +101,6 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = __WEBPACK_EXTERNAL_MODULE__19dc__; -/***/ }), - -/***/ "65ae": -/***/ (function(module, exports) { - - - /***/ }), /***/ "8bbf": @@ -150,7 +143,7 @@ var external_CoreHome_ = __webpack_require__("19dc"); // 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/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=0b948dfb +// 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/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=ddf373e4 var _hoisted_1 = { class: "manageCustomVars" @@ -238,7 +231,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) { _: 1 }, 8, ["content-title"]), [[external_commonjs_vue_commonjs2_vue_root_Vue_["vShow"], !_ctx.isLoading]])]); } -// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=0b948dfb +// CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=template&id=ddf373e4 // CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.store.ts function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } @@ -425,19 +418,11 @@ function ManageCustomVarsvue_type_script_lang_ts_arrayLikeToArray(arr, len) { if })); // CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=script&lang=ts -// EXTERNAL MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue?vue&type=custom&index=0&blockType=todo -var ManageCustomVarsvue_type_custom_index_0_blockType_todo = __webpack_require__("65ae"); -var ManageCustomVarsvue_type_custom_index_0_blockType_todo_default = /*#__PURE__*/__webpack_require__.n(ManageCustomVarsvue_type_custom_index_0_blockType_todo); - // CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.vue ManageCustomVarsvue_type_script_lang_ts.render = render -/* custom blocks */ - -if (typeof ManageCustomVarsvue_type_custom_index_0_blockType_todo_default.a === 'function') ManageCustomVarsvue_type_custom_index_0_blockType_todo_default()(ManageCustomVarsvue_type_script_lang_ts) - /* harmony default export */ var ManageCustomVars = (ManageCustomVarsvue_type_script_lang_ts); // CONCATENATED MODULE: ./plugins/CustomVariables/vue/src/ManageCustomVars/ManageCustomVars.adapter.ts diff --git a/vue/dist/CustomVariables.umd.min.js b/vue/dist/CustomVariables.umd.min.js index c65871d..68cfa43 100644 --- a/vue/dist/CustomVariables.umd.min.js +++ b/vue/dist/CustomVariables.umd.min.js @@ -1,14 +1,14 @@ -(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue")):"function"===typeof define&&define.amd?define(["CoreHome"],t):"object"===typeof exports?exports["CustomVariables"]=t(require("CoreHome"),require("vue")):e["CustomVariables"]=t(e["CoreHome"],e["Vue"])})("undefined"!==typeof self?self:this,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},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/CustomVariables/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"65ae":function(e,t){},"8bbf":function(e,n){e.exports=t},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"ManageCustomVarsStore",(function(){return _})),n.d(t,"ManageCustomVars",(function(){return P})),"undefined"!==typeof window){var r=window.document.currentScript,a=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);a&&(n.p=a[1])}var o=n("19dc"),i=n("8bbf"),l={class:"manageCustomVars"},c=["innerHTML"],s={class:"index"},u=["title"],b={key:0},m=Object(i["createElementVNode"])("br",null,null,-1),d=Object(i["createElementVNode"])("br",null,null,-1),f=["innerHTML"],p=Object(i["createElementVNode"])("br",null,null,-1),v=Object(i["createElementVNode"])("br",null,null,-1),O=Object(i["createElementVNode"])("br",null,null,-1),j=["textContent"];function h(e,t,n,r,a,o){var h=Object(i["resolveComponent"])("EnrichedHeadline"),g=Object(i["resolveComponent"])("ContentBlock"),y=Object(i["resolveDirective"])("content-intro"),V=Object(i["resolveDirective"])("content-table"),C=Object(i["resolveDirective"])("select-on-focus");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",l,[Object(i["withDirectives"])(Object(i["createElementVNode"])("div",null,[Object(i["createElementVNode"])("h2",null,[Object(i["createVNode"])(h,{"help-url":"https://matomo.org/docs/custom-variables/"},{default:Object(i["withCtx"])((function(){return[Object(i["createTextVNode"])(Object(i["toDisplayString"])(e.translate("CustomVariables_CustomVariables")),1)]})),_:1})]),Object(i["createElementVNode"])("p",null,[Object(i["createElementVNode"])("span",{innerHTML:e.$sanitize(e.translate("CustomVariables_ManageDescription",e.siteName))},null,8,c)])],512),[[y]]),Object(i["withDirectives"])(Object(i["createElementVNode"])("div",{class:"alert alert-info"},Object(i["toDisplayString"])(e.translate("CustomVariables_SlotsReportIsGeneratedOverTime")),513),[[i["vShow"],!e.isLoading&&e.hasCustomVariablesInGeneral&&!e.hasAtLeastOneUsage]]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.scopes,(function(t){return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",{key:t.name},[Object(i["createVNode"])(g,{"content-title":e.translate("CustomVariables_ScopeX",t.name)},{default:Object(i["withCtx"])((function(){return[Object(i["withDirectives"])(Object(i["createElementVNode"])("table",null,[Object(i["createElementVNode"])("thead",null,[Object(i["createElementVNode"])("tr",null,[Object(i["createElementVNode"])("th",null,Object(i["toDisplayString"])(e.translate("CustomVariables_Index")),1),Object(i["createElementVNode"])("th",null,Object(i["toDisplayString"])(e.translate("CustomVariables_Usages")),1)])]),Object(i["createElementVNode"])("tbody",null,[Object(i["createElementVNode"])("tr",null,[Object(i["withDirectives"])(Object(i["createElementVNode"])("td",{colspan:"3"},Object(i["toDisplayString"])(e.translate("General_Loading")),513),[[i["vShow"],e.isLoading]])]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.customVariablesByScope[t.value],(function(t,n){return Object(i["openBlock"])(),Object(i["createElementBlock"])("tr",{key:n},[Object(i["createElementVNode"])("td",s,Object(i["toDisplayString"])(t.index),1),Object(i["createElementVNode"])("td",null,[Object(i["withDirectives"])(Object(i["createElementVNode"])("span",{class:"unused"},Object(i["toDisplayString"])(e.translate("CustomVariables_Unused")),513),[[i["vShow"],0===t.usages.length]]),(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(e.sortUsages(t),(function(n,r){return Object(i["withDirectives"])((Object(i["openBlock"])(),Object(i["createElementBlock"])("span",{key:r},[Object(i["createElementVNode"])("span",{title:e.translate("CustomVariables_UsageDetails",n.nb_visits?n.nb_visits:0,n.nb_actions?n.nb_actions:0)},Object(i["toDisplayString"])(n.name),9,u),re.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0}))}},{key:"fetchUsages",value:function(){var e=this;return this.privateState.isLoading=!0,Promise.all([this.fetchCustomVariables(),o["AjaxHelper"].fetch({method:"CustomVariables.getUsagesOfSlots",filter_limit:"-1"})]).then((function(t){var n=g(t,2),r=n[1];e.privateState.customVariables=r,r.forEach((function(t){t.index>e.state.value.numSlotsAvailable&&(e.privateState.numSlotsAvailable=t.index),t.usages&&t.usages.length>0&&(e.privateState.hasAtLeastOneUsage=!0)}))})).finally((function(){e.privateState.isLoading=!1}))}}]),e}(),_=new A;function D(e){return I(e)||B(e)||T(e)||L()}function L(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){if(e){if("string"===typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function B(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e){if(Array.isArray(e))return M(e)}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n".concat(this.numSlotsAvailable,""))},setMaxCustomVariablesCmd:function(){return"./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable+1)}}}),H=n("65ae"),G=n.n(H);U.render=h,"function"===typeof G.a&&G()(U);var P=U; + */var A=function(){function e(){var t=this;N(this,e),k(this,"privateState",Object(l["reactive"])({customVariables:[],isLoading:!1,hasCustomVariablesInGeneral:!1,hasAtLeastOneUsage:!1,numSlotsAvailable:5})),k(this,"state",Object(l["computed"])((function(){return Object(l["readonly"])(t.privateState)})))}return x(e,[{key:"init",value:function(){return this.fetchUsages()}},{key:"fetchCustomVariables",value:function(){var e=this;return o["AjaxHelper"].fetch({method:"CustomVariables.getCustomVariables",period:"year",date:"today",filter_limit:1}).then((function(t){e.privateState.hasCustomVariablesInGeneral=(null===t||void 0===t?void 0:t.length)>0}))}},{key:"fetchUsages",value:function(){var e=this;return this.privateState.isLoading=!0,Promise.all([this.fetchCustomVariables(),o["AjaxHelper"].fetch({method:"CustomVariables.getUsagesOfSlots",filter_limit:"-1"})]).then((function(t){var n=g(t,2),r=n[1];e.privateState.customVariables=r,r.forEach((function(t){t.index>e.state.value.numSlotsAvailable&&(e.privateState.numSlotsAvailable=t.index),t.usages&&t.usages.length>0&&(e.privateState.hasAtLeastOneUsage=!0)}))})).finally((function(){e.privateState.isLoading=!1}))}}]),e}(),_=new A;function D(e){return I(e)||B(e)||T(e)||L()}function L(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){if(e){if("string"===typeof e)return M(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(e,t):void 0}}function B(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(e){if(Array.isArray(e))return M(e)}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n".concat(this.numSlotsAvailable,""))},setMaxCustomVariablesCmd:function(){return"./console customvariables:set-max-custom-variables ".concat(this.numSlotsAvailable+1)}}});U.render=h;var H=U; /*! * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */Object(o["createAngularJsAdapter"])({component:P,directiveName:"piwikManageCustomVars"})}})})); + */Object(o["createAngularJsAdapter"])({component:H,directiveName:"piwikManageCustomVars"})}})})); //# sourceMappingURL=CustomVariables.umd.min.js.map \ No newline at end of file diff --git a/vue/src/ManageCustomVars/ManageCustomVars.vue b/vue/src/ManageCustomVars/ManageCustomVars.vue index 439a8e4..3361f5c 100644 --- a/vue/src/ManageCustomVars/ManageCustomVars.vue +++ b/vue/src/ManageCustomVars/ManageCustomVars.vue @@ -4,10 +4,6 @@ @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later --> - -- test in UI - -