Dashboard - Add text color settings (#6950)
* Dashboard - Add text color setting
This commit is contained in:
+16
-34
@@ -72,6 +72,8 @@
|
||||
$sql .= "dashboard_uuid, \n";
|
||||
$sql .= "dashboard_name, \n";
|
||||
$sql .= "dashboard_path, \n";
|
||||
$sql .= "dashboard_heading_text_color, \n";
|
||||
$sql .= "dashboard_number_text_color, \n";
|
||||
$sql .= "dashboard_column_span, \n";
|
||||
$sql .= "dashboard_details_state, \n";
|
||||
$sql .= "dashboard_order, \n";
|
||||
@@ -127,6 +129,9 @@
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//add the settings object
|
||||
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
|
||||
|
||||
//load the header
|
||||
$document['title'] = $text['title-dashboard'];
|
||||
require_once "resources/header.php";
|
||||
@@ -138,40 +143,15 @@
|
||||
echo "<script src='/resources/chartjs/chart.min.js'></script>";
|
||||
|
||||
//chart variables
|
||||
?>
|
||||
<script>
|
||||
var chart_text_font = 'arial';
|
||||
var chart_text_size = '<?php echo $_SESSION['dashboard']['chart_text_size']['text']; ?>';
|
||||
var chart_text_color = '<?php echo $_SESSION['dashboard']['chart_text_color']['text']; ?>';
|
||||
var chart_cutout = '75%';
|
||||
|
||||
const chart_counter = {
|
||||
id: 'chart_counter',
|
||||
beforeDraw(chart, args, options){
|
||||
const {ctx, chartArea: {top, right, bottom, left, width, height} } = chart;
|
||||
ctx.font = chart_text_size + 'px ' + chart_text_font;
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillStyle = chart_text_color;
|
||||
ctx.fillText(options.chart_text, width / 2, top + (height / 2));
|
||||
ctx.save();
|
||||
}
|
||||
};
|
||||
|
||||
const chart_counter_2 = {
|
||||
id: 'chart_counter_2',
|
||||
beforeDraw(chart, args, options){
|
||||
const {ctx, chartArea: {top, right, bottom, left, width, height} } = chart;
|
||||
ctx.font = (chart_text_size - 7) + 'px ' + chart_text_font;
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillStyle = chart_text_color;
|
||||
ctx.fillText(options.chart_text + '%', width / 2, top + (height / 2) + 35);
|
||||
ctx.save();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<?php
|
||||
echo "<script>\n";
|
||||
echo " var chart_text_font = 'arial';\n";
|
||||
echo " var chart_text_size = 30;\n";
|
||||
echo " Chart.defaults.responsive = true;\n";
|
||||
echo " Chart.defaults.maintainAspectRatio = false;\n";
|
||||
echo " Chart.defaults.plugins.legend.display = false;\n";
|
||||
echo " Chart.defaults.plugins.title.display = true;\n";
|
||||
echo " Chart.overrides.doughnut.cutout = '75%';\n";
|
||||
echo "</script>\n";
|
||||
|
||||
// determine initial state all button to display
|
||||
$expanded_all = true;
|
||||
@@ -323,6 +303,8 @@
|
||||
foreach($dashboard as $row) {
|
||||
$dashboard_name = strtolower($row['dashboard_name']);
|
||||
$dashboard_name = str_replace(" ", "_", $dashboard_name);
|
||||
$dashboard_heading_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_heading_text_color');
|
||||
$dashboard_number_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color');
|
||||
echo "<div class='widget' id='".$dashboard_name."' draggable='false'>\n";
|
||||
include($row['dashboard_path']);
|
||||
echo "</div>\n";
|
||||
|
||||
Reference in New Issue
Block a user