mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
API detect if new location should be fixed by default (#13637)
This commit is contained in:
@@ -12,7 +12,7 @@ Input:
|
||||
- location: name of the new location
|
||||
- lat: latitude
|
||||
- lng: longitude
|
||||
- fixed_coordinates: 0 if updated from the device or 1 if the coordinate is fixed (default is fixed)
|
||||
- fixed_coordinates: 0 if updated from the device or 1 if the coordinate is fixed (default is fixed if lat and lng are valid)
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -2695,11 +2695,11 @@ function add_location(Illuminate\Http\Request $request)
|
||||
return api_error(400, 'Required fields missing (location, lat and lng needed)');
|
||||
}
|
||||
// Set the location
|
||||
$timestamp = date('Y-m-d H:m:s');
|
||||
$insert = ['location' => $data['location'], 'lat' => $data['lat'], 'lng' => $data['lng'], 'fixed_coordinates' => $data['fixed_coordinates'] ?? 1, 'timestamp' => $timestamp];
|
||||
$location_id = dbInsert($insert, 'locations');
|
||||
if ($location_id != false) {
|
||||
return api_success_noresult(201, "Location added with id #$location_id");
|
||||
$location = new \App\Models\Location($data);
|
||||
$location->fixed_coordinates = $data['fixed_coordinates'] ?? $location->coordinatesValid();
|
||||
|
||||
if ($location->save()) {
|
||||
return api_success_noresult(201, "Location added with id #$location->id");
|
||||
}
|
||||
|
||||
return api_error(500, 'Failed to add the location');
|
||||
|
||||
Reference in New Issue
Block a user