From 30a18db5d54508991e24fde5ebf2e4258fb2ba8f Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 07:37:30 -0500 Subject: [PATCH 01/21] wip --- .../admin-directives/dashboard/dashboard.js | 8 ++++++++ avAdmin/elections-api-service.js | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 2e73feb7..97d91e22 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -81,6 +81,14 @@ angular.module('avAdmin') } } + function setTrusteesState() { + ElectionsApi + .authoritiesStatus() + .then(function (trustees) { + scope.trusteesState = trustees; + }) + } + function waitElectionChange() { ElectionsApi diff --git a/avAdmin/elections-api-service.js b/avAdmin/elections-api-service.js index 579ac75c..6d67a83b 100644 --- a/avAdmin/elections-api-service.js +++ b/avAdmin/elections-api-service.js @@ -275,6 +275,26 @@ angular.module('avAdmin') return deferred.promise; }; + electionsapi.authoritiesStatus = function () + { + var deferred = $q.defer();$http + .get( + backendUrl + 'authorities-state', + {headers: {'Authorization': perm}} + ) + .then( + function (response) { + if (response && response.data && response.data.payload) { + deferred.resolve(response.data.payload); + } else { + deferred.reject(response); + } + }, + deferred.reject + ); + return deferred.promise; + }; + electionsapi.parseElection = function(d) { var election = d.payload; var conf = electionsapi.templateEl(); From 5d036b4f9892267c5a4797fda8a25c62484124c7 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 09:44:57 -0500 Subject: [PATCH 02/21] wip --- .../admin-directives/dashboard/dashboard.html | 5 ++++- avAdmin/admin-directives/dashboard/dashboard.js | 3 +++ .../admin-directives/dashboard/dashboard.less | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index 8772ceda..2d3f100a 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -213,7 +213,10 @@

  • - {{ auth }} + + {{ auth }} +
    +
diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 97d91e22..a5f99043 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -37,6 +37,7 @@ angular.module('avAdmin') function link(scope, element, attrs) { scope.reloadTimeout = null; + scope.trusteesState = {}; scope.isWriteInResult = function(answer) { @@ -91,6 +92,7 @@ angular.module('avAdmin') function waitElectionChange() { + setTrusteesState(); ElectionsApi .getElection(scope.id, /*ignorecache = */ true) .then(function(el) @@ -1416,6 +1418,7 @@ angular.module('avAdmin') scope.prevStatus = null; scope.percentVotes = PercentVotesService; + setTrusteesState(); // get the election at the begining ElectionsApi .getElection(scope.id) diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index 86697b69..93821dfe 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -21,6 +21,23 @@ } } +.auth-name-container { + display: flex; + flex-direction: row; + + .auth-badge { + width: 25px; + height: 25px; + border-radius: 25px; + background-color: red; + margin: auto 0 auto 8px; + + .auth-badge-green { + background-color: green; + } + } +} + /** descriptive radio buttons */ .descriptive-radio { border: 2px solid transparent; From 3ce16c95def422b54f206d00afcd30a8edfa5038 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 09:50:54 -0500 Subject: [PATCH 03/21] wip --- avAdmin/admin-directives/dashboard/dashboard.js | 2 +- avAdmin/elections-api-service.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index a5f99043..b3e3ecce 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -87,7 +87,7 @@ angular.module('avAdmin') .authoritiesStatus() .then(function (trustees) { scope.trusteesState = trustees; - }) + }); } function waitElectionChange() diff --git a/avAdmin/elections-api-service.js b/avAdmin/elections-api-service.js index 6d67a83b..c963cba1 100644 --- a/avAdmin/elections-api-service.js +++ b/avAdmin/elections-api-service.js @@ -279,8 +279,7 @@ angular.module('avAdmin') { var deferred = $q.defer();$http .get( - backendUrl + 'authorities-state', - {headers: {'Authorization': perm}} + backendUrl + 'authorities-state' ) .then( function (response) { From 525b059ef667eeb08563b4298e363eefc0f4762e Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:03:47 -0500 Subject: [PATCH 04/21] wip --- avAdmin/admin-directives/dashboard/dashboard.html | 2 +- avAdmin/admin-directives/dashboard/dashboard.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index 2d3f100a..aadf3069 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -215,7 +215,7 @@

{{ auth }} -
+
diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index b3e3ecce..1dcd7165 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -90,6 +90,10 @@ angular.module('avAdmin') }); } + function isTrusteeOk(name) { + return scope.trusteesState && scope.trusteesState[name] && 'ok' === scope.trusteesState[name].state; + } + function waitElectionChange() { setTrusteesState(); @@ -1491,6 +1495,7 @@ angular.module('avAdmin') launchKeyDistributionCeremony: launchKeyDistributionCeremony, launchOpeningCeremony: launchOpeningCeremony, configureScheduledEvents: configureScheduledEvents, + isTrusteeOk: isTrusteeOk, }); // initialize From de2ee2c953e880bdd8cd9d8431496d24497da735 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:06:47 -0500 Subject: [PATCH 05/21] wip --- avAdmin/admin-directives/dashboard/dashboard.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index 93821dfe..fdc7a5ea 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -32,7 +32,7 @@ background-color: red; margin: auto 0 auto 8px; - .auth-badge-green { + &.auth-badge-green { background-color: green; } } From 8f7f9ea30f18f7bd4ed12c8b4bce8ca6a7ecbb6e Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:14:02 -0500 Subject: [PATCH 06/21] wip --- .../admin-directives/dashboard/dashboard.html | 6 +++++- .../admin-directives/dashboard/dashboard.less | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index aadf3069..4bd69bcf 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -215,7 +215,11 @@

{{ auth }} -
+
+
+ {{ scope.trusteesState[auth].message }} +
+
diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index fdc7a5ea..90d195d7 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -31,10 +31,26 @@ border-radius: 25px; background-color: red; margin: auto 0 auto 8px; + position: relative; &.auth-badge-green { background-color: green; } + + .auth-tooltip { + visibility: hidden; + width: 120px; + background-color: black; + color: #fff; + text-align: center; + padding: 5px 0; + border-radius: 6px; + position: absolute; + z-index: 1; + } + } + .auth-badge:hover .auth-tooltip { + visibility: visible; } } From b22d0d5c068eff10948f1f5e9df20d493ce96672 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:18:44 -0500 Subject: [PATCH 07/21] wip --- avAdmin/admin-directives/dashboard/dashboard.html | 4 ++-- avAdmin/admin-directives/dashboard/dashboard.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index 4bd69bcf..e4cdddbd 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -216,8 +216,8 @@

{{ auth }}
-
- {{ scope.trusteesState[auth].message }} +
+ {{ getTrusteeMsg(auth) }}
diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 1dcd7165..e8aa124d 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -94,6 +94,10 @@ angular.module('avAdmin') return scope.trusteesState && scope.trusteesState[name] && 'ok' === scope.trusteesState[name].state; } + function getTrusteeMsg(name) { + return scope.trusteesState && scope.trusteesState[name] && scope.trusteesState && scope.trusteesState[name].message || ''; + } + function waitElectionChange() { setTrusteesState(); @@ -1496,6 +1500,7 @@ angular.module('avAdmin') launchOpeningCeremony: launchOpeningCeremony, configureScheduledEvents: configureScheduledEvents, isTrusteeOk: isTrusteeOk, + getTrusteeMsg: getTrusteeMsg, }); // initialize From 54cea84b691831ef4c2f6c25a5dfb9375dea5fa4 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:21:40 -0500 Subject: [PATCH 08/21] wip --- avAdmin/admin-directives/dashboard/dashboard.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index e8aa124d..611772ab 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -87,6 +87,8 @@ angular.module('avAdmin') .authoritiesStatus() .then(function (trustees) { scope.trusteesState = trustees; + + setTimeout(function () { scope.$apply(); }, 0); }); } From 0fcb16cd53382f1ff2cdbb3f8639573cbc74c251 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:25:28 -0500 Subject: [PATCH 09/21] wip --- avAdmin/admin-directives/dashboard/dashboard.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 611772ab..ff9d4937 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -88,7 +88,7 @@ angular.module('avAdmin') .then(function (trustees) { scope.trusteesState = trustees; - setTimeout(function () { scope.$apply(); }, 0); + //setTimeout(function () { scope.$apply(); }, 0); }); } @@ -97,6 +97,9 @@ angular.module('avAdmin') } function getTrusteeMsg(name) { + if (scope.trusteesState && scope.trusteesState[name]) { + name = '9xx-a1'; + } return scope.trusteesState && scope.trusteesState[name] && scope.trusteesState && scope.trusteesState[name].message || ''; } From f4e423cac24d665128143ad3f4402f50e75a6a72 Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:29:57 -0500 Subject: [PATCH 10/21] wip --- avAdmin/admin-directives/dashboard/dashboard.less | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index 90d195d7..d70489f2 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -29,24 +29,24 @@ width: 25px; height: 25px; border-radius: 25px; - background-color: red; + background-color: @error-primary-color; margin: auto 0 auto 8px; position: relative; &.auth-badge-green { - background-color: green; + background-color: @action-primary-color; } .auth-tooltip { visibility: hidden; - width: 120px; - background-color: black; - color: #fff; + width: 240px; + background-color: @blue-contrast-color; text-align: center; padding: 5px 0; border-radius: 6px; position: absolute; z-index: 1; + font-size: 0.7rem; } } .auth-badge:hover .auth-tooltip { From 54adcc51c45b21473eb29d7321ea00905da9cfeb Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 10:33:26 -0500 Subject: [PATCH 11/21] wip --- avAdmin/admin-directives/dashboard/dashboard.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index d70489f2..e8660fe7 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -34,13 +34,13 @@ position: relative; &.auth-badge-green { - background-color: @action-primary-color; + background-color: @av-secondary-contrast; } .auth-tooltip { visibility: hidden; width: 240px; - background-color: @blue-contrast-color; + background-color: @av-bg; text-align: center; padding: 5px 0; border-radius: 6px; From bd3a791e9bf40b6d8349bb0e195273ae7cb74c7e Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 11:11:33 -0500 Subject: [PATCH 12/21] wip --- .../admin-directives/dashboard/dashboard.html | 15 +++-- .../admin-directives/dashboard/dashboard.less | 58 ++++++++++--------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index e4cdddbd..53ab8f23 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -212,15 +212,14 @@

  • - - - {{ auth }} -
    -
    - {{ getTrusteeMsg(auth) }} -
    + {{ auth }} +
    +
    + {{ getTrusteeMsg(auth) }}
    - +
    + +

diff --git a/avAdmin/admin-directives/dashboard/dashboard.less b/avAdmin/admin-directives/dashboard/dashboard.less index e8660fe7..ad90c00b 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.less +++ b/avAdmin/admin-directives/dashboard/dashboard.less @@ -21,39 +21,43 @@ } } -.auth-name-container { +.authority { display: flex; flex-direction: row; + justify-content: space-between; +} - .auth-badge { - width: 25px; - height: 25px; - border-radius: 25px; - background-color: @error-primary-color; - margin: auto 0 auto 8px; - position: relative; - - &.auth-badge-green { - background-color: @av-secondary-contrast; - } - - .auth-tooltip { - visibility: hidden; - width: 240px; - background-color: @av-bg; - text-align: center; - padding: 5px 0; - border-radius: 6px; - position: absolute; - z-index: 1; - font-size: 0.7rem; - } - } - .auth-badge:hover .auth-tooltip { - visibility: visible; +.auth-badge { + width: 25px; + height: 25px; + border-radius: 25px; + background-color: @error-primary-color; + margin: auto 0; + position: relative; + + &.auth-badge-green { + background-color: @av-secondary-contrast; + } + + .auth-tooltip { + visibility: hidden; + width: 240px; + background-color: @av-bg; + text-align: center; + padding: 5px 0; + border-radius: 6px; + position: absolute; + z-index: 1; + font-size: 1rem; + top: 25px; + left: 16px; } } +.auth-badge:hover .auth-tooltip { + visibility: visible; +} + /** descriptive radio buttons */ .descriptive-radio { border: 2px solid transparent; From 2bdb38a0f1db277601f344a390d1ed5f4d8759ff Mon Sep 17 00:00:00 2001 From: Findeton Date: Wed, 27 Mar 2024 11:14:45 -0500 Subject: [PATCH 13/21] wip --- avAdmin/admin-directives/dashboard/dashboard.html | 2 +- avAdmin/admin-directives/dashboard/dashboard.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.html b/avAdmin/admin-directives/dashboard/dashboard.html index 53ab8f23..6c7a6107 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.html +++ b/avAdmin/admin-directives/dashboard/dashboard.html @@ -219,7 +219,7 @@

- + diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index ff9d4937..e8aa124d 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -87,8 +87,6 @@ angular.module('avAdmin') .authoritiesStatus() .then(function (trustees) { scope.trusteesState = trustees; - - //setTimeout(function () { scope.$apply(); }, 0); }); } @@ -97,9 +95,6 @@ angular.module('avAdmin') } function getTrusteeMsg(name) { - if (scope.trusteesState && scope.trusteesState[name]) { - name = '9xx-a1'; - } return scope.trusteesState && scope.trusteesState[name] && scope.trusteesState && scope.trusteesState[name].message || ''; } From b7cc18bb997f91dec01d6ada9e9bfcebf8c88821 Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 09:22:52 -0500 Subject: [PATCH 14/21] wip --- avAdmin/admin-directives/create/create.js | 43 +++++++++++++++++++++++ locales/en.json | 4 +++ locales/es.json | 4 +++ 3 files changed, 51 insertions(+) diff --git a/avAdmin/admin-directives/create/create.js b/avAdmin/admin-directives/create/create.js index 83a133f4..088f60ad 100644 --- a/avAdmin/admin-directives/create/create.js +++ b/avAdmin/admin-directives/create/create.js @@ -1044,6 +1044,48 @@ angular.module('avAdmin') } }); + function checkTrustees(el) { + logInfo($i18next.t('avAdmin.create.checkingTrustees', {title: el.title})); + var deferred = $q.defer(); + var auths = el.authorities || []; + if (el.director) { + auths.push(el.director); + } + + if (0 === auths.length) { + logError($i18next.t('avAdmin.create.errors.election-auths-missing', {title: el.title})); + deferred.reject(); + } else { + ElectionsApi + .authoritiesStatus() + .then(function (trustees) { + var hasError = false; + for (var i = 0; i < auths.length; i++) { + var auth = auths[i]; + if (!trustees[auth]) { + logError($i18next.t('avAdmin.create.errors.election-auth-not-found', {title: el.title, auth: auth})); + hasError = true; + continue; + } + if ('ok' !== trustees[auth].state) { + logError($i18next.t('avAdmin.create.errors.election-auth-error', {title: el.title, auth: auth, message: trustees[auth].message})); + hasError = true; + continue; + } + } + if (hasError) { + deferred.reject(); + } else { + deferred.resolve(); + } + }) + .catch(deferred.reject); + } + + + return deferred.promise; + } + function createAuthEvent(el) { console.log("creating auth event for election " + el.title); var deferred = $q.defer(); @@ -1264,6 +1306,7 @@ angular.module('avAdmin') var promise = deferred.promise; promise = promise + .then(checkTrustees) .then(createAuthEvent) .then(registerElection) .then(function(election) { diff --git a/locales/en.json b/locales/en.json index ce411653..6581e33a 100644 --- a/locales/en.json +++ b/locales/en.json @@ -922,6 +922,7 @@ "create": { "summary": "Summary: creating __num__ elections", "summary__plural": "Summary: creating __num__ elections", + "checkingTrustees": "Checking trustees status for election __title__", "create": "Create the elections", "creating": "Creating the authentication for election __title__", "setChildrenElectionInfo": "Setting the children election info for election (id: __id__) __title__", @@ -942,6 +943,9 @@ "confirmEdit": "Finish edit" }, "errors": { + "election-auths-missing": "Election '__eltitle__': Missing trustees", + "election-auth-not-found": "Election '__eltitle__': Trustee not found '__auth__'", + "election-auth-error": "Election '__eltitle__': Trustee '__auth__' has invalid status '__message__'", "lambda-live-preview-parent-children": "Missing election IDs for a parent-children election", "election-is-array-questions": "Election '__eltitle__': list of questions is not an array", "election-lambda-success-action-url-mode": "Election '__eltitle__': invalid success action url", diff --git a/locales/es.json b/locales/es.json index 496cfe85..198b6727 100644 --- a/locales/es.json +++ b/locales/es.json @@ -809,6 +809,7 @@ "create": { "summary": "Resumen: creando __num__ votaciones", "summary__plural": "Resumen: creando __num__ votaciones", + "checkingTrustees": "Checking trustees status for election __title__", "create": "Crear las votaciones", "create__plural": "Crear las votaciones", "creating": "Creando la autenticación de la votación __title__", @@ -822,6 +823,9 @@ "livePreview": "Previsualización en vivo" }, "errors": { + "election-auths-missing": "Election '__eltitle__': Faltan autoridades", + "election-auth-not-found": "Election '__eltitle__': Autoridad no encontrada '__auth__'", + "election-auth-error": "Election '__eltitle__': Autoridad '__auth__' tiene un estado inválido '__message__'", "lambda-live-preview-parent-children": "Faltan ID de la votación para una votación padre-hijos", "election-is-array-questions": "Votación '__eltitle__': la lista de pregunta no es un array", "election-lambda-success-action-url-mode": "Votación '__eltitle__': url de redirección en 'Acción de éxito' inválida", From 307ee41994f2ebadeb1ec7f6601b84855a6cb149 Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 09:56:51 -0500 Subject: [PATCH 15/21] wip --- avAdmin/admin-directives/create/create.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/avAdmin/admin-directives/create/create.js b/avAdmin/admin-directives/create/create.js index 088f60ad..69ea5679 100644 --- a/avAdmin/admin-directives/create/create.js +++ b/avAdmin/admin-directives/create/create.js @@ -1045,7 +1045,7 @@ angular.module('avAdmin') }); function checkTrustees(el) { - logInfo($i18next.t('avAdmin.create.checkingTrustees', {title: el.title})); + logInfo($i18next.t('avAdmin.create.checkingTrustees', {eltitle: el.title})); var deferred = $q.defer(); var auths = el.authorities || []; if (el.director) { @@ -1053,7 +1053,7 @@ angular.module('avAdmin') } if (0 === auths.length) { - logError($i18next.t('avAdmin.create.errors.election-auths-missing', {title: el.title})); + logError($i18next.t('avAdmin.create.errors.election-auths-missing', {eltitle: el.title})); deferred.reject(); } else { ElectionsApi @@ -1063,12 +1063,12 @@ angular.module('avAdmin') for (var i = 0; i < auths.length; i++) { var auth = auths[i]; if (!trustees[auth]) { - logError($i18next.t('avAdmin.create.errors.election-auth-not-found', {title: el.title, auth: auth})); + logError($i18next.t('avAdmin.create.errors.election-auth-not-found', {eltitle: el.title, auth: auth})); hasError = true; continue; } if ('ok' !== trustees[auth].state) { - logError($i18next.t('avAdmin.create.errors.election-auth-error', {title: el.title, auth: auth, message: trustees[auth].message})); + logError($i18next.t('avAdmin.create.errors.election-auth-error', {eltitle: el.title, auth: auth, message: trustees[auth].message})); hasError = true; continue; } From ded76a3839c562ef6426a34fa901355f2da0ee21 Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 09:58:58 -0500 Subject: [PATCH 16/21] wip --- avAdmin/admin-directives/create/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/create/create.js b/avAdmin/admin-directives/create/create.js index 69ea5679..8e9138de 100644 --- a/avAdmin/admin-directives/create/create.js +++ b/avAdmin/admin-directives/create/create.js @@ -1045,7 +1045,7 @@ angular.module('avAdmin') }); function checkTrustees(el) { - logInfo($i18next.t('avAdmin.create.checkingTrustees', {eltitle: el.title})); + logInfo($i18next.t('avAdmin.create.checkingTrustees', {title: el.title})); var deferred = $q.defer(); var auths = el.authorities || []; if (el.director) { From 4a1a3f91b586cf2e06df6794654c150bea2b0ed5 Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 10:03:38 -0500 Subject: [PATCH 17/21] wip --- avAdmin/admin-directives/create/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/create/create.js b/avAdmin/admin-directives/create/create.js index 8e9138de..498f6c52 100644 --- a/avAdmin/admin-directives/create/create.js +++ b/avAdmin/admin-directives/create/create.js @@ -1047,7 +1047,7 @@ angular.module('avAdmin') function checkTrustees(el) { logInfo($i18next.t('avAdmin.create.checkingTrustees', {title: el.title})); var deferred = $q.defer(); - var auths = el.authorities || []; + var auths = el.authorities && Array.from(el.authorities) || []; if (el.director) { auths.push(el.director); } From 288164232577de9a4051648c12b931e87baef51a Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 11:26:52 -0500 Subject: [PATCH 18/21] wip --- .../admin-directives/dashboard/dashboard.js | 68 ++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index e8aa124d..17b6060c 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -720,6 +720,46 @@ angular.module('avAdmin') ); } + function checkTrustees() { + var deferred = $q.defer(); + + var errors = []; + + var auths = scope.election.authorities && Array.from(scope.election.authorities) || []; + if (scope.election.director) { + auths.push(scope.election.director); + } + + if (0 === auths.length) { + errors.push($i18next.t('avAdmin.create.errors.election-auths-missing', {eltitle: scope.election.title})); + deferred.reject(errors.join("\n")); + } else { + ElectionsApi + .authoritiesStatus() + .then(function (trustees) { + for (var i = 0; i < auths.length; i++) { + var auth = auths[i]; + if (!trustees[auth]) { + errors.push($i18next.t('avAdmin.create.errors.election-auth-not-found', {eltitle: scope.election.title, auth: auth})); + continue; + } + if ('ok' !== trustees[auth].state) { + errors.push($i18next.t('avAdmin.create.errors.election-auth-error', {eltitle: scope.election.title, auth: auth, message: trustees[auth].message})); + continue; + } + } + if (errors) { + deferred.reject(errors); + } else { + deferred.resolve(); + } + }) + .catch(deferred.reject); + } + + return deferred.promise; + } + // performs all the initialization function init() { @@ -872,13 +912,17 @@ angular.module('avAdmin') scope.index = scope.getStatusIndex('stopped') + 1; } scope.nextaction = false; - Authmethod - .launchTally( - scope.election.id, - data.tallyElectionIds, - 'force-all', - data.mode - ) + + checkTrustees() + .then(function () { + return Authmethod + .launchTally( + scope.election.id, + data.tallyElectionIds, + 'force-all', + data.mode + ); + }) .then( function onSuccess() { @@ -892,7 +936,15 @@ angular.module('avAdmin') scope.loading = false; scope.error = error; } - ); + ) + .catch(function(error) + { + if (scope.launchedTally) { + scope.launchedTally = false; + } + scope.loading = false; + scope.error = error; + }); }, enableFunc: function () { return ( From fc72defc354fcaaf42fb81117a7f72907934bcb1 Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 11:44:05 -0500 Subject: [PATCH 19/21] wip --- avAdmin/admin-directives/create/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/create/create.js b/avAdmin/admin-directives/create/create.js index 498f6c52..7121baeb 100644 --- a/avAdmin/admin-directives/create/create.js +++ b/avAdmin/admin-directives/create/create.js @@ -1076,7 +1076,7 @@ angular.module('avAdmin') if (hasError) { deferred.reject(); } else { - deferred.resolve(); + deferred.resolve(el); } }) .catch(deferred.reject); From 947d7f220bb1e2b9347723d6fe783ad387421e1d Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 11:45:21 -0500 Subject: [PATCH 20/21] wip --- avAdmin/admin-directives/dashboard/dashboard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 17b6060c..d0d89dde 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -22,6 +22,7 @@ angular.module('avAdmin') $q, $window, $state, + $i18next, Authmethod, Plugins, ElectionsApi, From 9ac420d5bc5247970812ef9ea8920ec9c20489ba Mon Sep 17 00:00:00 2001 From: Findeton Date: Thu, 4 Apr 2024 12:03:45 -0500 Subject: [PATCH 21/21] wip --- avAdmin/admin-directives/dashboard/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index d0d89dde..df05771f 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -749,7 +749,7 @@ angular.module('avAdmin') continue; } } - if (errors) { + if (errors.length > 0) { deferred.reject(errors); } else { deferred.resolve();