Fix grafico in statistiche

This commit is contained in:
valentina 2024-09-09 09:28:48 +02:00
parent 306a28737d
commit 11c0768197
5 changed files with 42 additions and 53 deletions

View File

@ -112,7 +112,7 @@ switch (filter('op')) {
if ($hook->permission != '-') { if ($hook->permission != '-') {
$results[] = [ $results[] = [
'id' => $hook->id, 'id' => $hook->id,
'name' => $hook->getTranslation('title'), 'name' => $hook->name,
]; ];
} }
} }

View File

@ -309,7 +309,7 @@ switch (filter('op')) {
->where('id', '=', $id) ->where('id', '=', $id)
->first(); ->first();
flash()->info(tr('Hook "_NAME_" disabilitato!', [ flash()->info(tr('Hook "_NAME_" disabilitato!', [
'_NAME_' => $hook->getTranslation('title'), '_NAME_' => $hook->name,
])); ]));
echo json_encode([]); echo json_encode([]);
@ -329,7 +329,7 @@ switch (filter('op')) {
->where('id', '=', $id) ->where('id', '=', $id)
->first(); ->first();
flash()->info(tr('Hook "_NAME_" abilitato!', [ flash()->info(tr('Hook "_NAME_" abilitato!', [
'_NAME_' => $hook->getTranslation('title'), '_NAME_' => $hook->name,
])); ]));
echo json_encode([]); echo json_encode([]);

View File

@ -57,9 +57,9 @@ foreach ($gruppi as $modulo => $hooks) {
$nome_tipo = 'hook'; $nome_tipo = 'hook';
echo ' echo '
<tr class="'.$class.'" data-id="'.$hook->id.'" data-nome='.json_encode($hook->getTranslation('title')).'> <tr class="'.$class.'" data-id="'.$hook->id.'" data-nome='.json_encode($hook->name).'>
<td> <td>
'.$hook->getTranslation('title').(!empty($hook->help) ? ' '.$hook->name.(!empty($hook->help) ? '
<i class="tip fa fa-question-circle-o" title="'.$hook->help.'"</i>' : '').' <i class="tip fa fa-question-circle-o" title="'.$hook->help.'"</i>' : '').'
</td> </td>

View File

@ -41,86 +41,72 @@ $(document).ready(function() {
}, },
success: function(data) { success: function(data) {
data = JSON.parse(data); data = JSON.parse(data);
crea_grafico(data); crea_grafico(data);
} }
}); });
}); });
function crea_grafico(values){ function crea_grafico(values){
var ctx = $("#chart"); var ctx = $("#chart");
$data = [];
$data = []; $labels = [];
$labels = [];
values.forEach(function(element) { values.forEach(function(element) {
$data.push(element.size); $data.push(element.size);
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB //Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbSize>0 && element.description == "Allegati"){ if (element.dbSize > 0 && element.description == "Allegati"){
if (element.size<element.dbSize){ if (element.size < element.dbSize){
var diff = (element.dbSize-element.size); var diff = (element.dbSize - element.size);
if (diff > 1000){
if (diff>1000){ $("#message").append("<div class=\"badge badge-warning\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+formatBytes(diff)+" di files mancanti per allegati.</div><br>");
$("#message").append("<div class=\"badge badge-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+formatBytes(diff)+" di files mancanti per allegati.</div><br>");
} }
} }
} }
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB //Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbCount>0 && element.description == "Allegati" ){ if (element.dbCount > 0 && element.description == "Allegati" ){
if (element.count<element.dbCount){ if (element.count < element.dbCount){
var diff = (element.dbCount-element.count); var diff = (element.dbCount - element.count);
$("#message").append("<div class=\"badge badge-warning\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati per allegati.</div><br>");
$("#message").append("<div class=\"badge badge-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati per allegati.</div><br>");
} }
} }
//Numero di file in Allegati suddivisi per estensione //Numero di file in Allegati suddivisi per estensione
if (element.dbExtensions.length > 0){ if (element.dbExtensions.length > 0){
$("#message").append("<br><p><b>Top 10 allegati:</b></p>"); $("#message").append("<br><p><b>Top 10 allegati:</b></p>");
element.dbExtensions.forEach(function(ext) { element.dbExtensions.forEach(function(ext) {
$("#message").append("<div class=\"badge badge-info\" ><i class=\"fa fa-file\" aria-hidden=\"true\"></i> <b>"+ext["num"]+"</b> files con estensione <b>"+ext["extension"]+"</b>.</div><br>"); $("#message").append("<div class=\"badge badge-info\"><i class=\"fa fa-file\" aria-hidden=\"true\"></i> <b>"+ext.num+"</b> files con estensione <b>"+ext.extension+"</b>.</div><br>");
}); });
} }
$labels.push(`${element.description} (${element.formattedSize}) [${element.count}]`);
$labels.push(element.description + " (" + element.formattedSize + ")" + " [" + element.count + "]" )
}); });
options = { const options = {
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
legend: { legend: {
display: true, display: true,
position: "right", position: "right",
}, },
animation:{ animation: {
animateScale: true, animateScale: true,
animateRotate: true, animateRotate: true,
}, },
tooltips: { tooltips: {
callbacks: { callbacks: {
title: function(tooltipItem, data) { title: function(tooltipItem, data) {
return data["labels"][tooltipItem[0]["index"]]; return data.labels[tooltipItem[0].index];
}, },
label: function(tooltipItem, data) { label: function(tooltipItem, data) {
//return data["datasets"][0]["data"][tooltipItem["index"]]; const dataset = data.datasets[0];
var dataset = data["datasets"][0]; const percent = Math.round((dataset.data[tooltipItem.index] / dataset._meta[0].total) * 100);
var percent = Math.round((dataset["data"][tooltipItem["index"]] / dataset["_meta"][0]["total"]) * 100) return `(${percent}%)`;
return "(" + percent + "%)"; },
},
afterLabel: function(tooltipItem, data) {
//var dataset = data["datasets"][0];
//var percent = Math.round((dataset["data"][tooltipItem["index"]] / dataset["_meta"][0]["total"]) * 100)
//return "(" + percent + "%)";
}
}, },
backgroundColor: "#fbfbfb", backgroundColor: "#fbfbfb",
titleFontSize: 12, titleFontSize: 12,
@ -162,7 +148,7 @@ function crea_grafico(values){
}); });
} }
</script> </script>
<div id="message" class="pull-right"></div> <div id="message float-right"></div>
<div class="chart-container"> <div class="chart-container">
<canvas id="chart"></canvas> <canvas id="chart"></canvas>
</div>'; </div>';

View File

@ -21,4 +21,7 @@ INSERT INTO `zz_settings` (`id`, `nome`, `valore`, `tipo`, `editable`, `sezione`
INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES (NULL, '1', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Geolocalizzazione automatica'), 'Geolocalizzazione automatica', ''); INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES (NULL, '1', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Geolocalizzazione automatica'), 'Geolocalizzazione automatica', '');
INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES (NULL, '1', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Gestore mappa'), 'Gestore mappa', ''); INSERT INTO `zz_settings_lang` (`id`, `id_lang`, `id_record`, `title`, `help`) VALUES (NULL, '1', (SELECT `zz_settings`.`id` FROM `zz_settings` WHERE `zz_settings`.`nome` = 'Gestore mappa'), 'Gestore mappa', '');
-- Fix widget statistiche
UPDATE `zz_widgets` SET `class` = 'col-md-6' WHERE `zz_widgets`.`name` = "Spazio utilizzato";