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/MobileMessaging/angularjs/manage-sms-provider/manage-sms-provider.controller.js')
-rw-r--r--plugins/MobileMessaging/angularjs/manage-sms-provider/manage-sms-provider.controller.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/MobileMessaging/angularjs/manage-sms-provider/manage-sms-provider.controller.js b/plugins/MobileMessaging/angularjs/manage-sms-provider/manage-sms-provider.controller.js
new file mode 100644
index 0000000000..482445f1b2
--- /dev/null
+++ b/plugins/MobileMessaging/angularjs/manage-sms-provider/manage-sms-provider.controller.js
@@ -0,0 +1,64 @@
+/*!
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+(function () {
+ angular.module('piwikApp').controller('ManageSmsProviderController', ManageSmsProviderController);
+
+ ManageSmsProviderController.$inject = ['piwikApi', 'piwik'];
+
+ function ManageSmsProviderController(piwikApi, piwik) {
+
+ var self = this;
+ this.isDeletingAccount = false;
+ this.isUpdatingAccount = false;
+ this.showAccountForm = false;
+ this.isUpdateAccountPossible = false;
+
+ function deleteApiAccount() {
+ self.isDeletingAccount = true;
+
+ piwikApi.fetch(
+ {method: 'MobileMessaging.deleteSMSAPICredential'},
+ {placeat: '#ajaxErrorManageSmsProviderSettings'}
+ ).then(function () {
+ self.isDeletingAccount = false;
+ piwik.helper.redirect();
+ }, function () {
+ self.isDeletingAccount = false;
+ });
+ }
+
+ this.showUpdateAccount = function () {
+ this.showAccountForm = true;
+ };
+
+ this.isUpdateAccountPossible = function () {
+ this.canBeUpdated = (!!this.apiKey && this.apiKey != '' && !!this.smsProvider);
+ return this.canBeUpdated;
+ }
+
+ this.updateAccount = function () {
+ if (this.isUpdateAccountPossible()) {
+ this.isUpdatingAccount = true;
+
+ piwikApi.post(
+ {method: 'MobileMessaging.setSMSAPICredential'},
+ {provider: this.smsProvider, apiKey: this.apiKey},
+ {placeat: '#ajaxErrorManageSmsProviderSettings'}
+ ).then(function () {
+ self.isUpdatingAccount = false;
+ piwik.helper.redirect();
+ }, function () {
+ self.isUpdatingAccount = false;
+ });
+ }
+ }
+
+ this.deleteAccount = function () {
+ piwikHelper.modalConfirm('#confirmDeleteAccount', {yes: deleteApiAccount});
+ };
+ }
+})(); \ No newline at end of file