mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Initial dashboard, code formatting is bad + lots needs tidying up
This commit is contained in:
89
html/includes/common/alerts.inc.php
Normal file
89
html/includes/common/alerts.inc.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
$common_output[] = '
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<span id="message"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table id="alerts" class="table table-hover table-condensed alerts">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="status" data-formatter="status" data-sortable="false">Status</th>
|
||||
<th data-column-id="rule">Rule</th>
|
||||
<th data-column-id="details" data-sortable="false"> </th>
|
||||
<th data-column-id="hostname">Hostname</th>
|
||||
<th data-column-id="timestamp">Timestamp</th>
|
||||
<th data-column-id="severity">Severity</th>
|
||||
<th data-column-id="ack" data-formatter="ack" data-sortable="false">Acknowledge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
var grid = $("#alerts").bootgrid({
|
||||
ajax: true,
|
||||
post: function ()
|
||||
{
|
||||
return {
|
||||
id: "alerts",
|
||||
device_id: \'' . $device['device_id'] .'\'
|
||||
};
|
||||
},
|
||||
url: "/ajax_table.php",
|
||||
formatters: {
|
||||
"status": function(column,row) {
|
||||
return "<h4><span class=\'label label-"+row.extra+" threeqtr-width\'>" + row.msg + "</span></h4>";
|
||||
},
|
||||
"ack": function(column,row) {
|
||||
return "<button type=\'button\' class=\'btn btn-"+row.ack_col+" btn-sm command-ack-alert\' data-target=\'#ack-alert\' data-state=\'"+row.state+"\' data-alert_id=\'"+row.alert_id+"\' name=\'ack-alert\' id=\'ack-alert\' data-extra=\'"+row.extra+"\'><span class=\'glyphicon glyphicon-"+row.ack_ico+"\'aria-hidden=\'true\'></span></button>";
|
||||
}
|
||||
},
|
||||
templates: {
|
||||
}
|
||||
}).on("loaded.rs.jquery.bootgrid", function() {
|
||||
grid.find(".incident-toggle").each( function() {
|
||||
$(this).parent().addClass(\'incident-toggle-td\');
|
||||
}).on("click", function(e) {
|
||||
var target = $(this).data("target");
|
||||
$(target).collapse(\'toggle\');
|
||||
$(this).toggleClass(\'glyphicon-plus glyphicon-minus\');
|
||||
});
|
||||
grid.find(".incident").each( function() {
|
||||
$(this).parent().addClass(\'col-lg-4 col-md-4 col-sm-4 col-xs-4\');
|
||||
$(this).parent().parent().on("mouseenter", function() {
|
||||
$(this).find(".incident-toggle").fadeIn(200);
|
||||
}).on("mouseleave", function() {
|
||||
$(this).find(".incident-toggle").fadeOut(200);
|
||||
}).on("click", "td:not(.incident-toggle-td)", function() {
|
||||
var target = $(this).parent().find(".incident-toggle").data("target");
|
||||
if( $(this).parent().find(".incident-toggle").hasClass(\'glyphicon-plus\') ) {
|
||||
$(this).parent().find(".incident-toggle").toggleClass(\'glyphicon-plus glyphicon-minus\');
|
||||
$(target).collapse(\'toggle\');
|
||||
}
|
||||
});
|
||||
});
|
||||
grid.find(".command-ack-alert").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
var alert_id = $(this).data("alert_id");
|
||||
var state = $(this).data("state");
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/ajax_form.php",
|
||||
data: { type: "ack-alert", alert_id: alert_id, state: state },
|
||||
success: function(msg){
|
||||
$("#message").html(\'<div class="alert alert-info">\'+msg+\'</div>\');
|
||||
if(msg.indexOf("ERROR:") <= -1) {
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
$("#message").html(\'<div class="alert alert-info">An error occurred acking this alert.</div>\');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
||||
45
html/includes/common/availability-map.inc.php
Normal file
45
html/includes/common/availability-map.inc.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* 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. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$sql = "SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`";
|
||||
|
||||
if (is_admin() === false && is_read() === false) {
|
||||
$sql .= " , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND";
|
||||
$param = array($_SESSION['user_id']);
|
||||
}
|
||||
else {
|
||||
$sql .= " WHERE";
|
||||
}
|
||||
|
||||
$sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`";
|
||||
|
||||
$temp_output = array();
|
||||
|
||||
foreach(dbFetchRows($sql,$param) as $device) {
|
||||
if ($device['status'] == '1') {
|
||||
$btn_type = 'btn-success';
|
||||
if ($device['uptime'] < $config['uptime_warning']) {
|
||||
$btn_type = 'btn-warning';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$btn_type = 'btn-danger';
|
||||
}
|
||||
$temp_output[] = "<a href='" .generate_url(array('page' => 'device', 'device' => $device['device_id'])). "' role='button' class='btn " . $btn_type . " btn-xs' title='" . $device['hostname'] . "' style='min-height:25px; min-width:25px; border-radius:0px; border:0px; margin:0; padding:0;'></a>";
|
||||
}
|
||||
|
||||
$temp_rows = count($temp_output);
|
||||
|
||||
$temp_output[] = "</div>";
|
||||
$temp_header = array("<div style='margin-left:auto; margin-right:auto;'><center><h3>All Devices(" . $temp_rows . ")</h3></center>");
|
||||
$common_output = array_merge($temp_header,$temp_output);
|
||||
|
||||
52
html/includes/common/device-summary-horiz.inc.php
Normal file
52
html/includes/common/device-summary-horiz.inc.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
require_once 'includes/object-cache.inc.php';
|
||||
|
||||
$temp_output = '
|
||||
<div class="panel panel-default panel-condensed table-responsive">
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr class="info">
|
||||
<th> </th>
|
||||
<th>Total</th>
|
||||
<th>Up</th>
|
||||
<th>Down</th>
|
||||
<th>Ignored</th>
|
||||
<th>Disabled</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="active">
|
||||
<td><a href="devices/">Devices</a></td>
|
||||
<td><a href="devices/"><span>'.$devices['count'].'</span></a></td>
|
||||
<td><a href="devices/state=up/format=list_detail/"><span class="green"> '.$devices['up'].' up</span></a></td>
|
||||
<td><a href="devices/state=down/format=list_detail/"><span class="red"> '.$devices['down'].' down</span></a></td>
|
||||
<td><a href="devices/ignore=1/format=list_detail/"><span class="grey"> '.$devices['ignored'].' ignored </span></a></td>
|
||||
<td><a href="devices/disabled=1/format=list_detail/"><span class="black"> '.$devices['disabled'].' disabled</span></a></td>
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<td><a href="ports/">Ports</a></td>
|
||||
<td><a href="ports/"><span>'.$ports['count'].'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=up/"><span class="green"> '.$ports['up'].' up </span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=down/"><span class="red"> '.$ports['down'].' down </span></a></td>
|
||||
<td><a href="ports/format=list_detail/ignore=1/"><span class="grey"> '.$ports['ignored'].' ignored </span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=admindown/"><span class="black"> '.$ports['shutdown'].' shutdown</span></a></td>
|
||||
</tr>';
|
||||
if ($config['show_services']) {
|
||||
|
||||
$temp_output .= '
|
||||
<tr class="active">
|
||||
<td><a href="services/">Services</a></td>
|
||||
<td><a href="services/"><span>'.$services['count'].'</span></a></td>
|
||||
<td><a href="services/state=up/view=details/"><span class="green">'.$services['up'].' up</span></a></td>
|
||||
<td><a href="services/state=down/view=details/"><span class="red"> '.$services['down'].' down</span></a></td>
|
||||
<td><a href="services/ignore=1/view=details/"><span class="grey"> '.$services['ignored'].' ignored</span></a></td>
|
||||
<td><a href="services/disabled=1/view=details/"><span class="black"> '.$services['disabled'].' disabled</span></a></td>
|
||||
</tr>';
|
||||
}
|
||||
$temp_output .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
|
||||
$common_output[] = $temp_output;
|
||||
Reference in New Issue
Block a user