national_admin_functions #1

Manually merged
michele.artini merged 75 commits from national_admin_functions into master 2020-10-26 08:32:19 +01:00
3 changed files with 481 additions and 166 deletions
Showing only changes of commit 4c180e390c - Show all commits

View File

@ -4,12 +4,9 @@ orgsModule.service('vocabulariesService', function($http) {
this.vocs = {};
this.getVocs = function(f) {
if (Object.keys(this.vocs).length === 0) {
$http.get('api/vocabularies').then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_get($http, 'api/vocabularies', function(res) {
this.vocs = res.data;
f(angular.copy(this.vocs));
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
} else {
f(this.vocs);
@ -23,15 +20,11 @@ orgsModule.factory('suggestionInfo', function($http) {
var getInfo = function() { return info; };
var updateInfo = function(callback) {
$http.get('api/organizations/suggestionsInfo').then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_get($http, 'api/organizations/suggestionsInfo', function(res) {
info.data = res.data;
if (callback) { callback(info); }
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
};
return {
getInfo: getInfo,
@ -63,12 +56,9 @@ orgsModule.directive('selectOrgModal', function($http, $timeout) {
scope.search = function(text, page, size) {
scope.searchOrgs = {};
$http.get('api/organizations/search/' + page + '/' + size + '?status='+ scope.filterStatus + '&q=' + text).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_get($http, 'api/organizations/search/' + page + '/' + size + '?status='+ scope.filterStatus + '&q=' + text, function(res) {
scope.searchValue = text;
scope.searchOrgs = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
@ -119,15 +109,10 @@ orgsModule.directive('resolveConflictsModal', function($http, $route) {
else { otherIds.push(o.id); }
});
if (masterId && otherIds.length > 0) {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post('api/organizations/conflicts/fix/' + masterId, otherIds).then(function successCallback(res) {
if ((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_post($http, 'api/organizations/conflicts/fix/' + masterId, otherIds, function(res) {
$('#' + scope.modalId).modal('hide');
$('#' + scope.modalId).on('hidden.bs.modal', function (e) {
$route.reload();
});
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
$('#' + scope.modalId).on('hidden.bs.modal', function (e) { $route.reload(); });
});
}
}
@ -164,45 +149,27 @@ orgsModule.directive('orgFormMetadata', function($http, $location, $route, $rout
}
scope.save = function() {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post('api/organizations/save', scope.org).then(function successCallback(res) {
if ((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
else if (scope.mode == 'insert') { $location.url('/edit/1/' + res.data[0]); }
call_http_post($http, 'api/organizations/save', scope.org, function(res) {
if (scope.mode == 'insert') { $location.url('/edit/1/' + res.data[0]); }
else if (scope.mode == 'approve') { $location.url('/edit/3/' + res.data[0]); }
else if ($routeParams.msg == 2) { $route.reload(); }
else { $location.url('/edit/2/' + res.data[0]); }
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
scope.deleteOrg = function() {
if (confirm("Are you sure?")) {
$http.get('api/organizations/delete?id=' + scope.org.id).then(function successCallback(res) {
if ((typeof res.data) == 'string') {
alert("Session expired !");
location.reload(true);
} else {
alert("Organization marked as deleted !!!");
$route.reload();
}
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
call_http_get($http, 'api/organizations/delete?id=' + scope.org.id, function(res) {
alert("Organization marked as deleted !!!");
$route.reload();
});
}
};
scope.saveAsDiscarded = function() {
if (confirm("Are you sure?")) {
$http.get('api/organizations/discard?id=' + scope.org.id).then(function successCallback(res) {
if ((typeof res.data) == 'string') {
alert("Session expired !");
location.reload(true);
} else {
alert("Organization marked as discarded !!!");
$route.reload();
}
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
call_http_get($http, 'api/organizations/discard?id=' + scope.org.id, function(res) {
alert("Organization marked as discarded !!!");
$route.reload();
});
}
};
@ -282,14 +249,11 @@ orgsModule.directive('orgDuplicates', function($http, $location, $route) {
});
$http.get('api/organizations/duplicates?id=' + scope.newDuplicate.id).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_get($http, 'api/organizations/duplicates?id=' + scope.newDuplicate.id, function(res) {
angular.forEach(res.data, function(dup) {
dup.localId = scope.orgId;
scope.duplicates.push(dup);
});
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
@ -408,12 +372,7 @@ orgsModule.controller('searchResultsCtrl', function ($scope, $http, $routeParams
}
$scope.orgs = {};
$http.get('api/organizations/search/' + $routeParams.page + '/' + $routeParams.size + '?q=' + $scope.searchText).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.orgs = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/search/' + $routeParams.page + '/' + $routeParams.size + '?q=' + $scope.searchText, function(res) { $scope.orgs = res.data; });
$scope.prev = function() {
if ($scope.searchText) {
@ -439,12 +398,7 @@ orgsModule.controller('countriesCtrl', function ($scope, $http, $routeParams) {
$scope.resultsBasePath = '/byCountry'
$scope.entries = [];
$http.get('api/organizations/browse/countries').then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.entries = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/browse/countries', function(res) { $scope.entries = res.data; });
});
@ -452,12 +406,7 @@ orgsModule.controller('byCountryCtrl', function ($scope, $http, $routeParams, $l
$scope.fieldValue = decodeURIComponent($routeParams.code);
$scope.orgs = {};
$http.get('api/organizations/byCountry/' + $routeParams.status + '/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.orgs = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/byCountry/' + $routeParams.status + '/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; });
$scope.prev = function() {
$location.url('/byCountry/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue));
@ -475,13 +424,7 @@ orgsModule.controller('typesCtrl', function ($scope, $http, $routeParams) {
$scope.resultsBasePath = '/byType'
$scope.entries = [];
$http.get('api/organizations/browse/types').then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.entries = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/browse/types', function(res) { $scope.entries = res.data; });
});
orgsModule.controller('byTypeCtrl', function ($scope, $http, $routeParams, $location) {
@ -490,12 +433,7 @@ orgsModule.controller('byTypeCtrl', function ($scope, $http, $routeParams, $loca
$scope.orgs = {};
$http.get('api/organizations/byType/' + $routeParams.status + '/' + $routeParams.type + '/' + $routeParams.page + '/' + $routeParams.size).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.orgs = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/byType/' + $routeParams.status + '/' + $routeParams.type + '/' + $routeParams.page + '/' + $routeParams.size, function(res) { $scope.orgs = res.data; });
$scope.prev = function() {
$location.url('/byType/' + ($scope.orgs.number - 1) + '/' + $scope.orgs.size + '/' + $routeParams.status + '/' + encodeURIComponent($scope.fieldValue));
@ -518,39 +456,19 @@ orgsModule.controller('showEditCtrl', function ($scope, $http, $routeParams, $ro
$scope.adminMode = adminMode();
$scope.getInfo = function() {
$http.get('api/organizations/info?id=' + $scope.orgId).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.info = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/info?id=' + $scope.orgId, function(res) { $scope.info = res.data; });
};
$scope.gotoTab = function(tab) {
$scope.org = {};
$http.get('api/organizations/get?id=' + $scope.orgId).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.org = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/get?id=' + $scope.orgId, function(res) { $scope.org = res.data; });
if (tab == 2) {
$scope.duplicates = [];
$http.get('api/organizations/duplicates?id=' + $scope.orgId).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.duplicates = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/duplicates?id=' + $scope.orgId, function(res) { $scope.duplicates = res.data; });
} else if (tab == 3) {
$scope.conflicts = [];
$http.get('api/organizations/conflicts?id=' + $scope.orgId).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.conflicts = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/conflicts?id=' + $scope.orgId, function(res) { $scope.conflicts = res.data; });
}
$scope.currentTab = tab;
}
@ -559,14 +477,11 @@ orgsModule.controller('showEditCtrl', function ($scope, $http, $routeParams, $ro
$scope.saveDuplicates = function() {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post('api/organizations/duplicates', $scope.duplicates).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_post($http, 'api/organizations/duplicates', $scope.duplicates, function(res) {
$scope.getInfo();
alert('Events updated !!!');
$scope.duplicates = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
@ -615,12 +530,7 @@ orgsModule.controller('pendingOrgsCtrl', function ($scope, $http, $routeParams,
$scope.orgs = [];
if ($scope.country != '_') {
$http.get('api/organizations/byCountry/suggested/' + $scope.country).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.orgs = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/byCountry/suggested/' + $scope.country, function(res) { $scope.orgs = res.data; });
}
$scope.getInfo();
}
@ -640,19 +550,8 @@ orgsModule.controller('duplicatesCtrl', function ($scope, $http, $routeParams, $
$scope.currentOrgDetails = {};
$scope.currentDuplicates = [];
$http.get('api/organizations/get?id=' + org.id).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.currentOrgDetails = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
$http.get('api/organizations/duplicates?id=' + org.id).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.currentDuplicates = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/get?id=' + org.id, function(res) { $scope.currentOrgDetails = res.data; });
call_http_get($http, 'api/organizations/duplicates?id=' + org.id, function(res) { $scope.currentDuplicates = res.data; });
};
$scope.getInfo = function() {
@ -670,9 +569,8 @@ orgsModule.controller('duplicatesCtrl', function ($scope, $http, $routeParams, $
};
$scope.saveCurrentDuplicates = function() {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post('api/organizations/duplicates', $scope.currentDuplicates).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
call_http_post($http, 'api/organizations/duplicates', $scope.currentDuplicates, function(res) {
$scope.getInfo();
@ -692,8 +590,6 @@ orgsModule.controller('duplicatesCtrl', function ($scope, $http, $routeParams, $
}
}, 600);
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
};
@ -701,12 +597,7 @@ orgsModule.controller('duplicatesCtrl', function ($scope, $http, $routeParams, $
$scope.duplicates = [];
if ($scope.country != '_') {
$http.get('api/organizations/duplicates/byCountry/' + $scope.country).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.duplicates = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/duplicates/byCountry/' + $scope.country, function(res) { $scope.duplicates = res.data; });
}
$scope.getInfo();
}
@ -767,12 +658,7 @@ orgsModule.controller('conflictsCtrl', function ($scope, $http, $routeParams, $l
$scope.conflicts = [];
if ($scope.country != '_') {
$http.get('api/organizations/conflicts/byCountry/' + $scope.country).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.conflicts = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/organizations/conflicts/byCountry/' + $scope.country, function(res) { $scope.conflicts = res.data; });
}
$scope.getInfo();
}
@ -791,12 +677,7 @@ orgsModule.controller('usersCtrl', function ($scope, $http, $timeout, $route, vo
$scope.vocabularies = {};
vocabulariesService.getVocs(function(vocs) { $scope.vocabularies = vocs; });
$http.get('api/users').then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.users = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_get($http, 'api/users', function(res) { $scope.users = res.data; });
$scope.setCurrentUser = function(user) {
angular.copy(user, $scope.currentUser);
@ -806,23 +687,12 @@ orgsModule.controller('usersCtrl', function ($scope, $http, $timeout, $route, vo
}
$scope.saveUser = function(user) {
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post('api/users', user).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.users = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_post($http, 'api/users', user, function(res) { $scope.users = res.data; });
}
$scope.deleteUser = function(email) {
if (confirm("Are you sure ?")) {
$http.delete('api/users?email=' + email).then(function successCallback(res) {
if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
$scope.users = res.data;
}, function errorCallback(res) {
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
call_http_delete($http, 'api/users?email=' + email, function(res) { $scope.users = res.data; });
}
}
});

View File

@ -0,0 +1,348 @@
/**
* Copyright (c) 2011-2014 Felix Gnass
* Licensed under the MIT license
*/
(function(root, factory) {
/* CommonJS */
if (typeof exports == 'object') module.exports = factory()
/* AMD module */
else if (typeof define == 'function' && define.amd) define(factory)
/* Browser global */
else root.Spinner = factory()
}
(this, function() {
"use strict";
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
, animations = {} /* Animation rules keyed by their name */
, useCssAnimations /* Whether to use CSS animations or setTimeout */
/**
* Utility function to create elements. If no tag name is given,
* a DIV is created. Optionally properties can be passed.
*/
function createEl(tag, prop) {
var el = document.createElement(tag || 'div')
, n
for(n in prop) el[n] = prop[n]
return el
}
/**
* Appends children and returns the parent.
*/
function ins(parent /* child1, child2, ...*/) {
for (var i=1, n=arguments.length; i<n; i++)
parent.appendChild(arguments[i])
return parent
}
/**
* Insert a new stylesheet to hold the @keyframe or VML rules.
*/
var sheet = (function() {
var el = createEl('style', {type : 'text/css'})
ins(document.getElementsByTagName('head')[0], el)
return el.sheet || el.styleSheet
}())
/**
* Creates an opacity keyframe animation rule and returns its name.
* Since most mobile Webkits have timing issues with animation-delay,
* we create separate rules for each line/segment.
*/
function addAnimation(alpha, trail, i, lines) {
var name = ['opacity', trail, ~~(alpha*100), i, lines].join('-')
, start = 0.01 + i/lines * 100
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
, pre = prefix && '-' + prefix + '-' || ''
if (!animations[name]) {
sheet.insertRule(
'@' + pre + 'keyframes ' + name + '{' +
'0%{opacity:' + z + '}' +
start + '%{opacity:' + alpha + '}' +
(start+0.01) + '%{opacity:1}' +
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
'100%{opacity:' + z + '}' +
'}', sheet.cssRules.length)
animations[name] = 1
}
return name
}
/**
* Tries various vendor prefixes and returns the first supported property.
*/
function vendor(el, prop) {
var s = el.style
, pp
, i
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
for(i=0; i<prefixes.length; i++) {
pp = prefixes[i]+prop
if(s[pp] !== undefined) return pp
}
if(s[prop] !== undefined) return prop
}
/**
* Sets multiple style properties at once.
*/
function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n)||n] = prop[n]
return el
}
/**
* Fills in default values.
*/
function merge(obj) {
for (var i=1; i < arguments.length; i++) {
var def = arguments[i]
for (var n in def)
if (obj[n] === undefined) obj[n] = def[n]
}
return obj
}
/**
* Returns the absolute page-offset of the given element.
*/
function pos(el) {
var o = { x:el.offsetLeft, y:el.offsetTop }
while((el = el.offsetParent))
o.x+=el.offsetLeft, o.y+=el.offsetTop
return o
}
/**
* Returns the line color from the given string or array.
*/
function getColor(color, idx) {
return typeof color == 'string' ? color : color[idx % color.length]
}
// Built-in defaults
var defaults = {
lines: 12, // The number of lines to draw
length: 7, // The length of each line
width: 5, // The line thickness
radius: 10, // The radius of the inner circle
rotate: 0, // Rotation offset
corners: 1, // Roundness (0..1)
color: '#000', // #rgb or #rrggbb
direction: 1, // 1: clockwise, -1: counterclockwise
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
opacity: 1/4, // Opacity of the lines
fps: 20, // Frames per second when using setTimeout()
zIndex: 2e9, // Use a high z-index by default
className: 'spinner', // CSS class to assign to the element
top: '50%', // center vertically
left: '50%', // center horizontally
position: 'absolute' // element position
}
/** The constructor */
function Spinner(o) {
this.opts = merge(o || {}, Spinner.defaults, defaults)
}
// Global defaults that override the built-ins:
Spinner.defaults = {}
merge(Spinner.prototype, {
/**
* Adds the spinner to the given target element. If this instance is already
* spinning, it is automatically removed from its previous target b calling
* stop() internally.
*/
spin: function(target) {
this.stop()
var self = this
, o = self.opts
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
, mid = o.radius+o.length+o.width
if (target) {
target.insertBefore(el, target.firstChild||null)
css(el, {
left: o.left,
top: o.top
})
}
el.setAttribute('role', 'progressbar')
self.lines(el, self.opts)
if (!useCssAnimations) {
// No CSS animation support, use setTimeout() instead
var i = 0
, start = (o.lines - 1) * (1 - o.direction) / 2
, alpha
, fps = o.fps
, f = fps/o.speed
, ostep = (1-o.opacity) / (f*o.trail / 100)
, astep = f/o.lines
;(function anim() {
i++;
for (var j = 0; j < o.lines; j++) {
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
self.opacity(el, j * o.direction + start, alpha, o)
}
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
})()
}
return self
},
/**
* Stops and removes the Spinner.
*/
stop: function() {
var el = this.el
if (el) {
clearTimeout(this.timeout)
if (el.parentNode) el.parentNode.removeChild(el)
this.el = undefined
}
return this
},
/**
* Internal method that draws the individual lines. Will be overwritten
* in VML fallback mode below.
*/
lines: function(el, o) {
var i = 0
, start = (o.lines - 1) * (1 - o.direction) / 2
, seg
function fill(color, shadow) {
return css(createEl(), {
position: 'absolute',
width: (o.length+o.width) + 'px',
height: o.width + 'px',
background: color,
boxShadow: shadow,
transformOrigin: 'left',
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
borderRadius: (o.corners * o.width>>1) + 'px'
})
}
for (; i < o.lines; i++) {
seg = css(createEl(), {
position: 'absolute',
top: 1+~(o.width/2) + 'px',
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
})
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
}
return el
},
/**
* Internal method that adjusts the opacity of a single line.
* Will be overwritten in VML fallback mode below.
*/
opacity: function(el, i, val) {
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
}
})
function initVML() {
/* Utility function to create a VML tag */
function vml(tag, attr) {
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
}
// No CSS transforms but VML support, add a CSS rule for VML elements:
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
Spinner.prototype.lines = function(el, o) {
var r = o.length+o.width
, s = 2*r
function grp() {
return css(
vml('group', {
coordsize: s + ' ' + s,
coordorigin: -r + ' ' + -r
}),
{ width: s, height: s }
)
}
var margin = -(o.width+o.length)*2 + 'px'
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
, i
function seg(i, dx, filter) {
ins(g,
ins(css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx}),
ins(css(vml('roundrect', {arcsize: o.corners}), {
width: r,
height: o.width,
left: o.radius,
top: -o.width>>1,
filter: filter
}),
vml('fill', {color: getColor(o.color, i), opacity: o.opacity}),
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
)
)
)
}
if (o.shadow)
for (i = 1; i <= o.lines; i++)
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
for (i = 1; i <= o.lines; i++) seg(i)
return ins(el, g)
}
Spinner.prototype.opacity = function(el, i, val, o) {
var c = el.firstChild
o = o.shadow && o.lines || 0
if (c && i+o < c.childNodes.length) {
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
if (c) c.opacity = val
}
}
}
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
if (!vendor(probe, 'transform') && probe.adj) initVML()
else useCssAnimations = vendor(probe, 'animation')
return Spinner
}));

View File

@ -18,6 +18,25 @@
.table > tbody > tr > td { vertical-align : middle !important; }
.card > .table { margin-bottom : 0 !important; }
fieldset > legend { font-size : 1.2rem !important; }
.overlaydiv {
position: fixed;
width: 100%;
height: 100%;
z-index: 10000;
visibility: hidden;
}
.grayRectangle {
position: absolute;
background-color: black;
opacity:0.6;
top: 30%;
left: 40%;
width: 20%;
height: 20%;
z-index: 100;
border-radius: 15px;
}
</style>
@ -92,6 +111,10 @@ fieldset > legend { font-size : 1.2rem !important; }
<div class="container-fluid small mt-4" ng-view></div>
<div id="spinnerdiv" class="overlaydiv">
<span class="grayRectangle"><!--The spinner is added on loading here--></span>
</div>
<script sec:authorize="hasRole('ROLE_ADMIN')">
function superAdminMode() { return true; }
</script>
@ -112,6 +135,80 @@ fieldset > legend { font-size : 1.2rem !important; }
<script src="resources/js/angular-route.min.js"></script>
<script src='resources/js/checklist-model.js'></script>
<script src="resources/js/organizations.js"></script>
<script src="resources/js/spin.js"></script>
<script>
// Spinner show/hide methods ~ Andrea Mannocci
var spinnerOpts = {
lines: 15,
length: 16,
width: 5,
radius: 25,
color: '#eeeeee',
className: 'spinner',
top: '40%'
};
var spinnerTarget = document.getElementById('spinnerdiv');
var spinner;
function showSpinner() {
spinner = new Spinner(spinnerOpts).spin(spinnerTarget);
spinnerTarget.style.visibility = 'visible';
}
function hideSpinner() {
spinnerTarget.style.visibility = 'hidden';
spinner.stop();
}
function call_http_get($http, url, onSuccess) {
showSpinner();
$http.get(url).then(function successCallback(res) {
hideSpinner();
if((typeof res.data) == 'string') {
alert("Session expired !"); location.reload(true);
} else {
onSuccess(res);
}
}, function errorCallback(res) {
hideSpinner();
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
function call_http_post($http, url, obj, onSuccess) {
showSpinner();
$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
$http.post(url, obj).then(function successCallback(res) {
hideSpinner();
if ((typeof res.data) == 'string') {
alert("Session expired !"); location.reload(true);
} else {
onSuccess(res);
}
}, function errorCallback(res) {
hideSpinner();
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
function call_http_delete($http, url, onSuccess) {
showSpinner();
$http.delete(url).then(function successCallback(res) {
hideSpinner();
if ((typeof res.data) == 'string') {
alert("Session expired !"); location.reload(true);
} else {
onSuccess(res);
}
}, function errorCallback(res) {
hideSpinner();
alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
});
}
</script>
</body>
</html>