Dashboard: Call Forward widget, Edit position without reload, misc adjustments.

This commit is contained in:
fusionate
2023-01-31 00:19:09 +00:00
parent ba344fd56b
commit d04b6db96a
17 changed files with 473 additions and 116 deletions

View File

@@ -426,4 +426,50 @@
$text['label-welcome']['ru-ru'] = "Добро пожаловать:";
$text['label-welcome']['sv-se'] = "Välkommen:";
$text['label-welcome']['uk-ua'] = "Ласкаво просимо:";
?>
$text['button-contract_all']['en-us'] = "Contract All";
$text['button-contract_all']['en-gb'] = "Contract All";
$text['button-contract_all']['ar-eg'] = "Contract All";
$text['button-contract_all']['de-at'] = "Contract All";
$text['button-contract_all']['de-ch'] = "Contract All";
$text['button-contract_all']['de-de'] = "Contract All";
$text['button-contract_all']['el-gr'] = "Contract All";
$text['button-contract_all']['es-cl'] = "Contract All";
$text['button-contract_all']['es-mx'] = "Contract All";
$text['button-contract_all']['fr-ca'] = "Contract All";
$text['button-contract_all']['fr-fr'] = "Contract All";
$text['button-contract_all']['he-il'] = "Contract All";
$text['button-contract_all']['it-it'] = "Contract All";
$text['button-contract_all']['nl-nl'] = "Contract All";
$text['button-contract_all']['pl-pl'] = "Contract All";
$text['button-contract_all']['pt-br'] = "Contract All";
$text['button-contract_all']['pt-pt'] = "Contract All";
$text['button-contract_all']['ro-ro'] = "Contract All";
$text['button-contract_all']['ru-ru'] = "Contract All";
$text['button-contract_all']['sv-se'] = "Contract All";
$text['button-contract_all']['uk-ua'] = "Contract All";
$text['button-contract_all']['tr-tr'] = "Contract All";
$text['button-expand_all']['en-us'] = "Expand All";
$text['button-expand_all']['en-gb'] = "Expand All";
$text['button-expand_all']['ar-eg'] = "Expand All";
$text['button-expand_all']['de-at'] = "Expand All";
$text['button-expand_all']['de-ch'] = "Expand All";
$text['button-expand_all']['de-de'] = "Expand All";
$text['button-expand_all']['el-gr'] = "Expand All";
$text['button-expand_all']['es-cl'] = "Expand All";
$text['button-expand_all']['es-mx'] = "Expand All";
$text['button-expand_all']['fr-ca'] = "Expand All";
$text['button-expand_all']['fr-fr'] = "Expand All";
$text['button-expand_all']['he-il'] = "Expand All";
$text['button-expand_all']['it-it'] = "Expand All";
$text['button-expand_all']['nl-nl'] = "Expand All";
$text['button-expand_all']['pl-pl'] = "Expand All";
$text['button-expand_all']['pt-br'] = "Expand All";
$text['button-expand_all']['pt-pt'] = "Expand All";
$text['button-expand_all']['ro-ro'] = "Expand All";
$text['button-expand_all']['ru-ru'] = "Expand All";
$text['button-expand_all']['sv-se'] = "Expand All";
$text['button-expand_all']['uk-ua'] = "Expand All";
$text['button-expand_all']['tr-tr'] = "Expand All";
?>

View File

@@ -241,6 +241,7 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-dashboard']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['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'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','name'=>'btn_add','link'=>'dashboard_edit.php']);
}

View File

@@ -172,6 +172,14 @@
</script>
<?php
// determine initial state all button to display
if (is_array($dashboard) && @sizeof($dashboard) != 0) {
$expanded_all = true;
foreach ($dashboard as $row) {
if ($row['dashboard_details_state'] == 'contracted') { $expanded_all = false; }
}
}
//show the content
echo "<form id='dashboard' method='POST' onsubmit='setFormSubmitting()'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
@@ -181,13 +189,13 @@
echo " ".$text['label-welcome']." <a href='".PROJECT_PATH."/core/users/user_edit.php?id=user'>".$_SESSION["username"]."</a>&nbsp; &nbsp;";
}
if (permission_exists('dashboard_edit')) {
if ($_GET['edit'] == 'true') {
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','name'=>'btn_back','link'=>'index.php']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','name'=>'btn_save']);
}
else {
echo button::create(['type'=>'button','label'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'id'=>'btn_edit','name'=>'btn_edit','link'=>'index.php?edit=true']);
}
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;']);
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();"]);
echo button::create(['type'=>'button','label'=>$text['button-contract_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();"]);
echo "</span>\n";
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');"]);
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";
@@ -213,6 +221,7 @@
.widget {
/*background-color: #eee;*/
cursor: pointer;
}
.widgets {
@@ -312,11 +321,7 @@
foreach($dashboard as $row) {
$dashboard_name = strtolower($row['dashboard_name']);
$dashboard_name = str_replace(" ", "_", $dashboard_name);
$draggable = '';
if ($_GET['edit'] == 'true') {
$draggable = "draggable='true'";
}
echo "<div class='widget' id='".$dashboard_name."' ".$draggable.">\n";
echo "<div class='widget' id='".$dashboard_name."' draggable='false'>\n";
include($row['dashboard_path']);
echo "</div>\n";
$x++;
@@ -324,7 +329,7 @@
echo "</div>\n";
//begin edit
if ($_GET['edit'] == 'true') {
if (permission_exists('dashboard_edit')) {
?>
<style>
@@ -336,83 +341,112 @@
user-select: none;
}
.widget {
div.widget.editable {
cursor: move;
}
.hud_box {
.hud_box.editable {
transition: 0.2s;
border: 1px dashed rgba(0,0,0,0.4);
}
.hud_box:hover {
.hud_box.editable:hover {
box-shadow: 0 5px 10px rgba(0,0,0,0.2);
border: 1px dashed rgba(0,0,0,0.4);
transform: scale(1.03, 1.03);
transition: 0.2s;
}
.hud_box .hud_box:hover {
.hud_box .hud_box.editable:hover {
box-shadow: none;
transform: none;
}
.ghost {
border: 3px dashed rgba(0,0,0,1);
border: 2px dashed rgba(0,0,0,1);
<?php $br = format_border_radius($_SESSION['theme']['dashboard_border_radius']['text'], '5px'); ?>
-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); ?>
opacity: 0.2;
}
</style>
<script>
//make widgets draggable
var widgets = document.getElementById('widgets');
var sortable = Sortable.create(widgets, {
animation: 150,
draggable: ".widget",
preventOnFilter: true,
ghostClass: 'ghost',
/*
onChange: function (evt) {
//check if chart exists
let chart_status = Chart.getChart(evt.item.id + "_chart");
if(chart_status !== undefined && chart_status !== null) {
let context = eval(evt.item.id + "_chart_context");
let chart = Chart.getChart(context);
let config = eval(evt.item.id + "_chart_config");
var sortable;
//make widgets draggable
function edit_mode(state) {
//re render the chart
chart.destroy();
chart.options.animation = { duration: 0 };
chart = new Chart(context, config);
}
},
*/
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;
},
});
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');
/*
//warn the user before leaving the page
var formSubmitting = false;
var setFormSubmitting = function() { formSubmitting = true; };
sortable = Sortable.create(widgets, {
animation: 150,
draggable: ".widget",
preventOnFilter: true,
ghostClass: 'ghost',
/*
onChange: function (evt) {
//check if chart exists
let chart_status = Chart.getChart(evt.item.id + "_chart");
if(chart_status !== undefined && chart_status !== null) {
let context = eval(evt.item.id + "_chart_context");
let chart = Chart.getChart(context);
let config = eval(evt.item.id + "_chart_config");
window.onload = function() {
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = 'You have unsaved changes which will not be saved.';
//re render the chart
chart.destroy();
chart.options.animation = { duration: 0 };
chart = new Chart(context, config);
}
},
*/
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;
},
});
if (formSubmitting) {
return undefined;
}
/*
//warn the user before leaving the page
var formSubmitting = false;
var setFormSubmitting = function() { formSubmitting = true; };
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
};
*/
window.onload = function() {
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = 'You have unsaved changes which will not be saved.';
if (formSubmitting) {
return undefined;
}
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
});
};
*/
}
else { // off
$('div.widget').attr('draggable',false).removeClass('editable');
$('.hud_box').removeClass('editable');
$('#btn_back, #btn_save').hide();
$('span#expand_contract, #btn_edit, #btn_add').show();
sortable.option('disabled', true);
}
}
</script>
<?php
} //end edit
@@ -420,4 +454,4 @@
//show the footer
require_once "resources/footer.php";
?>
?>

View File

@@ -2589,16 +2589,16 @@ $text['label-active']['ru-ru'] = "Активные";
$text['label-active']['sv-se'] = "Aktiv";
$text['label-active']['uk-ua'] = "";
$text['label-inactive']['en-us'] = "InActive";
$text['label-inactive']['en-gb'] = "InActive";
$text['label-inactive']['en-us'] = "Inactive";
$text['label-inactive']['en-gb'] = "Inactive";
$text['label-inactive']['ar-eg'] = "";
$text['label-inactive']['de-at'] = "InAktiv"; //copied from de-de
$text['label-inactive']['de-ch'] = "InAktiv"; //copied from de-de
$text['label-inactive']['de-de'] = "InAktiv";
$text['label-inactive']['de-at'] = "Inaktiv"; //copied from de-de
$text['label-inactive']['de-ch'] = "Inaktiv"; //copied from de-de
$text['label-inactive']['de-de'] = "Inaktiv";
$text['label-inactive']['es-cl'] = "";
$text['label-inactive']['es-mx'] = "";
$text['label-inactive']['fr-ca'] = "InActif";
$text['label-inactive']['fr-fr'] = "InActif";
$text['label-inactive']['fr-ca'] = "Inactif";
$text['label-inactive']['fr-fr'] = "Inactif";
$text['label-inactive']['he-il'] = "";
$text['label-inactive']['it-it'] = "Non Attivo";
$text['label-inactive']['nl-nl'] = "";
@@ -2607,7 +2607,7 @@ $text['label-inactive']['pt-br'] = "";
$text['label-inactive']['pt-pt'] = "";
$text['label-inactive']['ro-ro'] = "";
$text['label-inactive']['ru-ru'] = "Неактивный";
$text['label-inactive']['sv-se'] = "InAktiv";
$text['label-inactive']['sv-se'] = "Inaktiv";
$text['label-inactive']['uk-ua'] = "";
?>