This commit is contained in:
xdrm-brackets 2018-04-17 17:38:38 +02:00
commit 9e96d7a84e
6 changed files with 64 additions and 55 deletions

View File

@ -154,23 +154,19 @@ class PDOWrapper extends \PDO
//find the given pattern in the request, then call our function and replace the matched string by the return value of our function
$finalStatement .= rtrim(preg_replace_callback("/(:[a-z_\-0-9]*)/is",function($matches) use (&$i,&$tempParametes){
//get next number
$i++;
//delete the ':' at the beginning of the string
$tempKey = ltrim($matches[0],':');
//copy the parameter with the modified index
$tempParametes[$tempKey.$i] = $tempParametes[$tempKey];
$tempParametes[":$i"] = $tempParametes[$matches[0]];
//delete the old index
unset($tempParametes[$tempKey]);
unset($tempParametes[$matches[0]]);
//return the modified string for replacement
return $matches[0].$i;
return ":".$i++;
},$statement),';').';';
$finalExecute = array_merge($finalExecute,$tempParametes);
$finalExecute += $tempParametes;
}
//disable stacking
@ -184,6 +180,7 @@ class PDOWrapper extends \PDO
$req = $this->prepare($finalStatement);
$success = $req->execute($finalExecute);
//as we execute multiple query that we don't fetch, we have to close the cursor if we want to do other requests later
$req->closeCursor();
$this->commit();

View File

@ -195,9 +195,9 @@ class ue extends Repo_i {
IFNULL(formlist.nbrCours,0) nbrCours,
IFNULL(formlist.nbrTD,0) nbrTD,
IFNULL(formlist.nbrTP,0) nbrTP,
IFNULL(formlist.modCours,1) modCours,
IFNULL(formlist.modTD,1) modTD,
IFNULL(formlist.modTP,1) modTP,
IFNULL(formlist.modCours,0) modCours,
IFNULL(formlist.modTD,0) modTD,
IFNULL(formlist.modTP,0) modTP,
IFNULL(formlist.nbrProfCours,0) nbrProfCours,
IFNULL(formlist.nbrProfTD,0) nbrProfTD,
IFNULL(formlist.nbrProfTP,0) nbrProfTP

View File

@ -1,41 +1,42 @@
<template>
<div id='CONTAINER' class='list'>
<svg xmlns="http://www.w3.org/2000/svg">
<path
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size) + ',' + (gstore.dimensions.padding) + ' ' +
<svg xmlns="http://www.w3.org/2000/svg" :viewBox="gstore.viewBox">
<template v-if="gstore.dimensions">
<path
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size) + ',' + (gstore.dimensions.padding) + ' ' +
'0,' + (gstore.dimensions.axis.height + gstore.dimensions.padding) + ' ' +
(gstore.dimensions.axis.width) + ',0'"></path>
<text
class="precision"
:x="gstore.dimensions.padding + gstore.dimensions.text.size"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">0</text>
<template v-for="i in gstore.dimensions.axis.precision">
<path
<text
class="precision"
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)) + ',' + (gstore.dimensions.padding) + ' ' +
:x="gstore.dimensions.padding + gstore.dimensions.text.size"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">0</text>
<template v-for="i in gstore.dimensions.axis.precision">
<path
class="precision"
:d="'m ' + (gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)) + ',' + (gstore.dimensions.padding) + ' ' +
'0,' + (gstore.dimensions.axis.height+gstore.dimensions.padding) + ' '"></path>
<text
class="precision"
:x="gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">{{ i*gstore.maxValue/gstore.dimensions.axis.precision }}</text>
<text
class="precision"
:x="gstore.dimensions.padding + gstore.dimensions.text.size + (i*gstore.dimensions.axis.width/gstore.dimensions.axis.precision)"
:y="gstore.dimensions.text.alignV + gstore.dimensions.axis.height + gstore.dimensions.padding">{{ i*gstore.maxValue/gstore.dimensions.axis.precision }}</text>
</template>
<template v-for="(value, key, i) in gstore.stats">
<text
:x="gstore.dimensions.text.size + gstore.dimensions.padding - gstore.dimensions.text.alignH"
:y="i*(gstore.dimensions.bin.width + gstore.dimensions.bin.spacing) + gstore.dimensions.padding + gstore.dimensions.text.alignV"
>{{ key }}</text>
<rect
:class="gstore.colors[i] + ' hiding'"
:x="gstore.dimensions.text.size + gstore.dimensions.padding + 1"
:y="i*(gstore.dimensions.bin.width+gstore.dimensions.bin.spacing) + gstore.dimensions.padding"
:height="gstore.dimensions.bin.width"
:width="gstore.dimensions.bin.margin + (gstore.dimensions.axis.width * value)/gstore.maxValue"
:data-info="value">
<title>{{ (gstore.titles && gstore.titles[key]) ? value + ' ' + gstore.titles[key] : value }}</title>
</rect>
</template>
</template>
<template v-for="(value, key, i) in gstore.stats">
<text
:x="gstore.dimensions.text.size + gstore.dimensions.padding - gstore.dimensions.text.alignH"
:y="i*(gstore.dimensions.bin.width + gstore.dimensions.bin.spacing) + gstore.dimensions.padding + gstore.dimensions.text.alignV"
>{{ key }}</text>
<rect
:class="gstore.colors[i] + ' hiding'"
:x="gstore.dimensions.text.size + gstore.dimensions.padding + 1"
:y="i*(gstore.dimensions.bin.width+gstore.dimensions.bin.spacing) + gstore.dimensions.padding"
:height="gstore.dimensions.bin.width"
:width="gstore.dimensions.bin.margin + (gstore.dimensions.axis.width * value)/gstore.maxValue"
:data-info="value">
<title>{{ value }}</title>
</rect>
</template>
</svg>
<section>bla</section>

View File

@ -2,7 +2,7 @@
/* (1) Load statistics
---------------------------------------------------------*/
/* (1) Initialize list */
gstore.add('stats', []);
gstore.add('stats', null);
gstore.add('dimensions', null);
/* (2) Get statistics */
@ -13,31 +13,40 @@ api.call('GET department/stats', {}, function(rs) {
return console.log('No formation found, error: ' + rs.error);
}
let maxValue = null;
let maxKeyLength = null;
let data = {};
let maxValue = null; // plus haute valeur des stats
let maxLabelLength = null; // plus longues chaîne de caractères pour les stats
let data = {}; // ensemble des statistiques à transmettre à VueJS
let map = {
"potentiel" : "Heures es",
"sous_service" : "Heures à faire",
"potentiel" : "Heures potentielles",
"sous_service" : "Heures en sous-services",
"heures_comp" : "Heures comp.",
"heures_vacataire" : "Heures vacataires",
"heures_exterieur" : "Heures extérieurs",
"heures_exterieur" : "Heures à l'extérieurs",
"heures_ue_desactive" : "Heures UE annulées",
"nbr_ue_desactive" : "Nombre d'UE annulées"
};
for (let stat in rs.data) {
// détection de la plus grande valeur statistique
maxValue = rs.data[stat] > maxValue ? rs.data[stat] : maxValue;
maxKeyLength = stat.length > maxKeyLength ? stat.length : maxKeyLength;
// détection du plus grand nom présent
maxLabelLength = map[stat].length > maxLabelLength ? map[stat].length : maxLabelLength;
data[map[stat]] = Math.round(rs.data[stat] * 100) / 100;
}
// légendes à afficher en plus de la valeur
gstore.get.titles = {};
gstore.get.titles[map['heures_ue_desactive']] = `sur ${data[map['nbr_ue_desactive']]} UE annulées`;
// statistiques à ne pas afficher
delete data[map['nbr_ue_desactive']];
gstore.get.stats = data;
gstore.get.dimensions = {
padding: 5,
text: {
size: maxKeyLength * 9.5,
size: maxLabelLength * 8.5,
alignH: 5,
alignV: 20,
},
@ -62,6 +71,8 @@ api.call('GET department/stats', {}, function(rs) {
width: 500,
precision: 4
};
gstore.get.viewBox = `0 0 ${gstore.get.dimensions.axis.width + gstore.get.dimensions.text.size + 50} ${gstore.get.dimensions.axis.height + 30}`;
});
gstore.add('colors', ["blue", "yellow", "green", "red", "purple", "lightblue", "lightred", "lightyellow", "lightgreen", "lightpurple"]);

View File

@ -43,7 +43,7 @@ window.cas_callback = function(cas_login){
// re-activate button
gstore.add('popup_opened', false);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
/* (4) If error code -> display error */
}else if( !isNaN(cas_login) ){
@ -71,7 +71,7 @@ window.cas_callback = function(cas_login){
// re-activate button
gstore.add('popup_opened', false);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 1500);
setTimeout(function(){ gstore.get.login_class = 'neutral'; }, 3000);
/* (4) If login -> reload page */
}else{
@ -81,7 +81,7 @@ window.cas_callback = function(cas_login){
var redirect_url = `/${gstore.get.URI.join('/')}`;
setTimeout(function(){ document.location = redirect_url; }, 1500);
setTimeout(function(){ document.location = redirect_url; }, 3000);
}

View File

@ -12,8 +12,8 @@ $svg-lightpurple: #994499;
svg {
width: 50em;
height: 20em;
width: 100%;
height: 30vh;
margin: 10px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */