From 973746389da732336f988ada888b0ab4f89b9158 Mon Sep 17 00:00:00 2001 From: Marcos Zuriaga Date: Sat, 1 Oct 2016 19:04:05 +0200 Subject: [PATCH] Sharing settings improvements More sharing logic benchmarking and tests --- js/app/controllers/share.js | 11 ++++++++ js/app/controllers/share_settings.js | 28 +++++++++++++++++++ js/templates.js | 4 +-- .../partials/forms/settings/sharing.html | 12 ++++---- .../forms/share_credential/basics.html | 1 + 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/js/app/controllers/share.js b/js/app/controllers/share.js index 5bbd05c8..e2e026e7 100644 --- a/js/app/controllers/share.js +++ b/js/app/controllers/share.js @@ -123,6 +123,7 @@ angular.module('passmanApp') $scope.share_settings.cypher_progress.done = 0; $scope.share_settings.cypher_progress.total = 0; $scope.share_settings.cypher_progress.times = []; + $scope.share_settings.cypher_progress.times_total = []; ShareService.generateSharedKey(20).then(function(key){ console.log(key); @@ -159,4 +160,14 @@ angular.module('passmanApp') } }) }; + + $scope.calculate_total_time = function(){ + $scope.share_settings.cypher_progress.times = $scope.share_settings.cypher_progress.times || []; + var total = 0; + for (var i = 0; i < $scope.share_settings.cypher_progress.times.length; i++){ + total += $scope.share_settings.cypher_progress.times[i].time; + } + console.log(total); + return total; + } }]); diff --git a/js/app/controllers/share_settings.js b/js/app/controllers/share_settings.js index 3be5ba36..1a911fe9 100644 --- a/js/app/controllers/share_settings.js +++ b/js/app/controllers/share_settings.js @@ -10,6 +10,34 @@ angular.module('passmanApp') $scope.progress = 1; $scope.generating = false; + + + $scope.available_sizes = [ + { + size: 1024, + name: 1024 + }, + { + size: 2048, + name: 2048 + }, + { + size: 4096, + name: 4096 + } + ]; + + $scope.setKeySize = function (size) { + for (var i = 0; i < $scope.available_sizes.length; i++) { + if ($scope.available_sizes[i].size == size) { + $scope.key_size = $scope.available_sizes[i]; + return; + } + } + }; + + $scope.setKeySize(2048); + $scope.generateKeys = function (length) { $scope.progress = 1; $scope.generating = true; diff --git a/js/templates.js b/js/templates.js index 58bd4e8f..a7e9566d 100644 --- a/js/templates.js +++ b/js/templates.js @@ -69,7 +69,7 @@ angular.module('views/partials/forms/settings/password_settings.html', []).run([ angular.module('views/partials/forms/settings/sharing.html', []).run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('views/partials/forms/settings/sharing.html', - '
'); + '
'); }]); angular.module('views/partials/forms/settings/tool.html', []).run(['$templateCache', function($templateCache) { @@ -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', - '
Cyphering...
UserCrypto time
{{user.user}}{{user.time}} s
User / groupAccess
{{user.userId}}{{user.accessLevel}}
'); }]); diff --git a/templates/views/partials/forms/settings/sharing.html b/templates/views/partials/forms/settings/sharing.html index b21bdc93..530bbf1f 100644 --- a/templates/views/partials/forms/settings/sharing.html +++ b/templates/views/partials/forms/settings/sharing.html @@ -13,13 +13,13 @@
diff --git a/templates/views/partials/forms/share_credential/basics.html b/templates/views/partials/forms/share_credential/basics.html index 2995aeab..079748fc 100644 --- a/templates/views/partials/forms/share_credential/basics.html +++ b/templates/views/partials/forms/share_credential/basics.html @@ -53,6 +53,7 @@ {{user.time}} s + Total time spent cyphering: {{ calculate_total_time() }}