add location picker so set receiver location
This commit is contained in:
parent
29566430a6
commit
f0ef5bb371
@ -5,6 +5,9 @@
|
|||||||
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
|
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" type="text/css" href="static/css/admin.css" />
|
<link rel="stylesheet" type="text/css" href="static/css/admin.css" />
|
||||||
|
<script src="static/lib/jquery-3.2.1.min.js"></script>
|
||||||
|
<script src="https://unpkg.com/location-picker/dist/location-picker.min.js"></script>
|
||||||
|
<script src="static/settings.js"></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -14,3 +14,7 @@ body {
|
|||||||
.buttons {
|
.buttons {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.row .map-input {
|
||||||
|
margin: 15px 15px 0;
|
||||||
|
}
|
||||||
|
23
htdocs/settings.js
Normal file
23
htdocs/settings.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
$(function(){
|
||||||
|
$(".map-input").each(function(el) {
|
||||||
|
var $el = $(this);
|
||||||
|
var field_id = $el.attr("for");
|
||||||
|
var $lat = $('#' + field_id + '-lat');
|
||||||
|
var $lon = $('#' + field_id + '-lon');
|
||||||
|
$.getScript("https://maps.googleapis.com/maps/api/js?key=" + $el.data("key")).done(function(){
|
||||||
|
$el.css("height", "200px");
|
||||||
|
var lp = new locationPicker($el.get(0), {
|
||||||
|
lat: parseFloat($lat.val()),
|
||||||
|
lng: parseFloat($lon.val())
|
||||||
|
}, {
|
||||||
|
zoom: 7
|
||||||
|
});
|
||||||
|
|
||||||
|
google.maps.event.addListener(lp.map, 'idle', function(event){
|
||||||
|
var pos = lp.getMarkerPosition();
|
||||||
|
$lat.val(pos.lat);
|
||||||
|
$lon.val(pos.lng);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
@ -1,5 +1,6 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from owrx.service import ServiceDetector
|
from owrx.service import ServiceDetector
|
||||||
|
from owrx.config import Config
|
||||||
|
|
||||||
|
|
||||||
class Input(ABC):
|
class Input(ABC):
|
||||||
@ -81,13 +82,17 @@ class FloatInput(NumberInput):
|
|||||||
|
|
||||||
class LocationInput(Input):
|
class LocationInput(Input):
|
||||||
def render_input(self, value):
|
def render_input(self, value):
|
||||||
# TODO make this work and pretty
|
|
||||||
return """
|
return """
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{inputs}
|
{inputs}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col map-input" data-key="{key}" for="{id}"></div>
|
||||||
|
</div>
|
||||||
""".format(
|
""".format(
|
||||||
inputs="".join(self.render_sub_input(value, id) for id in ["lat", "lon"])
|
id=self.id,
|
||||||
|
inputs="".join(self.render_sub_input(value, id) for id in ["lat", "lon"]),
|
||||||
|
key=Config.get()["google_maps_api_key"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_sub_input(self, value, id):
|
def render_sub_input(self, value, id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user