2016-09-01 06:34:38 +02:00
|
|
|
|
angular
|
|
|
|
|
.module('bit.vault')
|
|
|
|
|
|
2016-09-04 06:34:24 +02:00
|
|
|
|
.controller('vaultController', function ($scope, $ionicModal, siteService, folderService) {
|
|
|
|
|
$scope.parentScope = $scope;
|
|
|
|
|
$scope.sites = [];
|
|
|
|
|
$scope.folders = [];
|
|
|
|
|
|
|
|
|
|
var decSites = [];
|
|
|
|
|
var decFolders = [{
|
|
|
|
|
id: null,
|
|
|
|
|
name: '(none)'
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
folderService.getAll(function (folders) {
|
|
|
|
|
siteService.getAll(function (sites) {
|
|
|
|
|
for (var i = 0; i < folders.length; i++) {
|
|
|
|
|
decFolders.push({
|
|
|
|
|
id: folders[i].id,
|
|
|
|
|
name: folders[i].name.decrypt()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < sites.length; j++) {
|
|
|
|
|
decSites.push({
|
|
|
|
|
id: sites[j].id,
|
|
|
|
|
folderId: sites[j].folderId,
|
|
|
|
|
favorite: sites[j].favorite,
|
|
|
|
|
name: sites[j].name.decrypt(),
|
|
|
|
|
username: sites[j].username.decrypt()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.sites = decSites;
|
|
|
|
|
$scope.folders = decFolders;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-09-03 22:48:39 +02:00
|
|
|
|
$scope.addSite = function () {
|
2016-09-04 03:45:45 +02:00
|
|
|
|
$ionicModal.fromTemplateUrl('app/vault/views/vaultAddSite.html', {
|
|
|
|
|
scope: $scope,
|
|
|
|
|
animation: 'slide-in-up'
|
|
|
|
|
}).then(function (modal) {
|
|
|
|
|
$scope.addSiteModal = modal;
|
|
|
|
|
modal.show();
|
|
|
|
|
});
|
2016-09-03 22:48:39 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.closeAddSite = function () {
|
|
|
|
|
$scope.addSiteModal.hide();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Cleanup the modal when we're done with it!
|
|
|
|
|
$scope.$on('$destroy', function () {
|
2016-09-04 03:45:45 +02:00
|
|
|
|
console.log('modal destroyed');
|
2016-09-03 22:48:39 +02:00
|
|
|
|
$scope.addSiteModal.remove();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Execute action on hide modal
|
|
|
|
|
$scope.$on('modal.hidden', function () {
|
2016-09-04 03:45:45 +02:00
|
|
|
|
console.log('modal hidden');
|
2016-09-03 22:48:39 +02:00
|
|
|
|
// Execute action
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Execute action on remove modal
|
|
|
|
|
$scope.$on('modal.removed', function () {
|
2016-09-04 03:45:45 +02:00
|
|
|
|
console.log('modal removed');
|
2016-09-03 22:48:39 +02:00
|
|
|
|
// Execute action
|
|
|
|
|
});
|
2016-09-01 06:34:38 +02:00
|
|
|
|
});
|