From dac5c17360ba5c322641f0ab919150ed7c34ccb2 Mon Sep 17 00:00:00 2001 From: Marcos Zuriaga Date: Thu, 29 Sep 2016 01:12:39 +0200 Subject: [PATCH 1/2] Some more sharing logic --- controller/sharecontroller.php | 11 ++++++ js/app/controllers/share.js | 67 ++++++++++++++++++++++++++++------ 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/controller/sharecontroller.php b/controller/sharecontroller.php index d7184baf..5e2636f0 100644 --- a/controller/sharecontroller.php +++ b/controller/sharecontroller.php @@ -77,9 +77,20 @@ class ShareController extends ApiController { foreach ($groupsTmp as $group) { + $group_users = $group->getUsers(); + $final_users = []; + foreach ($group_users as $user){ + $final_users[] = [ + 'text' => $user->getDisplayName(), + 'uid' => $user->getUID(), + 'type' => 'user' + ]; + } + $groups[] = array( 'text' => $group->getGID(), 'uid' => $group->getGID(), + 'users' => $final_users, 'type' => 'group' ); } diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index 60bc0666..beddbb83 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -105,20 +105,65 @@ angular.module('passmanApp') var list = $scope.share_settings.credentialSharedWithUserAndGroup; console.log(list); for (var i = 0; i < list.length; i++){ - ShareService.getVaultsByUser(list[i].userId).then(function(data){ - list[i].vaults = data; - console.log(data); - var start = new Date().getTime() / 1000;; - ShareService.cypherRSAStringWithPublicKeyBulkAsync(data, key) - .progress(function(data){ + if (list[i].type == "user") { + ShareService.getVaultsByUser(list[i].userId).then(function (data) { + list[i].vaults = data; console.log(data); - }) - .then(function(result){ - console.log(result); - console.log("Took: " + ((new Date().getTime() / 1000) - start) + "s to cypher the string for user [" + data[0].user_id + "]"); + var start = new Date().getTime() / 1000; + ; + ShareService.cypherRSAStringWithPublicKeyBulkAsync(data, key) + .progress(function (data) { + console.log(data); + }) + .then(function (result) { + console.log(result); + console.log("Took: " + ((new Date().getTime() / 1000) - start) + "s to cypher the string for user [" + data[0].user_id + "]"); + }); }); - }); + list[i].processed = true; + } + else if (list[i].type == "group"){ + for (var x = 0; x < list[i].users.length; x++){ + if ($scope.isUserReady(list[i].users[x].userId)){ + continue; + } + ShareService.getVaultsByUser(list[i].userId).then(function (data) { + list[i].vaults = data; + console.log(data); + var start = new Date().getTime() / 1000; + ; + ShareService.cypherRSAStringWithPublicKeyBulkAsync(data, key) + .progress(function (data) { + console.log(data); + }) + .then(function (result) { + console.log(result); + console.log("Took: " + ((new Date().getTime() / 1000) - start) + "s to cypher the string for user [" + data[0].user_id + "]"); + }); + }); + list[i].processed = true; + } + } } }) + }; + + $scope.isUserReady = function (userId){ + var list = $scope.share_settings.credentialSharedWithUserAndGroup; + for (var i = 0; i < list.length; i++){ + if (list[i].type == "user"){ + if (list[i].userId == userId && list[i].ready){ + return true; + } + } + else if (list[i].type == "group"){ + for (var x = 0; x < list[i].users.length; x++){ + if (list[i].users[x].userId == userId && list[i].users[x].ready){ + return true; + } + } + } + } + return false; } }]); From 95a870a740c2bb50ed0ba109b06146dc1cc34c8e Mon Sep 17 00:00:00 2001 From: brantje Date: Thu, 29 Sep 2016 10:05:57 +0200 Subject: [PATCH 2/2] Decrease title width --- css/app.css | 2 +- sass/credentials.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/css/app.css b/css/app.css index 36facb16..290057e7 100644 --- a/css/app.css +++ b/css/app.css @@ -147,7 +147,7 @@ #app-content #app-content-wrapper #passman-controls { border-bottom: 1px solid #c9c9c9; } #app-content #app-content-wrapper .title { - width: calc( 100% - 370px); + width: calc( 100% - 375px); text-align: center; display: inline-block; font-weight: bold; diff --git a/sass/credentials.scss b/sass/credentials.scss index 46de925e..3e7dffd3 100644 --- a/sass/credentials.scss +++ b/sass/credentials.scss @@ -6,7 +6,7 @@ border-bottom: 1px solid #c9c9c9 } .title{ - width: calc( 100% - 370px); + width: calc( 100% - 375px); text-align: center; display: inline-block; font-weight: bold;