2017-03-30 04:23:00 +02:00
|
|
|
|
angular
|
|
|
|
|
.module('bit.organization')
|
|
|
|
|
|
|
|
|
|
.controller('organizationSubvaultsEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
|
|
|
|
$analytics, id) {
|
2017-04-26 16:32:14 +02:00
|
|
|
|
$analytics.eventTrack('organizationSubvaultsEditController', { category: 'Modal' });
|
2017-03-30 04:23:00 +02:00
|
|
|
|
$scope.subvault = {};
|
|
|
|
|
|
|
|
|
|
$uibModalInstance.opened.then(function () {
|
|
|
|
|
apiService.subvaults.get({ orgId: $state.params.orgId, id: id }, function (subvault) {
|
|
|
|
|
$scope.subvault = cipherService.decryptSubvault(subvault);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$scope.submit = function (model) {
|
|
|
|
|
var subvault = cipherService.encryptSubvault(model, $state.params.orgId);
|
|
|
|
|
$scope.submitPromise = apiService.subvaults.put({ orgId: $state.params.orgId }, subvault, function (response) {
|
|
|
|
|
$analytics.eventTrack('Edited Subvault');
|
|
|
|
|
var decSubvault = cipherService.decryptSubvault(response, $state.params.orgId, true);
|
|
|
|
|
$uibModalInstance.close(decSubvault);
|
|
|
|
|
}).$promise;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.close = function () {
|
|
|
|
|
$uibModalInstance.dismiss('cancel');
|
|
|
|
|
};
|
|
|
|
|
});
|