mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
api: Added lattitude and longitude on devices/device fetch (#8515)
* 'lat' and 'lng' columns added on list_devices() * 'lat' and 'lng' columns added on device fetch Helped by https://github.com/laf * Commit user.name changed
This commit is contained in:
committed by
Neil Lathwood
parent
f69412525e
commit
c22b31506e
@@ -304,8 +304,8 @@ function list_devices()
|
||||
$order = 'd.`'.$order.'` ASC';
|
||||
}
|
||||
|
||||
$select = " d.*, GROUP_CONCAT(dd.device_id) AS dependency_parent_id, GROUP_CONCAT(dd.hostname) AS dependency_parent_hostname ";
|
||||
$join = " LEFT JOIN `device_relationships` AS dr ON dr.`child_device_id` = d.`device_id` LEFT JOIN `devices` AS dd ON dr.`parent_device_id` = dd.`device_id` ";
|
||||
$select = " d.*, GROUP_CONCAT(dd.device_id) AS dependency_parent_id, GROUP_CONCAT(dd.hostname) AS dependency_parent_hostname, `lat`, `lng` ";
|
||||
$join = " LEFT JOIN `device_relationships` AS dr ON dr.`child_device_id` = d.`device_id` LEFT JOIN `devices` AS dd ON dr.`parent_device_id` = dd.`device_id` LEFT JOIN `locations` ON `locations`.`location` = `d`.`location`";
|
||||
|
||||
if ($type == 'all' || empty($type)) {
|
||||
$sql = '1';
|
||||
|
@@ -365,7 +365,7 @@ function device_by_id_cache($device_id, $refresh = false)
|
||||
if (!$refresh && isset($cache['devices']['id'][$device_id]) && is_array($cache['devices']['id'][$device_id])) {
|
||||
$device = $cache['devices']['id'][$device_id];
|
||||
} else {
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id));
|
||||
$device = dbFetchRow("SELECT `devices`.*, `lat`, `lng` FROM `devices` LEFT JOIN locations ON `devices`.`location`=`locations`.`location` WHERE `device_id` = ?", array($device_id));
|
||||
$device['attribs'] = get_dev_attribs($device['device_id']);
|
||||
load_os($device);
|
||||
|
||||
|
Reference in New Issue
Block a user