Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new property to dashboard sql table "fullscreen" #245

Merged
merged 1 commit into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Views/dashboard_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<abbr title="<?php echo dgettext('dashboard_messages','Shows dashboard description on mouse over dashboard name in menu project'); ?>"><?php echo dgettext('dashboard_messages','Show description'); ?></abbr>
</label>

<label class="checkbox">
<input type="checkbox" name="fullscreen" id="chk_fullscreen" value="1" <?php if ($dashboard['fullscreen'] == true) echo 'checked'; ?> />
<abbr title="<?php echo dgettext('dashboard_messages','Hide menus on dashboard. Make full screen.'); ?>"><?php echo dgettext('dashboard_messages','Hide Menus'); ?></abbr>
</label>

<label><?php echo dgettext('dashboard_messages','Content: '); ?></label>
<i style="font-size:12px"><?php echo dgettext('dashboard_messages','To view content changes reload editor after saving');?></i>
<textarea name="content" style="width:100%; height:200px;"><?php echo $dashboard['content']; ?></textarea>
Expand Down Expand Up @@ -95,6 +100,7 @@
if ($("#chk_public").is(":checked")) fields['public'] = true; else fields['public'] = false;
if ($("#chk_published").is(":checked")) fields['published'] = true; else fields['published'] = false;
if ($("#chk_showdescription").is(":checked")) fields['showdescription'] = true; else fields['showdescription'] = false;
fields['fullscreen'] = $("#chk_fullscreen").is(":checked");

$.ajax({
type: "POST",
Expand Down
25 changes: 24 additions & 1 deletion Views/dashboard_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,30 @@

if ($session['write']) $dashboard_editor_icon ='<a href="'.$path.'dashboard/edit?id='. $dashboard['id'].'"> <img src="'.$path.'Modules/dashboard/Views/icons/gear-icon-outlined.png" style="width:80%" ></a>';

?>
if($dashboard['fullscreen']): ?>

<script>
/**
* if the dashboard's property "fullscreen" is true
* hide the menus and shift the content up and left
*/
$(function(){
// hide menus
$('#emoncms-navbar, #sidebar').hide();
// shift content
$('.content-container').css({margin:0});
// fit footer to botttom of screen
$('#footer').css({
bottom: 0,
position: 'absolute',
width: '100vw'
});
// shift edit icon up
$('#editicon').css({top: '.5rem'});
})
</script>

<?php endif; ?>
<style>
#editicon{
text-align: center;
Expand Down
3 changes: 1 addition & 2 deletions dashboard_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function dashboard_controller()

require "Modules/dashboard/dashboard_model.php";
$dashboard = new Dashboard($mysqli);
// id, userid, content, height, name, alias, description, main, public, published, showdescription
// id, userid, content, height, name, alias, description, main, public, published, showdescription, fullscreen

$js_css_version = 5;

Expand Down Expand Up @@ -61,7 +61,6 @@ function dashboard_controller()
{
if ($route->subaction) $dash = $dashboard->get_from_alias($session['userid'],$route->subaction);
elseif (isset($_GET['id'])) $dash = $dashboard->get(get('id'));

$result = view("Modules/dashboard/Views/dashboard_edit_view.php",array('dashboard'=>$dash, 'js_css_version'=>$js_css_version));
$result .= view("Modules/dashboard/Views/dashboard_config.php", array('dashboard'=>$dash, 'js_css_version'=>$js_css_version));

Expand Down
7 changes: 4 additions & 3 deletions dashboard_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function get_list($userid, $public, $published)
$qB = ""; $qC = "";
if ($public==true) $qB = " and public=1";
if ($published==true) $qC = " and published=1";
if (!$result = $this->mysqli->query("SELECT id, name, alias, description, main, published, public, showdescription FROM dashboard WHERE userid='$userid'".$qB.$qC)) {
if (!$result = $this->mysqli->query("SELECT id, name, alias, description, main, published, public, showdescription, fullscreen FROM dashboard WHERE userid='$userid'".$qB.$qC)) {
return array();
}

Expand Down Expand Up @@ -152,13 +152,14 @@ public function set($userid,$id,$fields)
}

if (isset($fields->public)) $row->public = (bool) $fields->public;
if (isset($fields->fullscreen)) $row->fullscreen = (bool) $fields->fullscreen;
if (isset($fields->published)) $row->published = (bool) $fields->published;
if (isset($fields->showdescription)) $row->showdescription = (bool) $fields->showdescription;

if (!$stmt = $this->mysqli->prepare("UPDATE dashboard SET height=?,name=?,alias=?,description=?,backgroundcolor=?,gridsize=?,feedmode=?,main=?,public=?,published=?,showdescription=? WHERE userid=? AND id=?")) {
if (!$stmt = $this->mysqli->prepare("UPDATE dashboard SET height=?,name=?,alias=?,description=?,backgroundcolor=?,gridsize=?,feedmode=?,main=?,public=?,published=?,showdescription=?,fullscreen=? WHERE userid=? AND id=?")) {
return array('success'=>false, 'message'=>'Dashboard schema error, please run emoncms database update');
}
$stmt->bind_param("issssisiiiiii",$row->height,$row->name,$row->alias,$row->description,$row->backgroundcolor,$row->gridsize,$row->feedmode,$row->main,$row->public,$row->published,$row->showdescription,$userid,$id);
$stmt->bind_param("issssisiiiiiii",$row->height,$row->name,$row->alias,$row->description,$row->backgroundcolor,$row->gridsize,$row->feedmode,$row->main,$row->public,$row->published,$row->showdescription,$row->fullscreen,$userid,$id);

$stmt->execute();
$affected_rows = $stmt->affected_rows;
Expand Down
1 change: 1 addition & 0 deletions dashboard_schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
'showdescription' => array('type' => 'tinyint(1)', 'default'=>'0'),
'backgroundcolor' => array('type' => "varchar(6)", 'default'=>'EDF7FC'),
'gridsize' => array('type' => 'tinyint(1)', 'default'=>'20'),
'fullscreen' => array('type' => 'tinyint(1)', 'default'=>'0'),
'feedmode' => array('type' => "varchar(8)", 'default'=>'feedid')
);