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:
Diffstat (limited to 'plugins/CoreAdminHome/angularjs/trustedhosts/trustedhosts.controller.js')
-rw-r--r--plugins/CoreAdminHome/angularjs/trustedhosts/trustedhosts.controller.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/CoreAdminHome/angularjs/trustedhosts/trustedhosts.controller.js b/plugins/CoreAdminHome/angularjs/trustedhosts/trustedhosts.controller.js
new file mode 100644
index 0000000000..adcaf69e29
--- /dev/null
+++ b/plugins/CoreAdminHome/angularjs/trustedhosts/trustedhosts.controller.js
@@ -0,0 +1,61 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+/**
+ * Controller to save archiving settings
+ */
+(function () {
+ angular.module('piwikApp').controller('TrustedHostsController', TrustedHostsController);
+
+ TrustedHostsController.$inject = ['$scope', 'piwikApi', '$timeout'];
+
+ function TrustedHostsController($scope, piwikApi, $timeout) {
+
+ var self = this;
+ this.isLoading = false;
+
+ this.addTrustedHost = function () {
+ this.hosts.push({host: ''});
+
+ $timeout(function () {
+ $('#trustedHostSettings').find('li:last input').val('').focus();
+ });
+ };
+
+ this.removeTrustedHost = function (index) {
+ this.hosts.splice(index,1);
+ };
+
+ this.save = function () {
+ var hosts = [];
+ angular.forEach(self.hosts, function (host) {
+ hosts.push(host.host);
+ });
+
+ var doSubmit = function () {
+ self.isLoading = true;
+
+ piwikApi.post({module: 'API', method: 'CoreAdminHome.setTrustedHosts'}, {
+ trustedHosts: hosts
+ }).then(function (success) {
+ self.isLoading = false;
+
+ var UI = require('piwik/UI');
+ var notification = new UI.Notification();
+ notification.show(_pk_translate('CoreAdminHome_SettingsSaveSuccess'), {
+ id: 'generalSettings', context: 'success'
+ });
+ notification.scrollToNotification();
+ }, function () {
+ self.isLoading = false;
+ });
+ };
+
+ piwikHelper.modalConfirm('#confirmTrustedHostChange', {yes: doSubmit});
+ };
+ }
+})(); \ No newline at end of file