diff --git a/modules/stato_servizi/actions.php b/modules/stato_servizi/actions.php index 7aa178a5d..4ce4892d9 100755 --- a/modules/stato_servizi/actions.php +++ b/modules/stato_servizi/actions.php @@ -154,9 +154,11 @@ switch (filter('op')) { 'description' => $description, 'size' => $size, 'formattedSize' => FileSystem::formatBytes($size), - 'count' => (FileSystem::folderCount($dir)? : 0), + 'count' => (FileSystem::fileCount($dir, ['htaccess'])? : 0), 'dbSize' => (($description == "Allegati") ? $dbo->fetchOne("SELECT SUM(`size`) AS dbsize FROM zz_files")["dbsize"] : ""), 'dbCount' => (($description == "Allegati") ? $dbo->fetchOne("SELECT COUNT(`id`) AS dbcount FROM zz_files")["dbcount"] : ""), + 'dbExtensions' => (($description == "Allegati") ? $dbo->fetchArray("SELECT SUBSTRING_INDEX(FILENAME, '.', -1) AS EXTENSION, COUNT(*) AS NUM FROM ZZ_FILES GROUP BY EXTENSION ORDER BY NUM DESC LIMIT 10") : ""), + ]; } diff --git a/modules/stato_servizi/widgets/spazio_utilizzato.php b/modules/stato_servizi/widgets/spazio_utilizzato.php index 63019893d..be1cc8a8d 100755 --- a/modules/stato_servizi/widgets/spazio_utilizzato.php +++ b/modules/stato_servizi/widgets/spazio_utilizzato.php @@ -43,7 +43,7 @@ function crea_grafico(values){ var diff = (element.dbSize-element.size); if (diff>1000){ - $("#message").append("
"+formatBytes(diff)+" di file mancanti per allegati.
"); + $("#message").append("
"+formatBytes(diff)+" di file mancanti per allegati.

"); } } } @@ -53,11 +53,26 @@ function crea_grafico(values){ if (element.count "+diff+" di file mancanti per allegati."); + $("#message").append("
"+diff+" di file mancanti per allegati.

"); } } + //Numero di file in Allegati per estensione + if (element.dbExtensions.length > 0){ + + $("#message").append("

Top 10 allegati:

"); + + element.dbExtensions.forEach(function(extension) { + + $("#message").append("
"+extension["NUM"]+" file con estensione "+extension["EXTENSION"]+".

"); + + }); + + } + + + $labels.push(element.description + " (" + element.formattedSize + ")" + " [" + element.count + "]" ) @@ -71,7 +86,31 @@ function crea_grafico(values){ 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 + "%)"; + } + }, + backgroundColor: "#fbfbfb", + titleFontSize: 12, + titleFontColor: "#000", + bodyFontColor: "#444", + bodyFontSize: 10, + displayColors: true + } }; data = { @@ -105,7 +144,7 @@ function crea_grafico(values){ }); } - -
+
+
-
'; +
'; diff --git a/src/Util/FileSystem.php b/src/Util/FileSystem.php index 68113c936..253702e95 100755 --- a/src/Util/FileSystem.php +++ b/src/Util/FileSystem.php @@ -67,14 +67,17 @@ class FileSystem * * @return int */ - public static function folderCount($path) + public static function fileCount($path, $exclusions = array()) { + + $total = 0; $path = realpath($path); if ($path !== false && $path != '' && file_exists($path)) { foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) { - $total += 1; + if (!in_array($object->getExtension(), $exclusions)) + $total += 1; } }