mirror of
https://github.com/nextcloud/passman.git
synced 2025-01-27 09:49:02 +08:00
Display revisions
This commit is contained in:
parent
6b6eaaf070
commit
eb6fe069e5
4 changed files with 136 additions and 4 deletions
|
@ -144,7 +144,7 @@ class CredentialController extends ApiController {
|
|||
$link, $this->userId, Activity::TYPE_ITEM_ACTION);
|
||||
}
|
||||
|
||||
$this->credentialRevisionService->createRevision($credential, $this->userId, $credential_id);
|
||||
$this->credentialRevisionService->createRevision($storedCredential, $this->userId, $credential_id);
|
||||
$credential = $this->credentialService->updateCredential($credential);
|
||||
|
||||
return new JSONResponse($credential);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Controller of the passmanApp
|
||||
*/
|
||||
angular.module('passmanApp')
|
||||
.controller('RevisionCtrl', ['$scope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', function ($scope, SettingsService, VaultService, CredentialService, $location, $routeParams) {
|
||||
.controller('RevisionCtrl', ['$scope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$rootScope', function ($scope, SettingsService, VaultService, CredentialService, $location, $routeParams, $rootScope) {
|
||||
|
||||
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
|
||||
if (!$scope.active_vault) {
|
||||
|
@ -31,6 +31,7 @@ angular.module('passmanApp')
|
|||
var getRevisions = function () {
|
||||
CredentialService.getRevisions($scope.storedCredential.credential_id).then(function (revisions) {
|
||||
console.log(revisions)
|
||||
$scope.revisions = revisions;
|
||||
})
|
||||
};
|
||||
|
||||
|
@ -44,7 +45,16 @@ angular.module('passmanApp')
|
|||
getRevisions();
|
||||
}
|
||||
|
||||
$scope.selectRevision = function(revision){
|
||||
$scope.selectedRevision = angular.copy(revision);
|
||||
$scope.selectedRevision.credential_data = CredentialService.decryptCredential(angular.copy(revision.credential_data));
|
||||
$rootScope.$emit('app_menu', true);
|
||||
};
|
||||
|
||||
$scope.closeSelected = function () {
|
||||
$rootScope.$emit('app_menu', false);
|
||||
$scope.selectedRevision = false;
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
$location.path('/vault/' + $routeParams.vault_id);
|
||||
|
|
|
@ -3,7 +3,7 @@ angular.module('templates-main', ['views/credential_revisions.html', 'views/edit
|
|||
angular.module('views/credential_revisions.html', []).run(['$templateCache', function($templateCache) {
|
||||
'use strict';
|
||||
$templateCache.put('views/credential_revisions.html',
|
||||
'<div id="controls"><div class="actions creatable"><div class="breadcrumb"><div class="crumb svg ui-droppable" data-dir="/"><a ng-click="logout()"><i class="fa fa-home"></i></a></div><div class="crumb svg" data-dir="/Test"><a ng-click="cancel()">{{active_vault.name}}</a></div><div class="crumb svg last" data-dir="/Test"><a ng-if="storedCredential.credential_id">Showing revisions of "{{storedCredential.label}}"</a></div></div></div></div>Show revisions...');
|
||||
'<div id="controls"><div class="actions creatable"><div class="breadcrumb"><div class="crumb svg ui-droppable" data-dir="/"><a ng-click="logout()"><i class="fa fa-home"></i></a></div><div class="crumb svg" data-dir="/Test"><a ng-click="cancel()">{{active_vault.name}}</a></div><div class="crumb svg last" data-dir="/Test"><a ng-if="storedCredential.credential_id">Showing revisions of "{{storedCredential.label}}"</a></div></div></div></div><div off-click="closeSelected()"><table class="credential-table" ng-init="menuOpen = false;"><tr ng-repeat="revision in revisions | orderBy:\'-created\'" ng-click="selectRevision(revision)" ng-class="{\'selected\': selectedRevision.revision_id == revision.revision_id}"><td><span class="icon"><i class="fa fa-lock"></i></span> <span class="label">Revision of {{revision.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</span></td></tr></table><div id="app-sidebar" class="detailsView scroll-container app_sidebar" ng-show="selectedRevision"><span class="close icon-close" ng-click="closeSelected()" alt="Close"></span> <b ng-show="selectedRevision">Revision of {{selectedRevision.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</b><table class="revision-details"><tr ng-show="selectedRevision.credential_data.label"><td>Label</td><td>{{selectedRevision.credential_data.label}}</td></tr><tr ng-show="selectedRevision.credential_data.username"><td>Account</td><td><span credential-field value="selectedRevision.credential_data.username"></span></td></tr><tr ng-show="selectedRevision.credential_data.password"><td>Password</td><td><span credential-field value="selectedRevision.credential_data.password" secret="\'true\'"></span></td></tr><tr ng-show="selectedRevision.credential_data.otp.secret"><td>OTP</td><td><span otp-generator secret="selectedRevision.credential_data.otp.secret"></span></td></tr><tr ng-show="selectedRevision.credential_data.email"><td>E-mail</td><td><span credential-field value="selectedRevision.credential_data.email"></span></td></tr><tr ng-show="selectedRevision.credential_data.url"><td>URL</td><td><span credential-field value="selectedRevision.url"></span></td></tr><tr ng-show="selectedRevision.credential_data.files.length > 0"><td>Files</td><td><div ng-repeat="file in selectedRevision.credential_data.files" class="link" ng-click="downloadFile(file)">{{file.filename}} ({{file.size | bytes}})</div></td></tr><tr ng-repeat="field in selectedRevision.credential_data.custom_fields"><td>{{field.label}}</td><td><span credential-field value="field.value" secret="field.secret"></span></td></tr><tr ng-show="selectedRevision.credential_data.changed"><td>Changed</td><td>{{selectedRevision.credential_data.changed * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr><tr ng-show="selectedRevision.credential_data.created"><td>Created</td><td>{{selectedRevision.credential_data.created * 1000 | date:\'dd-MM-yyyy @ HH:mm:ss\'}}</td></tr></table><div ng-show="selectedRevision"><button class="button" ng-click="restoreRevision(selectedRevision)"><span class="fa fa-edit"></span> Restore revision</button> <button class="button" ng-click="deleteRevision(selectedRevision)"><span class="fa fa-trash"></span> Delete revision</button></div></div></div>');
|
||||
}]);
|
||||
|
||||
angular.module('views/edit_credential.html', []).run(['$templateCache', function($templateCache) {
|
||||
|
|
|
@ -15,4 +15,126 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
Show revisions...
|
||||
|
||||
|
||||
<div off-click="closeSelected()">
|
||||
<table class="credential-table" ng-init="menuOpen = false;">
|
||||
<tr ng-repeat="revision in revisions | orderBy:'-created'"
|
||||
ng-click="selectRevision(revision)"
|
||||
ng-class="{'selected': selectedRevision.revision_id == revision.revision_id}">
|
||||
<td>
|
||||
<span class="icon"><i class="fa fa-lock"></i> </span>
|
||||
<span class="label">Revision of {{revision.created * 1000 | date:'dd-MM-yyyy @ HH:mm:ss'}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="app-sidebar" class="detailsView scroll-container app_sidebar"
|
||||
ng-show="selectedRevision">
|
||||
<span class="close icon-close" ng-click="closeSelected()"
|
||||
alt="Close"></span>
|
||||
<b ng-show="selectedRevision">Revision of {{selectedRevision.created * 1000 | date:'dd-MM-yyyy @ HH:mm:ss'}}</b>
|
||||
<table class="revision-details">
|
||||
<tr ng-show="selectedRevision.credential_data.label">
|
||||
<td>
|
||||
Label
|
||||
</td>
|
||||
<td>
|
||||
{{selectedRevision.credential_data.label}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.username">
|
||||
<td>
|
||||
Account
|
||||
</td>
|
||||
<td>
|
||||
<span credential-field
|
||||
value="selectedRevision.credential_data.username"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.password">
|
||||
<td>
|
||||
Password
|
||||
</td>
|
||||
<td>
|
||||
<span credential-field value="selectedRevision.credential_data.password"
|
||||
secret="'true'"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.otp.secret">
|
||||
<td>
|
||||
OTP
|
||||
</td>
|
||||
<td>
|
||||
<span otp-generator
|
||||
secret="selectedRevision.credential_data.otp.secret"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.email">
|
||||
<td>
|
||||
E-mail
|
||||
</td>
|
||||
<td>
|
||||
<span credential-field
|
||||
value="selectedRevision.credential_data.email"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.url">
|
||||
<td>
|
||||
URL
|
||||
</td>
|
||||
<td>
|
||||
<span credential-field
|
||||
value="selectedRevision.url"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.files.length > 0">
|
||||
<td>
|
||||
Files
|
||||
</td>
|
||||
<td>
|
||||
<div ng-repeat="file in selectedRevision.credential_data.files"
|
||||
class="link" ng-click="downloadFile(file)">
|
||||
{{file.filename}} ({{file.size | bytes}})
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-repeat="field in selectedRevision.credential_data.custom_fields">
|
||||
<td>
|
||||
{{field.label}}
|
||||
</td>
|
||||
<td>
|
||||
<span credential-field value="field.value"
|
||||
secret="field.secret"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.changed">
|
||||
<td>
|
||||
Changed
|
||||
</td>
|
||||
<td>
|
||||
{{selectedRevision.credential_data.changed * 1000 | date:'dd-MM-yyyy @ HH:mm:ss'}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-show="selectedRevision.credential_data.created">
|
||||
<td>
|
||||
Created
|
||||
</td>
|
||||
<td>
|
||||
{{selectedRevision.credential_data.created * 1000 | date:'dd-MM-yyyy @ HH:mm:ss'}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<div ng-show="selectedRevision">
|
||||
<button class="button" ng-click="restoreRevision(selectedRevision)" >
|
||||
<span class="fa fa-edit"></span> Restore revision
|
||||
</button>
|
||||
<button class="button" ng-click="deleteRevision(selectedRevision)" >
|
||||
<span class="fa fa-trash"></span> Delete revision
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue