Dashboard - Added chart cutout and text size default settings (#6976)

This commit is contained in:
Alex
2024-05-13 13:20:33 -07:00
committed by GitHub
parent 2d3dca985d
commit 98d5e4fd67
8 changed files with 71 additions and 47 deletions

View File

@@ -42,8 +42,8 @@
$text = $language->get($_SESSION['domain']['language']['code'], 'app/call_centers');
//get http variables and set as php variables
$order_by = $_GET["order_by"];
$order = $_GET["order"];
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
//connect to the database
if (!isset($database)) {
@@ -119,7 +119,7 @@
$cmd = "callcenter_config tier del ".$row['queue_extension']."@".$_SESSION['domain_name']." ".$row['id'];
$response = event_socket::api($cmd);
}
//small sleep
usleep(200);
}
@@ -164,8 +164,8 @@
}
//get the agent details from event socket
$switch_cmd = 'callcenter_config agent list '.$agent['call_center_agent_uuid'];
$event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd));
$switch_cmd = 'callcenter_config agent list '.($agent['call_center_agent_uuid'] ?? null);
$event_socket_str = trim(event_socket_request($fp ?? null, 'api '.$switch_cmd));
$call_center_agent = csv_to_named_array($event_socket_str, '|');
//set the agent status
@@ -173,7 +173,7 @@
//update the queue status
$x = 0;
if (is_array($call_center_queues)) {
if (!empty($call_center_queues) && is_array($call_center_queues)) {
foreach ($call_center_queues as $queue) {
$call_center_queues[$x]['queue_status'] = 'Logged Out';
foreach ($call_center_tiers as $tier) {
@@ -228,7 +228,7 @@
//echo " radio_checked_value = 'Logged Out';\n";
//echo " }\n";
echo " if (radio_button.checked) { console.log('checked: '+radio_button.value) }\n";
echo " if (radio_button.value === 'Available' && agent_status === 'Available') {\n"; // radio_checked_value == 'On Break' &&
echo " if (radio_button.value === 'Available' && agent_status === 'Available') {\n"; // radio_checked_value == 'On Break' &&
//echo " radio_button.checked = true;\n";
//echo " radio_button.value = 'Available';\n";
//echo " radio_button[agent_status]\"]:checked').value == 'On Break';\n";
@@ -236,7 +236,7 @@
//echo " console.log('need to change status On Break to Available');\n";
//echo " console.log('---');\n";
echo " }\n";
echo " if (radio_button.value === 'On Break' && agent_status === 'On Break') {\n"; // radio_checked_value == 'Available' &&
echo " if (radio_button.value === 'On Break' && agent_status === 'On Break') {\n"; // radio_checked_value == 'Available' &&
//echo " radio_button.checked = true;\n";
//echo " radio_button.value = 'On Break';\n";
//echo " radio_button[agent_status]\"]:checked').value == 'On Break';\n";
@@ -259,7 +259,7 @@
//show the content
echo "<div class='action_bar sub'>\n";
echo " <div class='heading'><b>".$text['header-call_center_queues'].($agent['agent_name'] != '' ? "&nbsp;&nbsp;&nbsp;</b> Agent: <strong>".$agent['agent_name']."</strong>" : "</b>")."</div>\n";
echo " <div class='heading'><b>".$text['header-call_center_queues'].(!empty($agent['agent_name']) ? "&nbsp;&nbsp;&nbsp;</b> Agent: <strong>".$agent['agent_name']."</strong>" : "</b>")."</div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.getElementById('form_list_call_center_agent_dashboard').submit();"]);
echo " </div>\n";
@@ -274,7 +274,7 @@
echo " <th class='shrink'>".$text['label-status']."</th>\n";
echo "</tr>\n";
if (is_array($call_center_queues) && @sizeof($call_center_queues) != 0) {
if (!empty($call_center_queues) && is_array($call_center_queues) && @sizeof($call_center_queues) != 0) {
$x = 0;
foreach ($call_center_queues as $row) {
$onclick = "onclick=\"cycle('agents[".$x."][agent_status]');\"";

View File

@@ -308,7 +308,7 @@
unset($sql, $parameters, $row);
//get device lines
if (is_uuid($device_uuid)) {
if (!empty($device_uuid) && is_uuid($device_uuid)) {
$sql = "select * from v_device_lines ";
$sql .= "where device_uuid = :device_uuid ";
$parameters['device_uuid'] = $device_uuid;
@@ -317,7 +317,7 @@
}
//get the user
if (is_array($device_lines)) {
if (!empty($device_lines) && is_array($device_lines)) {
foreach ($device_lines as $row) {
if ($_SESSION['domain_name'] == $row['server_address']) {
$user_id = $row['user_id'];
@@ -331,7 +331,7 @@
$sip_profile_name = 'internal';
//get the device keys in the right order where device keys are listed after the profile keys
if (is_uuid($device_uuid)) {
if (!empty($device_uuid) && is_uuid($device_uuid)) {
$sql = "select * from v_device_keys ";
$sql .= "where (";
$sql .= "device_uuid = :device_uuid ";
@@ -356,7 +356,7 @@
}
//override profile keys with device keys
if (is_array($keys) && @sizeof($keys) != 0) {
if (!empty($keys) && is_array($keys) && @sizeof($keys) != 0) {
foreach($keys as $row) {
$id = $row['device_key_id'];
$device_keys[$id] = $row;
@@ -371,7 +371,7 @@
}
//get the vendor count and last and device information
if (is_array($device_keys) && @sizeof($device_keys) != 0) {
if (!empty($device_keys) && is_array($device_keys) && @sizeof($device_keys) != 0) {
$vendor_count = 0;
foreach($device_keys as $row) {
if ($previous_vendor != $row['device_key_vendor']) {
@@ -388,10 +388,10 @@
//add a new key
if (permission_exists('device_key_add')) {
$device_keys[$x]['device_key_category'] = $device_key_category;
$device_keys[$x]['device_key_category'] = $device_key_category ?? '';
$device_keys[$x]['device_key_id'] = '';
$device_keys[$x]['device_uuid'] = $device_uuid;
$device_keys[$x]['device_key_vendor'] = $device_key_vendor;
$device_keys[$x]['device_uuid'] = $device_uuid ?? '';
$device_keys[$x]['device_key_vendor'] = $device_key_vendor ?? '';
$device_keys[$x]['device_key_type'] = '';
$device_keys[$x]['device_key_line'] = '';
$device_keys[$x]['device_key_value'] = '';
@@ -422,7 +422,7 @@
unset($device_keys[$row['device_key_id']]);
}
//hide protected keys
if ($row['device_key_protected'] == "true") {
if (!empty($row['device_key_protected']) && $row['device_key_protected'] == "true") {
unset($device_keys[$row['device_key_id']]);
}
}
@@ -436,13 +436,13 @@
echo "<div class='action_bar sub'>\n";
echo " <div class='heading'><b>".$text['title-device_keys']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".$user_id."@".$server_address."&domain=".$server_address."&agent=".$device_key_vendor."';"]);
echo button::create(['type'=>'button','label'=>$text['button-apply'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&user=".($user_id ?? '')."@".($server_address ?? '')."&domain=".($server_address ?? '')."&agent=".($device_key_vendor ?? '')."';"]);
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>false,'onclick'=>"list_form_submit('form_list_device_keys');"]);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (!$is_included) {
if (!empty($is_included) && !$is_included) {
echo $text['description-device_keys']."\n";
echo "<br /><br />\n";
}
@@ -458,7 +458,7 @@
$device_vendor = $row['device_key_vendor'];
//set the column names
if ($previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') {
if (!empty($previous_device_key_vendor) && $previous_device_key_vendor != $row['device_key_vendor'] || $row['device_key_vendor'] == '') {
echo " <tr class='list-header'>\n";
echo " <th class='shrink'>".$text['label-device_key_id']."</th>\n";
if (!empty($row['device_key_vendor'])) {
@@ -572,9 +572,9 @@
echo " <td class='input'>\n";
echo " <input class='formfld' type='hidden' id='key_vendor_".$x."' name='device_keys[".$x."][device_key_vendor]' value=\"".$device_key_vendor."\">\n";
echo " <input class='formfld' type='hidden' id='key_category_".$x."' name='device_keys[".$x."][device_key_category]' value=\"".$device_key_category."\">\n";
echo " <input class='formfld' type='hidden' id='key_uuid_".$x."' name='device_keys[".$x."][device_uuid]' value=\"".$device_uuid."\">\n";
echo " <input class='formfld' type='hidden' id='key_key_line_".$x."' name='device_keys[".$x."][device_key_line]' value=\"".$device_key_line."\">\n";
echo " <input class='formfld' type='hidden' id='key_category_".$x."' name='device_keys[".$x."][device_key_category]' value=\"".($device_key_category ?? '')."\">\n";
echo " <input class='formfld' type='hidden' id='key_uuid_".$x."' name='device_keys[".$x."][device_uuid]' value=\"".($device_uuid ?? '')."\">\n";
echo " <input class='formfld' type='hidden' id='key_key_line_".$x."' name='device_keys[".$x."][device_key_line]' value=\"".($device_key_line ?? '')."\">\n";
echo " <select class='formfld' name='device_keys[".$x."][device_key_type]' id='key_type_".$x."'>\n";
echo " <option value=''></option>\n";
$previous_vendor = '';
@@ -611,7 +611,7 @@
echo " </td>\n";
echo " <td class='input'>\n";
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='device_keys[".$x."][device_key_label]' maxlength='255' value=\"".$row['device_key_label']."\">\n";
echo " <input type='hidden' name='device_keys[".$x."][device_profile_uuid]' value=\"".$row['device_profile_uuid']."\">\n";
echo " <input type='hidden' name='device_keys[".$x."][device_profile_uuid]' value=\"".($row['device_profile_uuid'] ?? '')."\">\n";
echo " </td>\n";
if (permission_exists('device_key_icon')) {
echo " <td class='input'>\n";

View File

@@ -55,7 +55,7 @@
echo "<div class='hud_container' ".($dashboard_details_state == "disabled" ?: "onclick=\"$('#hud_voicemail_details').slideToggle('fast'); toggle_grid_row_end('".$dashboard_name."')\"").">\n";
echo " <span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/voicemails/voicemail_messages.php'\">".$text['label-new_messages']."</span>";
if ($dashboard_chart_type == "doughnut") {
if ($row['dashboard_chart_type'] == "doughnut") {
//add doughnut chart
?>
<div class='hud_chart'><canvas id='new_messages_chart'></canvas></div>
@@ -100,7 +100,7 @@
</script>
<?php
}
if ($dashboard_chart_type == "none") {
if ($row['dashboard_chart_type'] == "none" || !isset($row['dashboard_chart_type'])) {
echo " <span class='hud_stat'>".$messages['new']."</span>";
}
echo "</div>\n";

View File

@@ -93,7 +93,7 @@
echo "<div class='hud_container' ".($dashboard_details_state == "disabled" ?: "onclick=\"$('#hud_missed_calls_details').slideToggle('fast'); toggle_grid_row_end('".$dashboard_name."')\"").">\n";
echo " <span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php?call_result=missed'\">".$text['label-missed_calls']."</span>";
if ($dashboard_chart_type == "doughnut") {
if ($row['dashboard_chart_type'] == "doughnut") {
//add doughnut chart
?>
<div class='hud_chart'><canvas id='missed_calls_chart'></canvas></div>
@@ -138,7 +138,7 @@
</script>
<?php
}
if ($dashboard_chart_type == "none") {
if ($row['dashboard_chart_type'] == "none" || !isset($row['dashboard_chart_type'])) {
echo "<span class='hud_stat'>".$num_rows."</span>";
}
echo "</div>\n";

View File

@@ -90,7 +90,7 @@
echo "<div class='hud_container' ".($dashboard_details_state == "disabled" ?: "onclick=\"$('#hud_recent_calls_details').slideToggle('fast'); toggle_grid_row_end('".$dashboard_name."')\"").">\n";
echo " <span class='hud_title' onclick=\"document.location.href='".PROJECT_PATH."/app/xml_cdr/xml_cdr.php';\">".$text['label-recent_calls']."</span>\n";
if ($dashboard_chart_type == "doughnut") {
if ($row['dashboard_chart_type'] == "doughnut") {
//add doughnut chart
?>
@@ -136,7 +136,7 @@
</script>
<?php
}
if ($dashboard_chart_type == "none") {
if ($row['dashboard_chart_type'] == "none" || !isset($row['dashboard_chart_type'])) {
echo "<span class='hud_stat'>".$num_rows."</span>";
}
echo "</div>\n";

View File

@@ -44,11 +44,14 @@
$dashboard_path = 'core/dashboard/resources/dashboard/icon.php';
$dashboard_url = '';
$dashboard_icon = '';
$dashboard_heading_text_color = '';
$dashboard_heading_background_color = '';
$dashboard_number_text_color = '';
$dashboard_groups = [];
$dashboard_column_span = '';
$dashboard_details_state = '';
$dashboard_order = '';
$dashboard_enabled = 'false';
$dashboard_enabled = $row["dashboard_enabled"] ?? 'true';
$dashboard_description = '';
$dashboard_uuid = '';
@@ -319,6 +322,17 @@
$dashboard_details_state = "expanded";
}
//add a default value to $dashboard_chart_type
if (!isset($dashboard_chart_type) && $dashboard_path == 'app/voicemails/resources/dashboard/voicemails.php') {
$dashboard_chart_type = "none";
}
if (!isset($dashboard_chart_type) && $dashboard_path == 'app/xml_cdr/resources/dashboard/missed_calls.php') {
$dashboard_chart_type = "none";
}
if (!isset($dashboard_chart_type) && $dashboard_path == 'app/xml_cdr/resources/dashboard/recent_calls.php') {
$dashboard_chart_type = "none";
}
//add an empty row
$x = is_array($dashboard_groups) ? count($dashboard_groups) : 0;
$dashboard_groups[$x]['dashboard_uuid'] = $dashboard_uuid;
@@ -752,4 +766,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -153,11 +153,11 @@
//chart variables
echo "<script>\n";
echo " var chart_text_font = '".($settings->get('theme', 'dashboard_number_text_font') ?? 'arial')."';\n";
echo " var chart_text_size = '30px';\n";
echo " var chart_text_size = '".($settings->get('theme', 'dashboard_chart_text_size') ?? '30px')."';\n";
echo " Chart.overrides.doughnut.cutout = '".($settings->get('theme', 'dashboard_chart_cutout') ?? '75%')."';\n";
echo " Chart.defaults.responsive = true;\n";
echo " Chart.defaults.maintainAspectRatio = false;\n";
echo " Chart.defaults.plugins.legend.display = false;\n";
echo " Chart.overrides.doughnut.cutout = '75%';\n";
echo "</script>\n";
// determine initial state all button to display
@@ -257,7 +257,6 @@ span.hud_stat { padding-bottom: 27px; }
echo " background-image: linear-gradient(to right, ".$detail_background_color[1]." 0%, ".$detail_background_color[0]." 30%, ".$detail_background_color[0]." 70%, ".$detail_background_color[1]." 100%);";
echo "}";
}
?>
/* Screen smaller than 575px? 1 columns */
@@ -294,13 +293,7 @@ span.hud_stat { padding-bottom: 27px; }
echo " display: none;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "hidden") {
echo "#".$dashboard_name." .hud_box .hud_expander, \n";
echo "#".$dashboard_name." .hud_box .hud_details {\n";
echo " display: none;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "disabled") {
if ($row['dashboard_details_state'] == "hidden" || $row['dashboard_details_state'] == "disabled") {
echo "#".$dashboard_name." .hud_box .hud_expander, \n";
echo "#".$dashboard_name." .hud_box .hud_details {\n";
echo " display: none;\n";
@@ -342,7 +335,7 @@ span.hud_stat { padding-bottom: 27px; }
<script>
function toggle_grid_row_end(dashboard_name) {
var widget = document.getElementById(dashboard_name);
var widget = document.getElementById(dashboard_name.toLowerCase().replace(/ /g, "_"));
var current_row_end = widget.style.gridRowEnd;
widget.style.gridRowEnd = (current_row_end == 'span 2') ? 'span 5' : 'span 2';
}
@@ -354,15 +347,16 @@ function toggle_grid_row_end(dashboard_name) {
echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
$x = 0;
foreach($dashboard as $row) {
$dashboard_name = str_replace(" ", "_", strtolower($row['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_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_heading_text_color');
$dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color');
$dashboard_details_state = $row['dashboard_details_state'];
$grid_row_end = ($dashboard_details_state == "expanded" || empty($dashboard_details_state)) ? "grid-row-end: span 5;" : "grid-row-end: span 2;";
echo "<div class='widget' style='".$grid_row_end."' id='".$dashboard_name."' draggable='false'>\n";
echo "<div class='widget' style='".$grid_row_end."' id='".str_replace(" ", "_", strtolower($row['dashboard_name']))."' draggable='false'>\n";
include($row['dashboard_path']);
echo "</div>\n";
$x++;

View File

@@ -1039,6 +1039,22 @@
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the shadow color (and opacity) of the Dashboard block number title.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "1fda5e52-d27a-45ac-b8ff-705347bc753c";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "dashboard_chart_text_size";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "30px";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the text size of the Dashboard chart number.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "093ed58c-7a8c-43e9-8ea0-c895dbed0750";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "dashboard_chart_cutout";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "75%";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the thickness of Dashboard doughnut charts in chart cutout percentage.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "caa50bb2-3db8-4c4d-9172-b60fa015a909";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "dashboard_detail_heading_text_size";