Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfnuesse <felix.nuesse@t-online.de>2019-01-01 22:06:25 +0300
committerfnuesse <felix.nuesse@t-online.de>2019-01-01 22:06:25 +0300
commit2ac1b17bfbf557ea7245e075875cd4638735be35 (patch)
tree87252456fa96655689054e54258f142d43e257d6
parente3f8c5573d48e0d93d4921074e49383e31e1ec3a (diff)
Moved folderlogic to service (wip)
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
-rw-r--r--js/app/controllers/credential.js108
-rw-r--r--js/app/controllers/edit_credential.js19
-rw-r--r--js/app/directives/folderpicker.js2
-rw-r--r--js/app/services/folderservice.js142
-rw-r--r--templates/main.php1
-rw-r--r--templates/views/edit_credential.html11
6 files changed, 169 insertions, 114 deletions
diff --git a/js/app/controllers/credential.js b/js/app/controllers/credential.js
index 0e528bcb..a20bf68a 100644
--- a/js/app/controllers/credential.js
+++ b/js/app/controllers/credential.js
@@ -32,9 +32,9 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
- .controller('CredentialCtrl', ['$scope', 'VaultService', 'SettingsService', '$location', 'CredentialService',
- '$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService', 'SharingACL', '$interval', '$filter', '$routeParams', '$sce', '$translate',
- function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService, SharingACL, $interval, $filter, $routeParams, $sce, $translate) {
+ .controller('CredentialCtrl', ['$scope', 'VaultService', 'SettingsService', '$location', 'CredentialService', '$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService', 'SharingACL', '$interval', '$filter', '$routeParams', '$sce', '$translate', 'FolderService',
+ function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService, SharingACL, $interval, $filter, $routeParams, $sce, $translate, FolderService) {
+
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
@@ -49,12 +49,6 @@
//@TODO check if vault exists
}
}
-
- $scope.currentFolder="/";
- $scope.FolderList=["/"];
- $scope.TempFolderList=[];
- $scope.BreadcrumbList=[];
-
$scope.show_spinner = true;
var fetchCredentials = function () {
VaultService.getVault({guid: $routeParams.vault_id}).then(function (vault) {
@@ -110,6 +104,7 @@
angular.merge($scope.active_vault.credentials, _credentials);
$scope.show_spinner = false;
+ FolderService.expandWithFolder($scope, $scope.active_vault.credentials);
$rootScope.$broadcast('credentials_loaded');
$rootScope.vaultCache[$scope.active_vault.guid] = angular.copy($scope.active_vault);
if(!vault.private_sharing_key){
@@ -472,74 +467,6 @@
return list_without_hidden;
};
- $scope.createBreadCrumbList = function () {
- var array= $scope.currentFolder.split("/").filter(Boolean);
- var res=[];
- var fullPath="/";
- array.forEach(function (element) {
- fullPath+=element+"/";
- res.push({fullPath:fullPath, name:element});
- });
- $scope.BreadcrumbList=res;
-
- };
-
- $scope.setCurrentFolder = function (folder) {
- $scope.currentFolder=folder;
- $scope.createBreadCrumbList();
- };
-
- $scope.setCurrentFolderFromBreadcrumb = function (folder) {
- $scope.currentFolder=folder;
- $scope.createBreadCrumbList();
- $scope.getCurrentFolderList();
- };
-
- $scope.setCurrentFolderFromUI = function (folder) {
- var c= $scope.currentFolder+folder+"/";//$scope.cutScopeFolderFromFoldername(folder);
- $scope.setCurrentFolder(c);
- $scope.getCurrentFolderList();
- };
-
- $scope.checkIfCurrentFolderIsSelected = function (folder) {
- if($scope.currentFolder === "/" && "/" === folder){
- return true;
- }
- return $scope.currentFolder.substring(0,$scope.currentFolder.length-1) === folder;
- };
-
- $scope.checkIfFolderIsSubfolder = function (folder) {
- return folder.startsWith($scope.currentFolder);
- };
-
- $scope.cutScopeFolderFromFoldername = function (folder) {
- var withoutParent=folder.replace($scope.currentFolder, "")+"/";
- var withoutRest="";
- var temp="";
- if(withoutParent.startsWith("/")){
- temp=withoutParent.substring(1,withoutParent.length);
- withoutRest=temp.substring(0,temp.indexOf("/"));
- }else{
- withoutRest=withoutParent.substring(0,withoutParent.indexOf("/"));
- }
-
- return withoutRest;
- };
-
- $scope.getCurrentFolderList = function () {
- var Temp=[];
- for (var i=0; i<$scope.FolderList.length; i++) {
- //console.log("test: "+$scope.FolderList[i]);
- if($scope.FolderList[i].startsWith($scope.currentFolder) && $scope.checkIfFolderIsSubfolder($scope.FolderList[i])){
- var reducedFoldername=$scope.cutScopeFolderFromFoldername($scope.FolderList[i]);
- if(Temp.indexOf(reducedFoldername) <= -1){
- Temp.push(reducedFoldername);
- }
- }
- }
- $scope.TempFolderList=Temp;
- };
-
$rootScope.$on('updateFolderInMainList', function (evt, updated_credential) {
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
@@ -559,34 +486,7 @@
$scope.getCurrentFolderList();
});
- $scope.buildFolderList = function (update) {
-
- $scope.FolderList=["/"];
- $scope.TempFolderList=[];
- $scope.BreadcrumbList=[];
- for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
- var _credential = $scope.active_vault.credentials[i];
-
- if(_credential.folderpath !== null){
- if(String(_credential.folderpath).startsWith(String($scope.currentFolder)) || update){
- if($scope.FolderList.indexOf(_credential.folderpath) <= -1){
- $scope.FolderList.push(_credential.folderpath);
- }
- }else{
- _credential.folderpath="/";
- }
- }else{
- _credential.folderpath="/";
- }
- $scope.active_vault.credentials[i]=_credential;
- }
-
- if(!$scope.FolderList.includes($scope.currentFolder)){
- $scope.currentFolder="/";
- }
-
- };
$scope.selectedtags = [];
var to;
diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js
index a4d59214..a119fbb7 100644
--- a/js/app/controllers/edit_credential.js
+++ b/js/app/controllers/edit_credential.js
@@ -32,9 +32,13 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
- .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate','$rootScope',
- function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope) {
- $scope.active_vault = VaultService.getActiveVault();
+ .controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate', '$rootScope', 'FolderService',
+ function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate, $rootScope, FolderService) {
+
+
+ $scope.FolderList=[];
+
+ $scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
$location.path('/');
@@ -67,6 +71,15 @@
});
});
+ 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',
diff --git a/js/app/directives/folderpicker.js b/js/app/directives/folderpicker.js
index 50044463..23e8fdbf 100644
--- a/js/app/directives/folderpicker.js
+++ b/js/app/directives/folderpicker.js
@@ -35,7 +35,7 @@
restrict: 'A',
scope: {
credential: '=folderPicker',
- folder: '=folder'
+ folder: '=folder',
},
link: function(scope, element) {
diff --git a/js/app/services/folderservice.js b/js/app/services/folderservice.js
new file mode 100644
index 00000000..d4fe72c9
--- /dev/null
+++ b/js/app/services/folderservice.js
@@ -0,0 +1,142 @@
+/**
+ * Nextcloud - passman
+ *
+ * @copyright Copyright (c) 2016, Sander Brand (brantje@gmail.com)
+ * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel (wolfi@wolfi.es)
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+(function () {
+ 'use strict';
+/**
+ * @ngdoc service
+ * @name passmanApp.CacheService
+ * @description
+ * # CacheService
+ * Service in the passmanApp.
+ */
+angular.module('passmanApp')
+ .service('FolderService', [function () {
+ return {
+ expandWithFolder: function ($scope, CredentialList) {
+
+ $scope.currentFolder = "/";
+ $scope.FolderList = ["/"];
+ $scope.TempFolderList = [];
+ $scope.BreadcrumbList = [];
+
+ $scope.buildFolderList = function (update) {
+
+ $scope.FolderList = ["/"];
+ $scope.TempFolderList = [];
+ $scope.BreadcrumbList = [];
+
+ for (var i = 0; i < CredentialList.length; i++) {
+ var _credential = CredentialList[i];
+
+ if (_credential.folderpath !== null) {
+ if (String(_credential.folderpath).startsWith(String($scope.currentFolder)) || update) {
+ if ($scope.FolderList.indexOf(_credential.folderpath) <= -1) {
+ $scope.FolderList.push(_credential.folderpath);
+ }
+ } else {
+ _credential.folderpath = "/";
+ }
+ } else {
+ _credential.folderpath = "/";
+ }
+ CredentialList[i] = _credential;
+ }
+
+ if (!$scope.FolderList.includes($scope.currentFolder)) {
+ $scope.currentFolder = "/";
+ }
+
+ };
+
+ $scope.createBreadCrumbList = function () {
+ var array = $scope.currentFolder.split("/").filter(Boolean);
+ var res = [];
+ var fullPath = "/";
+ array.forEach(function (element) {
+ fullPath += element + "/";
+ res.push({fullPath: fullPath, name: element});
+ });
+ $scope.BreadcrumbList = res;
+
+ };
+
+ $scope.setCurrentFolder = function (folder) {
+ $scope.currentFolder = folder;
+ $scope.createBreadCrumbList();
+ };
+
+ $scope.setCurrentFolderFromBreadcrumb = function (folder) {
+ $scope.currentFolder = folder;
+ $scope.createBreadCrumbList();
+ $scope.getCurrentFolderList();
+ };
+
+ $scope.setCurrentFolderFromUI = function (folder) {
+ var c = $scope.currentFolder + folder + "/";//$scope.cutScopeFolderFromFoldername(folder);
+ $scope.setCurrentFolder(c);
+ $scope.getCurrentFolderList();
+ };
+
+ $scope.checkIfCurrentFolderIsSelected = function (folder) {
+ if ($scope.currentFolder === "/" && "/" === folder) {
+ return true;
+ }
+ return $scope.currentFolder.substring(0, $scope.currentFolder.length - 1) === folder;
+ };
+
+ $scope.checkIfFolderIsSubfolder = function (folder) {
+ return folder.startsWith($scope.currentFolder);
+ };
+
+ $scope.cutScopeFolderFromFoldername = function (folder) {
+ var withoutParent = folder.replace($scope.currentFolder, "") + "/";
+ var withoutRest = "";
+ var temp = "";
+ if (withoutParent.startsWith("/")) {
+ temp = withoutParent.substring(1, withoutParent.length);
+ withoutRest = temp.substring(0, temp.indexOf("/"));
+ } else {
+ withoutRest = withoutParent.substring(0, withoutParent.indexOf("/"));
+ }
+
+ return withoutRest;
+ };
+
+ $scope.getCurrentFolderList = function () {
+ var Temp = [];
+ for (var i = 0; i < $scope.FolderList.length; i++) {
+ //console.log("test: "+$scope.FolderList[i]);
+ if ($scope.FolderList[i].startsWith($scope.currentFolder) && $scope.checkIfFolderIsSubfolder($scope.FolderList[i])) {
+ var reducedFoldername = $scope.cutScopeFolderFromFoldername($scope.FolderList[i]);
+ if (Temp.indexOf(reducedFoldername) <= -1) {
+ Temp.push(reducedFoldername);
+ }
+ }
+ }
+ $scope.TempFolderList = Temp;
+ };
+
+ },
+ };
+ }]);
+}()); \ No newline at end of file
diff --git a/templates/main.php b/templates/main.php
index e416283a..6c8dcc33 100644
--- a/templates/main.php
+++ b/templates/main.php
@@ -64,6 +64,7 @@ script('passman', 'app/services/iconservice');
script('passman', 'app/services/tagservice');
script('passman', 'app/services/notificationservice');
script('passman', 'app/services/shareservice');
+script('passman', 'app/services/folderservice');
script('passman', 'app/factory/sharingacl');
script('passman', 'app/directives/passwordgen');
script('passman', 'app/directives/fileselect');
diff --git a/templates/views/edit_credential.html b/templates/views/edit_credential.html
index ec6cc33d..04b4078f 100644
--- a/templates/views/edit_credential.html
+++ b/templates/views/edit_credential.html
@@ -16,12 +16,11 @@
</div>
<div class="addCredential">
- <button>{{ 'folderpath.move' | translate}}<div folder-picker="storedCredential"
- folder="FolderList"
- class=""
- ng-class="{'icon-settings-dark':hovering}"
- ng-mouseenter="hovering=true"
- ng-mouseleave="hovering=false"></div></button>
+ <button folder-picker="storedCredential"
+ folder="FolderList"
+ >
+ </button>
+
</div>
</div>
</div>