Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordizzy <diosmosis@users.noreply.github.com>2022-03-17 17:16:15 +0300
committerGitHub <noreply@github.com>2022-03-17 17:16:15 +0300
commitd5f50163782792ac42122c46d9e73f2e38e9029b (patch)
tree60900e2182f59df6c8e5d70b53d920a9dd88d5ba /plugins/CoreHome/vue
parent84c2cb1af82dca689480cdcf652afaeb01877d9a (diff)
[Vue] migrate custom dimension management (#18926)
* more migration work * get new code to work * make sure chunk assets can be removed * look over/remove todos * apply pr review fixes * Update plugins/CustomDimensions/lang/en.json Co-authored-by: Stefan Giehl <stefan@matomo.org> * apply review feedback * actual fix Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'plugins/CoreHome/vue')
-rw-r--r--plugins/CoreHome/vue/dist/CoreHome.umd.js6
-rw-r--r--plugins/CoreHome/vue/dist/CoreHome.umd.min.js2
-rw-r--r--plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts5
3 files changed, 12 insertions, 1 deletions
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.js b/plugins/CoreHome/vue/dist/CoreHome.umd.js
index d3b01038ef..c2b128d0f7 100644
--- a/plugins/CoreHome/vue/dist/CoreHome.umd.js
+++ b/plugins/CoreHome/vue/dist/CoreHome.umd.js
@@ -1144,6 +1144,12 @@ var MatomoUrl_MatomoUrl = /*#__PURE__*/function () {
}
MatomoUrl_createClass(MatomoUrl, [{
+ key: "updateHashToUrl",
+ value: function updateHashToUrl(url) {
+ var $location = Matomo_Matomo.helper.getAngularDependency('$location');
+ $location.url(url);
+ }
+ }, {
key: "updateHash",
value: function updateHash(params) {
var modifiedParams = this.getFinalHashParams(params);
diff --git a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js
index b0beae0e95..bb1c87e53f 100644
--- a/plugins/CoreHome/vue/dist/CoreHome.umd.min.js
+++ b/plugins/CoreHome/vue/dist/CoreHome.umd.min.js
@@ -79,7 +79,7 @@ function se(e,t){return fe(e)||me(e,t)||de(e,t)||ue()}function ue(){throw new Ty
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- */p.addCustomPeriod("year",ce);var ye=window,we=ye.piwik,Oe=ye.broadcast;function je(e,t){try{return p.parse(e,t),!0}catch(n){return!1}}var ke=function(){function e(){var t=this;he(this,e),be(this,"urlQuery",Object(a["ref"])("")),be(this,"hashQuery",Object(a["ref"])("")),be(this,"urlParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.urlQuery.value))}))),be(this,"hashParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.hashQuery.value))}))),be(this,"parsed",Object(a["computed"])((function(){return Object(a["readonly"])(Object.assign(Object.assign({},t.urlParsed.value),t.hashParsed.value))}))),this.setUrlQuery(window.location.search),this.setHashQuery(window.location.hash),S.on("$locationChangeSuccess",(function(e){var n=new URL(e);t.setUrlQuery(n.search.replace(/^\?/,"")),t.setHashQuery(n.hash.replace(/^#/,""))})),this.updatePeriodParamsFromUrl()}return ve(e,[{key:"updateHash",value:function(e){var t=this.getFinalHashParams(e),n=this.stringify(t),r=S.helper.getAngularDependency("$location");r.search(n);var i=S.helper.getAngularDependency("$timeout");i()}},{key:"updateUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?this.stringify(e):e,r=Object.keys(t).length?this.getFinalHashParams(t,e):{},i=this.stringify(r),a="?".concat(n);i.length&&(a="".concat(a,"#?").concat(i)),window.broadcast.propagateNewPage("",void 0,void 0,void 0,a)}},{key:"getFinalHashParams",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?e:this.parse(e),r="string"!==typeof e?t:this.parse(t);return Object.assign({period:r.period||this.parsed.value.period,date:r.date||this.parsed.value.date,segment:r.segment||this.parsed.value.segment},n)}},{key:"updateLocation",value:function(e){S.helper.isAngularRenderingThePage()?this.updateHash(e):this.updateUrl(e)}},{key:"getSearchParam",value:function(e){var t=window.location.href.split("#"),n=new RegExp("".concat(e,"(\\[]|=)"));if(t&&t[1]&&n.test(decodeURIComponent(t[1]))){var r=window.broadcast.getValueFromHash(e,window.location.href);if(r||"date"!==e&&"period"!==e&&"idSite"!==e)return r}return window.broadcast.getValueFromUrl(e,window.location.search)}},{key:"parse",value:function(e){return Oe.getValuesFromUrl("?".concat(e),!0)}},{key:"stringify",value:function(e){var t=Object.fromEntries(Object.entries(e).filter((function(e){var t=se(e,2),n=t[1];return""!==n&&null!==n&&void 0!==n})));return $.param(t).replace(/%5B%5D/g,"[]").replace(/%2C/g,",")}},{key:"updatePeriodParamsFromUrl",value:function(){var e=this.getSearchParam("date"),t=this.getSearchParam("period");if(je(t,e)&&(we.period!==t||we.currentDateString!==e)){we.period=t;var n=p.parse(t,e).getDateRange();we.startDateString=E(n[0]),we.endDateString=E(n[1]),we.updateDateInTitle(e,t),"range"===we.period&&(e="".concat(we.startDateString,",").concat(we.endDateString)),we.currentDateString=e}}},{key:"setUrlQuery",value:function(e){this.urlQuery.value=e.replace(/^\?/,"")}},{key:"setHashQuery",value:function(e){this.hashQuery.value=e.replace(/^[#/?]+/,"")}}]),e}(),Se=new ke,Ce=Se;
+ */p.addCustomPeriod("year",ce);var ye=window,we=ye.piwik,Oe=ye.broadcast;function je(e,t){try{return p.parse(e,t),!0}catch(n){return!1}}var ke=function(){function e(){var t=this;he(this,e),be(this,"urlQuery",Object(a["ref"])("")),be(this,"hashQuery",Object(a["ref"])("")),be(this,"urlParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.urlQuery.value))}))),be(this,"hashParsed",Object(a["computed"])((function(){return Object(a["readonly"])(t.parse(t.hashQuery.value))}))),be(this,"parsed",Object(a["computed"])((function(){return Object(a["readonly"])(Object.assign(Object.assign({},t.urlParsed.value),t.hashParsed.value))}))),this.setUrlQuery(window.location.search),this.setHashQuery(window.location.hash),S.on("$locationChangeSuccess",(function(e){var n=new URL(e);t.setUrlQuery(n.search.replace(/^\?/,"")),t.setHashQuery(n.hash.replace(/^#/,""))})),this.updatePeriodParamsFromUrl()}return ve(e,[{key:"updateHashToUrl",value:function(e){var t=S.helper.getAngularDependency("$location");t.url(e)}},{key:"updateHash",value:function(e){var t=this.getFinalHashParams(e),n=this.stringify(t),r=S.helper.getAngularDependency("$location");r.search(n);var i=S.helper.getAngularDependency("$timeout");i()}},{key:"updateUrl",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?this.stringify(e):e,r=Object.keys(t).length?this.getFinalHashParams(t,e):{},i=this.stringify(r),a="?".concat(n);i.length&&(a="".concat(a,"#?").concat(i)),window.broadcast.propagateNewPage("",void 0,void 0,void 0,a)}},{key:"getFinalHashParams",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="string"!==typeof e?e:this.parse(e),r="string"!==typeof e?t:this.parse(t);return Object.assign({period:r.period||this.parsed.value.period,date:r.date||this.parsed.value.date,segment:r.segment||this.parsed.value.segment},n)}},{key:"updateLocation",value:function(e){S.helper.isAngularRenderingThePage()?this.updateHash(e):this.updateUrl(e)}},{key:"getSearchParam",value:function(e){var t=window.location.href.split("#"),n=new RegExp("".concat(e,"(\\[]|=)"));if(t&&t[1]&&n.test(decodeURIComponent(t[1]))){var r=window.broadcast.getValueFromHash(e,window.location.href);if(r||"date"!==e&&"period"!==e&&"idSite"!==e)return r}return window.broadcast.getValueFromUrl(e,window.location.search)}},{key:"parse",value:function(e){return Oe.getValuesFromUrl("?".concat(e),!0)}},{key:"stringify",value:function(e){var t=Object.fromEntries(Object.entries(e).filter((function(e){var t=se(e,2),n=t[1];return""!==n&&null!==n&&void 0!==n})));return $.param(t).replace(/%5B%5D/g,"[]").replace(/%2C/g,",")}},{key:"updatePeriodParamsFromUrl",value:function(){var e=this.getSearchParam("date"),t=this.getSearchParam("period");if(je(t,e)&&(we.period!==t||we.currentDateString!==e)){we.period=t;var n=p.parse(t,e).getDateRange();we.startDateString=E(n[0]),we.endDateString=E(n[1]),we.updateDateInTitle(e,t),"range"===we.period&&(e="".concat(we.startDateString,",").concat(we.endDateString)),we.currentDateString=e}}},{key:"setUrlQuery",value:function(e){this.urlQuery.value=e.replace(/^\?/,"")}},{key:"setHashQuery",value:function(e){this.hashQuery.value=e.replace(/^[#/?]+/,"")}}]),e}(),Se=new ke,Ce=Se;
/*!
* Matomo - free/libre analytics platform
*
diff --git a/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts b/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts
index e8f1cb0ed3..9ab1dc54aa 100644
--- a/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts
+++ b/plugins/CoreHome/vue/src/MatomoUrl/MatomoUrl.ts
@@ -61,6 +61,11 @@ class MatomoUrl {
this.updatePeriodParamsFromUrl();
}
+ updateHashToUrl(url: string) {
+ const $location: ILocationService = Matomo.helper.getAngularDependency('$location');
+ $location.url(url);
+ }
+
updateHash(params: QueryParameters|string) {
const modifiedParams = this.getFinalHashParams(params);
const serializedParams = this.stringify(modifiedParams);