diff options
Diffstat (limited to 'plugins/CoreHome/angularjs/common/services/piwik-api.js')
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/piwik-api.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/piwik-api.js b/plugins/CoreHome/angularjs/common/services/piwik-api.js index 04160d5ee1..e2195f7ff1 100644 --- a/plugins/CoreHome/angularjs/common/services/piwik-api.js +++ b/plugins/CoreHome/angularjs/common/services/piwik-api.js @@ -11,9 +11,9 @@ var hasBlockedContent = false; (function () { angular.module('piwikApp.service').factory('piwikApi', piwikApiService); - piwikApiService.$inject = ['$http', '$q', '$rootScope', 'piwik', '$window']; + piwikApiService.$inject = ['$http', '$q', '$rootScope', 'piwik', '$window', 'piwikUrl']; - function piwikApiService ($http, $q, $rootScope, piwik, $window) { + function piwikApiService ($http, $q, $rootScope, piwik, $window, piwikUrl) { var url = 'index.php'; var format = 'json'; @@ -33,7 +33,15 @@ var hasBlockedContent = false; params = piwik.broadcast.getValuesFromUrl(params); } + var arrayParams = ['compareSegments', 'comparePeriods', 'compareDates']; + for (var key in params) { + if (arrayParams.indexOf(key) !== -1 + && !params[key] + ) { + continue; + } + getParams[key] = params[key]; } } @@ -95,9 +103,7 @@ var hasBlockedContent = false; if (!angular.isDefined(response) || response === null) { return $q.reject(null); - } else if (isErrorResponse(response)) { - createResponseErrorNotification(response, options); return $q.reject(response.message || null); @@ -132,9 +138,8 @@ var hasBlockedContent = false; var ajaxCall = { method: 'POST', - url: url, + url: url + '?' + $.param(mixinDefaultGetParams(getParams)), responseType: requestFormat, - params: mixinDefaultGetParams(getParams), data: $.param(getPostParams(postParams)), timeout: requestPromise, headers: headers @@ -199,15 +204,16 @@ var hasBlockedContent = false; * @private */ function mixinDefaultGetParams (getParamsToMixin) { - var segment = piwik.broadcast.getValueFromHash('segment', $window.location.href.split('#')[1]); - // we have to decode the value manually because broadcast will not decode anything itself. if we don't, // angular will encode it again before sending the value in an HTTP request. - segment = decodeURIComponent(segment); + var segment = piwikUrl.getSearchParam('segment'); + if (segment) { + segment = decodeURIComponent(segment); + } var defaultParams = { - idSite: piwik.idSite || piwik.broadcast.getValueFromUrl('idSite'), - period: piwik.period || piwik.broadcast.getValueFromUrl('period'), + idSite: piwik.idSite || piwikUrl.getSearchParam('idSite'), + period: piwik.period || piwikUrl.getSearchParam('period'), segment: segment }; |