From d4ae2952a3972fac826cb3f395efc21f4e9f75be Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 24 Apr 2024 19:49:16 -0600 Subject: [PATCH] Add Dashboard settings URL and Icon --- core/dashboard/app_config.php | 14 +++- core/dashboard/dashboard_edit.php | 76 ++++++++++++++++++- core/dashboard/index.php | 17 +++-- .../resources/classes/dashboard/icon.php | 33 ++++++++ 4 files changed, 131 insertions(+), 9 deletions(-) create mode 100644 core/dashboard/resources/classes/dashboard/icon.php diff --git a/core/dashboard/app_config.php b/core/dashboard/app_config.php index 2a50357cab..9f8f5265d0 100644 --- a/core/dashboard/app_config.php +++ b/core/dashboard/app_config.php @@ -72,6 +72,18 @@ $apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard path.'; $z++; + +$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_url'; +$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; +$apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; +$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard url.'; +$z++; +$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_icon'; +$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; +$apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; +$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard icon.'; +$z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_chart_type'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['search_by'] = ''; @@ -199,4 +211,4 @@ //default settings $y=0; -?> +?> \ No newline at end of file diff --git a/core/dashboard/dashboard_edit.php b/core/dashboard/dashboard_edit.php index ac80045f08..4163629519 100644 --- a/core/dashboard/dashboard_edit.php +++ b/core/dashboard/dashboard_edit.php @@ -18,7 +18,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2021-2023 + Portions created by the Initial Developer are Copyright (C) 2021-2024 the Initial Developer. All Rights Reserved. */ @@ -42,6 +42,8 @@ //set the defaults $dashboard_name = ''; $dashboard_path = ''; +$dashboard_url = ''; +$dashboard_icon = ''; $dashboard_groups = []; $dashboard_column_span = ''; $dashboard_details_state = ''; @@ -64,6 +66,8 @@ if (!empty($_POST)) { $dashboard_name = $_POST["dashboard_name"] ?? ''; $dashboard_path = $_POST["dashboard_path"] ?? ''; +$dashboard_icon = $_POST["dashboard_icon"] ?? ''; +$dashboard_url = $_POST["dashboard_url"] ?? ''; $dashboard_groups = $_POST["dashboard_groups"] ?? ''; $dashboard_chart_type = $_POST["dashboard_chart_type"] ?? ''; $dashboard_heading_background_color = $_POST["dashboard_heading_background_color"] ?? ''; @@ -168,6 +172,10 @@ $array['dashboard'][0]['dashboard_uuid'] = $dashboard_uuid; $array['dashboard'][0]['dashboard_name'] = $dashboard_name; $array['dashboard'][0]['dashboard_path'] = $dashboard_path; + +$array['dashboard'][0]['dashboard_icon'] = $dashboard_icon; +$array['dashboard'][0]['dashboard_url'] = $dashboard_url; + $array['dashboard'][0]['dashboard_chart_type'] = $dashboard_chart_type; $array['dashboard'][0]['dashboard_heading_background_color'] = $dashboard_heading_background_color; $array['dashboard'][0]['dashboard_heading_text_color'] = $dashboard_heading_text_color; @@ -218,6 +226,10 @@ $sql .= " dashboard_uuid, "; $sql .= " dashboard_name, "; $sql .= " dashboard_path, "; + +$sql .= " dashboard_icon, "; +$sql .= " dashboard_url, "; + $sql .= " dashboard_chart_type, "; $sql .= " dashboard_heading_background_color, "; $sql .= " dashboard_heading_text_color, "; @@ -236,6 +248,10 @@ if (is_array($row) && @sizeof($row) != 0) { $dashboard_name = $row["dashboard_name"]; $dashboard_path = $row["dashboard_path"]; + + $dashboard_icon = $row["dashboard_icon"]; + $dashboard_url = $row["dashboard_url"]; + $dashboard_chart_type = $row["dashboard_chart_type"]; $dashboard_heading_background_color = $row["dashboard_heading_background_color"]; $dashboard_heading_text_color = $row["dashboard_heading_text_color"]; @@ -374,6 +390,62 @@ echo "\n"; echo "\n"; +echo "\n"; +echo "\n"; +echo " ".$text['label-link']."\n"; +echo "\n"; +echo "\n"; +echo " \n"; +echo "
\n"; +echo $text['description-dashboard_url']."\n"; +echo "\n"; +echo "\n"; + +echo " "; +echo " ".$text['label-icon'].""; +echo " "; +if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fas_icons.php')) { + include 'resources/fontawesome/fas_icons.php'; + if (is_array($font_awesome_solid_icons) && @sizeof($font_awesome_solid_icons) != 0) { + // rebuild and sort array + foreach ($font_awesome_solid_icons as $i => $icon_class) { + $icon_label = str_replace('fa-', '', $icon_class); + $icon_label = str_replace('-', ' ', $icon_label); + $icon_label = ucwords($icon_label); + $icons[$icon_class] = $icon_label; + } + asort($icons, SORT_STRING); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo ""; + } +} +else { + echo " "; +} +echo " "; +echo " "; + + + echo "\n"; echo "\n"; echo " ".$text['label-dashboard_groups']."\n"; @@ -603,4 +675,4 @@ //include the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/core/dashboard/index.php b/core/dashboard/index.php index 3fe3cd62fe..e19fc97582 100644 --- a/core/dashboard/index.php +++ b/core/dashboard/index.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2022-2023 + Portions created by the Initial Developer are Copyright (C) 2022-2024 the Initial Developer. All Rights Reserved. Contributor(s): @@ -72,6 +72,8 @@ $sql .= "dashboard_uuid, \n"; $sql .= "dashboard_name, \n"; $sql .= "dashboard_path, \n"; + $sql .= "dashboard_url, \n"; + $sql .= "dashboard_icon, \n"; $sql .= "dashboard_chart_type, \n"; $sql .= "dashboard_heading_background_color, \n"; $sql .= "dashboard_heading_text_color, \n"; @@ -108,6 +110,8 @@ if ($widget == $dashboard_name) { $dashboard_order = $dashboard_order + 10; $array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name']; + $array['dashboard'][$x]['dashboard_url'] = $row['dashboard_url']; + $array['dashboard'][$x]['dashboard_icon'] = $row['dashboard_icon']; $array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid']; $array['dashboard'][$x]['dashboard_order'] = $dashboard_order; $x++; @@ -303,15 +307,16 @@ echo "
\n"; $x = 0; foreach($dashboard as $row) { - $dashboard_name = strtolower($row['dashboard_name']); - $dashboard_name = str_replace(" ", "_", $dashboard_name); + $dashboard_name = $row['dashboard_name']; + $dashboard_icon = $row['dashboard_icon'] ?? ''; + $dashboard_url = $row['dashboard_url'] ?? ''; $dashboard_chart_type = $row['dashboard_chart_type'] ?? 'doughnut'; $dashboard_heading_background_color = $row['dashboard_heading_background_color'] ?? $settings->get('theme', 'dashboard_heading_background_color'); $dashboard_heading_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_heading_text_color'); $dashboard_number_background_color = $row['dashboard_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color'); $dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color'); - echo "
\n"; - include($row['dashboard_path']); + echo "
\n"; + include($row['dashboard_path']); echo "
\n"; $x++; } @@ -416,4 +421,4 @@ //show the footer require_once "resources/footer.php"; -?> +?> \ No newline at end of file diff --git a/core/dashboard/resources/classes/dashboard/icon.php b/core/dashboard/resources/classes/dashboard/icon.php new file mode 100644 index 0000000000..f09c1a0587 --- /dev/null +++ b/core/dashboard/resources/classes/dashboard/icon.php @@ -0,0 +1,33 @@ +get($_SESSION['domain']['language']['code'], 'core/dashboard'); + +//dashboard icon + echo "
\n"; + + echo "
\n"; + echo " ". $dashboard_name . ""; // (isset($text['label-'.$dashboard_name])) ? $text['label-'.$dashboard_name] : $dashboard_name + echo " \n"; + echo "
\n"; + + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "  \n"; + echo "
\n"; + //echo "".$text['label-view_all']."\n"; + echo "
"; + //$n++; + + echo ""; + echo "
\n"; + +?> \ No newline at end of file