mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #2027 from f0o/issue-2026
Added bills to graph-widget
This commit is contained in:
@@ -318,6 +318,17 @@ if (isset($_REQUEST['search'])) {
|
|||||||
|
|
||||||
$json = json_encode($device);
|
$json = json_encode($device);
|
||||||
die($json);
|
die($json);
|
||||||
|
}
|
||||||
|
else if ($_REQUEST['type'] == 'bill') {
|
||||||
|
// Device search
|
||||||
|
if (is_admin() === true || is_read() === true) {
|
||||||
|
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%' LIMIT 8");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%') LIMIT 8", array($_SESSION['user_id']));
|
||||||
|
}
|
||||||
|
$json = json_encode($results);
|
||||||
|
die($json);
|
||||||
}//end if
|
}//end if
|
||||||
}//end if
|
}//end if
|
||||||
}//end if
|
}//end if
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ if( defined('show_settings') || empty($widget_settings) ) {
|
|||||||
<option value="peering"'.($widget_settings['graph_type'] == 'peering' ? ' selected' : '').'> Peering</option>
|
<option value="peering"'.($widget_settings['graph_type'] == 'peering' ? ' selected' : '').'> Peering</option>
|
||||||
<option value="core"'.($widget_settings['graph_type'] == 'core' ? ' selected' : '').'> Core</option>
|
<option value="core"'.($widget_settings['graph_type'] == 'core' ? ' selected' : '').'> Core</option>
|
||||||
<option value="custom"'.($widget_settings['graph_type'] == 'custom' ? ' selected' : '').'> Custom Descr</option>
|
<option value="custom"'.($widget_settings['graph_type'] == 'custom' ? ' selected' : '').'> Custom Descr</option>
|
||||||
|
<option disabled></option>
|
||||||
|
<option value="bill_bits"'.($widget_settings['graph_type'] == 'bill_bits' ? ' selected' : '').'>Bill</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-offset-10 col-sm-2">
|
<div class="col-sm-offset-10 col-sm-2">
|
||||||
@@ -140,6 +142,14 @@ if( defined('show_settings') || empty($widget_settings) ) {
|
|||||||
$common_output[] = ' </select>
|
$common_output[] = ' </select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_bill">
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<label for="graph_bill" class="control-label">Bill: </label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input type="text" class="form-control input_'.$unique_id.'_bill" name="graph_bill" placeholder="Bill" value="'.htmlspecialchars($widget_settings['graph_bill']).'">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<button type="submit" class="btn btn-default">Set</button>
|
<button type="submit" class="btn btn-default">Set</button>
|
||||||
@@ -301,6 +311,40 @@ function '.$unique_id.'() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var '.$unique_id.'_bill = new Bloodhound({
|
||||||
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("munin"),
|
||||||
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
remote: {
|
||||||
|
url: "ajax_search.php?search=%QUERY&type=bill",
|
||||||
|
filter: function (output) {
|
||||||
|
return $.map(output, function (item) {
|
||||||
|
return {
|
||||||
|
name: item.bill_name,
|
||||||
|
bill_id: item.bill_id,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
|
wildcard: "%QUERY"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
'.$unique_id.'_bill.initialize();
|
||||||
|
$(".input_'.$unique_id.'_bill").typeahead({
|
||||||
|
hint: true,
|
||||||
|
highlight: true,
|
||||||
|
minLength: 1,
|
||||||
|
classNames: {
|
||||||
|
menu: "typeahead-left"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '.$unique_id.'_bill.ttAdapter(),
|
||||||
|
async: false,
|
||||||
|
templates: {
|
||||||
|
header: "<h5><strong><i class=\'fa fa-money\'></i> Bill</strong></h5>",
|
||||||
|
suggestion: Handlebars.compile(\'<p><small><strong>{{name}}</strong></small></p>\')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
switch_'.$unique_id.'($("#select_'.$unique_id.'").val());
|
switch_'.$unique_id.'($("#select_'.$unique_id.'").val());
|
||||||
}
|
}
|
||||||
function switch_'.$unique_id.'(data) {
|
function switch_'.$unique_id.'(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user