Skip to content

Commit

Permalink
api: Added lattitude and longitude on devices/device fetch (#8515)
Browse files Browse the repository at this point in the history
* '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
  • Loading branch information
sorribes22 authored and laf committed Apr 7, 2018
1 parent f694125 commit c22b315
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions html/includes/api_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c22b315

Please sign in to comment.