do api calls on viewContentLoaded

This commit is contained in:
Kyle Spearrin 2017-03-07 00:36:27 -05:00
parent 22299c03cd
commit 3d273f041e
4 changed files with 47 additions and 40 deletions

View File

@ -6,11 +6,12 @@ angular
vm.bodyClass = ''; vm.bodyClass = '';
vm.searchVaultText = null; vm.searchVaultText = null;
vm.version = appSettings.version; vm.version = appSettings.version;
vm.userProfile = authService.getUserProfile();
$scope.currentYear = new Date().getFullYear(); $scope.currentYear = new Date().getFullYear();
$scope.$on('$viewContentLoaded', function () { $scope.$on('$viewContentLoaded', function () {
vm.userProfile = authService.getUserProfile();
if ($.AdminLTE) { if ($.AdminLTE) {
if ($.AdminLTE.layout) { if ($.AdminLTE.layout) {
$.AdminLTE.layout.fix(); $.AdminLTE.layout.fix();

View File

@ -3,7 +3,9 @@
.controller('organizationPeopleController', function ($scope, $state, $uibModal, cryptoService, apiService, toastr) { .controller('organizationPeopleController', function ($scope, $state, $uibModal, cryptoService, apiService, toastr) {
$scope.users = []; $scope.users = [];
loadList(); $scope.$on('$viewContentLoaded', function () {
loadList();
});
$scope.confirm = function (user) { $scope.confirm = function (user) {
apiService.users.getPublicKey({ id: user.userId }, function (userKey) { apiService.users.getPublicKey({ id: user.userId }, function (userKey) {

View File

@ -8,28 +8,30 @@
email: null email: null
}; };
apiService.accounts.getProfile({}, function (user) { $scope.$on('$viewContentLoaded', function () {
$scope.model = { apiService.accounts.getProfile({}, function (user) {
profile: { $scope.model = {
name: user.Name, profile: {
masterPasswordHint: user.MasterPasswordHint, name: user.Name,
culture: user.Culture masterPasswordHint: user.MasterPasswordHint,
}, culture: user.Culture
email: user.Email, },
twoFactorEnabled: user.TwoFactorEnabled email: user.Email,
}; twoFactorEnabled: user.TwoFactorEnabled
};
if (user.Organizations) { if (user.Organizations) {
var orgs = []; var orgs = [];
for (var i = 0; i < user.Organizations.length; i++) { for (var i = 0; i < user.Organizations.length; i++) {
orgs.push({ orgs.push({
id: user.Organizations[i].Id, id: user.Organizations[i].Id,
name: user.Organizations[i].Name name: user.Organizations[i].Name
}); });
}
$scope.model.organizations = orgs;
} }
});
$scope.model.organizations = orgs;
}
}); });
$scope.generalSave = function () { $scope.generalSave = function () {

View File

@ -7,28 +7,30 @@
$scope.folders = []; $scope.folders = [];
$scope.loading = true; $scope.loading = true;
apiService.ciphers.list({}, function (ciphers) { $scope.$on('$viewContentLoaded', function () {
$scope.loading = false; apiService.ciphers.list({}, function (ciphers) {
$scope.loading = false;
var decLogins = []; var decLogins = [];
var decFolders = [{ var decFolders = [{
id: null, id: null,
name: '(none)' name: '(none)'
}]; }];
for (var i = 0; i < ciphers.Data.length; i++) { for (var i = 0; i < ciphers.Data.length; i++) {
if (ciphers.Data[i].Type === 0) { if (ciphers.Data[i].Type === 0) {
var decFolder = cipherService.decryptFolderPreview(ciphers.Data[i]); var decFolder = cipherService.decryptFolderPreview(ciphers.Data[i]);
decFolders.push(decFolder); 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.folders = decFolders;
$scope.logins = decLogins; $scope.logins = decLogins;
});
}); });
$scope.folderSort = function (item) { $scope.folderSort = function (item) {