diff --git a/bower.json b/bower.json index 4ae4be92..b1932c85 100644 --- a/bower.json +++ b/bower.json @@ -39,7 +39,8 @@ "checklist-model": "~0.1.3", "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.4.2", "angular-borderlayout": "https://github.com/filearts/angular-borderlayout.git", - "angular-ui-bootstrap": "~0.11.0" + "angular-ui-bootstrap": "~0.11.0", + "angular-ladda": "~0.1.6" }, "private": true, "resolutions": { diff --git a/res/app/control-panes/automation/store-account/index.js b/res/app/control-panes/automation/store-account/index.js index f1c370fd..89ca8a31 100644 --- a/res/app/control-panes/automation/store-account/index.js +++ b/res/app/control-panes/automation/store-account/index.js @@ -1,7 +1,8 @@ require('./store-account.css') +require('angular-ladda') module.exports = angular.module('stf.store-account', [ - + 'angular-ladda' ]) .run(["$templateCache", function ($templateCache) { $templateCache.put('control-panes/automation/store-account/store-account.jade', diff --git a/res/app/control-panes/automation/store-account/store-account-controller.js b/res/app/control-panes/automation/store-account/store-account-controller.js index 3c87b042..346c2a22 100644 --- a/res/app/control-panes/automation/store-account/store-account-controller.js +++ b/res/app/control-panes/automation/store-account/store-account-controller.js @@ -1,4 +1,4 @@ -module.exports = function StoreAccountCtrl($scope, ngTableParams) { +module.exports = function StoreAccountCtrl($scope, ngTableParams, $timeout) { // TODO: This should come from the DB $scope.currentAppStore = 'google-play-store' $scope.deviceAppStores = { @@ -9,25 +9,28 @@ module.exports = function StoreAccountCtrl($scope, ngTableParams) { } } - console.log('$scope.deviceAppStores[$scope.currentAppStore].package', - $scope.deviceAppStores[$scope.currentAppStore].package) - + $scope.addingAccount = false $scope.addAccount = function () { + $scope.addingAccount = true var user = $scope.storeLogin.username.$modelValue var pass = $scope.storeLogin.password.$modelValue $scope.control.addAccount(user, pass).then(function () { - //getAccounts() }).catch(function (result) { console.log('Adding account failed', result) + }).finally(function () { + $scope.addingAccount = false + $timeout(function () { + getAccounts() + }, 500) }) } $scope.removeAccount = function (account) { var storeAccountType = $scope.deviceAppStores[$scope.currentAppStore].package $scope.control.removeAccount(storeAccountType, account) - .then(function (result) { + .then(function () { getAccounts() }) .catch(function (result) { @@ -38,10 +41,13 @@ module.exports = function StoreAccountCtrl($scope, ngTableParams) { function getAccounts() { var storeAccountType = $scope.deviceAppStores[$scope.currentAppStore].package $scope.control.getAccounts(storeAccountType).then(function (result) { - $scope.accountsList = result.body - $scope.accountsTable.reload() + $scope.$apply(function () { + $scope.accountsList = result.body + $scope.accountsTable.reload() + }) }) } + getAccounts() $scope.accountsTable = new ngTableParams({ diff --git a/res/app/control-panes/automation/store-account/store-account.jade b/res/app/control-panes/automation/store-account/store-account.jade index e03fc763..b517b52b 100644 --- a/res/app/control-panes/automation/store-account/store-account.jade +++ b/res/app/control-panes/automation/store-account/store-account.jade @@ -34,10 +34,11 @@ .btn-group label.btn.btn-sm.btn-default-outline(ng-repeat='a in deviceAppStores track by a.id', - ng-model='currentAppStore', btn-radio='a', tooltip='{{a.name}}') + ng-model='currentAppStore', btn-radio='currentAppStore', tooltip='{{a.name}}') img(ng-src='/static/app/appstores/icon/24x24/{{a.type}}.png', ng-show='a.type').appstore-icon.pointer - button.btn.btn-sm.btn-primary-outline(ng-click='addAccount()', ng-disabled='storeLogin.$invalid').pull-right + button.btn.btn-sm.btn-primary-outline(ng-click='addAccount()', ng-disabled='storeLogin.$invalid', + ladda='addingAccount', data-style='expand-left', data-spinner-color='#157afb').pull-right i.fa.fa-sign-in span(translate) Sign In diff --git a/res/web_modules/angular-ladda/index.js b/res/web_modules/angular-ladda/index.js new file mode 100644 index 00000000..3d2cc2d9 --- /dev/null +++ b/res/web_modules/angular-ladda/index.js @@ -0,0 +1,4 @@ +require('ladda/dist/ladda-themeless.min.css') +window.Ladda = require('ladda/js/ladda') +require('angular-ladda/src/angular-ladda') +