mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #1861 from QuxLabs/qux-issue-1
This commit is contained in:
+99
-9
@@ -96,23 +96,22 @@ if (isset($_REQUEST['search'])) {
|
||||
}//end if
|
||||
|
||||
$json = json_encode($device);
|
||||
print_r($json);
|
||||
exit;
|
||||
die($json);
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'ports') {
|
||||
// Search ports
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' ORDER BY ifDescr LIMIT 8");
|
||||
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' OR `ifName` LIKE '%".$search."%' ORDER BY ifDescr LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%') ORDER BY ifDescr LIMIT 8", array($_SESSION['user_id'], $_SESSION['user_id']));
|
||||
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' OR `ifName` LIKE '%".$search."%') ORDER BY ifDescr LIMIT 8", array($_SESSION['user_id'], $_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['ifDescr'];
|
||||
$name = $result['ifDescr'] == $result['ifAlias'] ? $result['ifName'] : $result['ifDescr'];
|
||||
$description = $result['ifAlias'];
|
||||
|
||||
if ($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) {
|
||||
@@ -143,13 +142,13 @@ if (isset($_REQUEST['search'])) {
|
||||
'description' => $description,
|
||||
'colours' => $highlight_colour,
|
||||
'hostname' => $result['hostname'],
|
||||
'port_id' => $result['port_id'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($ports);
|
||||
print_r($json);
|
||||
exit;
|
||||
die($json);
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'bgp') {
|
||||
// Search bgp peers
|
||||
@@ -204,8 +203,99 @@ if (isset($_REQUEST['search'])) {
|
||||
}//end if
|
||||
|
||||
$json = json_encode($bgp);
|
||||
print_r($json);
|
||||
exit;
|
||||
die($json);
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'applications') {
|
||||
// Device search
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT * FROM `applications` INNER JOIN `devices` ON devices.device_id = applications.device_id WHERE `app_type` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%' ORDER BY hostname LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT * FROM `applications` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `applications`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`app_type` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%') ORDER BY hostname LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
$devices = count($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['app_type'];
|
||||
if ($result['disabled'] == 1) {
|
||||
$highlight_colour = '#808080';
|
||||
}
|
||||
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#000000';
|
||||
}
|
||||
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#ff0000';
|
||||
}
|
||||
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#008000';
|
||||
}
|
||||
|
||||
$device[] = array(
|
||||
'name' => $name,
|
||||
'hostname' => $result['hostname'],
|
||||
'app_id' => $result['app_id'],
|
||||
'device_id' => $result['device_id'],
|
||||
'colours' => $highlight_colour,
|
||||
'device_image' => getImageSrc($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($device);
|
||||
die($json);
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'munin') {
|
||||
// Device search
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT * FROM `munin_plugins` INNER JOIN `devices` ON devices.device_id = munin_plugins.device_id WHERE `mplug_type` LIKE '%".$search."%' OR `mplug_title` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%' ORDER BY hostname LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT * FROM `munin_plugins` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `munin_plugins`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`mplug_type` LIKE '%".$search."%' OR `mplug_title` LIKE '%".$search."%' OR `hostname` LIKE '%".$search."%') ORDER BY hostname LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
$devices = count($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['mplug_title'];
|
||||
if ($result['disabled'] == 1) {
|
||||
$highlight_colour = '#808080';
|
||||
}
|
||||
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#000000';
|
||||
}
|
||||
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#ff0000';
|
||||
}
|
||||
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#008000';
|
||||
}
|
||||
|
||||
$device[] = array(
|
||||
'name' => $name,
|
||||
'hostname' => $result['hostname'],
|
||||
'device_id' => $result['device_id'],
|
||||
'colours' => $highlight_colour,
|
||||
'device_image' => getImageSrc($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
'plugin' => $result['mplug_type'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($device);
|
||||
die($json);
|
||||
}//end if
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
@@ -26,35 +26,108 @@ if( defined('show_settings') || empty($widget_settings) ) {
|
||||
$common_output[] = '
|
||||
<form class="form" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<label for="device_id" class="col-sm-2 control-label">Device: </label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input-sm widget-device-input-'.$unique_id.'" name="graph_device" placeholder="Device Name" value="'.$widget_settings['graph_device'].'">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_type" class="control-label">Graph: </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="graph_type" class="col-sm-2 control-label">Graph: </label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control input-sm" name="graph_type">';
|
||||
foreach (get_graph_subtypes('device') as $avail_type) {
|
||||
$common_output[] = '<option value="device_'.$avail_type.'"';
|
||||
if ('device_'.$avail_type == $widget_settings['graph_type']) {
|
||||
$common_output[] = " selected";
|
||||
<select class="form-control" name="graph_type" id="select_'.$unique_id.'" onchange="switch_'.$unique_id.'($(this).val());">';
|
||||
if (empty($widget_settings['graph_type'])) {
|
||||
$common_output[] = '<option disabled selected>Select a Graph</option>';
|
||||
}
|
||||
$sub = '';
|
||||
$old = '';
|
||||
foreach (array('device','port','application','munin') as $type) {
|
||||
$common_output[] = '<option disabled>'.nicecase($type).':</option>';
|
||||
foreach (get_graph_subtypes($type) as $avail_type) {
|
||||
$display_type = is_mib_graph($type, $avail_type) ? $avail_type : nicecase($avail_type);
|
||||
if( strstr($display_type,'_') ) {
|
||||
$sub = explode('_',$display_type,2);
|
||||
$sub = array_shift($sub);
|
||||
if( $sub != $old ) {
|
||||
$old = $sub;
|
||||
$common_output[] = '<option disabled> '.nicecase($sub).':</option>';
|
||||
}
|
||||
$display_type = str_replace($sub.'_','',$display_type);
|
||||
$space = ' ';
|
||||
} else {
|
||||
$space = ' ';
|
||||
}
|
||||
$common_output[] = '<option value="'.$type.'_'.$avail_type.'"';
|
||||
if ($type.'_'.$avail_type == $widget_settings['graph_type']) {
|
||||
$common_output[] = " selected";
|
||||
}
|
||||
$common_output[] = '>'.$space.nicecase($display_type).'</option>';
|
||||
}
|
||||
$display_type = is_mib_graph('device', $avail_type) ? $avail_type : nicecase($avail_type);
|
||||
$common_output[] = '>'.$display_type.'</option>';
|
||||
$common_output[] = '<option disabled></option>';
|
||||
}
|
||||
$common_output[] = '
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-offset-10 col-sm-2">
|
||||
<div class="checkbox input-sm">
|
||||
<label>
|
||||
<label class="control-label">
|
||||
<input type="checkbox" name="graph_legend" class="widget_setting" value="1" '.($widget_settings['graph_legend'] ? 'checked' : '').'> Legend
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_range" class="control-label">Range: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="graph_range">';
|
||||
$checked = '';
|
||||
foreach( array_diff_key($config['time'],array('now'=>'')) as $k=>$v ) {
|
||||
if ($widget_settings['graph_range'] == $k) {
|
||||
$checked = ' selected';
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$common_output[] = '<option value="'.$k.'"'.$checked.'>'.nicecase($k).'</option>';
|
||||
}
|
||||
$common_output[] = '
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_device">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_device" class="control-label">Device: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_device" name="graph_device" placeholder="Device Name" value="'.htmlspecialchars($widget_settings['graph_device']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_port">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_port" class="control-label">Port: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_port" name="graph_port" placeholder="Port" value="'.htmlspecialchars($widget_settings['graph_port']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_application">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_application" class="control-label">Application: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_application" name="graph_application" placeholder="Application" value="'.htmlspecialchars($widget_settings['graph_application']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_munin">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_munin" class="control-label">Munin Plugin: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_munin" name="graph_munin" placeholder="Munin Plugin" value="'.htmlspecialchars($widget_settings['graph_munin']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<style>
|
||||
.twitter-typeahead {
|
||||
@@ -63,23 +136,30 @@ if( defined('show_settings') || empty($widget_settings) ) {
|
||||
</style>
|
||||
<script>
|
||||
function '.$unique_id.'() {
|
||||
var '.$unique_id.' = new Bloodhound({
|
||||
var '.$unique_id.'_device = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=device&map=1",
|
||||
url: "ajax_search.php?search=%QUERY&type=device",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
name: item.name,
|
||||
device_id: item.device_id,
|
||||
device_image: item.device_image,
|
||||
name: item.name,
|
||||
device_os: item.device_os,
|
||||
version: item.version,
|
||||
device_hardware: item.device_hardware,
|
||||
device_ports: item.device_ports,
|
||||
location: item.location
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'.initialize();
|
||||
$(".widget-device-input-'.$unique_id.'").typeahead({
|
||||
'.$unique_id.'_device.initialize();
|
||||
$(".input_'.$unique_id.'_device").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
@@ -88,35 +168,161 @@ function '.$unique_id.'() {
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'.ttAdapter(),
|
||||
async: true,
|
||||
displayKey: "name",
|
||||
valueKey: "name",
|
||||
source: '.$unique_id.'_device.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Devices</strong></h5>",
|
||||
suggestion: Handlebars.compile("<p> {{name}}</p>")
|
||||
suggestion: Handlebars.compile(\'<p><img src="{{device_image}}" border="0"> <small><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_port = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("port_id"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=ports",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
hostname: item.hostname,
|
||||
port_id: item.port_id
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_port.initialize();
|
||||
$(".input_'.$unique_id.'_port").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_port.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Ports</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}} - <i>{{description}}</i></small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_application = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("app_id"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=applications",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
name: item.name,
|
||||
hostname: item.hostname,
|
||||
app_id: item.app_id
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_application.initialize();
|
||||
$(".input_'.$unique_id.'_application").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_application.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Applications</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_munin = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("munin"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=munin",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
desc: item.name,
|
||||
name: item.plugin,
|
||||
hostname: item.hostname,
|
||||
plugin: item.plugin,
|
||||
device_id: item.device_id,
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_munin.initialize();
|
||||
$(".input_'.$unique_id.'_munin").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_munin.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Munin</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{plugin}}</strong> – {{hostname}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
switch_'.$unique_id.'($("#select_'.$unique_id.'").val());
|
||||
}
|
||||
function switch_'.$unique_id.'(data) {
|
||||
$(".input_'.$unique_id.'").fadeOut();
|
||||
if (data != undefined && data != "") {
|
||||
data = data.split("_");
|
||||
type = data.shift();
|
||||
data = data.join("_");
|
||||
$("#input_'.$unique_id.'_"+type).fadeIn();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$(function() { '.$unique_id.'(); });
|
||||
<script id="js_'.$unique_id.'">
|
||||
$(function() {
|
||||
$("#js_'.$unique_id.'").parent().parent().data("settings","1");
|
||||
'.$unique_id.'();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
else {
|
||||
$widget_settings['device_id'] = dbFetchCell('select device_id from devices where hostname = ?',array($widget_settings['graph_device']));
|
||||
$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
|
||||
);
|
||||
$widget_settings['title'] = "";
|
||||
$type = explode('_',$widget_settings['graph_type'],2);
|
||||
$type = array_shift($type);
|
||||
$widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true);
|
||||
if ($type == 'device') {
|
||||
$widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type'];
|
||||
$param = 'device='.$widget_settings['graph_device']['device_id'];
|
||||
}
|
||||
elseif ($type == 'application') {
|
||||
$param = 'id='.$widget_settings['graph_'.$type]['app_id'];
|
||||
}
|
||||
elseif ($type == 'munin') {
|
||||
$param = 'device='.$widget_settings['graph_'.$type]['device_id'].'&plugin='.$widget_settings['graph_'.$type]['name'];
|
||||
}
|
||||
else {
|
||||
$param = 'id='.$widget_settings['graph_'.$type][$type.'_id'];
|
||||
}
|
||||
if (empty($widget_settings['title'])) {
|
||||
$widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type'];
|
||||
}
|
||||
$common_output[] = '<img class="minigraph-image" src="graph.php?'.$param.'&from='.$config['time'][$widget_settings['graph_range']].'&to='.$config['time']['now'].'&width='.$widget_dimensions['x'].'&height='.$widget_dimensions['y'].'&type='.$widget_settings['graph_type'].'&legend='.($widget_settings['graph_legend'] == 1 ? 'yes' : 'no').'&absolute=1"/>';
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
|
||||
});
|
||||
|
||||
function widget_dom(data) {
|
||||
dom = '<li id="'+data.user_widget_id+'" data-type="'+data.widget+'">'+
|
||||
dom = '<li id="'+data.user_widget_id+'" data-type="'+data.widget+'" data-settings="0">'+
|
||||
'<header class="widget_header"><span id="widget_title_'+data.user_widget_id+'">'+data.title+'</span>'+
|
||||
'<button style="color: #ffffff;" type="button" class="fa fa-times close close-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Close"> </button>'+
|
||||
'<button style="color: #ffffff;" type="button" class="fa fa-pencil-square-o close edit-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Settings"> </button>'+
|
||||
@@ -273,8 +273,10 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
|
||||
}
|
||||
|
||||
function grab_data(id,refresh,data_type) {
|
||||
if( $("#widget_body_"+id).parent().data('settings') == 0 ) {
|
||||
widget_reload(id,data_type);
|
||||
}
|
||||
new_refresh = refresh * 1000;
|
||||
widget_reload(id,data_type);
|
||||
setTimeout(function() {
|
||||
grab_data(id,refresh,data_type);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user