Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Findeton committed Apr 16, 2024
2 parents b45d0b5 + 8ecb123 commit dd17a84
Show file tree
Hide file tree
Showing 16 changed files with 720 additions and 35 deletions.
32 changes: 17 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

var pkg = require('./package.json');
var SEQUENT_CONFIG_VERSION = '10.2.0';
var SEQUENT_CONFIG_VERSION = '10.3.0';

//Using exclusion patterns slows down Grunt significantly
//instead of creating a set of patterns like '**/*.js' and '!**/node_modules/**'
Expand Down Expand Up @@ -269,6 +269,7 @@ module.exports = function (grunt) {
{src: ['node_modules/common-ui/dist/img/flags.png'], dest: 'dist/img/flags.png'},
{src: ['node_modules/common-ui/dist/utils.js'], dest: 'dist/utils.js'},
{src: ['node_modules/common-ui/dist/intlTelInput.css'], dest: 'dist/intlTelInput.css'},
{src: ['node_modules/angular-moment-picker/dist/angular-moment-picker.min.css'], dest: 'dist/angular-moment-picker.min.css'},
{
expand: true,
cwd:'node_modules/common-ui/themes',
Expand Down Expand Up @@ -325,17 +326,18 @@ module.exports = function (grunt) {
{selector:'head',html:'<link class="favicon" rel="icon" href="/admin/img/cropped-FAV-6-192x192.png" sizes="192x192" />'},
{selector:'head',html:'<link class="favicon" rel="apple-touch-icon" href="/admin/img/cropped-FAV-6-180x180.png" />'},
{selector:'body',html:'<%= variables.admin_html_body_include %>'},
{selector:'body',html:'<!--[if lte IE 8]><script src="/admin/libcompat-v10.2.0.min.js"></script><![endif]--><!--[if gte IE 9]><script src="/admin/libnocompat-v10.2.0.min.js"></script><![endif]--><!--[if !IE]><!--><script src="/admin/libnocompat-v10.2.0.min.js"></script><!--<![endif]-->'},
{selector:'body',html:'<!--[if lte IE 8]><script src="/admin/libcompat-v10.3.0.min.js"></script><![endif]--><!--[if gte IE 9]><script src="/admin/libnocompat-v10.3.0.min.js"></script><![endif]--><!--[if !IE]><!--><script src="/admin/libnocompat-v10.3.0.min.js"></script><!--<![endif]-->'},
{selector:'body',html:'<!--All the source code of this program under copyright. Take a look at the license details at https://github.com/sequent/sequent-core-view/blob/master/README.md -->'},
{selector:'body',html:'<script src="/admin/lib-v10.2.0.min.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentConfig-v10.2.0.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentThemes-v10.2.0.js"></script>'},
{selector:'body',html:'<script src="/admin/app-v10.2.0.min.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentPlugins-v10.2.0.js"></script>'},
{selector:'body',html:'<script src="/admin/lib-v10.3.0.min.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentConfig-v10.3.0.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentThemes-v10.3.0.js"></script>'},
{selector:'body',html:'<script src="/admin/app-v10.3.0.min.js"></script>'},
{selector:'body',html:'<script src="/admin/SequentPlugins-v10.3.0.js"></script>'},
{selector:'head',html:'<link rel="stylesheet" id="theme" data-base="/admin/" href="/admin/themes/default/app.min.css">'},
{selector:'head',html:'<link rel="stylesheet" id="plugins" data-base="/admin/" href="/admin/plugins.css">'},
{selector:'head',html:'<link rel="stylesheet" id="vendor-css" data-base="/admin/" href="/admin/vendor.min.css">'},
{selector:'head',html:'<link rel="stylesheet" href="/admin/intlTelInput.css" />'}
{selector:'head',html:'<link rel="stylesheet" href="/admin/intlTelInput.css" />'},
{selector:'head',html:'<link rel="stylesheet" href="/admin/angular-moment-picker.min.css" />'}
]
},
src:'index.html',
Expand Down Expand Up @@ -375,9 +377,9 @@ module.exports = function (grunt) {
'temp/libnocompat.js': ['<%= dom_munger.data.libnocompatjs %>'],
'temp/lib.js': ['<%= dom_munger.data.libjs %>'],
'temp/app.js': ['<%= dom_munger.data.appjs %>','<%= ngtemplates.main.dest %>','<%= ngtemplates.common.dest %>'],
'dist/SequentConfig-v10.2.0.js': ['SequentConfig.js'],
'dist/SequentThemes-v10.2.0.js': ['node_modules/common-ui/dist/SequentThemes-v10.2.0.js'],
'dist/SequentPlugins-v10.2.0.js': [
'dist/SequentConfig-v10.3.0.js': ['SequentConfig.js'],
'dist/SequentThemes-v10.3.0.js': ['node_modules/common-ui/dist/SequentThemes-v10.3.0.js'],
'dist/SequentPlugins-v10.3.0.js': [
'SequentPluginsConfig.js',
'plugins/**/*.js',
'!plugins/**/*-spec.js'
Expand Down Expand Up @@ -438,10 +440,10 @@ module.exports = function (grunt) {
beautify: true
},
files: {
'dist/app-v10.2.0.min.js': 'temp/app.js',
'dist/lib-v10.2.0.min.js': 'temp/lib.js',
'dist/libnocompat-v10.2.0.min.js': 'temp/libnocompat.js',
'dist/libcompat-v10.2.0.min.js': 'temp/libcompat.js',
'dist/app-v10.3.0.min.js': 'temp/app.js',
'dist/lib-v10.3.0.min.js': 'temp/lib.js',
'dist/libnocompat-v10.3.0.min.js': 'temp/libnocompat.js',
'dist/libcompat-v10.3.0.min.js': 'temp/libcompat.js',
'dist/avWidgets.min.js': 'avWidgets.js',

"dist/locales/moment/en.js": "node_modules/moment/locale/en-gb.js",
Expand Down
4 changes: 2 additions & 2 deletions SequentConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* in this same file, which you might want to edit and tune if needed.
*/

var SEQUENT_CONFIG_VERSION = '10.2.0';
var SEQUENT_CONFIG_VERSION = '10.3.0';

var SequentConfigData = {
// the base url path for ajax requests, for example for sending ballots or
Expand Down Expand Up @@ -229,7 +229,7 @@ var SequentConfigData = {
title: ""
},

mainVersion: '10.2.0',
mainVersion: '10.3.0',
repoVersions: [],

// Number of seconds after which an authentication token expires.
Expand Down
4 changes: 3 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ angular.module(
'angularLoad',
'ng-autofocus',
'LocalStorageModule',
'common-ui'
'common-ui',
'chart.js',
'moment-picker'
]);

/**
Expand Down
1 change: 1 addition & 0 deletions app.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@import "avAdmin/admin-directives/social-networks/social-item-directive.less";
@import "avAdmin/admin-directives/social-networks/social-networks.less";
@import "avAdmin/admin-directives/social-networks/change-social-modal.less";
@import "avAdmin/admin-directives/dashboard/turnout-graph.less";
@import "avAdmin/admin-directives/dashboard/dashboard.less";
@import "avAdmin/admin-directives/question/question.less";
@import "avAdmin/admin-directives/elauth/elauth.less";
Expand Down
43 changes: 43 additions & 0 deletions avAdmin/admin-directives/create/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 && Array.from(el.authorities) || [];
if (el.director) {
auths.push(el.director);
}

if (0 === auths.length) {
logError($i18next.t('avAdmin.create.errors.election-auths-missing', {eltitle: 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', {eltitle: el.title, auth: auth}));
hasError = true;
continue;
}
if ('ok' !== trustees[auth].state) {
logError($i18next.t('avAdmin.create.errors.election-auth-error', {eltitle: el.title, auth: auth, message: trustees[auth].message}));
hasError = true;
continue;
}
}
if (hasError) {
deferred.reject();
} else {
deferred.resolve(el);
}
})
.catch(deferred.reject);
}


return deferred.promise;
}

function createAuthEvent(el) {
console.log("creating auth event for election " + el.title);
var deferred = $q.defer();
Expand Down Expand Up @@ -1264,6 +1306,7 @@ angular.module('avAdmin')

var promise = deferred.promise;
promise = promise
.then(checkTrustees)
.then(createAuthEvent)
.then(registerElection)
.then(function(election) {
Expand Down
11 changes: 9 additions & 2 deletions avAdmin/admin-directives/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,14 @@ <h4>

<ul class="list-group">
<li class="authority list-group-item" ng-repeat="auth in election.auths">
<span class="badge" ng-if="auth == election.director"><i class="fa fa-sitemap"></i></span>
{{ auth }}
<span class="auth-name-container">{{ auth }}</span>
<div class="auth-badge" ng-class="{'auth-badge-green': isTrusteeOk(auth)}">
<div class="auth-tooltip" ng-if="getTrusteeMsg(auth)">
{{ getTrusteeMsg(auth) }}
</div>
</div>
<span class="badge" ng-if="auth === election.director"><i class="fa fa-sitemap"></i></span>
<span ng-if="auth !== election.director" style="width: 30px;"></span>
</li>
</ul>
</div>
Expand All @@ -240,6 +246,7 @@ <h4>
</div>
</div>
<!-- end of general -->
<div av-turnout-graph></div>

<!-- allows to choose which children election to show -->
<div class="row general">
Expand Down
90 changes: 82 additions & 8 deletions avAdmin/admin-directives/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ angular.module('avAdmin')
$q,
$window,
$state,
$i18next,
Authmethod,
Plugins,
ElectionsApi,
Expand All @@ -37,6 +38,7 @@ angular.module('avAdmin')
function link(scope, element, attrs)
{
scope.reloadTimeout = null;
scope.trusteesState = {};

scope.isWriteInResult = function(answer)
{
Expand Down Expand Up @@ -81,8 +83,25 @@ angular.module('avAdmin')
}
}

function setTrusteesState() {
ElectionsApi
.authoritiesStatus()
.then(function (trustees) {
scope.trusteesState = trustees;
});
}

function isTrusteeOk(name) {
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();
ElectionsApi
.getElection(scope.id, /*ignorecache = */ true)
.then(function(el)
Expand Down Expand Up @@ -743,6 +762,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.length > 0) {
deferred.reject(errors);
} else {
deferred.resolve();
}
})
.catch(deferred.reject);
}

return deferred.promise;
}

// performs all the initialization
function init()
{
Expand Down Expand Up @@ -895,13 +954,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()
{
Expand All @@ -915,7 +978,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 (
Expand Down Expand Up @@ -1460,6 +1531,7 @@ angular.module('avAdmin')
scope.prevStatus = null;
scope.percentVotes = PercentVotesService;

setTrusteesState();
// get the election at the begining
ElectionsApi
.getElection(scope.id)
Expand Down Expand Up @@ -1532,6 +1604,8 @@ angular.module('avAdmin')
launchKeyDistributionCeremony: launchKeyDistributionCeremony,
launchOpeningCeremony: launchOpeningCeremony,
configureScheduledEvents: configureScheduledEvents,
isTrusteeOk: isTrusteeOk,
getTrusteeMsg: getTrusteeMsg,
downloadTurnout: downloadTurnout
});

Expand Down
37 changes: 37 additions & 0 deletions avAdmin/admin-directives/dashboard/dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,43 @@
}
}

.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;
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;
Expand Down
Loading

0 comments on commit dd17a84

Please sign in to comment.