From 31bf0b4dbf935e3002a75549f085ddb0f27f021a Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sat, 5 Sep 2015 15:51:20 +0100 Subject: [PATCH 1/8] remove debug statement --- includes/common.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/common.php b/includes/common.php index 1fc1e648c..bcef46da0 100644 --- a/includes/common.php +++ b/includes/common.php @@ -693,9 +693,7 @@ function get_graph_subtypes($type) { // find the MIB subtypes foreach ($config['graph_types'] as $type => $unused1) { - print_r($type); foreach ($config['graph_types'][$type] as $subtype => $unused2) { - print_r($subtype); if (is_mib_graph($type, $subtype)) { $types[] = $subtype; } From 41cff319410e44db99aa653bb8db2929933de7cd Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sat, 5 Sep 2015 15:53:43 +0100 Subject: [PATCH 2/8] Allow multiple instances of the same widget --- .../forms/update-dashboard-config.inc.php | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/html/includes/forms/update-dashboard-config.inc.php b/html/includes/forms/update-dashboard-config.inc.php index c2760adb5..fd6dc18a4 100644 --- a/html/includes/forms/update-dashboard-config.inc.php +++ b/html/includes/forms/update-dashboard-config.inc.php @@ -20,22 +20,14 @@ elseif ($sub_type == 'remove-all') { } } elseif ($sub_type == 'add' && is_numeric($widget_id)) { - $dupe_check = dbFetchCEll('SELECT `user_widget_id` FROM `users_widgets` WHERE `user_id`=? AND `widget_id`=?',array($_SESSION['user_id'],$widget_id)); - - if (is_numeric($dupe_check)) { - $message = 'This widget has already been added'; - } - else { - - $widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id)); - if (is_array($widget)) { - list($x,$y) = explode(',',$widget['base_dimensions']); - $item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); - if (is_numeric($item_id)) { - $extra = array('widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y); - $status = 'ok'; - $message = ''; - } + $widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id)); + if (is_array($widget)) { + list($x,$y) = explode(',',$widget['base_dimensions']); + $item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); + if (is_numeric($item_id)) { + $extra = array('widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y); + $status = 'ok'; + $message = ''; } } } From 7acc1d266a6e5fc013fad4cea085338d8bafaf25 Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sat, 5 Sep 2015 16:15:11 +0100 Subject: [PATCH 3/8] Added per-widget settings --- html/ajax_dash.php | 7 ++- html/includes/forms/widget-settings.inc.php | 52 +++++++++++++++++++++ html/pages/front/tiles.php | 46 +++++++++++++++--- sql-schema/068.sql | 1 + 4 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 html/includes/forms/widget-settings.inc.php create mode 100644 sql-schema/068.sql diff --git a/html/ajax_dash.php b/html/ajax_dash.php index 3b4c56e46..a26e46e5a 100644 --- a/html/ajax_dash.php +++ b/html/ajax_dash.php @@ -33,8 +33,11 @@ if ($type == 'placeholder') { } elseif (is_file('includes/common/'.$type.'.inc.php')) { - $results_limit = 10; - $no_form = true; + $results_limit = 10; + $no_form = true; + $widget_id = mres($_POST['id']); + $widget_settings = json_decode(dbFetchCell('select settings from users_widgets where user_widget_id = ?',array($widget_id)),true); + $widget_dimensions = dbfetchRow('select size_x,size_y from users_widgets where user_widget_id = ?',array($widget_id)); include 'includes/common/'.$type.'.inc.php'; $output = implode('', $common_output); $status = 'ok'; diff --git a/html/includes/forms/widget-settings.inc.php b/html/includes/forms/widget-settings.inc.php new file mode 100644 index 000000000..2ce0cde63 --- /dev/null +++ b/html/includes/forms/widget-settings.inc.php @@ -0,0 +1,52 @@ + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/** + * Store per-widget settings + * @author Daniel Preussker + * @copyright 2015 Daniel Preussker, QuxLabs UG + * @license GPL + * @package LibreNMS + * @subpackage Widgets + */ + +$status = 'error'; +$message = 'unknown error'; +$widget_id = (int) $_REQUEST['id']; + +if ($widget_id < 1) { + $status = 'error'; + $message = 'ERROR: malformed widget ID.'; +} +else { + $widget_settings = $_REQUEST['settings']; + if (!is_array($widget_settings)) { + $widget_settings = array(); + } + if (dbUpdate(array('settings'=>json_encode($widget_settings)),'users_widgets','user_widget_id=?',array($widget_id))) { + $status = 'ok'; + $message = 'Updated'; + } + else { + $status = 'error'; + $message = 'ERROR: Could not update'; + } +} + +die(json_encode(array( + 'status' => $status, + 'message' => $message +))); +?> diff --git a/html/pages/front/tiles.php b/html/pages/front/tiles.php index ddaf61af4..063b4bba6 100644 --- a/html/pages/front/tiles.php +++ b/html/pages/front/tiles.php @@ -18,7 +18,7 @@ $no_refresh = true; -foreach (dbFetchRows('SELECT * FROM `users_widgets` LEFT JOIN `widgets` ON `widgets`.`widget_id`=`users_widgets`.`widget_id` WHERE `user_id`=?',array($_SESSION['user_id'])) as $items) { +foreach (dbFetchRows('SELECT user_widget_id,users_widgets.widget_id,title,widget,col,row,size_x,size_y,refresh FROM `users_widgets` LEFT JOIN `widgets` ON `widgets`.`widget_id`=`users_widgets`.`widget_id` WHERE `user_id`=?',array($_SESSION['user_id'])) as $items) { $data[] = $items; } @@ -121,7 +121,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg gridster.remove_all_widgets(); $.each(serialization, function() { gridster.add_widget( - '
  • '+ + '
  • '+ '\var timeout'+this.user_widget_id+' = grab_data('+this.user_widget_id+','+this.refresh+',\''+this.widget+'\');\<\/script\>'+ '
    '+this.title+'
    '+ '
    '+this.widget+'
    '+ @@ -166,7 +166,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg var size_x = data.extra.size_x; var size_y = data.extra.size_y; gridster.add_widget( - '
  • '+ + '
  • '+ '\var timeout'+widget_id+' = grab_data('+widget_id+',60,\''+widget+'\');\<\/script\>'+ '
    '+title+'
    '+ '
    '+widget+'
    '+ @@ -209,12 +209,40 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg }); - function grab_data(id,refresh,data_type) { - new_refresh = refresh * 1000; + function widget_settings(data) { + var widget_settings = {}; + var widget_id = 0; + datas = $(data).serializeArray(); + for( var field in datas ) { + widget_settings[datas[field].name] = datas[field].value; + } +console.log(widget_settings); + $('.gridster').find('div[id^=widget_body_]').each(function() { + if(this.contains(data)) { + widget_id = $(this).parent().attr('id'); + widget_type = $(this).parent().data('type'); + } + }); + if( widget_id > 0 && widget_settings != {} ) { + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: {type: 'widget-settings', id: widget_id, settings: widget_settings}, + dataType: "json", + success: function (data) { + if( data.status == "ok" ) { + widget_reload(widget_id,widget_type); + } + } + }); + } + } + + function widget_reload(id,data_type) { $.ajax({ type: 'POST', url: 'ajax_dash.php', - data: {type: data_type}, + data: {type: data_type, id: id}, dataType: "json", success: function (data) { if (data.status == 'ok') { @@ -228,7 +256,11 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg $("#widget_body_"+id).html('
    Problem with backend
    '); } }); - + } + + function grab_data(id,refresh,data_type) { + new_refresh = refresh * 1000; + widget_reload(id,data_type); setTimeout(function() { grab_data(id,refresh,data_type); }, diff --git a/sql-schema/068.sql b/sql-schema/068.sql new file mode 100644 index 000000000..39784b418 --- /dev/null +++ b/sql-schema/068.sql @@ -0,0 +1 @@ +alter table users_widgets add column `settings` text not null; From 63ed6e25aab2176ff1602355401fefe129ee49b9 Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sat, 5 Sep 2015 16:15:56 +0100 Subject: [PATCH 4/8] Added generic graph widget (non-responsive sizing) --- html/includes/common/generic-graph.inc.php | 114 +++++++++++++++++++++ sql-schema/068.sql | 1 + 2 files changed, 115 insertions(+) create mode 100644 html/includes/common/generic-graph.inc.php diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php new file mode 100644 index 000000000..b6e5773ee --- /dev/null +++ b/html/includes/common/generic-graph.inc.php @@ -0,0 +1,114 @@ + + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/** + * Generic Graph Widget + * @author Daniel Preussker + * @copyright 2015 Daniel Preussker, QuxLabs UG + * @license GPL + * @package LibreNMS + * @subpackage Widgets + */ + +if( empty($widget_settings) ) { + $common_output[] = ' +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    +'; +} +else { + $widget_settings['device_id'] = dbFetchCell('select device_id from devices where hostname = ?',array($widget_settings['graph_device'])); + $common_output[] = "
    ".$widget_settings['graph_device']." / ".$widget_settings['graph_type']."
    "; + $common_output[] = generate_minigraph_image(array('device_id'=>(int) $widget_settings['device_id']), $config['time']['day'], $config['time']['now'], $widget_settings['graph_type'], $widget_settings['graph_legend'] == 1 ? 'yes' : 'no', $widget_settings['graph_width'], $widget_settings['graph_height'], '&', $widget_settings['graph_type']); +} +?> + diff --git a/sql-schema/068.sql b/sql-schema/068.sql index 39784b418..d0bbda576 100644 --- a/sql-schema/068.sql +++ b/sql-schema/068.sql @@ -1 +1,2 @@ alter table users_widgets add column `settings` text not null; +insert into widgets values(null,'Graph','generic-graph','6,2'); From f081706ab1258e5df068fcd75001064ce128b91c Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sun, 6 Sep 2015 10:59:44 +0100 Subject: [PATCH 5/8] Added option to allow absolute dimensions on graphs --- html/includes/functions.inc.php | 4 ++-- html/includes/graphs/common.inc.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 7b7ea62ca..b4ab63c70 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -181,8 +181,8 @@ function get_percentage_colours($percentage) { }//end get_percentage_colours() -function generate_minigraph_image($device, $start, $end, $type, $legend='no', $width=275, $height=100, $sep='&', $class='minigraph-image') { - return ''; +function generate_minigraph_image($device, $start, $end, $type, $legend='no', $width=275, $height=100, $sep='&', $class='minigraph-image',$absolute_size=0) { + return ''; }//end generate_minigraph_image() diff --git a/html/includes/graphs/common.inc.php b/html/includes/graphs/common.inc.php index 9dbc97b80..ba77fb3f6 100644 --- a/html/includes/graphs/common.inc.php +++ b/html/includes/graphs/common.inc.php @@ -103,3 +103,7 @@ else { } $rrd_options .= ' --font-render-mode normal'; + +if (isset($_GET['absolute']) && $_GET['absolute'] == "1") { + $rrd_options .= ' --full-size-mode'; +} From 9951c98e70bbb8c394864cbcce4169482fe00e48 Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sun, 6 Sep 2015 13:18:54 +0100 Subject: [PATCH 6/8] Added edit-page Added responsive resizing support for graph widget --- html/ajax_dash.php | 11 +- html/includes/common/generic-graph.inc.php | 81 ++++---- .../forms/update-dashboard-config.inc.php | 2 +- html/pages/front/tiles.php | 183 ++++++++++-------- 4 files changed, 153 insertions(+), 124 deletions(-) diff --git a/html/ajax_dash.php b/html/ajax_dash.php index a26e46e5a..ec88e68ec 100644 --- a/html/ajax_dash.php +++ b/html/ajax_dash.php @@ -30,23 +30,30 @@ $type = mres($_POST['type']); if ($type == 'placeholder') { $output = 'Please add a Widget to get started'; $status = 'ok'; + $title = 'Placeholder'; } elseif (is_file('includes/common/'.$type.'.inc.php')) { $results_limit = 10; $no_form = true; + $title = ucfirst($type); + $unique_id = str_replace(array("-","."),"_",uniqid($type,true)); $widget_id = mres($_POST['id']); $widget_settings = json_decode(dbFetchCell('select settings from users_widgets where user_widget_id = ?',array($widget_id)),true); - $widget_dimensions = dbfetchRow('select size_x,size_y from users_widgets where user_widget_id = ?',array($widget_id)); + $widget_dimensions = $_POST['dimensions']; + if( !empty($_POST['settings']) ) { + define('show_settings',true); + } include 'includes/common/'.$type.'.inc.php'; $output = implode('', $common_output); $status = 'ok'; - + $title = $widget_settings['title'] ?: $title; } $response = array( 'status' => $status, 'html' => $output, + 'title' => $title, ); echo _json_encode($response); diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index b6e5773ee..9d79fff22 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -22,13 +22,13 @@ * @subpackage Widgets */ -if( empty($widget_settings) ) { +if( defined('show_settings') || empty($widget_settings) ) { $common_output[] = '
    - +
    @@ -37,10 +37,10 @@ if( empty($widget_settings) ) { Legend + Legend
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    + +'; } else { $widget_settings['device_id'] = dbFetchCell('select device_id from devices where hostname = ?',array($widget_settings['graph_device'])); - $common_output[] = "
    ".$widget_settings['graph_device']." / ".$widget_settings['graph_type']."
    "; - $common_output[] = generate_minigraph_image(array('device_id'=>(int) $widget_settings['device_id']), $config['time']['day'], $config['time']['now'], $widget_settings['graph_type'], $widget_settings['graph_legend'] == 1 ? 'yes' : 'no', $widget_settings['graph_width'], $widget_settings['graph_height'], '&', $widget_settings['graph_type']); + $widget_settings['title'] = $widget_settings['graph_device']." / ".$widget_settings['graph_type']; + $common_output[] = generate_minigraph_image( + array('device_id'=>(int) $widget_settings['device_id']), + $config['time']['day'], + $config['time']['now'], + $widget_settings['graph_type'], + $widget_settings['graph_legend'] == 1 ? 'yes' : 'no', + $widget_dimensions['x'], + $widget_dimensions['y'], + '&', + 'minigraph-image', + 1 + ); } ?> diff --git a/html/includes/forms/update-dashboard-config.inc.php b/html/includes/forms/update-dashboard-config.inc.php index fd6dc18a4..de278fd91 100644 --- a/html/includes/forms/update-dashboard-config.inc.php +++ b/html/includes/forms/update-dashboard-config.inc.php @@ -25,7 +25,7 @@ elseif ($sub_type == 'add' && is_numeric($widget_id)) { list($x,$y) = explode(',',$widget['base_dimensions']); $item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); if (is_numeric($item_id)) { - $extra = array('widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y); + $extra = array('user_widget_id'=>$item_id,'widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'refresh'=>60,'size_x'=>$x,'size_y'=>$y); $status = 'ok'; $message = ''; } diff --git a/html/pages/front/tiles.php b/html/pages/front/tiles.php index 063b4bba6..5c6effb1e 100644 --- a/html/pages/front/tiles.php +++ b/html/pages/front/tiles.php @@ -103,31 +103,25 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg }, resize: { enabled: true, - stop: function(e, ui, $widget) { + stop: function(e, ui, widget) { updatePos(gridster); + widget_reload(widget.attr('id'),widget.data('type')); } }, - serialize_params: function($w, wgd) { - return { - id: $($w).attr('id'), - col: wgd.col, - row: wgd.row, - size_x: wgd.size_x, - size_y: wgd.size_y + serialize_params: function(w, wgd) { + return { + id: $(w).attr('id'), + col: wgd.col, + row: wgd.row, + size_x: wgd.size_x, + size_y: wgd.size_y }; } }).data('gridster'); gridster.remove_all_widgets(); $.each(serialization, function() { - gridster.add_widget( - '
  • '+ - '\var timeout'+this.user_widget_id+' = grab_data('+this.user_widget_id+','+this.refresh+',\''+this.widget+'\');\<\/script\>'+ - '
    '+this.title+'
    '+ - '
    '+this.widget+'
    '+ - '
  • ', - parseInt(this.size_x), parseInt(this.size_y), parseInt(this.col), parseInt(this.row) - ); + widget_dom(this); }); $(document).on('click','#clear_widgets', function() { @@ -160,19 +154,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg dataType: "json", success: function (data) { if (data.status == 'ok') { - var widget_id = data.extra.widget_id; - var title = data.extra.title; - var widget = data.extra.widget; - var size_x = data.extra.size_x; - var size_y = data.extra.size_y; - gridster.add_widget( - '
  • '+ - '\var timeout'+widget_id+' = grab_data('+widget_id+',60,\''+widget+'\');\<\/script\>'+ - '
    '+title+'
    '+ - '
    '+widget+'
    '+ - '
  • ', - parseInt(size_x), parseInt(size_y) - ); + widget_dom(data.extra); updatePos(gridster); } else { @@ -207,65 +189,96 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg }); }); + $(document).on("click",".edit-widget",function() { + obj = $(this).parent().parent(); + if( obj.data('settings') == 1 ) { + obj.data('settings','0'); + } else { + obj.data('settings','1'); + } + widget_reload(obj.attr('id'),obj.data('type')); + }); + }); - function widget_settings(data) { - var widget_settings = {}; - var widget_id = 0; - datas = $(data).serializeArray(); - for( var field in datas ) { - widget_settings[datas[field].name] = datas[field].value; - } -console.log(widget_settings); - $('.gridster').find('div[id^=widget_body_]').each(function() { - if(this.contains(data)) { - widget_id = $(this).parent().attr('id'); - widget_type = $(this).parent().data('type'); - } - }); - if( widget_id > 0 && widget_settings != {} ) { - $.ajax({ - type: 'POST', - url: 'ajax_form.php', - data: {type: 'widget-settings', id: widget_id, settings: widget_settings}, - dataType: "json", - success: function (data) { - if( data.status == "ok" ) { - widget_reload(widget_id,widget_type); - } - } - }); - } - } + function widget_dom(data) { + dom = '
  • '+ + '
    '+data.title+''+ + ''+ + ''+ + '
    '+ + '
    '+data.widget+'
    '+ + '\var timeout'+data.user_widget_id+' = grab_data('+data.user_widget_id+','+data.refresh+',\''+data.widget+'\');\<\/script\>'+ + '
  • '; + if (data.hasOwnProperty('col') && data.hasOwnProperty('row')) { + gridster.add_widget(dom, parseInt(data.size_x), parseInt(data.size_y), parseInt(data.col), parseInt(data.row)); + } else { + gridster.add_widget(dom, parseInt(data.size_x), parseInt(data.size_y)); + } + } - function widget_reload(id,data_type) { - $.ajax({ - type: 'POST', - url: 'ajax_dash.php', - data: {type: data_type, id: id}, - dataType: "json", - success: function (data) { - if (data.status == 'ok') { - $("#widget_body_"+id).html(data.html); - } - else { - $("#widget_body_"+id).html('
    ' + data.message + '
    '); - } - }, - error: function () { - $("#widget_body_"+id).html('
    Problem with backend
    '); - } - }); - } + function widget_settings(data) { + var widget_settings = {}; + var widget_id = 0; + datas = $(data).serializeArray(); + for( var field in datas ) { + widget_settings[datas[field].name] = datas[field].value; + } + $('.gridster').find('div[id^=widget_body_]').each(function() { + if(this.contains(data)) { + widget_id = $(this).parent().attr('id'); + widget_type = $(this).parent().data('type'); + $(this).parent().data('settings','0'); + } + }); + if( widget_id > 0 && widget_settings != {} ) { + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: {type: 'widget-settings', id: widget_id, settings: widget_settings}, + dataType: "json", + success: function (data) { + if( data.status == "ok" ) { + widget_reload(widget_id,widget_type); + } + } + }); + } + } - function grab_data(id,refresh,data_type) { - new_refresh = refresh * 1000; - widget_reload(id,data_type); - setTimeout(function() { - grab_data(id,refresh,data_type); - }, - new_refresh); - } -$('#new-widget').popover(); + function widget_reload(id,data_type) { + if( $("#widget_body_"+id).parent().data('settings') == 1 ) { + settings = 1; + } else { + settings = 0; + } + $.ajax({ + type: 'POST', + url: 'ajax_dash.php', + data: {type: data_type, id: id, dimensions: {x:$("#widget_body_"+id).innerWidth()-50, y:$("#widget_body_"+id).innerHeight()-50}, settings:settings}, + dataType: "json", + success: function (data) { + if (data.status == 'ok') { + $("#widget_title_"+id).html(data.title); + $("#widget_body_"+id).html(data.html); + } + else { + $("#widget_body_"+id).html('
    ' + data.message + '
    '); + } + }, + error: function () { + $("#widget_body_"+id).html('
    Problem with backend
    '); + } + }); + } + function grab_data(id,refresh,data_type) { + new_refresh = refresh * 1000; + widget_reload(id,data_type); + setTimeout(function() { + grab_data(id,refresh,data_type); + }, + new_refresh); + } + $('#new-widget').popover(); From b741e479a446258d02dcf258e55fe369bfa616da Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sun, 6 Sep 2015 13:37:48 +0100 Subject: [PATCH 7/8] Allow drag on title-text --- html/pages/front/tiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/front/tiles.php b/html/pages/front/tiles.php index 5c6effb1e..e679f5079 100644 --- a/html/pages/front/tiles.php +++ b/html/pages/front/tiles.php @@ -96,7 +96,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg widget_margins: [5, 5], avoid_overlapped_widgets: true, draggable: { - handle: 'header', + handle: 'header, span', stop: function(e, ui, $widget) { updatePos(gridster); }, From 64f1f3a6365eb2930a91aee19e826a5b68d6d5ed Mon Sep 17 00:00:00 2001 From: Daniel Preussker Date: Sun, 6 Sep 2015 14:28:55 +0100 Subject: [PATCH 8/8] scrut fixes --- html/includes/common/generic-graph.inc.php | 1 - html/includes/forms/widget-settings.inc.php | 1 - 2 files changed, 2 deletions(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index 9d79fff22..3ac02ab69 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -119,5 +119,4 @@ else { 1 ); } -?> diff --git a/html/includes/forms/widget-settings.inc.php b/html/includes/forms/widget-settings.inc.php index 2ce0cde63..1926d3491 100644 --- a/html/includes/forms/widget-settings.inc.php +++ b/html/includes/forms/widget-settings.inc.php @@ -49,4 +49,3 @@ die(json_encode(array( 'status' => $status, 'message' => $message ))); -?>