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 != '-') {
$results[] = [
'id' => $hook->id,
'name' => $hook->getTranslation('title'),
'name' => $hook->name,
];
}
}

View File

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

View File

@ -57,9 +57,9 @@ foreach ($gruppi as $modulo => $hooks) {
$nome_tipo = 'hook';
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>
'.$hook->getTranslation('title').(!empty($hook->help) ? '
'.$hook->name.(!empty($hook->help) ? '
<i class="tip fa fa-question-circle-o" title="'.$hook->help.'"</i>' : '').'
</td>

View File

@ -41,86 +41,72 @@ $(document).ready(function() {
},
success: function(data) {
data = JSON.parse(data);
crea_grafico(data);
}
});
});
function crea_grafico(values){
var ctx = $("#chart");
var ctx = $("#chart");
$data = [];
$labels = [];
$data = [];
$labels = [];
values.forEach(function(element) {
values.forEach(function(element) {
$data.push(element.size);
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbSize>0 && element.description == "Allegati"){
if (element.size<element.dbSize){
var diff = (element.dbSize-element.size);
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>");
if (element.dbSize > 0 && element.description == "Allegati"){
if (element.size < element.dbSize){
var diff = (element.dbSize - element.size);
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>");
}
}
}
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
if (element.dbCount>0 && element.description == "Allegati" ){
if (element.count<element.dbCount){
var diff = (element.dbCount-element.count);
if (element.dbCount > 0 && element.description == "Allegati" ){
if (element.count < element.dbCount){
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
if (element.dbExtensions.length > 0){
$("#message").append("<br><p><b>Top 10 allegati:</b></p>");
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,
maintainAspectRatio: false,
legend: {
display: true,
position: "right",
},
animation:{
animateScale: true,
animateRotate: true,
legend: {
display: true,
position: "right",
},
animation: {
animateScale: true,
animateRotate: true,
},
tooltips: {
callbacks: {
title: function(tooltipItem, data) {
return data["labels"][tooltipItem[0]["index"]];
},
label: function(tooltipItem, data) {
//return data["datasets"][0]["data"][tooltipItem["index"]];
var dataset = data["datasets"][0];
var percent = Math.round((dataset["data"][tooltipItem["index"]] / dataset["_meta"][0]["total"]) * 100)
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 + "%)";
}
title: function(tooltipItem, data) {
return data.labels[tooltipItem[0].index];
},
label: function(tooltipItem, data) {
const dataset = data.datasets[0];
const percent = Math.round((dataset.data[tooltipItem.index] / dataset._meta[0].total) * 100);
return `(${percent}%)`;
},
},
backgroundColor: "#fbfbfb",
titleFontSize: 12,
@ -162,7 +148,7 @@ function crea_grafico(values){
});
}
</script>
<div id="message" class="pull-right"></div>
<div id="message float-right"></div>
<div class="chart-container">
<canvas id="chart"></canvas>
</div>';

View File

@ -22,3 +22,6 @@ 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` = 'Gestore mappa'), 'Gestore mappa', '');
-- Fix widget statistiche
UPDATE `zz_widgets` SET `class` = 'col-md-6' WHERE `zz_widgets`.`name` = "Spazio utilizzato";