2021-11-10 02:42:14 +01:00
|
|
|
<?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>
|
2024-04-25 03:49:16 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2022-2024
|
2021-11-10 02:42:14 +01:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
|
2023-06-15 19:28:23 +02:00
|
|
|
//includes files
|
|
|
|
|
require_once dirname(__DIR__, 2) . "/resources/require.php";
|
2021-11-10 02:42:14 +01:00
|
|
|
|
2022-10-12 18:45:40 +02:00
|
|
|
//if config.conf file does not exist then redirect to the install page
|
2022-10-11 03:38:46 +02:00
|
|
|
if (file_exists("/usr/local/etc/fusionpbx/config.conf")){
|
|
|
|
|
//BSD
|
2023-05-11 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
elseif (file_exists("/etc/fusionpbx/config.conf")){
|
2022-10-11 03:38:46 +02:00
|
|
|
//Linux
|
2023-05-11 00:23:22 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2022-10-16 05:14:43 +02:00
|
|
|
header("Location: /core/install/install.php");
|
2021-11-10 02:42:14 +01:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//additional includes
|
|
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
|
|
|
|
|
//disable login message
|
|
|
|
|
if (isset($_GET['msg']) && $_GET['msg'] == 'dismiss') {
|
|
|
|
|
unset($_SESSION['login']['message']['text']);
|
|
|
|
|
|
|
|
|
|
$sql = "update v_default_settings ";
|
|
|
|
|
$sql .= "set default_setting_enabled = 'false' ";
|
|
|
|
|
$sql .= "where ";
|
|
|
|
|
$sql .= "default_setting_category = 'login' ";
|
|
|
|
|
$sql .= "and default_setting_subcategory = 'message' ";
|
|
|
|
|
$sql .= "and default_setting_name = 'text' ";
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->execute($sql);
|
|
|
|
|
unset($sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//build a list of groups the user is a member of to be used in a SQL in
|
2022-09-27 22:29:53 +02:00
|
|
|
if (is_array($_SESSION['user']['groups'])) {
|
|
|
|
|
foreach($_SESSION['user']['groups'] as $group) {
|
|
|
|
|
$group_uuids[] = $group['group_uuid'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (is_array($group_uuids)) {
|
|
|
|
|
$group_uuids_in = "'".implode("','", $group_uuids)."'";
|
2021-11-10 02:42:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get the list
|
|
|
|
|
$sql = "select \n";
|
|
|
|
|
$sql .= "dashboard_uuid, \n";
|
|
|
|
|
$sql .= "dashboard_name, \n";
|
|
|
|
|
$sql .= "dashboard_path, \n";
|
2024-04-25 03:49:16 +02:00
|
|
|
$sql .= "dashboard_url, \n";
|
|
|
|
|
$sql .= "dashboard_icon, \n";
|
2024-04-19 00:57:45 +02:00
|
|
|
$sql .= "dashboard_chart_type, \n";
|
2024-04-24 22:14:24 +02:00
|
|
|
$sql .= "dashboard_heading_background_color, \n";
|
2024-04-18 00:01:54 +02:00
|
|
|
$sql .= "dashboard_heading_text_color, \n";
|
2024-04-24 22:14:24 +02:00
|
|
|
$sql .= "dashboard_number_background_color, \n";
|
2024-04-18 00:01:54 +02:00
|
|
|
$sql .= "dashboard_number_text_color, \n";
|
2021-12-23 19:44:57 +01:00
|
|
|
$sql .= "dashboard_column_span, \n";
|
2023-01-17 21:50:44 +01:00
|
|
|
$sql .= "dashboard_details_state, \n";
|
2021-11-10 02:42:14 +01:00
|
|
|
$sql .= "dashboard_order, \n";
|
|
|
|
|
$sql .= "cast(dashboard_enabled as text), \n";
|
|
|
|
|
$sql .= "dashboard_description \n";
|
|
|
|
|
$sql .= "from v_dashboard as d \n";
|
|
|
|
|
$sql .= "where dashboard_enabled = 'true' \n";
|
|
|
|
|
$sql .= "and dashboard_uuid in (\n";
|
|
|
|
|
$sql .= " select dashboard_uuid from v_dashboard_groups where group_uuid in (\n";
|
|
|
|
|
$sql .= " ".$group_uuids_in." \n";
|
|
|
|
|
$sql .= " )\n";
|
|
|
|
|
$sql .= ")\n";
|
|
|
|
|
$sql .= "order by dashboard_order asc \n";
|
|
|
|
|
$database = new database;
|
2023-05-11 00:23:22 +02:00
|
|
|
$dashboard = $database->select($sql, $parameters ?? null, 'all');
|
2021-11-10 02:42:14 +01:00
|
|
|
unset($sql, $parameters);
|
|
|
|
|
|
2021-11-24 02:34:00 +01:00
|
|
|
//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"]);
|
|
|
|
|
$dashboard_order = '0';
|
|
|
|
|
$x = 0;
|
|
|
|
|
foreach($widgets as $widget) {
|
|
|
|
|
foreach($dashboard as $row) {
|
|
|
|
|
$dashboard_name = strtolower($row['dashboard_name']);
|
|
|
|
|
$dashboard_name = str_replace(" ", "_", $dashboard_name);
|
|
|
|
|
if ($widget == $dashboard_name) {
|
|
|
|
|
$dashboard_order = $dashboard_order + 10;
|
|
|
|
|
$array['dashboard'][$x]['dashboard_name'] = $row['dashboard_name'];
|
2024-04-25 03:49:16 +02:00
|
|
|
$array['dashboard'][$x]['dashboard_url'] = $row['dashboard_url'];
|
|
|
|
|
$array['dashboard'][$x]['dashboard_icon'] = $row['dashboard_icon'];
|
2021-11-24 02:34:00 +01:00
|
|
|
$array['dashboard'][$x]['dashboard_uuid'] = $row['dashboard_uuid'];
|
|
|
|
|
$array['dashboard'][$x]['dashboard_order'] = $dashboard_order;
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//save the data
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'dashboard';
|
|
|
|
|
$database->app_uuid = '55533bef-4f04-434a-92af-999c1e9927f7';
|
|
|
|
|
$database->save($array);
|
|
|
|
|
|
|
|
|
|
//redirect the browser
|
|
|
|
|
message::add($text['message-update']);
|
|
|
|
|
header("Location: /core/dashboard/index.php");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 02:42:14 +01:00
|
|
|
//add multi-lingual support
|
|
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
|
|
|
|
|
2024-04-18 00:01:54 +02:00
|
|
|
//add the settings object
|
|
|
|
|
$settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]);
|
|
|
|
|
|
2021-11-10 02:42:14 +01:00
|
|
|
//load the header
|
|
|
|
|
$document['title'] = $text['title-dashboard'];
|
|
|
|
|
require_once "resources/header.php";
|
|
|
|
|
|
2021-11-24 02:34:00 +01:00
|
|
|
//include sortablejs
|
2021-11-24 02:59:23 +01:00
|
|
|
echo "<script src='/resources/sortablejs/sortable.min.js'></script>";
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2021-11-10 05:58:37 +01:00
|
|
|
//include chart.js
|
|
|
|
|
echo "<script src='/resources/chartjs/chart.min.js'></script>";
|
|
|
|
|
|
2021-11-10 06:15:53 +01:00
|
|
|
//chart variables
|
2024-04-18 00:01:54 +02:00
|
|
|
echo "<script>\n";
|
2024-04-24 22:14:24 +02:00
|
|
|
echo " var chart_text_font = '".($settings->get('theme', 'dashboard_number_text_font') ?? 'arial')."';\n";
|
|
|
|
|
echo " var chart_text_size = '30px';\n";
|
2024-04-18 00:01:54 +02:00
|
|
|
echo " Chart.defaults.responsive = true;\n";
|
|
|
|
|
echo " Chart.defaults.maintainAspectRatio = false;\n";
|
|
|
|
|
echo " Chart.defaults.plugins.legend.display = false;\n";
|
|
|
|
|
echo " Chart.overrides.doughnut.cutout = '75%';\n";
|
|
|
|
|
echo "</script>\n";
|
2021-11-10 06:15:53 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
// determine initial state all button to display
|
2024-04-02 17:23:37 +02:00
|
|
|
$expanded_all = true;
|
2023-01-31 01:19:09 +01:00
|
|
|
if (is_array($dashboard) && @sizeof($dashboard) != 0) {
|
|
|
|
|
foreach ($dashboard as $row) {
|
2023-02-18 01:18:29 +01:00
|
|
|
if ($row['dashboard_details_state'] == 'contracted' || $row['dashboard_details_state'] == 'hidden') { $expanded_all = false; }
|
2023-01-31 01:19:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-10 02:42:14 +01:00
|
|
|
//show the content
|
2023-02-18 01:11:36 +01:00
|
|
|
echo "<form id='dashboard' method='post' _onsubmit='setFormSubmitting()'>\n";
|
2021-11-10 02:42:14 +01:00
|
|
|
echo "<div class='action_bar' id='action_bar'>\n";
|
|
|
|
|
echo " <div class='heading'><b>".$text['title-dashboard']."</b></div>\n";
|
|
|
|
|
echo " <div class='actions'>\n";
|
|
|
|
|
if ($_SESSION['theme']['menu_style']['text'] != 'side') {
|
|
|
|
|
echo " ".$text['label-welcome']." <a href='".PROJECT_PATH."/core/users/user_edit.php?id=user'>".$_SESSION["username"]."</a> ";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('dashboard_edit')) {
|
2023-01-31 01:19:09 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','name'=>'btn_back','style'=>'display: none;','onclick'=>"edit_mode('off');"]);
|
|
|
|
|
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','name'=>'btn_save','style'=>'display: none; margin-left: 15px;']);
|
2023-01-31 03:45:06 +01:00
|
|
|
}
|
|
|
|
|
echo "<span id='expand_contract'>\n";
|
|
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-expand_all'],'icon'=>$_SESSION['theme']['button_icon_expand'],'id'=>'btn_expand','name'=>'btn_expand','style'=>($expanded_all ? 'display: none;' : null),'onclick'=>"$('.hud_details').slideDown('fast'); $(this).hide(); $('#btn_contract').show();"]);
|
2023-04-20 00:24:23 +02:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-collapse_all'],'icon'=>$_SESSION['theme']['button_icon_contract'],'id'=>'btn_contract','name'=>'btn_contract','style'=>(!$expanded_all ? 'display: none;' : null),'onclick'=>"$('.hud_details').slideUp('fast'); $(this).hide(); $('#btn_expand').show();"]);
|
2023-01-31 03:45:06 +01:00
|
|
|
echo "</span>\n";
|
|
|
|
|
if (permission_exists('dashboard_edit')) {
|
2023-01-31 01:19:09 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'id'=>'btn_edit','name'=>'btn_edit','style'=>'margin-left: 15px;','onclick'=>"edit_mode('on');"]);
|
2021-11-10 02:42:14 +01:00
|
|
|
echo button::create(['type'=>'button','label'=>$text['button-settings'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard.php']);
|
|
|
|
|
}
|
|
|
|
|
echo " </div>\n";
|
|
|
|
|
echo " <div style='clear: both; text-align: left;'>".$text['description-dashboard']."</div>\n";
|
|
|
|
|
echo "</div>\n";
|
2021-11-24 02:34:00 +01:00
|
|
|
echo "<input type='hidden' id='widget_order' name='widget_order' value='' />\n";
|
|
|
|
|
echo "</form>\n";
|
2021-11-10 02:42:14 +01:00
|
|
|
|
|
|
|
|
//display login message
|
2021-11-12 18:19:38 +01:00
|
|
|
if (if_group("superadmin") && isset($_SESSION['login']['message']['text']) && $_SESSION['login']['message']['text'] != '') {
|
2021-11-24 02:34:00 +01:00
|
|
|
echo "<div class='login_message' width='100%'><b>".$text['login-message_attention']."</b> ".$_SESSION['login']['message']['text']." (<a href='?msg=dismiss'>".$text['login-message_dismiss']."</a>)</div>\n";
|
2021-11-12 18:19:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
* {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.widget {
|
2021-12-23 19:44:57 +01:00
|
|
|
/*background-color: #eee;*/
|
2023-01-31 01:19:09 +01:00
|
|
|
cursor: pointer;
|
2021-11-12 18:19:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.widgets {
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-gap: 1rem;
|
|
|
|
|
grid-column: auto;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 21:50:44 +01:00
|
|
|
/* Screen smaller than 575px? 1 columns */
|
2021-11-12 18:19:38 +01:00
|
|
|
@media (max-width: 575px) {
|
2022-01-25 19:03:37 +01:00
|
|
|
.widgets { grid-template-columns: repeat(1, minmax(100px, 1fr)); }
|
2021-11-12 18:19:38 +01:00
|
|
|
.col-num { grid-column: span 1; }
|
2021-12-23 19:44:57 +01:00
|
|
|
<?php
|
|
|
|
|
foreach($dashboard as $row) {
|
|
|
|
|
$dashboard_name = strtolower($row['dashboard_name']);
|
|
|
|
|
$dashboard_name = str_replace(" ", "_", $dashboard_name);
|
2023-05-11 01:23:15 +02:00
|
|
|
if (isset($dashboard_column_span) && is_numeric($dashboard_column_span)) {
|
2021-12-23 19:44:57 +01:00
|
|
|
echo "#".$dashboard_name." {\n";
|
|
|
|
|
echo " grid-column: span 1;\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
2021-11-12 18:19:38 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-17 21:50:44 +01:00
|
|
|
/* Screen larger than 575px? 2 columns */
|
2021-11-12 18:19:38 +01:00
|
|
|
@media (min-width: 575px) {
|
2022-01-25 19:03:37 +01:00
|
|
|
.widgets { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
|
2021-11-12 18:19:38 +01:00
|
|
|
.col-num { grid-column: span 2; }
|
2021-12-23 19:44:57 +01:00
|
|
|
<?php
|
|
|
|
|
foreach($dashboard as $row) {
|
|
|
|
|
$dashboard_name = strtolower($row['dashboard_name']);
|
|
|
|
|
$dashboard_name = str_replace(" ", "_", $dashboard_name);
|
|
|
|
|
$dashboard_column_span = 1;
|
|
|
|
|
if (is_numeric($dashboard_column_span)) {
|
|
|
|
|
if ($row['dashboard_column_span'] > 2) {
|
|
|
|
|
$dashboard_column_span = 2;
|
|
|
|
|
}
|
|
|
|
|
echo "#".$dashboard_name." {\n";
|
|
|
|
|
echo " grid-column: span ".$dashboard_column_span.";\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
}
|
2023-01-17 21:50:44 +01:00
|
|
|
if ($row['dashboard_details_state'] == "contracted") {
|
|
|
|
|
echo "#".$dashboard_name." .hud_box .hud_details {\n";
|
|
|
|
|
echo " display: none;\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
}
|
|
|
|
|
if ($row['dashboard_details_state'] == "hidden") {
|
|
|
|
|
echo "#".$dashboard_name." .hud_box .hud_expander, \n";
|
|
|
|
|
echo "#".$dashboard_name." .hud_box .hud_details {\n";
|
|
|
|
|
echo " display: none;\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
}
|
2021-12-23 19:44:57 +01:00
|
|
|
}
|
|
|
|
|
?>
|
2021-11-12 18:19:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Screen larger than 1300px? 3 columns */
|
|
|
|
|
@media (min-width: 1300px) {
|
2022-01-25 19:03:37 +01:00
|
|
|
.widgets { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
|
2021-11-12 18:19:38 +01:00
|
|
|
.col-num { grid-column: span 2; }
|
2021-12-23 19:44:57 +01:00
|
|
|
<?php
|
|
|
|
|
foreach($dashboard as $row) {
|
2024-04-02 17:23:37 +02:00
|
|
|
$dashboard_name = str_replace(" ", "_", strtolower($row['dashboard_name']));
|
2021-12-23 19:44:57 +01:00
|
|
|
$dashboard_column_span = $row['dashboard_column_span'];
|
|
|
|
|
if (is_numeric($dashboard_column_span)) {
|
|
|
|
|
echo "#".$dashboard_name." {\n";
|
|
|
|
|
echo " grid-column: span ".$dashboard_column_span.";\n";
|
|
|
|
|
echo "}\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
2021-11-12 18:19:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Screen larger than 1500px? 4 columns */
|
|
|
|
|
@media (min-width: 1500px) {
|
2022-01-25 19:03:37 +01:00
|
|
|
.widgets { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
|
2021-11-12 18:19:38 +01:00
|
|
|
.col-num { grid-column: span 2; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Screen larger than 2000px? 5 columns */
|
|
|
|
|
@media (min-width: 2000px) {
|
2022-01-25 19:03:37 +01:00
|
|
|
.widgets { grid-template-columns: repeat(5, minmax(100px, 1fr)); }
|
2021-11-12 18:19:38 +01:00
|
|
|
.col-num { grid-column: span 2; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<?php
|
2021-11-10 02:42:14 +01:00
|
|
|
|
|
|
|
|
//include the dashboards
|
2021-11-24 02:34:00 +01:00
|
|
|
echo "<div class='widgets' id='widgets' style='padding: 0 5px;'>\n";
|
2021-11-12 18:19:38 +01:00
|
|
|
$x = 0;
|
2021-11-10 02:42:14 +01:00
|
|
|
foreach($dashboard as $row) {
|
2024-04-25 03:49:16 +02:00
|
|
|
$dashboard_name = $row['dashboard_name'];
|
|
|
|
|
$dashboard_icon = $row['dashboard_icon'] ?? '';
|
|
|
|
|
$dashboard_url = $row['dashboard_url'] ?? '';
|
2024-04-19 00:57:45 +02:00
|
|
|
$dashboard_chart_type = $row['dashboard_chart_type'] ?? 'doughnut';
|
2024-04-24 22:14:24 +02:00
|
|
|
$dashboard_heading_background_color = $row['dashboard_heading_background_color'] ?? $settings->get('theme', 'dashboard_heading_background_color');
|
2024-04-18 00:01:54 +02:00
|
|
|
$dashboard_heading_text_color = $row['dashboard_heading_text_color'] ?? $settings->get('theme', 'dashboard_heading_text_color');
|
2024-04-24 22:14:24 +02:00
|
|
|
$dashboard_number_background_color = $row['dashboard_number_background_color'] ?? $settings->get('theme', 'dashboard_number_background_color');
|
|
|
|
|
$dashboard_number_text_color = $row['dashboard_number_text_color'] ?? $settings->get('theme', 'dashboard_number_text_color');
|
2024-04-25 03:49:16 +02:00
|
|
|
echo "<div class='widget' id='".str_replace(" ", "_", strtolower($dashboard_name))."' draggable='false'>\n";
|
|
|
|
|
include($row['dashboard_path']);
|
2021-11-10 02:42:14 +01:00
|
|
|
echo "</div>\n";
|
2021-11-12 18:19:38 +01:00
|
|
|
$x++;
|
2021-11-10 02:42:14 +01:00
|
|
|
}
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
2021-11-24 02:34:00 +01:00
|
|
|
//begin edit
|
2023-01-31 01:19:09 +01:00
|
|
|
if (permission_exists('dashboard_edit')) {
|
2021-11-24 02:59:23 +01:00
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
/*To prevent user selecting inside the drag source*/
|
|
|
|
|
[draggable] {
|
2022-09-27 22:29:53 +02:00
|
|
|
-moz-user-select: none;
|
|
|
|
|
-khtml-user-select: none;
|
|
|
|
|
-webkit-user-select: none;
|
|
|
|
|
user-select: none;
|
2021-11-24 02:59:23 +01:00
|
|
|
}
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
div.widget.editable {
|
2021-11-24 02:59:23 +01:00
|
|
|
cursor: move;
|
|
|
|
|
}
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
.hud_box.editable {
|
2021-11-24 02:59:23 +01:00
|
|
|
transition: 0.2s;
|
2023-01-31 01:19:09 +01:00
|
|
|
border: 1px dashed rgba(0,0,0,0.4);
|
2021-11-24 02:59:23 +01:00
|
|
|
}
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
.hud_box.editable:hover {
|
2021-11-24 02:59:23 +01:00
|
|
|
box-shadow: 0 5px 10px rgba(0,0,0,0.2);
|
2023-01-31 01:19:09 +01:00
|
|
|
border: 1px dashed rgba(0,0,0,0.4);
|
2021-11-24 02:59:23 +01:00
|
|
|
transform: scale(1.03, 1.03);
|
|
|
|
|
transition: 0.2s;
|
|
|
|
|
}
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
.hud_box .hud_box.editable:hover {
|
2021-11-24 02:59:23 +01:00
|
|
|
box-shadow: none;
|
2021-12-23 19:44:57 +01:00
|
|
|
transform: none;
|
2021-11-24 02:59:23 +01:00
|
|
|
}
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2021-11-24 02:59:23 +01:00
|
|
|
.ghost {
|
2023-01-31 01:19:09 +01:00
|
|
|
border: 2px dashed rgba(0,0,0,1);
|
2023-05-16 20:55:10 +02:00
|
|
|
<?php $br = format_border_radius($_SESSION['theme']['dashboard_border_radius']['text'] ?? null, '5px'); ?>
|
2023-01-31 01:19:09 +01:00
|
|
|
-webkit-border-radius: <?php echo $br['tl']['n'].$br['tl']['u']; ?> <?php echo $br['tr']['n'].$br['tr']['u']; ?> <?php echo $br['br']['n'].$br['br']['u']; ?> <?php echo $br['bl']['n'].$br['bl']['u']; ?>;
|
|
|
|
|
-moz-border-radius: <?php echo $br['tl']['n'].$br['tl']['u']; ?> <?php echo $br['tr']['n'].$br['tr']['u']; ?> <?php echo $br['br']['n'].$br['br']['u']; ?> <?php echo $br['bl']['n'].$br['bl']['u']; ?>;
|
|
|
|
|
border-radius: <?php echo $br['tl']['n'].$br['tl']['u']; ?> <?php echo $br['tr']['n'].$br['tr']['u']; ?> <?php echo $br['br']['n'].$br['br']['u']; ?> <?php echo $br['bl']['n'].$br['bl']['u']; ?>;
|
|
|
|
|
<?php unset($br); ?>
|
2021-11-24 02:59:23 +01:00
|
|
|
opacity: 0.2;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
var widgets = document.getElementById('widgets');
|
2023-01-31 01:19:09 +01:00
|
|
|
var sortable;
|
|
|
|
|
//make widgets draggable
|
|
|
|
|
function edit_mode(state) {
|
|
|
|
|
|
|
|
|
|
if (state == 'on') {
|
|
|
|
|
$('span#expand_contract, #btn_edit, #btn_add').hide();
|
|
|
|
|
$('.hud_box').addClass('editable');
|
|
|
|
|
$('#btn_back, #btn_save').show();
|
|
|
|
|
$('div.widget').attr('draggable',true).addClass('editable');
|
|
|
|
|
|
|
|
|
|
sortable = Sortable.create(widgets, {
|
|
|
|
|
animation: 150,
|
|
|
|
|
draggable: ".widget",
|
|
|
|
|
preventOnFilter: true,
|
|
|
|
|
ghostClass: 'ghost',
|
|
|
|
|
onSort: function (evt) {
|
|
|
|
|
let widget_ids = document.querySelectorAll("#widgets > div[id]");
|
|
|
|
|
let widget_ids_list = [];
|
|
|
|
|
for (let i = 0; i < widget_ids.length; i++) {
|
|
|
|
|
widget_ids_list.push(widget_ids[i].id);
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('widget_order').value = widget_ids_list;
|
|
|
|
|
},
|
|
|
|
|
});
|
2023-02-18 01:11:36 +01:00
|
|
|
|
|
|
|
|
// set initial widget order
|
|
|
|
|
let widget_ids = document.querySelectorAll("#widgets > div[id]");
|
|
|
|
|
let widget_ids_list = [];
|
|
|
|
|
for (let i = 0; i < widget_ids.length; i++) {
|
|
|
|
|
widget_ids_list.push(widget_ids[i].id);
|
|
|
|
|
}
|
|
|
|
|
document.getElementById('widget_order').value = widget_ids_list;
|
|
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
}
|
|
|
|
|
else { // off
|
2021-11-30 16:36:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
$('div.widget').attr('draggable',false).removeClass('editable');
|
|
|
|
|
$('.hud_box').removeClass('editable');
|
|
|
|
|
$('#btn_back, #btn_save').hide();
|
|
|
|
|
$('span#expand_contract, #btn_edit, #btn_add').show();
|
2021-11-30 16:36:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
sortable.option('disabled', true);
|
2021-11-30 16:36:00 +01:00
|
|
|
|
2023-01-31 01:19:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-24 02:59:23 +01:00
|
|
|
</script>
|
|
|
|
|
<?php
|
|
|
|
|
} //end edit
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2021-11-24 02:59:23 +01:00
|
|
|
//show the footer
|
|
|
|
|
require_once "resources/footer.php";
|
2021-11-24 02:34:00 +01:00
|
|
|
|
2024-04-25 03:49:16 +02:00
|
|
|
?>
|