Fully implemented edit_credential folderhandling

Signed-off-by: fnuesse <felix.nuesse@t-online.de>
This commit is contained in:
fnuesse 2019-01-03 15:41:52 +01:00
parent 27d6fe83bf
commit 7db9c360f1
No known key found for this signature in database
GPG key ID: 2089A3431243E819
6 changed files with 49 additions and 18 deletions

View file

@ -425,6 +425,7 @@ class TranslationController extends ApiController {
//template/views/partials/folder-picker
'folderpath.credential' => $this->trans->t('Credential to move'),
'folderpath.move' => $this->trans->t('Move'),
'folderpath.moved' => $this->trans->t('Moved credential!'),
'folderpath.cancel' => $this->trans->t('Cancel'),
'folderpath.newfolder' => $this->trans->t('New Folder'),
'folderpath.createnewhint' => $this->trans->t('New...'),

View file

@ -105,6 +105,7 @@
angular.merge($scope.active_vault.credentials, _credentials);
$scope.show_spinner = false;
FolderService.expandWithFolder($scope, $scope.active_vault.credentials);
FolderService.initializeInCredentialJs();
$rootScope.$broadcast('credentials_loaded');
$rootScope.vaultCache[$scope.active_vault.guid] = angular.copy($scope.active_vault);
if(!vault.private_sharing_key){
@ -236,6 +237,8 @@
var _credential = angular.copy(credential);
$rootScope.$emit('app_menu', false);
SettingsService.setSetting('edit_credential', CredentialService.encryptCredential(_credential));
FolderService.setList($scope.active_vault.credentials);
$location.path('/vault/' + $scope.active_vault.guid + '/edit/' + _credential.guid);
};

View file

@ -36,9 +36,23 @@
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope, FolderService) {
$scope.FolderList=[];
//folderhandling
$scope.FolderList=[];
$scope.FullCredentialList=FolderService.getList();
FolderService.expandWithFolder($scope, $scope.FullCredentialList);
console.log("edit_cred.js");
console.log(FolderService.getList());
$scope.buildFolderList(true);
$scope.getCurrentFolderList();
$scope.createBreadCrumbList();
$scope.openFolderPicker = function () {
$( '#folderPicker-ButtonDiv' ).click();
};
$scope.active_vault = VaultService.getActiveVault();
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
$location.path('/');
@ -50,6 +64,7 @@
_vault.vaultKey = SettingsService.getSetting('defaultVaultPass');
VaultService.setActiveVault(_vault);
$scope.active_vault = _vault;
FolderService.isInitialized($scope);
}
}
@ -71,15 +86,6 @@
});
});
VaultService.getVault($scope.active_vault).then(function (vault) {
console.log(vault.credentials)
FolderService.expandWithFolder($scope, vault.credentials);
$scope.buildFolderList(true);
$scope.getCurrentFolderList();
$scope.createBreadCrumbList();
});
$scope.currentTab = {
title: $translate.instant('general'),
url: 'views/partials/forms/edit_credential/basics.html',

View file

@ -30,8 +30,29 @@
* Service in the passmanApp.
*/
angular.module('passmanApp')
.service('FolderService', [function () {
.service('FolderService', ['$location', function ($location) {
//takes load of edit_credentials, because the list is not available there
var decrypted_credential_list = {};
var initializedByCredentialjs = false;
return {
initializeInCredentialJs: function () {
initializedByCredentialjs=true;
},
isInitialized: function (scope) {
if(!initializedByCredentialjs){
$location.path('/vault/' + scope.active_vault.guid + '/');
}
},
setList: function (list) {
decrypted_credential_list=list;
},
getList: function () {
return decrypted_credential_list;
},
expandWithFolder: function ($scope, CredentialList) {
$scope.currentFolder = "/";
@ -48,7 +69,7 @@ angular.module('passmanApp')
for (var i = 0; i < CredentialList.length; i++) {
var _credential = CredentialList[i];
if (_credential.folderpath !== null) {
if (_credential.folderpath !== null && typeof _credential.folderpath !== 'undefined') {
while(_credential.folderpath.includes('//')){
_credential.folderpath=_credential.folderpath.replace("//", "/");
}

View file

@ -16,12 +16,12 @@
</div>
<div class="addCredential">
<button folder-picker="storedCredential"
folder="FolderList"
>
<button ng-click="openFolderPicker();">
{{ 'folderpath.move' | translate}}
</button>
</div>
<div id="folderPicker-ButtonDiv" folder-picker="storedCredential"
credentiallist="FullCredentialList"></div>
</div>
</div>
<div>

View file

@ -35,7 +35,7 @@
</div>
<label>{{ 'folderpath' | translate}}</label>
<div>
<input type="text" ng-model="storedCredential.folderpath">
<input type="text" ng-model="storedCredential.folderpath" readonly>
</div>
<label>{{ 'add.tag' | translate}}</label>
<div class="tags_input">