mirror of
https://github.com/bitwarden/web
synced 2025-12-17 16:53:14 +00:00
load cipher subvaults
This commit is contained in:
@@ -53,7 +53,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="subvault in subvaults | orderBy: ['name']">
|
<tr ng-repeat="subvault in subvaults | orderBy: ['name']">
|
||||||
<td style="valign="middle">
|
<td valign="middle">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
name="selectedSubvaults[]"
|
name="selectedSubvaults[]"
|
||||||
value="{{subvault.id}}"
|
value="{{subvault.id}}"
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
|
|
||||||
_service.ciphers = $resource(_apiUri + '/ciphers/:id', {}, {
|
_service.ciphers = $resource(_apiUri + '/ciphers/:id', {}, {
|
||||||
get: { method: 'GET', params: { id: '@id' } },
|
get: { method: 'GET', params: { id: '@id' } },
|
||||||
|
getFullDetails: { url: _apiUri + '/ciphers/:id/full-details', method: 'GET', params: { id: '@id' } },
|
||||||
list: { method: 'GET', params: {} },
|
list: { method: 'GET', params: {} },
|
||||||
listSubvaults: { url: _apiUri + '/ciphers/subvaults', method: 'GET', params: {} },
|
listDetails: { url: _apiUri + '/ciphers/details', method: 'GET', params: {} },
|
||||||
'import': { url: _apiUri + '/ciphers/import', method: 'POST', params: {} },
|
'import': { url: _apiUri + '/ciphers/import', method: 'POST', params: {} },
|
||||||
favorite: { url: _apiUri + '/ciphers/:id/favorite', method: 'POST', params: { id: '@id' } },
|
favorite: { url: _apiUri + '/ciphers/:id/favorite', method: 'POST', params: { id: '@id' } },
|
||||||
putPartial: { url: _apiUri + '/ciphers/:id/partial', method: 'POST', params: { id: '@id' } },
|
putPartial: { url: _apiUri + '/ciphers/:id/partial', method: 'POST', params: { id: '@id' } },
|
||||||
|
|||||||
@@ -212,4 +212,19 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.subvaults = function (login) {
|
||||||
|
var modal = $uibModal.open({
|
||||||
|
animation: true,
|
||||||
|
templateUrl: 'app/vault/views/vaultLoginSubvaults.html',
|
||||||
|
controller: 'vaultLoginSubvaultsController',
|
||||||
|
resolve: {
|
||||||
|
loginId: function () { return login.id; }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.result.then(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
101
src/app/vault/vaultLoginSubvaultsController.js
Normal file
101
src/app/vault/vaultLoginSubvaultsController.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
angular
|
||||||
|
.module('bit.vault')
|
||||||
|
|
||||||
|
.controller('vaultLoginSubvaultsController', function ($scope, apiService, $uibModalInstance, cipherService,
|
||||||
|
loginId, $analytics) {
|
||||||
|
$analytics.eventTrack('vaultLoginSubvaultsController', { category: 'Modal' });
|
||||||
|
$scope.login = {};
|
||||||
|
$scope.readOnly = false;
|
||||||
|
$scope.loadingLogin = true;
|
||||||
|
$scope.loadingSubvaults = true;
|
||||||
|
$scope.selectedSubvaults = {};
|
||||||
|
|
||||||
|
$uibModalInstance.opened.then(function () {
|
||||||
|
apiService.ciphers.getFullDetails({ id: loginId }).$promise.then(function (cipher) {
|
||||||
|
$scope.loadingLogin = false;
|
||||||
|
|
||||||
|
$scope.readOnly = !cipher.Edit;
|
||||||
|
if (cipher.Edit && cipher.OrganizationId) {
|
||||||
|
if (cipher.Type === 1) {
|
||||||
|
$scope.login = cipherService.decryptLoginPreview(cipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
var subvaults = {};
|
||||||
|
if (cipher.SubvaultIds) {
|
||||||
|
for (var i = 0; i < cipher.SubvaultIds.length; i++) {
|
||||||
|
subvaults[cipher.SubvaultIds[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$scope.selectedSubvaults = subvaults;
|
||||||
|
|
||||||
|
return cipher;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}).then(function (cipher) {
|
||||||
|
if (!cipher.Edit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiService.subvaults.listMe(function (response) {
|
||||||
|
var subvaults = [];
|
||||||
|
for (var i = 0; i < response.Data.length; i++) {
|
||||||
|
if (response.Data[i].OrganizationId !== cipher.OrganizationId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var decSubvault = cipherService.decryptSubvault(response.Data[i]);
|
||||||
|
subvaults.push(decSubvault);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.loadingSubvaults = false;
|
||||||
|
$scope.subvaults = subvaults;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.toggleSubvaultSelectionAll = function ($event) {
|
||||||
|
var subvaults = {};
|
||||||
|
if ($event.target.checked) {
|
||||||
|
for (var i = 0; i < $scope.subvaults.length; i++) {
|
||||||
|
subvaults[$scope.subvaults[i].id] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.selectedSubvaults = subvaults;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.toggleSubvaultSelection = function (id) {
|
||||||
|
if (id in $scope.selectedSubvaults) {
|
||||||
|
delete $scope.selectedSubvaults[id];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$scope.selectedSubvaults[id] = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.subvaultSelected = function (subvault) {
|
||||||
|
return subvault.id in $scope.selectedSubvaults;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.allSelected = function () {
|
||||||
|
return Object.keys($scope.selectedSubvaults).length === $scope.subvaults.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.save = function (model) {
|
||||||
|
var request = {
|
||||||
|
subvaultIds: model.subvaultIds
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.savePromise = apiService.ciphers.putSubvaults({ id: loginId }, request, function (response) {
|
||||||
|
$analytics.eventTrack('Edited Login Subvaults');
|
||||||
|
$uibModalInstance.close({
|
||||||
|
action: 'subvaultsEdit'
|
||||||
|
});
|
||||||
|
}).$promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.close = function () {
|
||||||
|
$uibModalInstance.dismiss('cancel');
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
$scope.subvaults = decSubvaults;
|
$scope.subvaults = decSubvaults;
|
||||||
}).$promise;
|
}).$promise;
|
||||||
|
|
||||||
var cipherPromise = apiService.ciphers.listSubvaults({}, function (ciphers) {
|
var cipherPromise = apiService.ciphers.listDetails({}, function (ciphers) {
|
||||||
var decLogins = [];
|
var decLogins = [];
|
||||||
|
|
||||||
for (var i = 0; i < ciphers.Data.length; i++) {
|
for (var i = 0; i < ciphers.Data.length; i++) {
|
||||||
|
|||||||
@@ -56,6 +56,11 @@
|
|||||||
<i class="fa fa-fw fa-share-alt"></i> Share
|
<i class="fa fa-fw fa-share-alt"></i> Share
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li ng-show="login.organizationId">
|
||||||
|
<a href="javascript:void(0)" ng-click="subvaults(login)">
|
||||||
|
<i class="fa fa-fw fa-share-alt"></i> Subvaults
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red">
|
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red">
|
||||||
<i class="fa fa-fw fa-trash"></i> Delete
|
<i class="fa fa-fw fa-trash"></i> Delete
|
||||||
@@ -133,6 +138,11 @@
|
|||||||
<i class="fa fa-fw fa-share-alt"></i> Share
|
<i class="fa fa-fw fa-share-alt"></i> Share
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li ng-show="login.organizationId">
|
||||||
|
<a href="javascript:void(0)" ng-click="subvaults(login)">
|
||||||
|
<i class="fa fa-fw fa-share-alt"></i> Subvaults
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red">
|
<a href="javascript:void(0)" ng-click="deleteLogin(login)" class="text-red">
|
||||||
<i class="fa fa-fw fa-trash"></i> Delete
|
<i class="fa fa-fw fa-trash"></i> Delete
|
||||||
|
|||||||
54
src/app/vault/views/vaultLoginSubvaults.html
Normal file
54
src/app/vault/views/vaultLoginSubvaults.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<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> Subvaults <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 ng-show="loadingSubvaults && !subvaults.length">
|
||||||
|
Loading...
|
||||||
|
</div>
|
||||||
|
<div ng-show="!loadingSubvaults && !subvaults.length">
|
||||||
|
<p>No subvaults.</p>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive" ng-show="subvaults.length" style="margin: 0;">
|
||||||
|
<table class="table table-striped table-hover" style="margin: 0;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 40px;">
|
||||||
|
<input type="checkbox"
|
||||||
|
ng-checked="allSelected()"
|
||||||
|
ng-click="toggleSubvaultSelectionAll($event)">
|
||||||
|
</th>
|
||||||
|
<th>Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="subvault in subvaults | orderBy: ['name']">
|
||||||
|
<td valign="middle">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="selectedSubvaults[]"
|
||||||
|
value="{{subvault.id}}"
|
||||||
|
ng-checked="subvaultSelected(subvault)"
|
||||||
|
ng-click="toggleSubvaultSelection(subvault.id)">
|
||||||
|
</td>
|
||||||
|
<td valign="middle">
|
||||||
|
{{subvault.name}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</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>
|
||||||
@@ -125,6 +125,7 @@
|
|||||||
<script src="app/vault/vaultAddFolderController.js"></script>
|
<script src="app/vault/vaultAddFolderController.js"></script>
|
||||||
<script src="app/vault/vaultShareController.js"></script>
|
<script src="app/vault/vaultShareController.js"></script>
|
||||||
<script src="app/vault/vaultSubvaultsController.js"></script>
|
<script src="app/vault/vaultSubvaultsController.js"></script>
|
||||||
|
<script src="app/vault/vaultLoginSubvaultsController.js"></script>
|
||||||
|
|
||||||
<script src="app/organization/organizationModule.js"></script>
|
<script src="app/organization/organizationModule.js"></script>
|
||||||
<script src="app/organization/organizationDashboardController.js"></script>
|
<script src="app/organization/organizationDashboardController.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user