Removed group sharing logics

Added user sharing crypto times to the UI
This commit is contained in:
Marcos Zuriaga 2016-10-01 15:18:22 +02:00
parent 739098ce39
commit 38299973d0
No known key found for this signature in database
GPG key ID: 7D15585354D072FF
3 changed files with 34 additions and 60 deletions

View file

@ -63,12 +63,12 @@ angular.module('passmanApp')
$scope.share_settings = {
credentialSharedWithUserAndGroup:[
// {
// accessLevel:1,
// displayName:"wolf",
// userId:"wolf",
// type:'user'
// },
{
accessLevel:1,
displayName:"wolf",
userId:"wolf",
type:'user'
},
{
accessLevel:1,
displayName:"cat",
@ -110,7 +110,7 @@ angular.module('passmanApp')
type: shareWith[i].type,
accessLevel: selectedAccessLevel
};
if (obj.type == 'group') obj.users = shareWith[i].users;
// if (obj.type == 'group') obj.users = shareWith[i].users;
$scope.share_settings.credentialSharedWithUserAndGroup.push(
obj
)
@ -119,8 +119,10 @@ angular.module('passmanApp')
};
$scope.applyShare = function(){
$scope.share_settings.cypher_progress.percent = 0;
$scope.share_settings.cypher_progress.done = 0;
$scope.share_settings.cypher_progress.total = 0;
$scope.share_settings.cypher_progress.times = [];
ShareService.generateSharedKey(20).then(function(key){
console.log(key);
@ -130,9 +132,6 @@ angular.module('passmanApp')
var iterator = i; // Keeps it available inside the promises callback
if (list[i].type == "user") {
if ($scope.isUserReady(list[iterator].userId)){ // Check if the user has already been processed on a group
continue;
}
ShareService.getVaultsByUser(list[i].userId).then(function (data) {
$scope.share_settings.cypher_progress.total += data.length;
@ -143,63 +142,21 @@ angular.module('passmanApp')
ShareService.cypherRSAStringWithPublicKeyBulkAsync(data, key)
.progress(function (data) {
$scope.share_settings.cypher_progress.done ++;
$scope.share_settings.cypher_progress.percent = $scope.share_settings.cypher_progress.done / $scope.share_settings.cypher_progress.total * 100;
$scope.$digest();
})
.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 + "]");
$scope.share_settings.cypher_progress.times.push({
time: ((new Date().getTime() / 1000) - start),
user: data[0].user_id
});
$scope.$digest();
});
});
list[i].processed = true;
}
else if (list[i].type == "group"){
for (var x = 0; x < list[iterator].users.length; x++){
var xiterator = x; // Keeps it available inside the promises callback
if ($scope.isUserReady(list[iterator].users[x].userId)){ // Check if the user was already processed all alone
continue;
}
ShareService.getVaultsByUser(list[iterator].users[xiterator].userId).then(function (data) {
if (data.length == 0) return;
$scope.share_settings.cypher_progress.total += data.length;
list[iterator].users[xiterator].vaults = data;
console.log(data);
var start = new Date().getTime() / 1000;
ShareService.cypherRSAStringWithPublicKeyBulkAsync(data, key)
.progress(function (data) {
// console.log(data);
$scope.share_settings.cypher_progress.done ++;
})
.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;
}
}]);

View file

@ -81,7 +81,7 @@ angular.module('views/partials/forms/settings/tool.html', []).run(['$templateCac
angular.module('views/partials/forms/share_credential/basics.html', []).run(['$templateCache', function($templateCache) {
'use strict';
$templateCache.put('views/partials/forms/share_credential/basics.html',
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><select ng-model="selectedAccessLevel"><option ng-repeat="lvl in accessLevels" value="{{lvl.value}}">{{lvl.label}}</option></select><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User / group</td><td>Access</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}}</td><td>{{user.accessLevel}}</td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
'<div class="row"><div class="col-xs-12 col-md-6"><div><table class="table sharing_table"><thead><tr><td><tags-input ng-model="inputSharedWith" replace-spaces-with-dashes="false" add-from-autocomplete-only="true" placeholder="Search users or groups..."><auto-complete source="searchUsers($query)" min-length="0" template="autocomplete-template"></auto-complete></tags-input></td><td><select ng-model="selectedAccessLevel"><option ng-repeat="lvl in accessLevels" value="{{lvl.value}}">{{lvl.label}}</option></select><button class="button" ng-click="shareWith(inputSharedWith, selectedAccessLevel)">+</button></td></tr></thead></table><div ng-if="share_settings.cypher_progress.done > 0">Cyphering...<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div></div></div></div><div class="col-xs-12 col-md-6"><table class="table"><thead><tr><td>User</td><td>Crypto time</td></tr></thead><tr ng-repeat="user in share_settings.cypher_progress.times"><td><i class="fa fa-user"></i> {{user.user}}</td><td>{{user.time}} s</td></tr></table></div></div><div class="row"><div class="col-xs-12 col-md-6"><table class="table shared_table" ng-show="share_settings.credentialSharedWithUserAndGroup.length > 0"><thead><tr><td>User / group</td><td>Access</td></tr></thead><tr ng-repeat="user in share_settings.credentialSharedWithUserAndGroup"><td><i class="fa fa-user" ng-if="user.type === \'user\'"></i> <i class="fa fa-group" ng-if="user.type === \'group\'"></i> {{user.userId}}</td><td>{{user.accessLevel}}</td></tr></table></div></div><script type="text/ng-template" id="autocomplete-template"><i class="fa fa-user" ng-if="data.type === \'user\'"></i>\n' +
' <i class="fa fa-group" ng-if="data.type === \'group\'"></i>\n' +
' {{data.text}}</script>');
}]);

View file

@ -33,10 +33,27 @@
<div ng-if="share_settings.cypher_progress.done > 0">
Cyphering...
<div progress-bar="share_settings.cypher_progress" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div>
<div progress-bar="share_settings.cypher_progress.percent" index="share_settings.cypher_progress.done" total="share_settings.cypher_progress.total"></div>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6">
<table class="table">
<thead>
<tr>
<td>User</td>
<td>Crypto time</td>
</tr>
</thead>
<tr ng-repeat="user in share_settings.cypher_progress.times">
<td>
<i class="fa fa-user"></i>
{{user.user}}
</td>
<td>{{user.time}} s</td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">