1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

subvault listing search and edit subvault

This commit is contained in:
Kyle Spearrin 2017-03-29 22:23:00 -04:00
parent 616a442fcb
commit 61cce7e8e7
6 changed files with 85 additions and 9 deletions

View File

@ -1,7 +1,7 @@
angular
.module('bit.organization')
.controller('organizationSubvaultsController', function ($scope, $state, apiService, $uibModal, cipherService) {
.controller('organizationSubvaultsController', function ($scope, $state, apiService, $uibModal, cipherService, $filter) {
$scope.subvaults = [];
$scope.loading = true;
$scope.$on('$viewContentLoaded', function () {
@ -20,6 +20,24 @@
});
};
$scope.edit = function (subvault) {
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/organization/views/organizationSubvaultsEdit.html',
controller: 'organizationSubvaultsEditController',
resolve: {
id: function () { return subvault.id; }
}
});
modal.result.then(function (editedSubvault) {
var existingSubvaults = $filter('filter')($scope.subvaults, { id: editedSubvault.id }, true);
if (existingSubvaults && existingSubvaults.length > 0) {
existingSubvaults[0].name = editedSubvault.name;
}
});
};
$scope.delete = function (subvault) {
if (!confirm('Are you sure you want to delete this subvault (' + subvault.name + ')?')) {
return;

View File

@ -0,0 +1,26 @@
angular
.module('bit.organization')
.controller('organizationSubvaultsEditController', function ($scope, $state, $uibModalInstance, apiService, cipherService,
$analytics, id) {
$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');
};
});

View File

@ -7,19 +7,27 @@
<section class="content">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
</h3>
&nbsp;
<div class="box-filters hidden-xs">
<div class="form-group form-group-sm has-feedback has-feedback-left">
<input type="text" id="search" class="form-control" placeholder="Search subvaults..."
style="width: 200px;" ng-model="filterSearch">
<span class="fa fa-search form-control-feedback text-muted" aria-hidden="true"></span>
</div>
</div>
<div class="box-tools">
<button type="button" class="btn btn-primary btn-sm btn-flat" ng-click="add()">
<i class="fa fa-fw fa-plus-circle"></i> New Subvault
</button>
</div>
</div>
<div class="box-body" ng-class="{'no-padding': subvaults.length}">
<div class="box-body" ng-class="{'no-padding': filteredSubvaults.length}">
<div ng-show="loading && !subvaults.length">
Loading...
</div>
<div ng-show="!filteredSubvaults.length && filterSearch">
No subvaults to list.
</div>
<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>
@ -27,7 +35,8 @@
<div class="table-responsive" ng-show="subvaults.length">
<table class="table table-striped table-hover">
<tbody>
<tr ng-repeat="subvault in subvaults | orderBy: ['name']">
<tr ng-repeat="subvault in filteredSubvaults = (subvaults | filter: (filterSearch || '') |
orderBy: ['name'])">
<td valign="middle">
<a href="javascript:void(0)" ng-click="edit(subvault)">
{{subvault.name}}

View File

@ -4,9 +4,6 @@
</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>

View File

@ -0,0 +1,25 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><i class="fa fa-share-alt"></i> Edit Subvault</h4>
</div>
<form name="form" ng-submit="form.$valid && submit(subvault)" api-form="submitPromise">
<div class="modal-body">
<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="subvault.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>

View File

@ -126,6 +126,7 @@
<script src="app/organization/organizationPeopleEditController.js"></script>
<script src="app/organization/organizationSubvaultsController.js"></script>
<script src="app/organization/organizationSubvaultsAddController.js"></script>
<script src="app/organization/organizationSubvaultsEditController.js"></script>
<script src="app/settings/settingsModule.js"></script>
<script src="app/settings/settingsController.js"></script>