mirror of
https://github.com/bitwarden/browser
synced 2025-12-25 20:53:22 +00:00
add subvault
This commit is contained in:
18
src/app/organization/organizationSubvaultsAddController.js
Normal file
18
src/app/organization/organizationSubvaultsAddController.js
Normal file
@@ -0,0 +1,18 @@
|
||||
angular
|
||||
.module('bit.organization')
|
||||
|
||||
.controller('organizationSubvaultsAddController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
|
||||
$analytics) {
|
||||
$scope.submit = function (model) {
|
||||
var subvault = cipherService.encryptSubvault(model, $state.params.orgId);
|
||||
$scope.submitPromise = apiService.subvaults.post({ orgId: $state.params.orgId }, subvault, function (response) {
|
||||
$analytics.eventTrack('Created Subvault');
|
||||
var decSubvault = cipherService.decryptSubvault(response, $state.params.orgId, true);
|
||||
$uibModalInstance.close(decSubvault);
|
||||
}).$promise;
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
||||
@@ -1,25 +1,41 @@
|
||||
angular
|
||||
.module('bit.organization')
|
||||
|
||||
.controller('organizationSubvaultsController', function ($scope, $state, apiService) {
|
||||
.controller('organizationSubvaultsController', function ($scope, $state, apiService, $uibModal, cipherService) {
|
||||
$scope.subvaults = [];
|
||||
$scope.loading = true;
|
||||
$scope.$on('$viewContentLoaded', function () {
|
||||
loadList();
|
||||
});
|
||||
|
||||
$scope.add = function () {
|
||||
var modal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/organization/views/organizationSubvaultsAdd.html',
|
||||
controller: 'organizationSubvaultsAddController'
|
||||
});
|
||||
|
||||
modal.result.then(function (subvault) {
|
||||
$scope.subvaults.push(subvault);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function (subvault) {
|
||||
if (!confirm('Are you sure you want to delete this subvault (' + subvault.name + ')?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
apiService.subvaults.del({ orgId: $state.params.orgId, id: subvault.id }, function () {
|
||||
var index = $scope.subvaults.indexOf(subvault);
|
||||
if (index > -1) {
|
||||
$scope.subvaults.splice(index, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function loadList() {
|
||||
apiService.subvaults.listOrganization({ orgId: $state.params.orgId }, function (list) {
|
||||
var subvaults = [];
|
||||
|
||||
for (var i = 0; i < list.Data.length; i++) {
|
||||
subvaults.push({
|
||||
id: list.Data[i].Id,
|
||||
name: list.Data[i].Name
|
||||
});
|
||||
}
|
||||
|
||||
$scope.subvaults = subvaults;
|
||||
$scope.subvaults = cipherService.decryptSubvaults(list.Data, $state.params.orgId, true);
|
||||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,20 +9,20 @@
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Subvaults</h3>
|
||||
<div class="box-tools">
|
||||
<button type="button" class="btn btn-primary btn-sm btn-flat">
|
||||
New subvault
|
||||
<button type="button" class="btn btn-primary btn-sm btn-flat" ng-click="add()">
|
||||
New Subvault
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body" ng-class="{'no-padding': subvault.length}">
|
||||
<div ng-show="loading && !subvault.length">
|
||||
<div class="box-body" ng-class="{'no-padding': subvaults.length}">
|
||||
<div ng-show="loading && !subvaults.length">
|
||||
Loading...
|
||||
</div>
|
||||
<div ng-show="!loading && !subvault.length">
|
||||
<div ng-show="!loading && !subvaults.length">
|
||||
<p>No subvaults.</p>
|
||||
<button type="button" ng-click="add()" class="btn btn-default btn-flat">Add a Subvault</button>
|
||||
</div>
|
||||
<div class="table-responsive" ng-show="subvault.length">
|
||||
<div class="table-responsive" ng-show="subvaults.length">
|
||||
<table class="table table-striped table-hover">
|
||||
<tbody>
|
||||
<tr ng-repeat="subvault in subvaults | orderBy: ['name']">
|
||||
@@ -32,13 +32,14 @@
|
||||
<i class="fa fa-cog"></i> <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#" class="text-danger">Remove</a></li>
|
||||
<li>
|
||||
<a href="javascript:void(0)" ng-click="delete(subvault)" class="text-danger">
|
||||
Delete
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width: 45px;" valign="middle">
|
||||
<i class="fa fa-share-alt fa-2x"></i>
|
||||
</td>
|
||||
<td valign="middle">
|
||||
{{subvault.name}}
|
||||
</td>
|
||||
|
||||
28
src/app/organization/views/organizationSubvaultsAdd.html
Normal file
28
src/app/organization/views/organizationSubvaultsAdd.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title"><i class="fa fa-share-alt"></i> Add Subvault</h4>
|
||||
</div>
|
||||
<form name="form" ng-submit="form.$valid && submit(model)" api-form="submitPromise">
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
Add a subvault.
|
||||
</p>
|
||||
<div class="callout callout-danger validation-errors" ng-show="form.$errors">
|
||||
<h4>Errors have occured</h4>
|
||||
<ul>
|
||||
<li ng-repeat="e in form.$errors">{{e}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="email">Name</label>
|
||||
<input type="text" id="name" name="Name" ng-model="model.name" class="form-control" required api-field />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading">
|
||||
<i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Submit
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user