Bookmark descriptions now operational.
This commit is contained in:
parent
0ca80d7fef
commit
90d3381529
|
|
@ -381,6 +381,10 @@
|
||||||
<label for="modulation">Modulation:</label>
|
<label for="modulation">Modulation:</label>
|
||||||
<select name="modulation" id="modulation"></select>
|
<select name="modulation" id="modulation"></select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-field">
|
||||||
|
<label for="name">Description:</label>
|
||||||
|
<input type="text" id="description" name="description">
|
||||||
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<div class="openwebrx-button" data-action="cancel">Cancel</div>
|
<div class="openwebrx-button" data-action="cancel">Cancel</div>
|
||||||
<div class="openwebrx-button" data-action="submit">Ok</div>
|
<div class="openwebrx-button" data-action="submit">Ok</div>
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,6 @@ function BookmarkBar() {
|
||||||
stopScanner();
|
stopScanner();
|
||||||
});
|
});
|
||||||
|
|
||||||
// me.$container.on('contextmenu', '.bookmark', function(e){
|
|
||||||
// e.stopPropagation();
|
|
||||||
// var $bookmark = $(e.target).closest('.bookmark');
|
|
||||||
// var b = $bookmark.data();
|
|
||||||
// if (!b || !b.description) return false;
|
|
||||||
// divlog(b.description, false);
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
|
|
||||||
me.$container.on('click', '.action[data-action=edit]', function(e){
|
me.$container.on('click', '.action[data-action=edit]', function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var $bookmark = $(e.target).closest('.bookmark');
|
var $bookmark = $(e.target).closest('.bookmark');
|
||||||
|
|
@ -103,6 +94,9 @@ BookmarkBar.prototype.render = function(){
|
||||||
'<div class="bookmark-content">' + b.name + '</div>' +
|
'<div class="bookmark-content">' + b.name + '</div>' +
|
||||||
'</div>'
|
'</div>'
|
||||||
);
|
);
|
||||||
|
if (b.description) {
|
||||||
|
$bookmark.prop('title', b.description);
|
||||||
|
}
|
||||||
$bookmark.data(b);
|
$bookmark.data(b);
|
||||||
return $bookmark;
|
return $bookmark;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ $.fn.bookmarkDialog = function() {
|
||||||
},
|
},
|
||||||
setValues: function(bookmark) {
|
setValues: function(bookmark) {
|
||||||
var $form = $el.find('form');
|
var $form = $el.find('form');
|
||||||
['name', 'frequency', 'modulation'].forEach(function(key){
|
['name', 'frequency', 'modulation', 'description'].forEach(function(key){
|
||||||
$form.find('#' + key).val(bookmark[key]);
|
$form.find('#' + key).val(bookmark[key]);
|
||||||
});
|
});
|
||||||
$el.data('id', bookmark.id || false);
|
$el.data('id', bookmark.id || false);
|
||||||
|
|
@ -20,7 +20,7 @@ $.fn.bookmarkDialog = function() {
|
||||||
getValues: function() {
|
getValues: function() {
|
||||||
var bookmark = {};
|
var bookmark = {};
|
||||||
var valid = true;
|
var valid = true;
|
||||||
['name', 'frequency', 'modulation'].forEach(function(key){
|
['name', 'frequency', 'modulation', 'description'].forEach(function(key){
|
||||||
var $input = $el.find('#' + key);
|
var $input = $el.find('#' + key);
|
||||||
valid = valid && $input[0].checkValidity();
|
valid = valid && $input[0].checkValidity();
|
||||||
bookmark[key] = $input.val();
|
bookmark[key] = $input.val();
|
||||||
|
|
@ -33,4 +33,4 @@ $.fn.bookmarkDialog = function() {
|
||||||
return bookmark;
|
return bookmark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ Utils.setIcaoUrl = function(url) {
|
||||||
|
|
||||||
// Escape HTML code
|
// Escape HTML code
|
||||||
Utils.htmlEscape = function(input) {
|
Utils.htmlEscape = function(input) {
|
||||||
return $('<div/>').text(input).html()
|
return $('<div/>').text(input).html();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Print frequency (in Hz) in a nice way
|
// Print frequency (in Hz) in a nice way
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ function Editor(table) {
|
||||||
|
|
||||||
Editor.prototype.getInputHtml = function() {
|
Editor.prototype.getInputHtml = function() {
|
||||||
return '<input>';
|
return '<input>';
|
||||||
}
|
};
|
||||||
|
|
||||||
Editor.prototype.render = function(el) {
|
Editor.prototype.render = function(el) {
|
||||||
this.input = $(this.getInputHtml());
|
this.input = $(this.getInputHtml());
|
||||||
|
|
@ -62,7 +62,7 @@ NameEditor.prototype = new Editor();
|
||||||
|
|
||||||
NameEditor.prototype.getInputHtml = function() {
|
NameEditor.prototype.getInputHtml = function() {
|
||||||
return '<input class="form-control form-control-sm" type="text">';
|
return '<input class="form-control form-control-sm" type="text">';
|
||||||
}
|
};
|
||||||
|
|
||||||
function FrequencyEditor(table) {
|
function FrequencyEditor(table) {
|
||||||
Editor.call(this, table);
|
Editor.call(this, table);
|
||||||
|
|
@ -122,7 +122,7 @@ FrequencyEditor.prototype.setupEvents = function() {
|
||||||
me.expInput.val(FrequencyEditor.suffixes[c]);
|
me.expInput.val(FrequencyEditor.suffixes[c]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
FrequencyEditor.prototype.getValue = function() {
|
FrequencyEditor.prototype.getValue = function() {
|
||||||
var frequency = parseFloat(this.freqInput.val());
|
var frequency = parseFloat(this.freqInput.val());
|
||||||
|
|
@ -160,7 +160,7 @@ var renderFrequency = function(freq) {
|
||||||
suffix = suffix[0] == 'K' ? 'k' : suffix[0];
|
suffix = suffix[0] == 'K' ? 'k' : suffix[0];
|
||||||
var expString = suffix[0] + 'Hz';
|
var expString = suffix[0] + 'Hz';
|
||||||
return frequency + ' ' + expString;
|
return frequency + ' ' + expString;
|
||||||
}
|
};
|
||||||
|
|
||||||
FrequencyEditor.prototype.getHtml = function() {
|
FrequencyEditor.prototype.getHtml = function() {
|
||||||
return renderFrequency(this.getValue());
|
return renderFrequency(this.getValue());
|
||||||
|
|
@ -186,11 +186,22 @@ ModulationEditor.prototype.getHtml = function() {
|
||||||
return $option.html();
|
return $option.html();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function DescriptionEditor(table) {
|
||||||
|
Editor.call(this, table);
|
||||||
|
}
|
||||||
|
|
||||||
|
DescriptionEditor.prototype = new Editor();
|
||||||
|
|
||||||
|
DescriptionEditor.prototype.getInputHtml = function() {
|
||||||
|
return '<input class="form-control form-control-sm" type="text">';
|
||||||
|
};
|
||||||
|
|
||||||
$.fn.bookmarktable = function() {
|
$.fn.bookmarktable = function() {
|
||||||
var editors = {
|
var editors = {
|
||||||
name: NameEditor,
|
name: NameEditor,
|
||||||
frequency: FrequencyEditor,
|
frequency: FrequencyEditor,
|
||||||
modulation: ModulationEditor
|
modulation: ModulationEditor,
|
||||||
|
description: DescriptionEditor
|
||||||
};
|
};
|
||||||
|
|
||||||
$.each(this, function(){
|
$.each(this, function(){
|
||||||
|
|
@ -386,6 +397,7 @@ $.fn.bookmarktable = function() {
|
||||||
'<td data-editor="name" data-value="' + bookmark.name + '">' + bookmark.name + '</td>' +
|
'<td data-editor="name" data-value="' + bookmark.name + '">' + bookmark.name + '</td>' +
|
||||||
'<td data-editor="frequency" data-value="' + bookmark.frequency + '" class="frequency">' + renderFrequency(bookmark.frequency) +'</td>' +
|
'<td data-editor="frequency" data-value="' + bookmark.frequency + '" class="frequency">' + renderFrequency(bookmark.frequency) +'</td>' +
|
||||||
'<td data-editor="modulation" data-value="' + bookmark.modulation + '">' + modulation_name + '</td>' +
|
'<td data-editor="modulation" data-value="' + bookmark.modulation + '">' + modulation_name + '</td>' +
|
||||||
|
'<td data-editor="description" data-value="' + bookmark.description + '">' + bookmark.description + '</td>' +
|
||||||
'<td>' +
|
'<td>' +
|
||||||
'<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>' +
|
'<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>' +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class Bookmark(object):
|
||||||
self.name = j["name"]
|
self.name = j["name"]
|
||||||
self.frequency = j["frequency"]
|
self.frequency = j["frequency"]
|
||||||
self.modulation = j["modulation"]
|
self.modulation = j["modulation"]
|
||||||
|
self.description = j["description"] if "description" in j else ""
|
||||||
self.srcFile = srcFile
|
self.srcFile = srcFile
|
||||||
|
|
||||||
def getName(self):
|
def getName(self):
|
||||||
|
|
@ -25,6 +26,9 @@ class Bookmark(object):
|
||||||
def getModulation(self):
|
def getModulation(self):
|
||||||
return self.modulation
|
return self.modulation
|
||||||
|
|
||||||
|
def getDescription(self):
|
||||||
|
return self.description
|
||||||
|
|
||||||
def getSrcFile(self):
|
def getSrcFile(self):
|
||||||
return self.srcFile
|
return self.srcFile
|
||||||
|
|
||||||
|
|
@ -33,6 +37,7 @@ class Bookmark(object):
|
||||||
"name": self.getName(),
|
"name": self.getName(),
|
||||||
"frequency": self.getFrequency(),
|
"frequency": self.getFrequency(),
|
||||||
"modulation": self.getModulation(),
|
"modulation": self.getModulation(),
|
||||||
|
"description": self.getDescription(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th class="frequency">Frequency</th>
|
<th class="frequency">Frequency</th>
|
||||||
<th>Modulation</th>
|
<th>Modulation</th>
|
||||||
|
<th>Description</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
{bookmarks}
|
{bookmarks}
|
||||||
|
|
@ -69,6 +70,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
<td data-editor="name" data-value="{name}">{name}</td>
|
<td data-editor="name" data-value="{name}">{name}</td>
|
||||||
<td data-editor="frequency" data-value="{frequency}" class="frequency">{rendered_frequency}</td>
|
<td data-editor="frequency" data-value="{frequency}" class="frequency">{rendered_frequency}</td>
|
||||||
<td data-editor="modulation" data-value="{modulation}">{modulation_name}</td>
|
<td data-editor="modulation" data-value="{modulation}">{modulation_name}</td>
|
||||||
|
<td data-editor="description" data-value="{description}">{description}</td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>
|
<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -81,6 +83,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
rendered_frequency=render_frequency(bookmark.getFrequency()),
|
rendered_frequency=render_frequency(bookmark.getFrequency()),
|
||||||
modulation=bookmark.getModulation() if mode is None else mode.modulation,
|
modulation=bookmark.getModulation() if mode is None else mode.modulation,
|
||||||
modulation_name=bookmark.getModulation() if mode is None else mode.name,
|
modulation_name=bookmark.getModulation() if mode is None else mode.name,
|
||||||
|
description=bookmark.getDescription(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _findBookmark(self, bookmark_id):
|
def _findBookmark(self, bookmark_id):
|
||||||
|
|
@ -98,7 +101,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
data = json.loads(self.get_body().decode("utf-8"))
|
data = json.loads(self.get_body().decode("utf-8"))
|
||||||
for key in ["name", "frequency", "modulation"]:
|
for key in ["name", "frequency", "modulation", "description"]:
|
||||||
if key in data:
|
if key in data:
|
||||||
value = data[key]
|
value = data[key]
|
||||||
if key == "frequency":
|
if key == "frequency":
|
||||||
|
|
@ -120,6 +123,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
||||||
"name": bookmark_data["name"],
|
"name": bookmark_data["name"],
|
||||||
"frequency": int(bookmark_data["frequency"]),
|
"frequency": int(bookmark_data["frequency"]),
|
||||||
"modulation": bookmark_data["modulation"],
|
"modulation": bookmark_data["modulation"],
|
||||||
|
"description": bookmark_data["description"],
|
||||||
}
|
}
|
||||||
bookmark = Bookmark(data)
|
bookmark = Bookmark(data)
|
||||||
bookmarks.addBookmark(bookmark)
|
bookmarks.addBookmark(bookmark)
|
||||||
|
|
|
||||||
30
owrx/eibi.py
30
owrx/eibi.py
|
|
@ -68,23 +68,29 @@ class EIBI(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getDescription(b):
|
def getDescription(b):
|
||||||
description = ""
|
description = []
|
||||||
# Describe target region
|
# Describe target region
|
||||||
if "tgt" in b:
|
if "tgt" in b:
|
||||||
description += "Targeting " + b["tgt"] + "."
|
target = b["tgt"]
|
||||||
# Describe transmitter locations
|
|
||||||
if "src" in b and b["src"] in EIBI_Locations:
|
|
||||||
description += (
|
|
||||||
(" " if len(description) > 0 else "") +
|
|
||||||
"Transmitting from " +
|
|
||||||
", ".join([x["name"] for x in EIBI_Locations[b["src"]]])
|
|
||||||
)
|
|
||||||
# Add country name if ITU code present
|
# Add country name if ITU code present
|
||||||
if "itu" in b and b["itu"] in EIBI_Countries:
|
if "itu" in b and b["itu"] in EIBI_Countries:
|
||||||
description += ", " + EIBI_Countries[b["itu"]]
|
source = EIBI_Countries[b["itu"]]
|
||||||
description += "."
|
else:
|
||||||
|
source = target
|
||||||
|
description += [(
|
||||||
|
"Broadcasting to " + target +
|
||||||
|
((" from " + source) if source != target else "") +
|
||||||
|
"."
|
||||||
|
)]
|
||||||
|
# Describe transmitter locations
|
||||||
|
if "src" in b and b["src"] in EIBI_Locations:
|
||||||
|
description += [(
|
||||||
|
"Transmitting from " +
|
||||||
|
", ".join([x["name"] for x in EIBI_Locations[b["src"]]]) +
|
||||||
|
"."
|
||||||
|
)]
|
||||||
# Done
|
# Done
|
||||||
return description
|
return " ".join(description)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.patternCSV = re.compile(r"^([\d\.]+);(\d\d\d\d)-(\d\d\d\d);(\S*);(\S+);(.*);(.*);(.*);(.*);(\d+);(.*);(.*)$")
|
self.patternCSV = re.compile(r"^([\d\.]+);(\d\d\d\d)-(\d\d\d\d);(\S*);(\S+);(.*);(.*);(.*);(.*);(\d+);(.*);(.*)$")
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,20 @@ class Repeaters(object):
|
||||||
else:
|
else:
|
||||||
return "nfm"
|
return "nfm"
|
||||||
|
|
||||||
|
# Compose textual description of an entry
|
||||||
|
@staticmethod
|
||||||
|
def getDescription(entry):
|
||||||
|
description = []
|
||||||
|
# Add information from the entry to the description
|
||||||
|
if "status" in entry:
|
||||||
|
description += [entry["status"] + "."]
|
||||||
|
if "updated" in entry:
|
||||||
|
description += ["Last updated " + entry["updated"] + "."]
|
||||||
|
if "comment" in entry:
|
||||||
|
description += [entry["comment"]]
|
||||||
|
# Done
|
||||||
|
return " ".join(description)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.refreshPeriod = 60*60*24
|
self.refreshPeriod = 60*60*24
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
@ -231,9 +245,10 @@ class Repeaters(object):
|
||||||
# Return bookmarks for all found entries
|
# Return bookmarks for all found entries
|
||||||
logger.info("Created {0} bookmarks for {1}-{2}kHz within {3}km.".format(len(result), f1//1000, f2//1000, rangeKm))
|
logger.info("Created {0} bookmarks for {1}-{2}kHz within {3}km.".format(len(result), f1//1000, f2//1000, rangeKm))
|
||||||
return [ Bookmark({
|
return [ Bookmark({
|
||||||
"name" : result[f][0]["name"],
|
"name" : result[f][0]["name"],
|
||||||
"modulation" : result[f][0]["mode"],
|
"modulation" : result[f][0]["mode"],
|
||||||
"frequency" : result[f][0]["freq"]
|
"frequency" : result[f][0]["freq"],
|
||||||
|
"description" : Repeaters.getDescription(result[f][0])
|
||||||
}, srcFile = "RepeaterBook") for f in result.keys() ]
|
}, srcFile = "RepeaterBook") for f in result.keys() ]
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue