1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| $(document).ready(function(){
var $month=$('#monthpicker'),
$day=$('#day'),
$selection_mois=$('#selection_mois'),
$selection_donnees=$('#selections_donnees'),
$selection_rp_mensuel=$('#selection_rp_mensuel'),
$selection_ws_mensuel=$('#selection_ws_mensuel'),
$selection_rp_journalier=$('#selection_rp_journalier'),
$selection_ws_journalier=$('#selection_ws_journalier'),
$stats=$('#statistiques'),
$graph=$('#graphiques'),
month='',
periode='';
// Fonction pour enlever les doublons
function removeDuplicates(num) {
let x;
const len=num.length;
const out=[];
const obj={};
for (x=0; x<len; x++) {
obj[num[x]]=0;
}
for (x in obj) {
out.push(x);
}
return out;
};
//début
$selection_donnees.hide();
$month.MonthPicker({
Button: '<img class="icon" src="icon.gif" />',
MonthFormat: 'mm-y',
OnAfterMenuClose: function () {
month=$(this).val();
console.log(month);
$graph.empty();
$stats.empty();
$selection_donnees.hide();
$selection_ws_mensuel.empty();
$selection_rp_mensuel.empty();
$stats.append("<p>Quelles statistiques souhaitez vous?</p>")
$stats.append("<select id='periode'><option disabled selected>Statistiques</option><option>mensuelle</option><option>journalière</option></select>")
$('#periode').on('change',function(){
periode=$('#periode option:selected').text();
$selection_ws_mensuel.empty();
if( periode == "mensuelle") {
$selection_donnees.show();
$selection_donnees.children().hide();
$selection_donnees.children('#'+periode).show();
$selection_rp_mensuel.empty();
$selection_rp_mensuel.append('<option disabled selected>Sélectionnez le reverse-proxy</option>');
$selection_ws_mensuel.append('<option disabled selected>Sélectionnez le webservice</option>');
$.ajaxSetup({cache: false});
//Chargement des selecteurs
// Reverse proxy
$.getJSON(month+'.json',function(rp_stats){
var date_value=[],
tmp_rp_value=[],
rp_value=[];
$.each(rp_stats,function(date){
date_value.push(date);
$.each(rp_stats[date], function(reverseproxy){
tmp_rp_value.push(reverseproxy);
rp_value=removeDuplicates(tmp_rp_value);
});
});
console.log(rp_value);
// console.log(rp_value);
for (var index in rp_value){
$selection_rp_mensuel.append('<option>'+rp_value[index]+'</option>');
}
$.ajaxSetup({cache: false});
});
//Affichage des webservices en fonctiondu rp sélectionné
$selection_rp_mensuel.on('change',function(){
var tmp_ws_value=[],
ws_value='';
$graph.empty();
ws_value=[];
rp=$('#selection_rp_mensuel option:selected').text();
$.getJSON(month+'.json',function(rp_stats){
$.each(rp_stats,function(date){
$.each(rp_stats[date], function(reverseproxy){
$.each(rp_stats[date][rp], function(webservices){
tmp_ws_value.push(webservices)
ws_value=removeDuplicates(tmp_ws_value);
});
});
});
console.log(ws_value);
});
$.ajaxSetup({cache: false});
for (var index in ws_value){
$selection_ws_mensuel.append('<option>'+ws_value[index]+'</option>');
}
});
}
});
}
});
}); |
Partager