예제 #1
0
    echo '</ul></li>';
} else {
    echo '<li class="dropdown-submenu"><a href="#">No devices</a></li>';
}
if (count($devices_groups) > 0) {
    echo '<li class="dropdown-submenu"><a href="#"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> Device Groups</a><ul class="dropdown-menu scrollable-menu">';
    foreach ($devices_groups as $group) {
        echo '<li><a href="' . generate_url(array('page' => 'devices', 'group' => $group['id'])) . '" title="' . $group['desc'] . '"><i class="fa fa-th fa-fw fa-lg" aria-hidden="true"></i> ' . ucfirst($group['name']) . '</a></li>';
    }
    unset($group);
    echo '</ul></li>';
}
if ($_SESSION['userlevel'] >= '10') {
    if ($config['show_locations']) {
        if ($config['show_locations_dropdown']) {
            $locations = getlocations();
            if (count($locations) > 0) {
                echo '
                    <li role="presentation" class="divider"></li>
                    <li class="dropdown-submenu">
                    <a href="#"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> Locations</a>
                    <ul class="dropdown-menu scrollable-menu">
                ';
                foreach ($locations as $location) {
                    echo '            <li><a href="devices/location=' . urlencode($location) . '/"><i class="fa fa-building-o fa-fw fa-lg" aria-hidden="true"></i> ' . $location . ' </a></li>';
                }
                echo '
                    </ul>
                    </li>
                ';
            }
예제 #2
0
파일: globe.php 프로젝트: borkz/librenms
 */
?>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
    google.load('visualization', '1', {'packages': ['geochart']});
    google.setOnLoadCallback(drawRegionsMap);
    function drawRegionsMap() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Site');
        data.addColumn('number', 'Status');
        data.addColumn('number', 'Size');
        data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});
        data.addRows([
<?php 
$locations = array();
foreach (getlocations() as $location) {
    $devices = array();
    $devices_down = array();
    $devices_up = array();
    $count = 0;
    $down = 0;
    foreach (dbFetchRows("SELECT devices.device_id,devices.hostname,devices.status FROM devices LEFT JOIN devices_attribs ON devices.device_id = devices_attribs.device_id WHERE devices.location = ?  && devices.disabled = 0 && devices.ignore = 0 GROUP BY devices.hostname", array($location)) as $device) {
        if ($config['frontpage_globe']['markers'] == 'devices' || empty($config['frontpage_globe']['markers'])) {
            $devices[] = $device['hostname'];
            $count++;
            if ($device['status'] == "0") {
                $down++;
                $devices_down[] = $device['hostname'] . " DOWN";
            } else {
                $devices_up[] = $device;
            }
예제 #3
0
function show_map($config)
{
    ?>
<div class="row-fluid">
    <div class="span12" style="padding: 10px;">
	<script type='text/javascript' src='https://www.google.com/jsapi'></script>
	<script type='text/javascript'>
	    google.load('visualization', '1.1', {'packages': ['geochart']});
	    google.setOnLoadCallback(drawRegionsMap);
	    function drawRegionsMap() {
		var data = new google.visualization.DataTable();
		data.addColumn('number', 'Latitude');
                data.addColumn('number', 'Longitude');
                data.addColumn('string', 'Location');
		data.addColumn('number', 'Status');
		data.addColumn('number', 'Devices');
		data.addColumn({type: 'string', role: 'tooltip'});
		data.addRows([
		<?php 
    $locations_up = array();
    $locations_down = array();
    $devicesArray = array();
    foreach (dbFetchRows("SELECT * FROM devices") as $device) {
        $devicesArray[] = array("device_id" => $device['device_id'], "hostname" => $device['hostname'], "location" => $device['location'], "status" => $device['status'], "ignore" => $device['ignore'], "disabled" => $device['disabled'], "location_lat" => $device['location_lat'], "location_lon" => $device['location_lon']);
    }
    foreach (getlocations() as $location) {
        $location = addslashes($location);
        $devices = array();
        $devices_down = array();
        $devices_up = array();
        $count = 0;
        $down = 0;
        foreach ($devicesArray as $device) {
            if ($device['location'] == $location) {
                $devices[] = $device['hostname'];
                $count++;
                if ($device['status'] == "0" && $device['disabled'] == "0" && $device['ignore'] == "0") {
                    $down++;
                    $devices_down[] = $device['hostname'];
                } elseif ($device['status'] == "1") {
                    $devices_up[] = $device['hostname'];
                    $lat = $device['location_lat'];
                    $lon = $device['location_lon'];
                }
            }
        }
        $count = $count < 100 ? $count : "100";
        if ($down > 0) {
            $locations_down[] = "[" . $lat . ", " . $lon . ", '" . $location . "', " . $down . ", " . $count * $down . ", '" . count($devices_up) . " Devices OK, " . count($devices_down) . " Devices DOWN: (" . implode(", ", $devices_down) . ")']";
        } else {
            $locations_up[] = "[" . $lat . ", " . $lon . ", '" . $location . "', 0, " . $count . ", '" . count($devices_up) . " Devices UP: (" . implode(", ", $devices_up) . ")']";
        }
    }
    unset($devicesArray);
    echo implode(",\n", array_merge($locations_up, $locations_down));
    ?>
		]);
		var options = {
		    region: '<?php 
    echo $config['frontpage']['map']['region'];
    ?>
',
		    resolution: '<?php 
    echo $config['frontpage']['map']['resolution'];
    ?>
',
		    displayMode: 'markers',
		    keepAspectRatio: 0,
		    width: 1160,
		    height: 480,
		    is3D: true,
		    legend: 'none',
                    enableRegionInteractivity: true,
		    <?php 
    if ($config['frontpage']['map']['realworld']) {
        echo "\t\t    datalessRegionColor: '#93CA76',";
    } else {
        echo "\t\t    datalessRegionColor: '#d5d5d5',";
    }
    ?>
                    <?php 
    if ($config['frontpage']['map']['realworld']) {
        echo "\t\t    backgroundColor: {fill: '#cceef0'},";
    }
    ?>
		    magnifyingGlass: {enable: true, zoomFactor: 5},
		    colorAxis: {values: [0, 1, 2, 3], colors: ['darkgreen', 'orange', 'orangered', 'red']},
		    markerOpacity: 0.75,
                    sizeAxis: {minValue: 1,  maxValue: 10, minSize: 10, maxSize: 40}
		};
		var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
		chart.draw(data, options);
		google.visualization.events.addListener(chart, 'ready', onReady);
		function onReady() {
		    google.visualization.events.addListener(chart, 'select', gotoLocation);
		}
		function gotoLocation() {
		    var selection = chart.getSelection();
		    var item = selection[0];
		    var url = '<?php 
    echo generate_url(array("page" => "devices"));
    ?>
';
		    var location = data.getValue(item.row, 2);
		    url = url+'location='+location+'/';
		    window.location = url;
		}
	    };
	</script>
	<div id="chart_div"></div>
    </div>
</div>
<?php 
}