From 3d273f041e1719870a94d1f35d7c5cf37c1b8874 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 7 Mar 2017 00:36:27 -0500 Subject: [PATCH] do api calls on viewContentLoaded --- src/app/global/mainController.js | 3 +- .../organizationPeopleController.js | 4 +- src/app/settings/settingsController.js | 42 ++++++++++--------- src/app/vault/vaultController.js | 38 +++++++++-------- 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/app/global/mainController.js b/src/app/global/mainController.js index d8db0a517c..79e66c78ec 100644 --- a/src/app/global/mainController.js +++ b/src/app/global/mainController.js @@ -6,11 +6,12 @@ angular vm.bodyClass = ''; vm.searchVaultText = null; vm.version = appSettings.version; - vm.userProfile = authService.getUserProfile(); $scope.currentYear = new Date().getFullYear(); $scope.$on('$viewContentLoaded', function () { + vm.userProfile = authService.getUserProfile(); + if ($.AdminLTE) { if ($.AdminLTE.layout) { $.AdminLTE.layout.fix(); diff --git a/src/app/organization/organizationPeopleController.js b/src/app/organization/organizationPeopleController.js index e69fab78b9..6ab8aaca91 100644 --- a/src/app/organization/organizationPeopleController.js +++ b/src/app/organization/organizationPeopleController.js @@ -3,7 +3,9 @@ .controller('organizationPeopleController', function ($scope, $state, $uibModal, cryptoService, apiService, toastr) { $scope.users = []; - loadList(); + $scope.$on('$viewContentLoaded', function () { + loadList(); + }); $scope.confirm = function (user) { apiService.users.getPublicKey({ id: user.userId }, function (userKey) { diff --git a/src/app/settings/settingsController.js b/src/app/settings/settingsController.js index 2ecb52308b..f71329d05b 100644 --- a/src/app/settings/settingsController.js +++ b/src/app/settings/settingsController.js @@ -8,28 +8,30 @@ email: null }; - apiService.accounts.getProfile({}, function (user) { - $scope.model = { - profile: { - name: user.Name, - masterPasswordHint: user.MasterPasswordHint, - culture: user.Culture - }, - email: user.Email, - twoFactorEnabled: user.TwoFactorEnabled - }; + $scope.$on('$viewContentLoaded', function () { + apiService.accounts.getProfile({}, function (user) { + $scope.model = { + profile: { + name: user.Name, + masterPasswordHint: user.MasterPasswordHint, + culture: user.Culture + }, + email: user.Email, + twoFactorEnabled: user.TwoFactorEnabled + }; - if (user.Organizations) { - var orgs = []; - for (var i = 0; i < user.Organizations.length; i++) { - orgs.push({ - id: user.Organizations[i].Id, - name: user.Organizations[i].Name - }); + if (user.Organizations) { + var orgs = []; + for (var i = 0; i < user.Organizations.length; i++) { + orgs.push({ + id: user.Organizations[i].Id, + name: user.Organizations[i].Name + }); + } + + $scope.model.organizations = orgs; } - - $scope.model.organizations = orgs; - } + }); }); $scope.generalSave = function () { diff --git a/src/app/vault/vaultController.js b/src/app/vault/vaultController.js index 39cd8cce26..58fbc06a40 100644 --- a/src/app/vault/vaultController.js +++ b/src/app/vault/vaultController.js @@ -7,28 +7,30 @@ $scope.folders = []; $scope.loading = true; - apiService.ciphers.list({}, function (ciphers) { - $scope.loading = false; + $scope.$on('$viewContentLoaded', function () { + apiService.ciphers.list({}, function (ciphers) { + $scope.loading = false; - var decLogins = []; - var decFolders = [{ - id: null, - name: '(none)' - }]; + var decLogins = []; + var decFolders = [{ + id: null, + name: '(none)' + }]; - for (var i = 0; i < ciphers.Data.length; i++) { - if (ciphers.Data[i].Type === 0) { - var decFolder = cipherService.decryptFolderPreview(ciphers.Data[i]); - decFolders.push(decFolder); + for (var i = 0; i < ciphers.Data.length; i++) { + if (ciphers.Data[i].Type === 0) { + var decFolder = cipherService.decryptFolderPreview(ciphers.Data[i]); + decFolders.push(decFolder); + } + else { + var decLogin = cipherService.decryptLoginPreview(ciphers.Data[i]); + decLogins.push(decLogin); + } } - else { - var decLogin = cipherService.decryptLoginPreview(ciphers.Data[i]); - decLogins.push(decLogin); - } - } - $scope.folders = decFolders; - $scope.logins = decLogins; + $scope.folders = decFolders; + $scope.logins = decLogins; + }); }); $scope.folderSort = function (item) {