Add ability to create multiple dashboards (#7483)

* Add ability to create multiple dashboards

* Create dashboard_widget_list.php

* Create dashboard_widget_edit.php

* Update dashboard_edit.php

* Update dashboard_config_json.php

* Update dashboard.php

* Update app_languages.php

* Update app_defaults.php

* Update app_config.php

* Update dashboard.php

* Create config.php

* Update content.php

* Update icon.php

* Update parent.php

* Update template.php

* Update config.php

* Update config.php

* Update domains.php

* Update config.php

* Update active_calls.php

* Update config.php

* Update config.php

* Update config.php

* Update config.php

* Update call_forward.php

* Update config.php

* Update config.php

* Update config.php

* Update config.php

* Update config.php

* Update domain_limits.php

* Update caller_id.php

* Update config.php

* Update config.php

* Update config.php

* Update config.php

* Update config.php

* Update registrations.php

* Update ring_group_forward.php

* Update config.php

* Update config.php

* Update switch_status.php

* Update config.php

* Update system_counts.php

* Update system_cpu_status.php

* Update system_disk_usage.php

* Update system_services.php

* Update system_status.php

* Update config.php

* Update config.php

* Update voicemails.php

* Update config.php

* Update missed_calls.php

* Update recent_calls.php

* Update dashboard_widget_edit.php

* Update app_languages.php

* Update dashboard_widget_edit.php

* Update index.php

* Update parent.php
This commit is contained in:
Alex
2025-09-08 16:33:29 -07:00
committed by GitHub
parent a7f4712ceb
commit e8681737dc
54 changed files with 6181 additions and 4812 deletions

View File

@@ -27,191 +27,62 @@
$apps[$x]['permissions'][$y]['name'] = 'dashboard_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_group_view';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_domain';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_group_add';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_group_edit';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_group_delete';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_group_all';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_parent_uuid';
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_group_view';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_group_add';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_group_edit';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_group_delete';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'dashboard_widget_parent_uuid';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
//dashboard
//dashboards
$y = 0;
$apps[$x]['db'][$y]['table']['name'] = 'v_dashboard';
$apps[$x]['db'][$y]['table']['name'] = 'v_dashboards';
$apps[$x]['db'][$y]['table']['parent'] = '';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_parent_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_name';
$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 name.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_path';
$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 path.';
$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_icon_color';
$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 color.';
$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_target';
$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 target.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_width';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard width.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_height';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard height.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_content';
$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 content.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_content_text_align';
$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'] = 'Select the dashboard content text alignment.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_content_details';
$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 content details.';
$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'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the chart type.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_label_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the label enabled';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'dashboard_label_text_color';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'dashboard_heading_text_color';
$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 label text color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'dashboard_label_text_color_hover';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'dashboard_heading_text_color_hover';
$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 label text color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'dashboard_label_background_color';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'dashboard_heading_background_color';
$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 label background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'dashboard_label_background_color_hover';
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'dashboard_heading_background_color_hover';
$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 label background color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_number_text_color';
$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 number text color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_number_text_color_hover';
$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 number text color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_number_background_color';
$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 number background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_background_color';
$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 background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_background_color_hover';
$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 background color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_detail_background_color';
$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 detail background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_background_gradient_style';
$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'] = 'Select a background gradient style.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_background_gradient_angle';
$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'] = 'Select a background gradient angle.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_column_span';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard column span.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_row_span';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard row span.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_details_state';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'expanded';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the default state of the widget details.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_order';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the dashboard order.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
@@ -246,24 +117,232 @@
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
//dashboard groups
$y = 5;
$apps[$x]['db'][$y]['table']['name'] = 'v_dashboard_groups';
$apps[$x]['db'][$y]['table']['parent'] = 'v_dashboard';
//dashboard widgets
$y++;
$apps[$x]['db'][$y]['table']['name'] = 'v_dashboard_widgets';
$apps[$x]['db'][$y]['table']['parent'] = '';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_group_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_dashboard';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'dashboard_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_widget_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_widget_parent_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_name';
$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 widget name.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_path';
$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 widget path.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_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 widget icon.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_icon_color';
$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 widget icon color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_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 widget url.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_target';
$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 widget target.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_width';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget width.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_height';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget height.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_content';
$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 widget content.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_content_text_align';
$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'] = 'Select the dashboard content text alignment.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_content_details';
$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 widget content details.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_chart_type';
$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 chart type.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_label_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the label enabled';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_label_text_color';
$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 label text color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_label_text_color_hover';
$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 label text color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_label_background_color';
$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 label background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_label_background_color_hover';
$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 label background color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_number_text_color';
$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 number text color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_number_text_color_hover';
$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 number text color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_number_background_color';
$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 number background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_background_color';
$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 background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_background_color_hover';
$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 background color hover.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_detail_background_color';
$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 detail background color.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_background_gradient_style';
$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'] = 'Select a background gradient style.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_background_gradient_angle';
$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'] = 'Select a background gradient angle.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_column_span';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget column span.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_row_span';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget row span.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_details_state';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'expanded';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Set the default state of the widget details.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_order';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = '';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget order.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_enabled';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'boolean';
$apps[$x]['db'][$y]['fields'][$z]['toggle'] = ['true','false'];
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the widget enabled.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'widget_description';
$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 widget description.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_date";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_user";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_date";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'date';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "update_user";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
//dashboard widget groups
$y++;
$apps[$x]['db'][$y]['table']['name'] = 'v_dashboard_widget_groups';
$apps[$x]['db'][$y]['table']['parent'] = 'v_dashboard_widgets';
$z = 0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_widget_group_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'dashboard_widget_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_dashboard_widgets';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'dashboard_widget_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'group_uuid';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';

View File

@@ -7,6 +7,133 @@ if ($domains_processed == 1) {
unset($array);
}
//migrate widget data
$sql = "select * from v_dashboard_widgets ";
$new_table = $database->select($sql, null, 'all');
unset($sql, $parameters);
$sql = "select * from v_dashboard ";
$old_table = $database->select($sql, null, 'all');
unset($sql, $parameters);
if (empty($new_table) && !empty($old_table)) {
$sql = "INSERT INTO v_dashboard_widgets ( ";
$sql .= " dashboard_uuid, ";
$sql .= " dashboard_widget_uuid, ";
$sql .= " dashboard_widget_parent_uuid, ";
$sql .= " widget_name, ";
$sql .= " widget_path, ";
$sql .= " widget_icon, ";
$sql .= " widget_icon_color, ";
$sql .= " widget_url, ";
$sql .= " widget_target, ";
$sql .= " widget_width, ";
$sql .= " widget_height, ";
$sql .= " widget_content, ";
$sql .= " widget_content_text_align, ";
$sql .= " widget_content_details, ";
$sql .= " widget_chart_type, ";
$sql .= " widget_label_enabled, ";
$sql .= " widget_label_text_color, ";
$sql .= " widget_label_text_color_hover, ";
$sql .= " widget_label_background_color, ";
$sql .= " widget_label_background_color_hover, ";
$sql .= " widget_number_text_color, ";
$sql .= " widget_number_text_color_hover, ";
$sql .= " widget_number_background_color, ";
$sql .= " widget_background_color, ";
$sql .= " widget_background_color_hover, ";
$sql .= " widget_detail_background_color, ";
$sql .= " widget_background_gradient_style, ";
$sql .= " widget_background_gradient_angle, ";
$sql .= " widget_column_span, ";
$sql .= " widget_row_span, ";
$sql .= " widget_details_state, ";
$sql .= " widget_order, ";
$sql .= " widget_enabled, ";
$sql .= " widget_description, ";
$sql .= " insert_date, ";
$sql .= " insert_user, ";
$sql .= " update_date, ";
$sql .= " update_user ";
$sql .= ") ";
$sql .= "SELECT ";
$sql .= " '3e2cbaa4-2bec-41b2-a626-999a59b8b19c', ";
$sql .= " dashboard_uuid, ";
$sql .= " dashboard_parent_uuid, ";
$sql .= " dashboard_name, ";
$sql .= " dashboard_path, ";
$sql .= " dashboard_icon, ";
$sql .= " dashboard_icon_color, ";
$sql .= " dashboard_url, ";
$sql .= " dashboard_target, ";
$sql .= " dashboard_width, ";
$sql .= " dashboard_height, ";
$sql .= " dashboard_content, ";
$sql .= " dashboard_content_text_align, ";
$sql .= " dashboard_content_details, ";
$sql .= " dashboard_chart_type, ";
$sql .= " dashboard_label_enabled, ";
$sql .= " dashboard_label_text_color, ";
$sql .= " dashboard_label_text_color_hover, ";
$sql .= " dashboard_label_background_color, ";
$sql .= " dashboard_label_background_color_hover, ";
$sql .= " dashboard_number_text_color, ";
$sql .= " dashboard_number_text_color_hover, ";
$sql .= " dashboard_number_background_color, ";
$sql .= " dashboard_background_color, ";
$sql .= " dashboard_background_color_hover, ";
$sql .= " dashboard_detail_background_color, ";
$sql .= " dashboard_background_gradient_style, ";
$sql .= " dashboard_background_gradient_angle, ";
$sql .= " dashboard_column_span, ";
$sql .= " dashboard_row_span, ";
$sql .= " dashboard_details_state, ";
$sql .= " dashboard_order, ";
$sql .= " dashboard_enabled, ";
$sql .= " dashboard_description, ";
$sql .= " insert_date, ";
$sql .= " insert_user, ";
$sql .= " update_date, ";
$sql .= " update_user ";
$sql .= "FROM v_dashboard; ";
$database->execute($sql);
unset($sql, $parameters);
}
$sql = "select * from v_dashboard_widget_groups ";
$new_groups = $database->select($sql, null, 'all');
unset($sql, $parameters);
$sql = "select * from v_dashboard_groups ";
$old_groups = $database->select($sql, null, 'all');
unset($sql, $parameters);
if (empty($new_groups) && !empty($old_groups)) {
$sql = "INSERT INTO v_dashboard_widget_groups ( ";
$sql .= " dashboard_uuid, ";
$sql .= " dashboard_widget_group_uuid, ";
$sql .= " dashboard_widget_uuid, ";
$sql .= " group_uuid, ";
$sql .= " insert_date, ";
$sql .= " insert_user, ";
$sql .= " update_date, ";
$sql .= " update_user ";
$sql .= ") ";
$sql .= "SELECT ";
$sql .= " '3e2cbaa4-2bec-41b2-a626-999a59b8b19c', ";
$sql .= " dashboard_group_uuid, ";
$sql .= " dashboard_uuid, ";
$sql .= " group_uuid, ";
$sql .= " insert_date, ";
$sql .= " insert_user, ";
$sql .= " update_date, ";
$sql .= " update_user ";
$sql .= "FROM v_dashboard_groups; ";
$database->execute($sql);
unset($sql, $parameters);
}
//make the default groups exist
$group = new groups;
$group->defaults();
@@ -16,15 +143,67 @@ if ($domains_processed == 1) {
$sql .= "where domain_uuid is null ";
$groups = $database->select($sql, null, 'all');
//get the dashboards
$sql = "select ";
$sql .= "domain_uuid, ";
$sql .= "dashboard_uuid, ";
$sql .= "dashboard_name, ";
$sql .= "cast(dashboard_enabled as text), ";
$sql .= "dashboard_description, ";
$sql .= "domain_uuid ";
$sql .= "from v_dashboards ";
$dashboard_widgets = $database->select($sql, null, 'all');
unset($sql, $parameters);
//add the dashboards
$dashboard_config_file = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/core/dashboard/resources/dashboard/config.php');
$x = 0;
foreach($dashboard_config_file as $file) {
include ($file);
$x++;
}
$dashboards = $array;
unset($array);
//build the array
$x = 0;
foreach($dashboards['dashboards'] as $row) {
//check if the dashboard is already in the database
$dashboard_found = false;
foreach($dashboard_widgets as $dashboard_widget) {
if ($dashboard_widget['dashboard_uuid'] == $row['dashboard_uuid']) {
$dashboard_found = true;
}
}
//add the dashboard to the array
if (!$dashboard_found) {
$array['dashboards'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboards'][$x]['dashboard_name'] = $row['dashboard_name'];
$array['dashboards'][$x]['dashboard_enabled'] = $row['dashboard_enabled'];
$array['dashboards'][$x]['dashboard_description'] = $row['dashboard_description'];
$x++;
}
}
//exit;
//save the data
if (!empty($array)) {
$database->app_name = 'dashboard';
$database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
$database->save($array, false);
}
unset($array);
//get the dashboard
$sql = "select ";
$sql .= "dashboard_uuid, ";
$sql .= "dashboard_name, ";
$sql .= "dashboard_path, ";
$sql .= "dashboard_order, ";
$sql .= "cast(dashboard_enabled as text), ";
$sql .= "dashboard_description ";
$sql .= "from v_dashboard ";
$sql .= "dashboard_widget_uuid, ";
$sql .= "widget_name, ";
$sql .= "widget_path, ";
$sql .= "widget_order, ";
$sql .= "cast(widget_enabled as text), ";
$sql .= "widget_description ";
$sql .= "from v_dashboard_widgets ";
$dashboard_widgets = $database->select($sql, null, 'all');
unset($sql, $parameters);
@@ -40,55 +219,58 @@ if ($domains_processed == 1) {
//build the array
$x = 0;
foreach($widgets['dashboard'] as $row) {
foreach($widgets['dashboard_widgets'] as $row) {
//check if the dashboard widget is already in the database
$dashboard_found = false;
$widget_found = false;
foreach($dashboard_widgets as $dashboard_widget) {
if ($dashboard_widget['dashboard_uuid'] == $row['dashboard_uuid']) {
$dashboard_found = true;
if ($dashboard_widget['dashboard_widget_uuid'] == $row['dashboard_widget_uuid']) {
$widget_found = true;
}
}
//add the dashboard widget to the array
if (!$dashboard_found) {
$array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name'];
$array['dashboard'][$x]['dashboard_path'] = $row['dashboard_path'];
$array['dashboard'][$x]['dashboard_chart_type'] = $row['dashboard_chart_type'];
$array['dashboard'][$x]['dashboard_column_span'] = $row['dashboard_column_span'] ?? 1;
$array['dashboard'][$x]['dashboard_row_span'] = $row['dashboard_row_span'] ?? 1;
$array['dashboard'][$x]['dashboard_details_state'] = $row['dashboard_details_state'];
$array['dashboard'][$x]['dashboard_order'] = $row['dashboard_order'];
$array['dashboard'][$x]['dashboard_enabled'] = $row['dashboard_enabled'];
$array['dashboard'][$x]['dashboard_description'] = $row['dashboard_description'];
$array['dashboard'][$x]['dashboard_label_enabled'] = $row['dashboard_label_enabled'] ?? 'true';
if (!empty($row['dashboard_label_text_color'])) { $array['dashboard'][$x]['dashboard_label_text_color'] = $row['dashboard_label_text_color']; }
if (!empty($row['dashboard_label_text_color_hover'])) { $array['dashboard'][$x]['dashboard_label_text_color_hover'] = $row['dashboard_label_text_color_hover']; }
if (!empty($row['dashboard_number_text_color'])) { $array['dashboard'][$x]['dashboard_number_text_color'] = $row['dashboard_number_text_color']; }
if (!empty($row['dashboard_number_text_color_hover'])) { $array['dashboard'][$x]['dashboard_number_text_color_hover'] = $row['dashboard_number_text_color_hover']; }
if (!empty($row['dashboard_number_background_color'])) { $array['dashboard'][$x]['dashboard_number_background_color'] = $row['dashboard_number_background_color']; }
if (!empty($row['dashboard_icon'])) { $array['dashboard'][$x]['dashboard_icon'] = $row['dashboard_icon']; }
if (!empty($row['dashboard_icon_color'])) { $array['dashboard'][$x]['dashboard_icon_color'] = $row['dashboard_icon_color']; }
if (!empty($row['dashboard_url'])) { $array['dashboard'][$x]['dashboard_url'] = $row['dashboard_url']; }
if (!empty($row['dashboard_width'])) { $array['dashboard'][$x]['dashboard_width'] = $row['dashboard_width']; }
if (!empty($row['dashboard_height'])) { $array['dashboard'][$x]['dashboard_height'] = $row['dashboard_height']; }
if (!empty($row['dashboard_target'])) { $array['dashboard'][$x]['dashboard_target'] = $row['dashboard_target']; }
if (!empty($row['dashboard_label_background_color'])) { $array['dashboard'][$x]['dashboard_label_background_color'] = $row['dashboard_label_background_color']; }
if (!empty($row['dashboard_label_background_color_hover'])) { $array['dashboard'][$x]['dashboard_label_background_color_hover'] = $row['dashboard_label_background_color_hover']; }
if (!empty($row['dashboard_background_color'])) { $array['dashboard'][$x]['dashboard_background_color'] = $row['dashboard_background_color']; }
if (!empty($row['dashboard_background_color_hover'])) { $array['dashboard'][$x]['dashboard_background_color_hover'] = $row['dashboard_background_color_hover']; }
if (!empty($row['dashboard_detail_background_color'])) { $array['dashboard'][$x]['dashboard_detail_background_color'] = $row['dashboard_detail_background_color']; }
if (!empty($row['dashboard_content'])) { $array['dashboard'][$x]['dashboard_content'] = $row['dashboard_content']; }
if (!empty($row['dashboard_content_details'])) { $array['dashboard'][$x]['dashboard_content_details'] = $row['dashboard_content_details']; }
if (!$widget_found) {
$array['dashboard_widgets'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboard_widgets'][$x]['dashboard_widget_uuid'] = $row['dashboard_widget_uuid'];
$array['dashboard_widgets'][$x]['widget_name'] = $row['widget_name'];
$array['dashboard_widgets'][$x]['widget_path'] = $row['widget_path'];
$array['dashboard_widgets'][$x]['widget_chart_type'] = $row['widget_chart_type'];
$array['dashboard_widgets'][$x]['widget_column_span'] = $row['widget_column_span'] ?? 1;
$array['dashboard_widgets'][$x]['widget_row_span'] = $row['widget_row_span'] ?? 1;
$array['dashboard_widgets'][$x]['widget_details_state'] = $row['widget_details_state'];
$array['dashboard_widgets'][$x]['widget_order'] = $row['widget_order'];
$array['dashboard_widgets'][$x]['widget_enabled'] = $row['widget_enabled'];
$array['dashboard_widgets'][$x]['widget_description'] = $row['widget_description'];
$array['dashboard_widgets'][$x]['widget_label_enabled'] = $row['widget_label_enabled'] ?? 'true';
if (!empty($row['widget_label_text_color'])) { $array['dashboard_widgets'][$x]['widget_label_text_color'] = $row['widget_label_text_color']; }
if (!empty($row['widget_label_text_color_hover'])) { $array['dashboard_widgets'][$x]['widget_label_text_color_hover'] = $row['widget_label_text_color_hover']; }
if (!empty($row['widget_number_text_color'])) { $array['dashboard_widgets'][$x]['widget_number_text_color'] = $row['widget_number_text_color']; }
if (!empty($row['widget_number_text_color_hover'])) { $array['dashboard_widgets'][$x]['widget_number_text_color_hover'] = $row['widget_number_text_color_hover']; }
if (!empty($row['widget_number_background_color'])) { $array['dashboard_widgets'][$x]['widget_number_background_color'] = $row['widget_number_background_color']; }
if (!empty($row['widget_icon'])) { $array['dashboard_widgets'][$x]['widget_icon'] = $row['widget_icon']; }
if (!empty($row['widget_icon_color'])) { $array['dashboard_widgets'][$x]['widget_icon_color'] = $row['widget_icon_color']; }
if (!empty($row['widget_url'])) { $array['dashboard_widgets'][$x]['widget_url'] = $row['widget_url']; }
if (!empty($row['widget_width'])) { $array['dashboard_widgets'][$x]['widget_width'] = $row['widget_width']; }
if (!empty($row['widget_height'])) { $array['dashboard_widgets'][$x]['widget_height'] = $row['widget_height']; }
if (!empty($row['widget_target'])) { $array['dashboard_widgets'][$x]['widget_target'] = $row['widget_target']; }
if (!empty($row['widget_label_background_color'])) { $array['dashboard_widgets'][$x]['widget_label_background_color'] = $row['widget_label_background_color']; }
if (!empty($row['widget_label_background_color_hover'])) { $array['dashboard_widgets'][$x]['widget_label_background_color_hover'] = $row['widget_label_background_color_hover']; }
if (!empty($row['widget_background_color'])) { $array['dashboard_widgets'][$x]['widget_background_color'] = $row['widget_background_color']; }
if (!empty($row['widget_background_color_hover'])) { $array['dashboard_widgets'][$x]['widget_background_color_hover'] = $row['widget_background_color_hover']; }
if (!empty($row['widget_detail_background_color'])) { $array['dashboard_widgets'][$x]['widget_detail_background_color'] = $row['widget_detail_background_color']; }
if (!empty($row['widget_content'])) { $array['dashboard_widgets'][$x]['widget_content'] = $row['widget_content']; }
if (!empty($row['widget_content_details'])) { $array['dashboard_widgets'][$x]['widget_content_details'] = $row['widget_content_details']; }
if (!empty($row['dashboard_widget_parent_uuid'])) { $array['dashboard_widgets'][$x]['dashboard_widget_parent_uuid'] = $row['dashboard_widget_parent_uuid']; }
$y = 0;
if (!empty($row['dashboard_groups'])) {
foreach ($row['dashboard_groups'] as $row) {
if (!empty($row['dashboard_widget_groups'])) {
foreach ($row['dashboard_widget_groups'] as $row) {
if (isset($row['group_name'])) {
foreach($groups as $field) {
if ($row['group_name'] == $field['group_name']) {
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = $row['dashboard_group_uuid'];
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboard'][$x]['dashboard_groups'][$y]['group_uuid'] = $field['group_uuid'];
$array['dashboard_widgets'][$x]['dashboard_widget_groups'][$y]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboard_widgets'][$x]['dashboard_widget_groups'][$y]['dashboard_widget_group_uuid'] = $row['dashboard_widget_group_uuid'];
$array['dashboard_widgets'][$x]['dashboard_widget_groups'][$y]['dashboard_widget_uuid'] = $row['dashboard_widget_uuid'];
$array['dashboard_widgets'][$x]['dashboard_widget_groups'][$y]['group_uuid'] = $field['group_uuid'];
}
}
$y++;
@@ -118,10 +300,10 @@ if ($domains_processed == 1) {
$p->delete('dashboard_group_add', 'temp');
//update dashboard icons to be prefixed with v6.x font awesome style class name (e.g. 'fa-solid ')
$queries[] = "update v_dashboard set dashboard_icon = concat('fa-solid ', dashboard_icon) where dashboard_icon is not null and dashboard_icon not like 'fa-solid fa-%' and dashboard_icon not like 'fa-regular fa-%' and dashboard_icon not like 'fa-brands fa-%' ";
$queries[] = "update v_dashboard_widgets set widget_icon = concat('fa-solid ', widget_icon) where widget_icon is not null and widget_icon not like 'fa-solid fa-%' and widget_icon not like 'fa-regular fa-%' and widget_icon not like 'fa-brands fa-%' ";
//simplify the dashboard path
$queries[] = "update v_dashboard set dashboard_path = regexp_replace(dashboard_path, 'app/|core/|resources/dashboard/|\.php', '', 'g') where dashboard_path like '%.php';";
$queries[] = "update v_dashboard_widgets set widget_path = regexp_replace(widget_path, 'app/|core/|resources/dashboard/|\.php', '', 'g') where widget_path like '%.php';";
//execute array of queries
foreach ($queries as $sql) {

File diff suppressed because it is too large Load Diff

View File

@@ -38,33 +38,36 @@
$language = new text;
$text = $language->get();
//set additional variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get the http post data
if (!empty($_POST['dashboard'])) {
if (!empty($_POST['dashboards'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$dashboard = $_POST['dashboard'];
$dashboards = $_POST['dashboards'];
}
//process the http post data by action
if (!empty($action) && is_array($dashboard) && @sizeof($dashboard) != 0) {
if (!empty($action) && is_array($dashboards) && @sizeof($dashboards) != 0) {
switch ($action) {
case 'copy':
if (permission_exists('dashboard_add')) {
$obj = new dashboard;
$obj->copy($dashboard);
$obj->copy($dashboards);
}
break;
case 'toggle':
if (permission_exists('dashboard_edit')) {
$obj = new dashboard;
$obj->toggle($dashboard);
$obj->toggle($dashboards);
}
break;
case 'delete':
if (permission_exists('dashboard_delete')) {
$obj = new dashboard;
$obj->delete($dashboard);
$obj->delete($dashboards);
}
break;
}
@@ -78,20 +81,29 @@
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
//add the search
if (isset($_GET["search"])) {
$search = strtolower($_GET["search"]);
}
//get the count
$sql = "select count(dashboard_uuid) ";
$sql .= "from v_dashboard ";
if (isset($search)) {
$sql .= "where (\n";
$sql .= " dashboard_name = :search \n";
$sql .= " or dashboard_description = :search \n";
$sql .= "from v_dashboards ";
$sql .= "where true \n";
if ($show == "all" && permission_exists('dashboard_all')) {
//$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
else {
$sql .= "and ( ";
$sql .= " domain_uuid = :domain_uuid ";
if (permission_exists('dashboard_domain')) {
$sql .= " or domain_uuid is null ";
}
$sql .= ") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (isset($_GET["search"])) {
$sql .= "and (\n";
$sql .= " lower(dashboard_name) like :search \n";
$sql .= " or lower(dashboard_description) like :search \n";
$sql .= ")\n";
$parameters['search'] = '%'.$search.'%';
$parameters['search'] = '%'.strtolower($search).'%';
}
$database = new database;
$num_rows = $database->select($sql, $parameters ?? null, 'column');
@@ -99,34 +111,37 @@
//get the list
$sql = "select \n";
$sql .= "domain_uuid, \n";
$sql .= "dashboard_uuid, \n";
$sql .= "dashboard_name, \n";
$sql .= "dashboard_icon, \n";
$sql .= "( \n";
$sql .= " select \n";
$sql .= " string_agg(g.group_name, ', ') \n";
$sql .= " from \n";
$sql .= " v_dashboard_groups as dg, \n";
$sql .= " v_groups as g \n";
$sql .= " where \n";
$sql .= " dg.group_uuid = g.group_uuid \n";
$sql .= " and d.dashboard_uuid = dg.dashboard_uuid \n";
$sql .= ") AS dashboard_groups, \n";
$sql .= "dashboard_order, \n";
$sql .= "cast(dashboard_enabled as text), \n";
$sql .= "dashboard_description \n";
$sql .= "from v_dashboard as d \n";
$sql .= "from v_dashboards as d \n";
$sql .= "where true \n";
if ($show == "all" && permission_exists('dashboard_all')) {
//$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
else {
$sql .= "and ( ";
$sql .= " domain_uuid = :domain_uuid ";
if (permission_exists('dashboard_domain')) {
$sql .= " or domain_uuid is null ";
}
$sql .= ") ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
if (isset($_GET["search"])) {
$sql .= "where (\n";
$sql .= "and (\n";
$sql .= " lower(dashboard_name) like :search \n";
$sql .= " or lower(dashboard_description) like :search \n";
$sql .= ")\n";
$parameters['search'] = '%'.strtolower($search).'%';
}
$sql .= order_by($order_by, $order, 'dashboard_order, dashboard_name', 'asc');
$sql .= order_by($order_by, $order, 'dashboard_name', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$database = new database;
$dashboard = $database->select($sql, $parameters ?? null, 'all');
$dashboards = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//create token
@@ -134,26 +149,34 @@
$token = $object->create($_SERVER['PHP_SELF']);
//additional includes
$document['title'] = $text['title-dashboard'];
$document['title'] = $text['title-dashboards'];
require_once "resources/header.php";
//show the content
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-dashboard']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='heading'><b>".$text['title-dashboards']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','name'=>'btn_back','style'=>'margin-right: 15px;','link'=>'index.php']);
if (permission_exists('dashboard_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard_edit.php']);
}
if (permission_exists('dashboard_add') && !empty($dashboard)) {
if (permission_exists('dashboard_add') && !empty($dashboards)) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display:none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('dashboard_edit') && !empty($dashboard)) {
if (permission_exists('dashboard_edit') && !empty($dashboards)) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display:none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('dashboard_delete') && !empty($dashboard)) {
if (permission_exists('dashboard_delete') && !empty($dashboards)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display:none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
if (permission_exists('domain_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?type='.urlencode($destination_type ?? '').'&show=all'.($search != '' ? "&search=".urlencode($search ?? '') : null)]);
}
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search ?? '')."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$settings->get('theme', 'button_icon_search'),'type'=>'submit','id'=>'btn_search']);
@@ -166,13 +189,13 @@
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('dashboard_add') && !empty($dashboard)) {
if (permission_exists('dashboard_add') && !empty($dashboards)) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('dashboard_edit') && !empty($dashboard)) {
if (permission_exists('dashboard_edit') && !empty($dashboards)) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('dashboard_delete') && !empty($dashboard)) {
if (permission_exists('dashboard_delete') && !empty($dashboards)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
@@ -185,13 +208,13 @@
echo "<tr class='list-header'>\n";
if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($dashboard) ?: "style='visibility: hidden;'").">\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($dashboards) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($show == 'all' && permission_exists('dashboard_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo th_order_by('dashboard_name', $text['label-dashboard_name'], $order_by, $order);
echo th_order_by('dashboard_groups', $text['label-dashboard_groups'], $order_by, $order);
echo th_order_by('dashboard_icon', $text['label-icons'], $order_by, $order);
echo th_order_by('dashboard_order', $text['label-dashboard_order'], $order_by, $order);
echo th_order_by('dashboard_enabled', $text['label-dashboard_enabled'], $order_by, $order, null, "class='center'");
echo " <th class='hide-sm-dn'>".$text['label-dashboard_description']."</th>\n";
if (permission_exists('dashboard_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
@@ -199,9 +222,9 @@
}
echo "</tr>\n";
if (!empty($dashboard)) {
if (!empty($dashboards)) {
$x = 0;
foreach ($dashboard as $row) {
foreach ($dashboards as $row) {
$list_row_url = '';
if (permission_exists('dashboard_edit')) {
$list_row_url = "dashboard_edit.php?id=".urlencode($row['dashboard_uuid']);
@@ -212,10 +235,18 @@
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('dashboard_add') || permission_exists('dashboard_edit') || permission_exists('dashboard_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='dashboard[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='dashboard[$x][dashboard_uuid]' value='".escape($row['dashboard_uuid'])."' />\n";
echo " <input type='checkbox' name='dashboards[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='dashboards[$x][dashboard_uuid]' value='".escape($row['dashboard_uuid'])."' />\n";
echo " </td>\n";
}
if (!empty($show) && $show == 'all' && permission_exists('domain_all')) {
if (!empty($row['domain_uuid']) && is_uuid($row['domain_uuid'])) {
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
}
else {
echo " <td>".$text['label-global']."</td>\n";
}
}
echo " <td>\n";
if (permission_exists('dashboard_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['dashboard_name'])."</a>\n";
@@ -224,9 +255,6 @@
echo " ".escape($row['dashboard_name']);
}
echo " </td>\n";
echo " <td>".escape($row['dashboard_groups'])."</td>\n";
echo " <td>".escape($row['dashboard_icon'])."</td>\n";
echo " <td>".escape($row['dashboard_order'])."</td>\n";
if (permission_exists('dashboard_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='number_translations[$x][dashboard_enabled]' value='".escape($row['dashboard_enabled'])."' />\n";
@@ -246,7 +274,7 @@
echo "</tr>\n";
$x++;
}
unset($dashboard);
unset($dashboards);
}
echo "</table>\n";

View File

@@ -1,5 +1,4 @@
<?php
/*
FusionPBX
Version: MPL 1.1
@@ -36,27 +35,27 @@
}
//find the widget config
if (!empty($_GET['dashboard_path'])) {
$dashboard_path = $_GET['dashboard_path'];
if (!empty($_GET['widget_path'])) {
$widget_path = $_GET['widget_path'];
if (!preg_match('/^[a-zA-Z0-9\/_]+$/', $dashboard_path)) {
echo json_encode(['error' => 'Invalid dashboard path']);
if (!preg_match('/^[a-zA-Z0-9\/_]+$/', $widget_path)) {
echo json_encode(['error' => 'Invalid widget path']);
exit;
}
//find the application and widget
$dashboard_path_array = explode('/', $dashboard_path);
$dashboard_path_array = explode('/', $widget_path);
$application_name = $dashboard_path_array[0];
$widget_name = $dashboard_path_array[1];
$widget_path_name = $dashboard_path_array[1];
$path_array = glob(dirname(__DIR__, 2) . '/*/' . $application_name . '/resources/dashboard/config.php');
if (file_exists($path_array[0])) {
include($path_array[0]);
foreach ($array['dashboard'] as $index => $row) {
if ($row['dashboard_path'] === "$application_name/$widget_name") {
foreach ($array['dashboard_widgets'] as $index => $row) {
if ($row['widget_path'] === "$application_name/$widget_path_name") {
echo json_encode([
'chart_type_options' => $row['dashboard_chart_type_options'],
'chart_type_options' => $row['widget_chart_type_options'],
]);
exit;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,275 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2021-2025
the Initial Developer. All Rights Reserved.
*/
//includes files
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('dashboard_widget_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the http post data
if (!empty($_POST['dashboard_widgets'])) {
$action = $_POST['action'];
$dashboard_uuid = $_POST['dashboard_uuid'];
$dashboard_widgets = $_POST['dashboard_widgets'];
}
//process the http post data by action
if (!empty($action) && !empty($dashboard_widgets)) {
switch ($action) {
case 'toggle':
if (permission_exists('dashboard_widget_edit')) {
$obj = new dashboard;
$obj->toggle_items($dashboard_widgets);
}
break;
case 'delete':
if (permission_exists('dashboard_widget_delete')) {
$obj = new dashboard;
$obj->delete_items($dashboard_widgets);
}
break;
}
//redirect the user
header('Location: dashboard_edit.php?id='.urlencode($dashboard_uuid));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
//get the count
$sql = "select count(dashboard_widget_uuid) ";
$sql .= "from v_dashboard_widgets ";
$sql .= "where dashboard_uuid = :dashboard_uuid ";
$parameters['dashboard_uuid'] = $dashboard_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters ?? null, 'column');
unset($sql, $parameters);
//get the list
$sql = "select \n";
$sql .= "dashboard_widget_uuid, \n";
$sql .= "widget_name, \n";
$sql .= "widget_path, \n";
$sql .= "widget_icon, \n";
$sql .= "( \n";
$sql .= " select \n";
$sql .= " string_agg(g.group_name, ', ') \n";
$sql .= " from \n";
$sql .= " v_dashboard_widget_groups as dg, \n";
$sql .= " v_groups as g \n";
$sql .= " where \n";
$sql .= " dg.group_uuid = g.group_uuid \n";
$sql .= " and d.dashboard_widget_uuid = dg.dashboard_widget_uuid \n";
$sql .= ") AS dashboard_widget_groups, \n";
$sql .= "dashboard_widget_parent_uuid, \n";
$sql .= "widget_order, \n";
$sql .= "cast(widget_enabled as text), \n";
$sql .= "widget_description \n";
$sql .= "from v_dashboard_widgets as d \n";
$sql .= "where dashboard_uuid = :dashboard_uuid ";
$sql .= order_by($order_by, $order, 'widget_order, widget_name', 'asc');
$sql .= limit_offset($rows_per_page ?? null, $offset ?? null);
$database = new database;
$parameters['dashboard_uuid'] = $dashboard_uuid;
$widget_data = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//get the list of widget uuids
$widget_uuid_list = [];
foreach ($widget_data as $row) {
$widget_uuid_list[] = $row['dashboard_widget_uuid'];
}
$widgets = [];
foreach ($widget_data as $row) {
//skip child widgets unless the parent doesn't exist
if (!empty($row['dashboard_widget_parent_uuid']) && in_array($row['dashboard_widget_parent_uuid'], $widget_uuid_list)) {
continue;
}
//add the widget to the array
$widgets[] = $row;
//add child widgets under parent widgets
if ($row['widget_path'] == 'dashboard/parent') {
foreach ($widget_data as $child) {
if ($child['dashboard_widget_parent_uuid'] == $row['dashboard_widget_uuid']) {
$widgets[] = $child;
}
}
}
}
//create token
$object = new token;
$token = $object->create('/core/dashboard/dashboard_widget_list.php');
//show the content
echo "<div class='action_bar' id='action_bar_sub'>\n";
echo " <div class='heading'><b>".$text['title-widgets']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','id'=>'action_bar_sub_button_back','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'collapse'=>'hide-xs','style'=>'margin-right: 15px; display: none;','link'=>'dashboard.php']);
if (permission_exists('dashboard_widget_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard_widget_edit.php?id='.escape($dashboard_uuid).'&widget_uuid='.escape($widget_uuid)]);
}
if (permission_exists('dashboard_widget_edit') && !empty($widgets)) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
}
if (permission_exists('dashboard_widget_delete') && !empty($widgets)) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
}
echo " </form>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('dashboard_widget_edit') && !empty($widgets)) {
echo modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('toggle'); list_form_submit('form_list');"])]);
}
if (permission_exists('dashboard_widget_delete') && !empty($widgets)) {
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
echo "<form id='form_list' method='post' action='dashboard_widget_list.php?'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='dashboard_uuid' value='".escape($dashboard_uuid)."'>\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('dashboard_widget_add') || permission_exists('dashboard_widget_edit') || permission_exists('dashboard_widget_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($widgets) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('widget_name', $text['label-widget_name'], $order_by, $order);
echo th_order_by('dashboard_widget_groups', $text['label-widget_groups'], $order_by, $order);
//echo th_order_by('widget_icon', $text['label-icons'], $order_by, $order);
echo th_order_by('widget_order', $text['label-widget_order'], $order_by, $order);
echo th_order_by('widget_enabled', $text['label-widget_enabled'], $order_by, $order, null, "class='center'");
echo " <th class='hide-sm-dn'>".$text['label-widget_description']."</th>\n";
if (permission_exists('dashboard_widget_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (!empty($widgets)) {
$x = 0;
foreach ($widgets as $row) {
$list_row_url = '';
if (permission_exists('dashboard_widget_edit')) {
$list_row_url = "dashboard_widget_edit.php?id=".urlencode($dashboard_uuid)."&widget_uuid=".urlencode($row['dashboard_widget_uuid']);
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('dashboard_widget_add') || permission_exists('dashboard_widget_edit') || permission_exists('dashboard_widget_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='dashboard_widgets[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='dashboard_widgets[$x][dashboard_widget_uuid]' value='".escape($row['dashboard_widget_uuid'])."' />\n";
echo " </td>\n";
}
$widget_icon = (!empty($row['widget_icon']) ? "<i class='fas ".$row['widget_icon']."' style='margin-left: 7px; margin-top: 2px; text-indent: initial; ".(!empty($row['widget_icon_color']) ? "color: ".$row['widget_icon_color'].";" : "opacity: 0.4;")."'></i>\n" : null);
echo " <td ".(!empty($row['dashboard_widget_parent_uuid']) && in_array($row['dashboard_widget_parent_uuid'], $widget_uuid_list) ? "style='text-indent: 1rem;'" : null).">\n";//indent child widgets
if (permission_exists('dashboard_widget_edit')) {
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['widget_name'])."</a>\n";
echo $widget_icon;
}
else {
echo " ".escape($row['widget_name']);
echo $widget_icon;
}
echo " </td>\n";
echo " <td>".escape($row['dashboard_widget_groups'])."</td>\n";
//echo " <td>".escape($row['widget_icon'])."</td>\n";
echo " <td>".escape($row['widget_order'])."</td>\n";
if (permission_exists('dashboard_widget_edit')) {
echo " <td class='no-link center'>\n";
echo " <input type='hidden' name='dashboard_widgets[$x][widget_enabled]' value='".escape($row['widget_enabled'])."' />\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.($row['widget_enabled']?:'false')],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.($row['widget_enabled']?:'false')];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['widget_description'])."</td>\n";
if (permission_exists('dashboard_widget_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
$x++;
}
unset($widgets);
}
echo "</table>\n";
echo "</div>\n";
echo "<br />\n";
echo "<div align='center'>".($paging_controls ?? '')."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//make sub action bar sticky
echo "<script>\n";
echo " window.addEventListener('scroll', function(){\n";
echo " action_bar_scroll('action_bar_sub', 350, heading_modify, heading_restore);\n";
echo " }, false);\n";
echo " function heading_modify() {\n";
echo " document.getElementById('action_bar_sub_button_back').style.display = 'inline-block';\n";
echo " }\n";
echo " function heading_restore() {\n";
echo " document.getElementById('action_bar_sub_button_back').style.display = 'none';\n";
echo " }\n";
echo "</script>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -72,88 +72,114 @@
$group_uuids_in = "'".implode("','", $group_uuids)."'";
}
//get the dashboard uuid
$sql = "select dashboard_uuid ";
$sql .= "from v_dashboards ";
$sql .= "where dashboard_enabled = 'true' ";
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$result = $database->select($sql, $parameters ?? null, 'all');
if (empty($result)) {
$sql = "select dashboard_uuid ";
$sql .= "from v_dashboards ";
$sql .= "where dashboard_enabled = 'true' ";
$sql .= "and domain_uuid is null";
$result = $database->select($sql, null, 'all');
}
$dashboard_uuid = $result[0]['dashboard_uuid'] ?? null;
unset($sql, $parameters);
//get the list
$sql = "select ";
$sql .= "dashboard_uuid, ";
$sql .= "dashboard_name, ";
$sql .= "dashboard_path, ";
$sql .= "dashboard_icon, ";
$sql .= "dashboard_icon_color, ";
$sql .= "dashboard_url, ";
$sql .= "dashboard_target, ";
$sql .= "dashboard_width, ";
$sql .= "dashboard_height, ";
$sql .= "dashboard_content, ";
$sql .= "dashboard_content_text_align, ";
$sql .= "dashboard_content_details, ";
$sql .= "dashboard_chart_type, ";
$sql .= "cast(dashboard_label_enabled as text), ";
$sql .= "dashboard_label_text_color, ";
$sql .= "dashboard_label_text_color_hover, ";
$sql .= "dashboard_label_background_color, ";
$sql .= "dashboard_label_background_color_hover, ";
$sql .= "dashboard_number_text_color, ";
$sql .= "dashboard_number_text_color_hover, ";
$sql .= "dashboard_number_background_color, ";
$sql .= "dashboard_background_color, ";
$sql .= "dashboard_background_color_hover, ";
$sql .= "dashboard_detail_background_color, ";
$sql .= "dashboard_background_gradient_style, ";
$sql .= "dashboard_background_gradient_angle, ";
$sql .= "dashboard_column_span, ";
$sql .= "dashboard_row_span, ";
$sql .= "dashboard_details_state, ";
$sql .= "dashboard_order, ";
$sql .= "cast(dashboard_enabled as text), ";
$sql .= "dashboard_description, ";
$sql .= "dashboard_parent_uuid ";
$sql .= "from v_dashboard as d ";
$sql .= "where dashboard_enabled = 'true' ";
$sql .= "and dashboard_uuid in ( ";
$sql .= " select dashboard_uuid from v_dashboard_groups where group_uuid in ( ";
$sql .= "dashboard_widget_uuid, ";
$sql .= "widget_name, ";
$sql .= "widget_path, ";
$sql .= "widget_icon, ";
$sql .= "widget_icon_color, ";
$sql .= "widget_url, ";
$sql .= "widget_target, ";
$sql .= "widget_width, ";
$sql .= "widget_height, ";
$sql .= "widget_content, ";
$sql .= "widget_content_text_align, ";
$sql .= "widget_content_details, ";
$sql .= "widget_chart_type, ";
$sql .= "cast(widget_label_enabled as text), ";
$sql .= "widget_label_text_color, ";
$sql .= "widget_label_text_color_hover, ";
$sql .= "widget_label_background_color, ";
$sql .= "widget_label_background_color_hover, ";
$sql .= "widget_number_text_color, ";
$sql .= "widget_number_text_color_hover, ";
$sql .= "widget_number_background_color, ";
$sql .= "widget_background_color, ";
$sql .= "widget_background_color_hover, ";
$sql .= "widget_detail_background_color, ";
$sql .= "widget_background_gradient_style, ";
$sql .= "widget_background_gradient_angle, ";
$sql .= "widget_column_span, ";
$sql .= "widget_row_span, ";
$sql .= "widget_details_state, ";
$sql .= "dashboard_widget_parent_uuid, ";
$sql .= "widget_order, ";
$sql .= "cast(widget_enabled as text), ";
$sql .= "widget_description ";
$sql .= "from v_dashboard_widgets as d ";
$sql .= "where widget_enabled = 'true' ";
$sql .= "and dashboard_widget_uuid in ( ";
$sql .= " select dashboard_widget_uuid from v_dashboard_widget_groups where group_uuid in ( ";
$sql .= " ".$group_uuids_in." ";
$sql .= " ) ";
$sql .= ") ";
$sql .= "order by dashboard_order, dashboard_name asc ";
$dashboard = $database->select($sql, $parameters ?? null, 'all');
$sql .= "and dashboard_uuid = :dashboard_uuid ";
$sql .= "order by widget_order, widget_name asc ";
$parameters['dashboard_uuid'] = $dashboard_uuid;
$widgets = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//get the list of widget uuids
$widget_uuid_list = [];
foreach ($widgets as $row) {
$widget_uuid_list[] = $row['dashboard_widget_uuid'];
}
//get http post variables and set them to php variables
if (count($_POST) > 0 && permission_exists('dashboard_edit')) {
//set the variables from the http values
if (isset($_POST["widget_order"])) {
$widgets = explode(",", $_POST["widget_order"]);
$widget_order = explode(",", $_POST["widget_order"]);
$x = 0;
foreach ($widgets as $widget) {
foreach ($widget_order as $widget) {
list($widget_id, $parent_id, $order) = explode("|", $widget);
$parent_uuid = null;
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if ($widget_id == $dashboard_id) {
foreach ($widgets as $row) {
$dashboard_widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if ($widget_id == $dashboard_widget_id) {
if (!empty($parent_id)) {
//find parent uuid
foreach ($dashboard as $parent_row) {
$parent_dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $parent_row['dashboard_uuid']));
if ($parent_dashboard_id === $parent_id) {
$parent_uuid = $parent_row['dashboard_uuid'];
foreach ($widgets as $parent_row) {
$parent_widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $parent_row['dashboard_widget_uuid']));
if ($parent_widget_id === $parent_id) {
$parent_uuid = $parent_row['dashboard_widget_uuid'];
break;
}
}
}
$array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
$array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name'];
$array['dashboard'][$x]['dashboard_icon'] = $row['dashboard_icon'];
$array['dashboard'][$x]['dashboard_url'] = $row['dashboard_url'];
$array['dashboard'][$x]['dashboard_content'] = $row['dashboard_content'];
$array['dashboard'][$x]['dashboard_content_text_align'] = $row['dashboard_content_text_align'];
$array['dashboard'][$x]['dashboard_content_details'] = $row['dashboard_content_details'];
$array['dashboard'][$x]['dashboard_target'] = $row['dashboard_target'];
$array['dashboard'][$x]['dashboard_width'] = $row['dashboard_width'];
$array['dashboard'][$x]['dashboard_height'] = $row['dashboard_height'];
$array['dashboard'][$x]['dashboard_order'] = $order;
$array['dashboard'][$x]['dashboard_parent_uuid'] = $parent_uuid;
$array['dashboard_widgets'][$x]['dashboard_widget_uuid'] = $row['dashboard_widget_uuid'];
$array['dashboard_widgets'][$x]['widget_name'] = $row['widget_name'];
$array['dashboard_widgets'][$x]['widget_icon'] = $row['widget_icon'];
$array['dashboard_widgets'][$x]['widget_url'] = $row['widget_url'];
$array['dashboard_widgets'][$x]['widget_content'] = $row['widget_content'];
$array['dashboard_widgets'][$x]['widget_content_text_align'] = $row['widget_content_text_align'];
$array['dashboard_widgets'][$x]['widget_content_details'] = $row['widget_content_details'];
$array['dashboard_widgets'][$x]['widget_target'] = $row['widget_target'];
$array['dashboard_widgets'][$x]['widget_width'] = $row['widget_width'];
$array['dashboard_widgets'][$x]['widget_height'] = $row['widget_height'];
$array['dashboard_widgets'][$x]['widget_order'] = $order;
$array['dashboard_widgets'][$x]['dashboard_widget_parent_uuid'] = $parent_uuid;
$x++;
break;
}
@@ -207,9 +233,9 @@
//determine initial state all button to display
$expanded_all = true;
if (!empty($dashboard)) {
foreach ($dashboard as $row) {
if ($row['dashboard_details_state'] == 'contracted' || $row['dashboard_details_state'] == 'hidden' || $row['dashboard_details_state'] == 'disabled') { $expanded_all = false; }
if (!empty($widgets)) {
foreach ($widgets as $row) {
if ($row['widget_details_state'] == 'contracted' || $row['widget_details_state'] == 'hidden' || $row['widget_details_state'] == 'disabled') { $expanded_all = false; }
}
}
@@ -288,152 +314,152 @@ div.hud_chart {
/* dashboard settings */
<?php
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if (!empty($row['dashboard_icon_color'])) {
echo "#".$dashboard_id." .hud_stat .fas {\n";
echo " color: ".$row['dashboard_icon_color'].";\n";
foreach ($widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if (!empty($row['widget_icon_color'])) {
echo "#".$widget_id." .hud_stat .fas {\n";
echo " color: ".$row['widget_icon_color'].";\n";
echo "}\n";
}
if ($row['dashboard_label_enabled'] == 'false' && $row['dashboard_path'] != 'dashboard/parent') {
echo "#".$dashboard_id." .hud_title:first-of-type {\n";
if ($row['widget_label_enabled'] == 'false' && $row['widget_path'] != 'dashboard/parent') {
echo "#".$widget_id." .hud_title:first-of-type {\n";
echo " display: none;\n";
echo "}\n";
echo "#".$dashboard_id." .hud_content {\n";
echo "#".$widget_id." .hud_content {\n";
echo " align-content: center;\n";
echo "}\n";
echo "#".$dashboard_id." .hud_chart {\n";
echo "#".$widget_id." .hud_chart {\n";
echo " padding-top: 0;\n";
echo "}\n";
}
if (!empty($row['dashboard_label_text_color']) || !empty($row['dashboard_label_background_color'])) {
echo "#".$dashboard_id." > .hud_box > .hud_content > .hud_title:first-of-type {\n";
if (!empty($row['dashboard_label_text_color'])) { echo " color: ".$row['dashboard_label_text_color'].";\n"; }
if (!empty($row['dashboard_label_background_color'])) { echo " background-color: ".$row['dashboard_label_background_color'].";\n"; }
if (!empty($row['widget_label_text_color']) || !empty($row['widget_label_background_color'])) {
echo "#".$widget_id." > .hud_box > .hud_content > .hud_title:first-of-type {\n";
if (!empty($row['widget_label_text_color'])) { echo " color: ".$row['widget_label_text_color'].";\n"; }
if (!empty($row['widget_label_background_color'])) { echo " background-color: ".$row['widget_label_background_color'].";\n"; }
echo "}\n";
}
if (!empty($row['dashboard_label_text_color_hover']) || !empty($row['dashboard_label_background_color_hover'])) {
echo "#".$dashboard_id.":hover > .hud_box > .hud_content > .hud_title:first-of-type {\n";
if (!empty($row['dashboard_label_text_color_hover'])) { echo " color: ".$row['dashboard_label_text_color_hover'].";\n"; }
if (!empty($row['dashboard_label_background_color_hover'])) { echo " background-color: ".$row['dashboard_label_background_color_hover'].";\n"; }
if (!empty($row['widget_label_text_color_hover']) || !empty($row['widget_label_background_color_hover'])) {
echo "#".$widget_id.":hover > .hud_box > .hud_content > .hud_title:first-of-type {\n";
if (!empty($row['widget_label_text_color_hover'])) { echo " color: ".$row['widget_label_text_color_hover'].";\n"; }
if (!empty($row['widget_label_background_color_hover'])) { echo " background-color: ".$row['widget_label_background_color_hover'].";\n"; }
echo "}\n";
}
if (!empty($row['dashboard_number_text_color'])) {
echo "#".$dashboard_id." > .hud_box > .hud_content > .hud_stat {\n";
echo " color: ".$row['dashboard_number_text_color'].";\n";
if (!empty($row['widget_number_text_color'])) {
echo "#".$widget_id." > .hud_box > .hud_content > .hud_stat {\n";
echo " color: ".$row['widget_number_text_color'].";\n";
echo "}\n";
}
if (!empty($row['dashboard_number_text_color_hover'])) {
echo "#".$dashboard_id.":hover > .hud_box > .hud_content > .hud_stat {\n";
echo " color: ".$row['dashboard_number_text_color_hover'].";\n";
if (!empty($row['widget_number_text_color_hover'])) {
echo "#".$widget_id.":hover > .hud_box > .hud_content > .hud_stat {\n";
echo " color: ".$row['widget_number_text_color_hover'].";\n";
echo "}\n";
}
if (!empty($row['dashboard_background_color'])) {
$background_color = json_decode($row['dashboard_background_color'], true);
echo "#".$dashboard_id." > .hud_box:first-of-type {\n";
if (!empty($row['widget_background_color'])) {
$background_color = json_decode($row['widget_background_color'], true);
echo "#".$widget_id." > .hud_box:first-of-type {\n";
echo " background: ".$background_color[0].";\n";
if (empty($row['dashboard_background_gradient_style']) || $row['dashboard_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$background_color[1]." 0%, ".$background_color[0]." 30%, ".$background_color[0]." 70%, ".$background_color[1]." 100%);\n";
if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$background_color[1]." 0%, ".$background_color[0]." 30%, ".$background_color[0]." 70%, ".$background_color[1]." 100%);\n";
}
else { //simple
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$background_color[0]." 0%, ".$background_color[1]." 100%);\n";
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$background_color[0]." 0%, ".$background_color[1]." 100%);\n";
}
echo "}\n";
}
if (!empty($row['dashboard_background_color_hover'])) {
$background_color_hover = json_decode($row['dashboard_background_color_hover'], true);
echo "#".$dashboard_id.":hover > .hud_box:first-of-type {\n";
if (!empty($row['widget_background_color_hover'])) {
$background_color_hover = json_decode($row['widget_background_color_hover'], true);
echo "#".$widget_id.":hover > .hud_box:first-of-type {\n";
echo " background: ".$background_color_hover[0].";\n";
if (empty($row['dashboard_background_gradient_style']) || $row['dashboard_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$background_color_hover[1]." 0%, ".$background_color_hover[0]." 30%, ".$background_color_hover[0]." 70%, ".$background_color_hover[1]." 100%);\n";
if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$background_color_hover[1]." 0%, ".$background_color_hover[0]." 30%, ".$background_color_hover[0]." 70%, ".$background_color_hover[1]." 100%);\n";
}
else { //simple
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$background_color_hover[0]." 0%, ".$background_color_hover[1]." 100%);\n";
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$background_color_hover[0]." 0%, ".$background_color_hover[1]." 100%);\n";
}
echo "}\n";
}
if (!empty($row['dashboard_detail_background_color'])) {
$detail_background_color = json_decode($row['dashboard_detail_background_color'], true);
echo "#".$dashboard_id." > .hud_box > .hud_details {\n";
if (!empty($row['widget_detail_background_color'])) {
$detail_background_color = json_decode($row['widget_detail_background_color'], true);
echo "#".$widget_id." > .hud_box > .hud_details {\n";
echo " background: ".$detail_background_color[0].";\n";
if (empty($row['dashboard_background_gradient_style']) || $row['dashboard_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$detail_background_color[1]." 0%, ".$detail_background_color[0]." 30%, ".$detail_background_color[0]." 70%, ".$detail_background_color[1]." 100%);\n";
if (empty($row['widget_background_gradient_style']) || $row['widget_background_gradient_style'] == 'mirror') {
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$detail_background_color[1]." 0%, ".$detail_background_color[0]." 30%, ".$detail_background_color[0]." 70%, ".$detail_background_color[1]." 100%);\n";
}
else { //simple
echo " background-image: linear-gradient(".(empty($row['dashboard_background_gradient_angle']) ? '0deg' : $row['dashboard_background_gradient_angle'].'deg').", ".$detail_background_color[0]." 0%, ".$detail_background_color[1]." 100%);\n";
echo " background-image: linear-gradient(".(empty($row['widget_background_gradient_angle']) ? '0deg' : $row['widget_background_gradient_angle'].'deg').", ".$detail_background_color[0]." 0%, ".$detail_background_color[1]." 100%);\n";
}
echo "}\n";
}
if ($row['dashboard_path'] == "dashboard/icon") {
echo "#".$dashboard_id." div.hud_content,\n";
echo "#".$dashboard_id." span.hud_title,\n";
echo "#".$dashboard_id." span.hud_stat {\n";
if ($row['widget_path'] == "dashboard/icon") {
echo "#".$widget_id." div.hud_content,\n";
echo "#".$widget_id." span.hud_title,\n";
echo "#".$widget_id." span.hud_stat {\n";
echo " transition: .4s;\n";
echo "}\n";
}
switch ($row['dashboard_row_span']) {
switch ($row['widget_row_span']) {
case 1:
echo "#".$dashboard_id." > .hud_box > .hud_content {\n";
echo "#".$widget_id." > .hud_box > .hud_content {\n";
echo " height: var(--row-height);\n";
echo "}\n";
echo "#".$dashboard_id." .hud_stat {\n";
echo "#".$widget_id." .hud_stat {\n";
echo " line-height: 0;\n";
echo " font-size: 30pt;\n";
echo "}\n";
echo "#".$dashboard_id." .hud_stat .fas {\n";
echo "#".$widget_id." .hud_stat .fas {\n";
echo " line-height: 0;\n";
echo " font-size: 24pt;\n";
echo "}\n";
echo "#".$dashboard_id.".widget > .hud_box > .hud_content > .hud_chart {\n";
echo "#".$widget_id." > .hud_box > .hud_content > .hud_chart {\n";
echo " height: 54px;\n";
echo " width: 180px;\n";
echo " padding-top: 0;\n";
echo "}\n";
break;
case 2:
echo "#".$dashboard_id." > .hud_box > .hud_content {\n";
echo "#".$widget_id." > .hud_box > .hud_content {\n";
echo " height: calc((var(--row-height) * 2) + var(--grid-gap));\n";
echo "}\n";
break;
case 3:
echo "#".$dashboard_id." > .hud_box > .hud_content {\n";
echo "#".$widget_id." > .hud_box > .hud_content {\n";
echo " height: calc((var(--row-height) * 3) + (var(--grid-gap) * 2));\n";
echo "}\n";
break;
case 4:
echo "#".$dashboard_id." > .hud_box > .hud_content {\n";
echo "#".$widget_id." > .hud_box > .hud_content {\n";
echo " height: calc((var(--row-height) * 4) + (var(--grid-gap) * 3));\n";
echo "}\n";
break;
default: //if empty
echo "#".$dashboard_id." > .hud_box > .hud_content {\n";
echo "#".$widget_id." > .hud_box > .hud_content {\n";
echo " height: calc((var(--row-height) * 2) + var(--grid-gap));\n";
echo "}\n";
}
$row_span = $row['dashboard_row_span'] * 4;
$row_span = $row['widget_row_span'] * 4;
$expanded_row_span = $row_span + 13;
if ($row['dashboard_details_state'] === "expanded" || $row['dashboard_details_state'] === "contracted") {
if ($row['widget_details_state'] === "expanded" || $row['widget_details_state'] === "contracted") {
$row_span += 1;
$expanded_row_span += 1;
}
if (!empty($row['dashboard_row_span'])) {
echo "#".$dashboard_id." {\n";
echo " --row-span: ".$row['dashboard_row_span'].";\n";
if (!empty($row['widget_row_span'])) {
echo "#".$widget_id." {\n";
echo " --row-span: ".$row['widget_row_span'].";\n";
echo "}\n";
echo "#".$dashboard_id." {\n";
echo "#".$widget_id." {\n";
echo " grid-row: span ".$row_span.";\n";
echo "}\n";
echo "#".$dashboard_id.".expanded {\n";
echo "#".$widget_id.".expanded {\n";
echo " grid-row: span ".$expanded_row_span.";\n";
echo "}\n";
}
if (!empty($row['dashboard_column_span'])) {
echo "#".$dashboard_id." {\n";
echo " grid-column: span ".$row['dashboard_column_span'].";\n";
if (!empty($row['widget_column_span'])) {
echo "#".$widget_id." {\n";
echo " grid-column: span ".$row['widget_column_span'].";\n";
echo "}\n";
}
if ($row['dashboard_path'] != "dashboard/icon" && $row['dashboard_chart_type'] != "icon" && $row['dashboard_column_span'] == 1) {
echo "#".$dashboard_id.".child_widget {\n";
if ($row['widget_path'] != "dashboard/icon" && $row['widget_chart_type'] != "icon" && $row['widget_column_span'] == 1) {
echo "#".$widget_id.".child_widget {\n";
echo " grid-column: span 2;\n";
echo "}\n";
}
@@ -445,16 +471,16 @@ foreach ($dashboard as $row) {
.widgets { grid-template-columns: repeat(1, minmax(100px, 1fr)); }
.col-num { grid-column: span 1; }
<?php
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if (!empty($row['dashboard_column_span'])) {
echo "#".$dashboard_id." {\n";
foreach ($widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if (!empty($row['widget_column_span'])) {
echo "#".$widget_id." {\n";
echo " grid-column: span 1;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "hidden" || $row['dashboard_details_state'] == "disabled") {
echo "#".$dashboard_id." .hud_box .hud_expander, \n";
echo "#".$dashboard_id." .hud_box .hud_details {\n";
if ($row['widget_details_state'] == "hidden" || $row['widget_details_state'] == "disabled") {
echo "#".$widget_id." .hud_box .hud_expander, \n";
echo "#".$widget_id." .hud_box .hud_details {\n";
echo " display: none;\n";
echo "}\n";
}
@@ -467,26 +493,26 @@ foreach ($dashboard as $row) {
.widgets { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
.col-num { grid-column: span 2; }
<?php
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if ($row['dashboard_column_span'] > 2) {
echo "#".$dashboard_id." {\n";
foreach ($widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if ($row['widget_column_span'] > 2) {
echo "#".$widget_id." {\n";
echo " grid-column: span 2;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "expanded") {
echo "#".$dashboard_id." .hud_box .hud_details {\n";
if ($row['widget_details_state'] == "expanded") {
echo "#".$widget_id." .hud_box .hud_details {\n";
echo " display: block;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "contracted") {
echo "#".$dashboard_id." .widget .hud_box .hud_details {\n";
if ($row['widget_details_state'] == "contracted") {
echo "#".$widget_id." .widget .hud_box .hud_details {\n";
echo " display: none;\n";
echo "}\n";
}
if ($row['dashboard_details_state'] == "hidden" || $row['dashboard_details_state'] == "disabled") {
echo "#".$dashboard_id." .hud_box .hud_expander, \n";
echo "#".$dashboard_id." .hud_box .hud_details {\n";
if ($row['widget_details_state'] == "hidden" || $row['widget_details_state'] == "disabled") {
echo "#".$widget_id." .hud_box .hud_expander, \n";
echo "#".$widget_id." .hud_box .hud_details {\n";
echo " display: none;\n";
echo "}\n";
}
@@ -499,10 +525,10 @@ foreach ($dashboard as $row) {
.widgets { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
.col-num { grid-column: span 2; }
<?php
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if ($row['dashboard_column_span'] > 3) {
echo "#".$dashboard_id." {\n";
foreach ($widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if ($row['widget_column_span'] > 3) {
echo "#".$widget_id." {\n";
echo " grid-column: span 3;\n";
echo "}\n";
}
@@ -515,11 +541,11 @@ foreach ($dashboard as $row) {
.widgets { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
.col-num { grid-column: span 2; }
<?php
foreach ($dashboard as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if (!empty($row['dashboard_column_span'])) {
echo "#".$dashboard_id." {\n";
echo " grid-column: span ".$row['dashboard_column_span'].";\n";
foreach ($widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if (!empty($row['widget_column_span'])) {
echo "#".$widget_id." {\n";
echo " grid-column: span ".$row['widget_column_span'].";\n";
echo "}\n";
}
}
@@ -553,8 +579,8 @@ document.addEventListener('click', function(event) {
}
});
function toggle_grid_row_span(dashboard_id) {
let widget = document.getElementById(dashboard_id);
function toggle_grid_row_span(widget_id) {
let widget = document.getElementById(widget_id);
if (widget.classList.contains('expanded')) {
widget.classList.remove('expanded');
@@ -628,29 +654,29 @@ window.addEventListener('resize', update_parent_height);
//include the dashboards
echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
$x = 0;
foreach ($dashboard as $row) {
//skip child widgets
if (!empty($row['dashboard_parent_uuid'])) {
foreach ($widgets as $row) {
//skip child widgets unless the parent doesn't exist
if (!empty($row['dashboard_widget_parent_uuid']) && in_array($row['dashboard_widget_parent_uuid'], $widget_uuid_list)) {
continue;
}
//set the variables
$dashboard_uuid = $row['dashboard_uuid'] ?? '';
$dashboard_name = $row['dashboard_name'] ?? '';
$dashboard_icon = $row['dashboard_icon'] ?? '';
$dashboard_url = $row['dashboard_url'] ?? '';
$dashboard_target = $row['dashboard_target'] ?? '';
$dashboard_width = $row['dashboard_width'] ?? '';
$dashboard_height = $row['dashboard_height'] ?? '';
$dashboard_content = $row['dashboard_content'] ?? '';
$dashboard_content_text_align = $row['dashboard_content_text_align'] ?? '';
$dashboard_content_details = $row['dashboard_content_details'] ?? '';
$dashboard_chart_type = $row['dashboard_chart_type'] ?? '';
$dashboard_label_text_color = $row['dashboard_label_text_color'] ?? $settings->get('theme', 'dashboard_label_text_color', '');
$dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color', '');
$dashboard_number_background_color = $row['dashboard_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color', '');
$dashboard_details_state = $row['dashboard_details_state'] ?? 'hidden';
$dashboard_row_span = $row['dashboard_row_span'] ?? '';
$widget_uuid = $row['dashboard_widget_uuid'] ?? '';
$widget_name = $row['widget_name'] ?? '';
$widget_icon = $row['widget_icon'] ?? '';
$widget_url = $row['widget_url'] ?? '';
$widget_target = $row['widget_target'] ?? '';
$widget_width = $row['widget_width'] ?? '';
$widget_height = $row['widget_height'] ?? '';
$widget_content = $row['widget_content'] ?? '';
$widget_content_text_align = $row['widget_content_text_align'] ?? '';
$widget_content_details = $row['widget_content_details'] ?? '';
$widget_chart_type = $row['widget_chart_type'] ?? '';
$widget_label_text_color = $row['widget_label_text_color'] ?? $settings->get('theme', 'dashboard_label_text_color', '');
$widget_number_text_color = $row['widget_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color', '');
$widget_number_background_color = $row['widget_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color', '');
$widget_details_state = $row['widget_details_state'] ?? 'hidden';
$widget_row_span = $row['widget_row_span'] ?? '';
//define the regex patterns
$uuid_pattern = '/[^-A-Fa-f0-9]/';
@@ -658,40 +684,39 @@ window.addEventListener('resize', update_parent_height);
$text_pattern = '/[^a-zA-Z0-9 _\-\/.\?:\=#\n]/';
//sanitize the data
$dashboard_uuid = preg_replace($uuid_pattern, '', $dashboard_uuid);
$dashboard_id = 'id_'.md5($dashboard_uuid);
$dashboard_name = trim(preg_replace($text_pattern, '', $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 = preg_replace($text_pattern, '', $dashboard_content);
$dashboard_content = str_replace("\n", '<br />', $dashboard_content);
$dashboard_content_text_align = trim(preg_replace($text_pattern, '', $dashboard_content_text_align));
$dashboard_content_details = preg_replace($text_pattern, '', $dashboard_content_details);
$dashboard_content_details = str_replace("\n", '<br />', $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_number_background_color = preg_replace($text_pattern, '', $dashboard_number_background_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']));
$widget_uuid = preg_replace($uuid_pattern, '', $widget_uuid);
$widget_id = 'id_'.md5($widget_uuid);
$widget_name = trim(preg_replace($text_pattern, '', $widget_name));
$widget_icon = preg_replace($text_pattern, '', $widget_icon);
$widget_url = trim(preg_replace($text_pattern, '', $widget_url));
$widget_target = trim(preg_replace($text_pattern, '', $widget_target));
$widget_width = trim(preg_replace($text_pattern, '', $widget_width));
$widget_height = trim(preg_replace($text_pattern, '', $widget_height));
$widget_content = preg_replace($text_pattern, '', $widget_content);
$widget_content = str_replace("\n", '<br />', $widget_content);
$widget_content_text_align = trim(preg_replace($text_pattern, '', $widget_content_text_align));
$widget_content_details = preg_replace($text_pattern, '', $widget_content_details);
$widget_content_details = str_replace("\n", '<br />', $widget_content_details);
$widget_chart_type = preg_replace($text_pattern, '', $widget_chart_type);
$widget_label_text_color = preg_replace($text_pattern, '', $widget_label_text_color);
$widget_number_text_color = preg_replace($text_pattern, '', $widget_number_text_color);
$widget_number_background_color = preg_replace($text_pattern, '', $widget_number_background_color);
$widget_details_state = preg_replace($text_pattern, '', $widget_details_state);
$widget_row_span = preg_replace($number_pattern, '', $widget_row_span);
$widget_path = preg_replace($text_pattern, '', strtolower($row['widget_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');
$widget_path_array = explode('/', $widget_path);
$application_name = $widget_path_array[0];
$widget_path_name = $widget_path_array[1];
$path_array = glob(dirname(__DIR__, 2).'/*/'.$application_name.'/resources/dashboard/'.$widget_path_name.'.php');
echo "<div class='widget ".$dashboard_details_state."' id='".$dashboard_id."' ".($dashboard_path == 'dashboard/parent' ? "data-is-parent='true'" : null)." draggable='false'>\n";
echo "<div class='widget ".$widget_details_state."' id='".$widget_id."' ".($widget_path == 'dashboard/parent' ? "data-is-parent='true'" : null)." draggable='false'>\n";
if (file_exists($path_array[0])) {
include $path_array[0];
}
echo "</div>\n";
$x++;
}
echo "</div>\n";

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2019 - 2021
Portions created by the Initial Developer are Copyright (C) 2019-2025
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -36,10 +36,12 @@
private $app_uuid;
private $name;
private $table;
private $tables;
private $toggle_field;
private $toggle_values;
private $description_field;
private $location;
private $uuid_prefix;
/**
* called when the object is created
@@ -48,18 +50,24 @@
//assign the variables
$this->app_name = 'dashboard';
$this->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
$this->name = 'dashboard';
$this->table = 'dashboard';
$this->tables[] = 'dashboards';
$this->tables[] = 'dashboard_widgets';
$this->tables[] = 'dashboard_widget_groups';
$this->toggle_field = 'dashboard_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'dashboard_description';
$this->location = 'dashboard.php';
$this->uuid_prefix = 'dashboard_';
}
/**
* delete rows from the database
*/
public function delete($records) {
//assign the variables
$this->name = 'dashboard';
$this->table = 'dashboards';
if (permission_exists($this->name.'_delete')) {
//add multi-lingual support
@@ -76,21 +84,28 @@
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
$array[$this->table][$x]['dashboard_uuid'] = $record['dashboard_uuid'];
$array[$this->table.'_groups'][$x]['dashboard_uuid'] = $record['dashboard_uuid'];
}
//increment the id
$x++;
//build the delete array
foreach ($records as $x => $record) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_uuid'])) {
if (is_array($this->tables) && @sizeof($this->tables) != 0) {
foreach ($this->tables as $table) {
$array[$table][$x][$this->uuid_prefix.'uuid'] = $record['dashboard_uuid'];
}
}
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temp permissions
$p = permissions::new();
$database = new database;
foreach ($this->tables as $table) {
$p->add(database::singular($table).'_delete', 'temp');
}
//execute delete
$database = new database;
$database->app_name = $this->app_name;
@@ -98,6 +113,12 @@
$database->delete($array);
unset($array);
//revoke temp permissions
$database = new database;
foreach ($this->tables as $table) {
$p->delete(database::singular($table).'_delete', 'temp');
}
//set message
message::add($text['message-delete']);
}
@@ -110,6 +131,10 @@
* toggle a field between two values
*/
public function toggle($records) {
//assign the variables
$this->name = 'dashboard';
$this->table = 'dashboards';
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
@@ -177,6 +202,10 @@
* copy rows from the database
*/
public function copy($records) {
//assign the variables
$this->name = 'dashboard';
$this->table = 'dashboards';
if (permission_exists($this->name.'_add')) {
//add multi-lingual support
@@ -241,4 +270,124 @@
}
}
public function delete_items($records) {
//assign the variables
$this->name = 'dashboard_widget';
$this->table = 'dashboard_widgets';
if (permission_exists($this->name.'_delete')) {
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($this->text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$array[$this->table][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
$array[$this->name.'_groups'][$x]['dashboard_widget_uuid'] = $record['dashboard_widget_uuid'];
}
//increment the id
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
public function toggle_items($records) {
//assign the variables
$this->name = 'dashboard_widget';
$this->table = 'dashboard_widgets';
$this->toggle_field = 'widget_enabled';
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/dashboard/dashboard_widget_list.php')) {
message::add($this->text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach($records as $record) {
if (isset($record['checked']) && $record['checked'] == 'true' && is_uuid($record['dashboard_widget_uuid'])) {
$uuids[] = "'".$record['dashboard_widget_uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
}
unset($sql, $parameters, $rows, $row);
}
//build update array
$x = 0;
foreach($states as $uuid => $state) {
//create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id
$x++;
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
}
}

View File

@@ -0,0 +1,9 @@
<?php
//default dashboard
$array['dashboards'][$x]['dashboard_uuid'] = '3e2cbaa4-2bec-41b2-a626-999a59b8b19c';
$array['dashboards'][$x]['dashboard_name'] = 'default';
$array['dashboards'][$x]['dashboard_enabled'] = 'true';
$array['dashboards'][$x]['dashboard_description'] = 'Default Dashboard';
?>

View File

@@ -9,27 +9,27 @@
$text = $language->get($_SESSION['domain']['language']['code'], 'core/dashboard');
//prepare the settings
$dashboard_content_length = strlen($dashboard_content);
$dashboard_content_text_vertical_align = 'top';
if ($dashboard_content_length < 30) { $dashboard_content_text_vertical_align = 'middle'; }
$dashboard_content_height = $dashboard_row_span * 120 . 'px';
$widget_content_length = strlen($widget_content);
$widget_content_text_vertical_align = 'top';
if ($widget_content_length < 30) { $widget_content_text_vertical_align = 'middle'; }
$widget_content_height = $widget_row_span * 120 . 'px';
//escape the content and details
$dashboard_content = escape($dashboard_content);
$dashboard_content_details = escape($dashboard_content_details);
$widget_content = escape($widget_content);
$widget_content_details = escape($widget_content_details);
//allow line breaks
$dashboard_content = str_replace('&lt;br &sol;&gt;', '<br />', $dashboard_content);
$dashboard_content_details = str_replace('&lt;br &sol;&gt;', '<br />', $dashboard_content_details);
$widget_content = str_replace('&lt;br &sol;&gt;', '<br />', $widget_content);
$widget_content_details = str_replace('&lt;br &sol;&gt;', '<br />', $widget_content_details);
//dashboard icon
echo "<div class='hud_box'>\n";
echo " <div class='hud_content' ".(!empty($row['dashboard_background_color']) ? "style='background: ".$row['dashboard_background_color'].";'" : null)." ".(empty($dashboard_details_state) || $dashboard_details_state != "disabled" ? "onclick=\"$('#hud_content_details').slideToggle('fast');\"" : null).">\n";
echo " <span class='hud_title' ".(!empty($row['dashboard_label_background_color']) ? "style='background: ".$row['dashboard_label_background_color'].";'" : null).">".escape($dashboard_name)."</span>";
echo " <span style='padding: 12px; height: ".$dashboard_content_height."; max-height: ".$dashboard_content_height."; text-align: ".$row['dashboard_content_text_align']."; vertical-align: ".$dashboard_content_text_vertical_align."; overflow: auto; ".(!empty($row['dashboard_number_text_color']) ? "color: ".$row['dashboard_number_text_color'].";" : null)."'>".$dashboard_content."</span>\n";
echo " <div class='hud_content' ".(!empty($row['widget_background_color']) ? "style='background: ".$row['widget_background_color'].";'" : null)." ".(empty($widget_details_state) || $widget_details_state != "disabled" ? "onclick=\"$('#hud_content_details').slideToggle('fast');\"" : null).">\n";
echo " <span class='hud_title' ".(!empty($row['widget_label_background_color']) ? "style='background: ".$row['widget_label_background_color'].";'" : null).">".escape($widget_name)."</span>";
echo " <span style='padding: 12px; height: ".$widget_content_height."; max-height: ".$widget_content_height."; text-align: ".$row['widget_content_text_align']."; vertical-align: ".$widget_content_text_vertical_align."; overflow: auto; ".(!empty($row['widget_number_text_color']) ? "color: ".$row['widget_number_text_color'].";" : null)."'>".$widget_content."</span>\n";
echo " </div>\n";
if (empty($dashboard_details_state) || $dashboard_details_state != "disabled") {
echo " <div class='hud_details hud_box' id='hud_content_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['dashboard_detail_background_color']) ? "background: ".$row['dashboard_detail_background_color'].";" : null)."'>".$dashboard_content_details."</div>\n";
if (empty($widget_details_state) || $widget_details_state != "disabled") {
echo " <div class='hud_details hud_box' id='hud_content_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['widget_detail_background_color']) ? "background: ".$row['widget_detail_background_color'].";" : null)."'>".$widget_content_details."</div>\n";
}
echo " <span class='hud_expander' onclick=\"$('#hud_content_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
echo "</div>\n";

View File

@@ -5,31 +5,31 @@
require_once "resources/check_auth.php";
//convert to a key
$dashboard_key = str_replace(' ', '_', strtolower($dashboard_name));
$widget_key = str_replace(' ', '_', strtolower($widget_name));
//add multi-lingual support
$language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], dirname($dashboard_url));
$text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url));
//get the dashboard label
$dashboard_label = $text['title-'.$dashboard_key] ?? $dashboard_name;
$widget_label = $text['title-'.$widget_key] ?? $widget_name;
//prepare variables
$dashboard_target = ($dashboard_target == 'new') ? '_blank' : '_self';
$widget_target = ($widget_target == 'new') ? '_blank' : '_self';
$window_parameters = '';
if (!empty($dashboard_width) && !empty($dashboard_height)) {
$window_parameters .= "width=".$dashboard_width.",height=".$dashboard_height;
if (!empty($widget_width) && !empty($widget_height)) {
$window_parameters .= "width=".$widget_width.",height=".$widget_height;
}
//dashboard icon
echo "<div class='hud_box'>\n";
echo " <div class='hud_content' ".(empty($dashboard_details_state) || $dashboard_details_state != "disabled" ? "onclick=\"$('#hud_icon_details').slideToggle('fast');\"" : null).">\n";
echo " <span class='hud_title'><a style='padding: 10px 0;' onclick=\"window.open('".$dashboard_url."', '".$dashboard_target."', '".$window_parameters."'); return false;\">".escape($dashboard_label)."</a></span>\n";
echo " <span class='hud_stat'><a style='padding: 10px 20px;' onclick=\"window.open('".$dashboard_url."', '".$dashboard_target."', '".$window_parameters."'); return false;\"><i class=\"fas ".$dashboard_icon."\"></i></a></span>\n";
echo " <div class='hud_content' ".(empty($widget_details_state) || $widget_details_state != "disabled" ? "onclick=\"$('#hud_icon_details').slideToggle('fast');\"" : null).">\n";
echo " <span class='hud_title'><a style='padding: 10px 0;' onclick=\"window.open('".$widget_url."', '".$widget_target."', '".$window_parameters."'); return false;\">".escape($widget_label)."</a></span>\n";
echo " <span class='hud_stat'><a style='padding: 10px 20px;' onclick=\"window.open('".$widget_url."', '".$widget_target."', '".$window_parameters."'); return false;\"><i class=\"fas ".$widget_icon."\"></i></a></span>\n";
echo " </div>\n";
if (empty($dashboard_details_state) || $dashboard_details_state != "disabled") {
echo " <div class='hud_details hud_box' id='hud_icon_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['dashboard_detail_background_color']) ? "background: ".$row['dashboard_detail_background_color'].";" : null)."'>".str_replace("\r", '<br>', escape($dashboard_content_details))."</div>\n";
if (empty($widget_details_state) || $widget_details_state != "disabled") {
echo " <div class='hud_details hud_box' id='hud_icon_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['widget_detail_background_color']) ? "background: ".$row['widget_detail_background_color'].";" : null)."'>".str_replace("\r", '<br>', escape($widget_content_details))."</div>\n";
}
echo " <span class='hud_expander' onclick=\"$('#hud_icon_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
echo "</div>\n";

View File

@@ -5,63 +5,64 @@
require_once "resources/check_auth.php";
//convert to a key
$dashboard_key = str_replace(' ', '_', strtolower($dashboard_name));
$widget_key = str_replace(' ', '_', strtolower($widget_name));
//add multi-lingual support
$language = new text;
$text = $language->get($_SESSION['domain']['language']['code'], dirname($dashboard_url));
$text = $language->get($_SESSION['domain']['language']['code'], dirname($widget_url));
//get the dashboard label
$dashboard_label = $text['title-'.$dashboard_key];
if (empty($dashboard_label)) {
$dashboard_label = $dashboard_name;
$widget_label = $text['title-'.$widget_key];
if (empty($widget_label)) {
$widget_label = $widget_name;
}
//get the list
$sql = "select ";
$sql .= "dashboard_uuid, ";
$sql .= "dashboard_name, ";
$sql .= "dashboard_path, ";
$sql .= "dashboard_icon, ";
$sql .= "dashboard_icon_color, ";
$sql .= "dashboard_url, ";
$sql .= "dashboard_target, ";
$sql .= "dashboard_width, ";
$sql .= "dashboard_height, ";
$sql .= "dashboard_content, ";
$sql .= "dashboard_content_text_align, ";
$sql .= "dashboard_content_details, ";
$sql .= "dashboard_chart_type, ";
$sql .= "cast(dashboard_label_enabled as text), ";
$sql .= "dashboard_label_text_color, ";
$sql .= "dashboard_label_text_color_hover, ";
$sql .= "dashboard_label_background_color, ";
$sql .= "dashboard_label_background_color_hover, ";
$sql .= "dashboard_number_text_color, ";
$sql .= "dashboard_number_text_color_hover, ";
$sql .= "dashboard_number_background_color, ";
$sql .= "dashboard_background_color, ";
$sql .= "dashboard_background_color_hover, ";
$sql .= "dashboard_detail_background_color, ";
$sql .= "dashboard_background_gradient_style, ";
$sql .= "dashboard_background_gradient_angle, ";
$sql .= "dashboard_column_span, ";
$sql .= "dashboard_row_span, ";
$sql .= "dashboard_details_state, ";
$sql .= "dashboard_order, ";
$sql .= "cast(dashboard_enabled as text), ";
$sql .= "dashboard_description ";
$sql .= "from v_dashboard as d ";
$sql .= "where dashboard_enabled = 'true' ";
$sql .= "and dashboard_uuid in (";
$sql .= " select dashboard_uuid from v_dashboard_groups where group_uuid in (";
$sql .= "dashboard_widget_uuid, ";
$sql .= "widget_name, ";
$sql .= "widget_path, ";
$sql .= "widget_icon, ";
$sql .= "widget_icon_color, ";
$sql .= "widget_url, ";
$sql .= "widget_target, ";
$sql .= "widget_width, ";
$sql .= "widget_height, ";
$sql .= "widget_content, ";
$sql .= "widget_content_text_align, ";
$sql .= "widget_content_details, ";
$sql .= "widget_chart_type, ";
$sql .= "cast(widget_label_enabled as text), ";
$sql .= "widget_label_text_color, ";
$sql .= "widget_label_text_color_hover, ";
$sql .= "widget_label_background_color, ";
$sql .= "widget_label_background_color_hover, ";
$sql .= "widget_number_text_color, ";
$sql .= "widget_number_text_color_hover, ";
$sql .= "widget_number_background_color, ";
$sql .= "widget_background_color, ";
$sql .= "widget_background_color_hover, ";
$sql .= "widget_detail_background_color, ";
$sql .= "widget_background_gradient_style, ";
$sql .= "widget_background_gradient_angle, ";
$sql .= "widget_column_span, ";
$sql .= "widget_row_span, ";
$sql .= "widget_details_state, ";
$sql .= "widget_order, ";
$sql .= "cast(widget_enabled as text), ";
$sql .= "widget_description ";
$sql .= "from v_dashboard_widgets as d ";
$sql .= "where widget_enabled = 'true' ";
$sql .= "and dashboard_widget_uuid in (";
$sql .= " select dashboard_widget_uuid from v_dashboard_widget_groups where group_uuid in (";
$sql .= " ".$group_uuids_in." ";
$sql .= " )";
$sql .= ")";
$sql .= "and dashboard_parent_uuid = :dashboard_uuid ";
$sql .= "order by dashboard_order, dashboard_name asc ";
$parameters['dashboard_uuid'] = $dashboard_uuid;
$parent_widgets = $database->select($sql, $parameters ?? null, 'all');
$sql .= "and dashboard_widget_parent_uuid = :dashboard_widget_uuid ";
$sql .= "order by widget_order, widget_name asc ";
$parameters['dashboard_widget_uuid'] = $widget_uuid;
$child_widgets = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
?>
@@ -101,11 +102,11 @@ div.child_widget div.hud_chart {
/* dashboard settings */
<?php
foreach ($parent_widgets as $row) {
$dashboard_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_uuid']));
if ($row['dashboard_path'] === "dashboard/icon" || $row['dashboard_chart_type'] === "icon") {
echo "#".$dashboard_id.":hover div.hud_box:first-of-type,\n";
echo "#".$dashboard_id.".editable:hover div.hud_box:first-of-type {\n";
foreach ($child_widgets as $row) {
$widget_id = 'id_'.md5(preg_replace('/[^-A-Fa-f0-9]/', '', $row['dashboard_widget_uuid']));
if ($row['widget_path'] === "dashboard/icon" || $row['widget_chart_type'] === "icon") {
echo "#".$widget_id.":hover div.hud_box:first-of-type,\n";
echo "#".$widget_id.".editable:hover div.hud_box:first-of-type {\n";
echo " transform: scale(1.05, 1.05);\n";
echo " -webkit-transition: .1s;\n";
echo " -moz-transition: .1s;\n";
@@ -124,25 +125,25 @@ foreach ($parent_widgets as $row) {
echo " <div class='hud_content parent_widget'>\n";
$x = 0;
foreach ($parent_widgets as $row) {
foreach ($child_widgets as $row) {
//set the variables
$dashboard_uuid = $row['dashboard_uuid'] ?? '';
$dashboard_name = $row['dashboard_name'] ?? '';
$dashboard_label = $row['dashboard_name'] ?? '';
$dashboard_icon = $row['dashboard_icon'] ?? '';
$dashboard_url = $row['dashboard_url'] ?? '';
$dashboard_target = $row['dashboard_target'] ?? '';
$dashboard_width = $row['dashboard_width'] ?? '';
$dashboard_height = $row['dashboard_height'] ?? '';
$dashboard_content = $row['dashboard_content'] ?? '';
$dashboard_content_text_align = $row['dashboard_content_text_align'] ?? '';
$dashboard_content_details = $row['dashboard_content_details'] ?? '';
$dashboard_chart_type = $row['dashboard_chart_type'] ?? '';
$dashboard_label_text_color = $row['dashboard_label_text_color'] ?? $settings->get('theme', 'dashboard_label_text_color', '');
$dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color', '');
$dashboard_number_background_color = $row['dashboard_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color', '');
$dashboard_details_state = $row['dashboard_details_state'] ?? 'disabled';
$dashboard_row_span = $row['dashboard_row_span'] ?? '';
$widget_uuid = $row['dashboard_widget_uuid'] ?? '';
$widget_name = $row['widget_name'] ?? '';
$widget_label = $row['widget_name'] ?? '';
$widget_icon = $row['widget_icon'] ?? '';
$widget_url = $row['widget_url'] ?? '';
$widget_target = $row['widget_target'] ?? '';
$widget_width = $row['widget_width'] ?? '';
$widget_height = $row['widget_height'] ?? '';
$widget_content = $row['widget_content'] ?? '';
$widget_content_text_align = $row['widget_content_text_align'] ?? '';
$widget_content_details = $row['widget_content_details'] ?? '';
$widget_chart_type = $row['widget_chart_type'] ?? '';
$widget_label_text_color = $row['widget_label_text_color'] ?? $settings->get('theme', 'dashboard_label_text_color', '');
$widget_number_text_color = $row['widget_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color', '');
$widget_number_background_color = $row['widget_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color', '');
$widget_details_state = $row['widget_details_state'] ?? 'disabled';
$widget_row_span = $row['widget_row_span'] ?? '';
//define the regex patterns
$uuid_pattern = '/[^-A-Fa-f0-9]/';
@@ -150,34 +151,34 @@ foreach ($parent_widgets as $row) {
$text_pattern = '/[^a-zA-Z0-9 _\-\/.\?:\=#\n]/';
//sanitize the data
$dashboard_uuid = preg_replace($uuid_pattern, '', $dashboard_uuid);
$dashboard_id = 'id_'.md5($dashboard_uuid);
$dashboard_name = trim(preg_replace($text_pattern, '', $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 = preg_replace($text_pattern, '', $dashboard_content);
$dashboard_content = str_replace("\n", '<br />', $dashboard_content);
$dashboard_content_text_align = trim(preg_replace($text_pattern, '', $dashboard_content_text_align));
$dashboard_content_details = preg_replace($text_pattern, '', $dashboard_content_details);
$dashboard_content_details = str_replace("\n", '<br />', $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_number_background_color = preg_replace($text_pattern, '', $dashboard_number_background_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']));
$widget_uuid = preg_replace($uuid_pattern, '', $widget_uuid);
$widget_id = 'id_'.md5($widget_uuid);
$widget_name = trim(preg_replace($text_pattern, '', $widget_name));
$widget_icon = preg_replace($text_pattern, '', $widget_icon);
$widget_url = trim(preg_replace($text_pattern, '', $widget_url));
$widget_target = trim(preg_replace($text_pattern, '', $widget_target));
$widget_width = trim(preg_replace($text_pattern, '', $widget_width));
$widget_height = trim(preg_replace($text_pattern, '', $widget_height));
$widget_content = preg_replace($text_pattern, '', $widget_content);
$widget_content = str_replace("\n", '<br />', $widget_content);
$widget_content_text_align = trim(preg_replace($text_pattern, '', $widget_content_text_align));
$widget_content_details = preg_replace($text_pattern, '', $widget_content_details);
$widget_content_details = str_replace("\n", '<br />', $widget_content_details);
$widget_chart_type = preg_replace($text_pattern, '', $widget_chart_type);
$widget_label_text_color = preg_replace($text_pattern, '', $widget_label_text_color);
$widget_number_text_color = preg_replace($text_pattern, '', $widget_number_text_color);
$widget_number_background_color = preg_replace($text_pattern, '', $widget_number_background_color);
$widget_details_state = preg_replace($text_pattern, '', $widget_details_state);
$widget_row_span = preg_replace($number_pattern, '', $widget_row_span);
$widget_path = preg_replace($text_pattern, '', strtolower($row['widget_path']));
//find the application and widget
$dashboard_path_array = explode('/', $dashboard_path);
$application_name = $dashboard_path_array[0];
$child_widget_name = $dashboard_path_array[1];
$widget_path_array = explode('/', $widget_path);
$application_name = $widget_path_array[0];
$child_widget_name = $widget_path_array[1];
$path_array = glob(dirname(__DIR__, 4).'/*/'.$application_name.'/resources/dashboard/'.$child_widget_name.'.php');
echo "<div class='child_widget ".$dashboard_details_state."' id='".$dashboard_id."' draggable='false'>\n";
echo "<div class='child_widget ".$widget_details_state."' id='".$widget_id."' draggable='false'>\n";
if (file_exists($path_array[0])) {
include $path_array[0];
}
@@ -185,8 +186,8 @@ foreach ($parent_widgets as $row) {
}
echo " </div>\n";
//if (empty($dashboard_details_state) || $dashboard_details_state != "disabled") {
// echo " <div class='hud_details hud_box' id='hud_icon_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['dashboard_detail_background_color']) ? "background: ".$row['dashboard_detail_background_color'].";" : null)."'>".str_replace("\r", '<br>', escape($dashboard_content_details))."</div>\n";
//if (empty($widget_details_state) || $widget_details_state != "disabled") {
// echo " <div class='hud_details hud_box' id='hud_icon_details' style='padding: 20px; 10%; overflow: auto; ".(!empty($row['widget_detail_background_color']) ? "background: ".$row['widget_detail_background_color'].";" : null)."'>".str_replace("\r", '<br>', escape($widget_content_details))."</div>\n";
//}
//echo " <span class='hud_expander' onclick=\"$('#hud_icon_details').slideToggle('fast');\"><span class='fas fa-ellipsis-h'></span></span>";
echo "</div>\n";