github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/static/app/accounts/accounts.controller.js (about) 1 (function(){ 2 'use strict'; 3 4 angular 5 .module('shipyard.accounts') 6 .controller('AccountsController', AccountsController); 7 8 AccountsController.$inject = ['accounts', 'roles', 'AccountsService', '$state', '$timeout']; 9 function AccountsController(accounts, roles, AccountsService, $state, $timeout) { 10 var vm = this; 11 vm.accounts = accounts; 12 vm.refresh = refresh; 13 vm.selectedAccount = null; 14 vm.removeAccount = removeAccount; 15 vm.showRemoveAccountDialog = showRemoveAccountDialog; 16 17 function showRemoveAccountDialog(account) { 18 vm.selectedAccount = account; 19 $('#remove-modal').modal('show'); 20 } 21 22 function refresh() { 23 AccountsService.list() 24 .then(function(data) { 25 vm.accounts = data; 26 }, function(data) { 27 vm.error = data; 28 }); 29 vm.error = ""; 30 } 31 32 function removeAccount() { 33 AccountsService.removeAccount(vm.selectedAccount) 34 .then(function(data) { 35 vm.refresh(); 36 }, function(data) { 37 vm.error = data; 38 }); 39 } 40 41 } 42 })();