Update the dashboard
Sanitize the data from the dashboard Use tabs instead of space indentation
This commit is contained in:
+80
-60
@@ -227,33 +227,33 @@
|
|||||||
<style>
|
<style>
|
||||||
|
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widget {
|
.widget {
|
||||||
/*background-color: #eee;*/
|
/*background-color: #eee;*/
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.widgets {
|
.widgets {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 1rem;
|
grid-gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.hud_content {
|
div.hud_content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-content: start;
|
align-content: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.hud_chart {
|
div.hud_chart {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
padding-top: 7px;
|
padding-top: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dashboard settings */
|
/* dashboard settings */
|
||||||
@@ -369,8 +369,8 @@ foreach ($dashboard as $row) {
|
|||||||
|
|
||||||
/* Screen smaller than 575px? 1 columns */
|
/* Screen smaller than 575px? 1 columns */
|
||||||
@media (max-width: 575px) {
|
@media (max-width: 575px) {
|
||||||
.widgets { grid-template-columns: repeat(1, minmax(100px, 1fr)); }
|
.widgets { grid-template-columns: repeat(1, minmax(100px, 1fr)); }
|
||||||
.col-num { grid-column: span 1; }
|
.col-num { grid-column: span 1; }
|
||||||
<?php
|
<?php
|
||||||
foreach ($dashboard as $row) {
|
foreach ($dashboard as $row) {
|
||||||
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
||||||
@@ -391,8 +391,8 @@ foreach ($dashboard as $row) {
|
|||||||
|
|
||||||
/* Screen larger than 575px? 2 columns */
|
/* Screen larger than 575px? 2 columns */
|
||||||
@media (min-width: 575px) {
|
@media (min-width: 575px) {
|
||||||
.widgets { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
|
.widgets { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
|
||||||
.col-num { grid-column: span 2; }
|
.col-num { grid-column: span 2; }
|
||||||
<?php
|
<?php
|
||||||
foreach ($dashboard as $row) {
|
foreach ($dashboard as $row) {
|
||||||
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
||||||
@@ -418,8 +418,8 @@ foreach ($dashboard as $row) {
|
|||||||
|
|
||||||
/* Screen larger than 1300px? 3 columns */
|
/* Screen larger than 1300px? 3 columns */
|
||||||
@media (min-width: 1300px) {
|
@media (min-width: 1300px) {
|
||||||
.widgets { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
|
.widgets { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
|
||||||
.col-num { grid-column: span 2; }
|
.col-num { grid-column: span 2; }
|
||||||
<?php
|
<?php
|
||||||
foreach ($dashboard as $row) {
|
foreach ($dashboard as $row) {
|
||||||
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
$dashboard_name = trim(preg_replace("/[^a-z]/", '_', strtolower($row['dashboard_name'])),'_');
|
||||||
@@ -434,14 +434,14 @@ foreach ($dashboard as $row) {
|
|||||||
|
|
||||||
/* Screen larger than 1500px? 4 columns */
|
/* Screen larger than 1500px? 4 columns */
|
||||||
@media (min-width: 1500px) {
|
@media (min-width: 1500px) {
|
||||||
.widgets { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
|
.widgets { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
|
||||||
.col-num { grid-column: span 2; }
|
.col-num { grid-column: span 2; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Screen larger than 2000px? 5 columns */
|
/* Screen larger than 2000px? 5 columns */
|
||||||
@media (min-width: 2000px) {
|
@media (min-width: 2000px) {
|
||||||
.widgets { grid-template-columns: repeat(5, minmax(100px, 1fr)); }
|
.widgets { grid-template-columns: repeat(5, minmax(100px, 1fr)); }
|
||||||
.col-num { grid-column: span 2; }
|
.col-num { grid-column: span 2; }
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -465,33 +465,33 @@ function toggle_grid_row_end(dashboard_name) {
|
|||||||
let first_toggle = false;
|
let first_toggle = false;
|
||||||
|
|
||||||
function toggle_grid_row_end_all() {
|
function toggle_grid_row_end_all() {
|
||||||
let widgets = document.querySelectorAll('div.widget');
|
let widgets = document.querySelectorAll('div.widget');
|
||||||
|
|
||||||
widgets.forEach(div => {
|
widgets.forEach(div => {
|
||||||
let state = div.getAttribute('data-state');
|
let state = div.getAttribute('data-state');
|
||||||
let current_row_end = div.style.gridRowEnd;
|
let current_row_end = div.style.gridRowEnd;
|
||||||
let current_row_end_number = current_row_end.startsWith('span ') ? Number(current_row_end.replace('span ', '')) : 0;
|
let current_row_end_number = current_row_end.startsWith('span ') ? Number(current_row_end.replace('span ', '')) : 0;
|
||||||
|
|
||||||
// Skip if widget details state is disabled
|
// Skip if widget details state is disabled
|
||||||
if (state === 'disabled') {
|
if (state === 'disabled') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On the first call, skip expanded widgets
|
// On the first call, skip expanded widgets
|
||||||
if (!first_toggle && state === 'expanded') {
|
if (!first_toggle && state === 'expanded') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state === 'expanded') {
|
||||||
|
div.style.gridRowEnd = 'span ' + (current_row_end_number - 3);
|
||||||
|
div.dataset.state = 'contracted';
|
||||||
|
} else {
|
||||||
|
div.style.gridRowEnd = 'span ' + (current_row_end_number + 3);
|
||||||
|
div.dataset.state = 'expanded';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (state === 'expanded') {
|
first_toggle = true;
|
||||||
div.style.gridRowEnd = 'span ' + (current_row_end_number - 3);
|
|
||||||
div.dataset.state = 'contracted';
|
|
||||||
} else {
|
|
||||||
div.style.gridRowEnd = 'span ' + (current_row_end_number + 3);
|
|
||||||
div.dataset.state = 'expanded';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
first_toggle = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -502,8 +502,9 @@ function toggle_grid_row_end_all() {
|
|||||||
echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
|
echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach ($dashboard as $row) {
|
foreach ($dashboard as $row) {
|
||||||
$dashboard_uuid = $row['dashboard_uuid'];
|
//set the variables
|
||||||
$dashboard_name = $row['dashboard_name'];
|
$dashboard_uuid = $row['dashboard_uuid'] ?? '';
|
||||||
|
$dashboard_name = $row['dashboard_name'] ?? '';
|
||||||
$dashboard_icon = $row['dashboard_icon'] ?? '';
|
$dashboard_icon = $row['dashboard_icon'] ?? '';
|
||||||
$dashboard_url = $row['dashboard_url'] ?? '';
|
$dashboard_url = $row['dashboard_url'] ?? '';
|
||||||
$dashboard_target = $row['dashboard_target'] ?? '';
|
$dashboard_target = $row['dashboard_target'] ?? '';
|
||||||
@@ -521,18 +522,38 @@ function toggle_grid_row_end_all() {
|
|||||||
$dashboard_row_span += 3;
|
$dashboard_row_span += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<div class='widget' style='grid-row-end: span ".$dashboard_row_span.";' data-state='".$dashboard_details_state."' id='".trim(preg_replace("/[^a-z]/", '_', strtolower($dashboard_name)),'_')."' draggable='false'>\n";
|
//define the regex patterns
|
||||||
$dashboard_path_array = explode('/', $row['dashboard_path']);
|
$uuid_pattern = '/[^-A-Fa-f0-9]/';
|
||||||
$path_array = glob(dirname(__DIR__, 2).'/*/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php');
|
$number_pattern = '/[^-A-Za-z0-9()*#]/';
|
||||||
include $path_array[0];
|
$text_pattern = '/[^a-zA-Z0-9 _\-\/.#]/';
|
||||||
//$file_name = dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
|
|
||||||
//if (file_exists(dirname(__DIR__, 2).'/core/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php')) {
|
|
||||||
// include dirname(__DIR__, 2).'/core/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
|
|
||||||
//}
|
|
||||||
//elseif (file_exists(dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php')) {
|
|
||||||
// include dirname(__DIR__, 2).'/app/'.$dashboard_path_array[0].'/resources/dashboard/'.$dashboard_path_array[1].'.php';
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
//sanitize the data
|
||||||
|
$dashboard_uuid = preg_replace($uuid_pattern, '', $dashboard_uuid);
|
||||||
|
$dashboard_name = trim(preg_replace($text_pattern, '', $dashboard_name));
|
||||||
|
$dashboard_name_id = trim(preg_replace("/[^a-z_]/", '_', strtolower($dashboard_name)),'_');
|
||||||
|
$dashboard_icon = preg_replace($text_pattern, '', $dashboard_icon);
|
||||||
|
$dashboard_url = trim(preg_replace($text_pattern, '', $dashboard_url));
|
||||||
|
$dashboard_target = trim(preg_replace($text_pattern, '', $dashboard_target));
|
||||||
|
$dashboard_width = trim(preg_replace($text_pattern, '', $dashboard_width));
|
||||||
|
$dashboard_height = trim(preg_replace($text_pattern, '', $dashboard_height));
|
||||||
|
$dashboard_content = trim(preg_replace($text_pattern, '', $dashboard_content));
|
||||||
|
$dashboard_content_text_align = trim(preg_replace($text_pattern, '', $dashboard_content_text_align));
|
||||||
|
$dashboard_content_details = trim(preg_replace($text_pattern, '', $dashboard_content_details));
|
||||||
|
$dashboard_chart_type = preg_replace($text_pattern, '', $dashboard_chart_type);
|
||||||
|
$dashboard_label_text_color = preg_replace($text_pattern, '', $dashboard_label_text_color);
|
||||||
|
$dashboard_number_text_color = preg_replace($text_pattern, '', $dashboard_number_text_color);
|
||||||
|
$dashboard_details_state = preg_replace($text_pattern, '', $dashboard_details_state);
|
||||||
|
$dashboard_row_span = preg_replace($number_pattern, '', $dashboard_row_span);
|
||||||
|
$dashboard_path = preg_replace($text_pattern, '', strtolower($row['dashboard_path']));
|
||||||
|
|
||||||
|
//find the application and widget
|
||||||
|
$dashboard_path_array = explode('/', $dashboard_path);
|
||||||
|
$application_name = $dashboard_path_array[0];
|
||||||
|
$widget_name = $dashboard_path_array[1];
|
||||||
|
$path_array = glob(dirname(__DIR__, 2).'/*/'.$application_name.'/resources/dashboard/'.$widget_name.'.php');
|
||||||
|
|
||||||
|
echo "<div class='widget' style='grid-row-end: span ".$dashboard_row_span.";' data-state='".$dashboard_details_state."' id='".$dashboard_name_id."' draggable='false'>\n";
|
||||||
|
include $path_array[0];
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
|
|
||||||
$x++;
|
$x++;
|
||||||
@@ -639,4 +660,3 @@ function toggle_grid_row_end_all() {
|
|||||||
require_once "resources/footer.php";
|
require_once "resources/footer.php";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user