mirror of
https://github.com/bitwarden/web
synced 2026-01-06 02:24:02 +00:00
Move and list ciphers from org subvaults
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
var folderPromise = apiService.folders.list({}, function (folders) {
|
||||
var decFolders = [{
|
||||
id: null,
|
||||
name: '(none)'
|
||||
name: 'No Folder'
|
||||
}];
|
||||
|
||||
for (var i = 0; i < folders.Data.length; i++) {
|
||||
@@ -172,4 +172,20 @@
|
||||
var logins = $filter('filter')($scope.logins, { folderId: folder.id });
|
||||
return logins.length === 0;
|
||||
};
|
||||
|
||||
$scope.share = function (login) {
|
||||
var modal = $uibModal.open({
|
||||
animation: true,
|
||||
templateUrl: 'app/vault/views/vaultShare.html',
|
||||
controller: 'vaultShareController',
|
||||
size: 'sm',
|
||||
resolve: {
|
||||
loginId: function () { return login.id; }
|
||||
}
|
||||
});
|
||||
|
||||
modal.result.then(function () {
|
||||
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
61
src/app/vault/vaultShareController.js
Normal file
61
src/app/vault/vaultShareController.js
Normal file
@@ -0,0 +1,61 @@
|
||||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultShareController', function ($scope, apiService, $uibModalInstance, authService, cipherService, loginId, $analytics) {
|
||||
$analytics.eventTrack('vaultShareController', { category: 'Modal' });
|
||||
$scope.model = {};
|
||||
$scope.login = {};
|
||||
$scope.subvaults = [];
|
||||
$scope.organizations = [];
|
||||
|
||||
apiService.logins.get({ id: loginId }, function (login) {
|
||||
$scope.login = cipherService.decryptLogin(login);
|
||||
});
|
||||
|
||||
var profile = authService.getUserProfile();
|
||||
if (profile && profile.organizations) {
|
||||
var orgs = [];
|
||||
for (var i = 0; i < profile.organizations.length; i++) {
|
||||
orgs.push({
|
||||
id: profile.organizations[i].id,
|
||||
name: profile.organizations[i].name
|
||||
});
|
||||
|
||||
if (i === 0) {
|
||||
$scope.model.organizationId = profile.organizations[i].id;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.organizations = orgs;
|
||||
|
||||
apiService.subvaults.listMe(function (response) {
|
||||
var subvaults = [];
|
||||
for (var i = 0; i < response.Data.length; i++) {
|
||||
var decSubvault = cipherService.decryptSubvault(response.Data[i]);
|
||||
decSubvault.organizationId = response.Data[i].OrganizationId;
|
||||
subvaults.push(decSubvault);
|
||||
}
|
||||
|
||||
$scope.subvaults = subvaults;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.submitPromise = null;
|
||||
$scope.submit = function (model) {
|
||||
$scope.login.organizationId = model.organizationId;
|
||||
|
||||
var request = {
|
||||
subvaultIds: model.subvaultIds,
|
||||
cipher: cipherService.encryptLogin($scope.login)
|
||||
};
|
||||
|
||||
$scope.savePromise = apiService.ciphers.move({ id: loginId }, request, function (response) {
|
||||
$analytics.eventTrack('Shared Login');
|
||||
$uibModalInstance.close();
|
||||
}).$promise;
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
});
|
||||
@@ -47,7 +47,7 @@
|
||||
<table class="table table-striped table-hover table-selectable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 75px; min-width: 75px;"></th>
|
||||
<th style="width: 110px; min-width: 110px;"></th>
|
||||
<th>Name</th>
|
||||
<th style="width: 300px;">Username</th>
|
||||
</tr>
|
||||
@@ -64,6 +64,10 @@
|
||||
uib-tooltip="View/Edit">
|
||||
<i class="fa fa-lg fa-pencil"></i>
|
||||
</button>
|
||||
<button type="button" ng-click="share(login)" class="btn btn-link btn-table"
|
||||
uib-tooltip="Share">
|
||||
<i class="fa fa-lg fa-share-alt"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td ng-click="editLogin(login)">
|
||||
<span ng-click="$event.stopPropagation()">
|
||||
|
||||
33
src/app/vault/views/vaultShare.html
Normal file
33
src/app/vault/views/vaultShare.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<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> Share Login <small>{{login.name}}</small></h4>
|
||||
</div>
|
||||
<form name="form" ng-submit="form.$valid && submit(model)" 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">
|
||||
<label for="organization">Organization</label> <span>*</span>
|
||||
<select id="organization" name="Organization" ng-model="model.organizationId" class="form-control">
|
||||
<option ng-repeat="org in organizations | orderBy: ['name']" value="{{org.id}}">{{org.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" show-errors>
|
||||
<label for="subvaults">Subvault</label> <span>*</span>
|
||||
<select id="subvaults" name="SubvaultIds" ng-model="model.subvaultIds" class="form-control" multiple api-field>
|
||||
<option ng-repeat="subvault in subvaults | filter: { organizationId: model.organizationId } |
|
||||
orderBy: ['name']" value="{{subvault.id}}">{{subvault.name}}</option>
|
||||
</select>
|
||||
</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>Save
|
||||
</button>
|
||||
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
Reference in New Issue
Block a user