Now able to edit "scannable" value in the bookmarks editor.
This commit is contained in:
parent
8d69c17c92
commit
66d230eaa8
|
|
@ -1,5 +1,6 @@
|
|||
function BookmarkBar() {
|
||||
var me = this;
|
||||
me.toScan = ['lsb', 'usb', 'usbd', 'cw', 'am', 'sam', 'nfm'];
|
||||
me.localBookmarks = new BookmarkLocalStorage();
|
||||
me.$container = $("#openwebrx-bookmarks-container");
|
||||
me.bookmarks = {};
|
||||
|
|
@ -107,10 +108,12 @@ BookmarkBar.prototype.render = function(){
|
|||
|
||||
BookmarkBar.prototype.showEditDialog = function(bookmark) {
|
||||
if (!bookmark) {
|
||||
var mode = this.getDemodulator().get_secondary_demod() || this.getDemodulator().get_modulation();
|
||||
bookmark = {
|
||||
name: "",
|
||||
frequency: center_freq + this.getDemodulator().get_offset_frequency(),
|
||||
modulation: this.getDemodulator().get_secondary_demod() || this.getDemodulator().get_modulation()
|
||||
modulation: mode,
|
||||
scannable : this.toScan.indexOf(mode) >= 0
|
||||
}
|
||||
}
|
||||
this.$dialog.bookmarkDialog().setValues(bookmark);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function Scanner(bookmarkBar, msec) {
|
||||
this.modes = ['lsb', 'usb', 'cw', 'am', 'sam', 'nfm'];
|
||||
this.modes = ['lsb', 'usb', 'usbd', 'cw', 'am', 'sam', 'nfm'];
|
||||
this.bbar = bookmarkBar;
|
||||
this.bookmarks = null;
|
||||
this.msec = msec;
|
||||
|
|
|
|||
|
|
@ -198,12 +198,35 @@ DescriptionEditor.prototype.getInputHtml = function() {
|
|||
return '<input class="form-control form-control-sm" type="text">';
|
||||
};
|
||||
|
||||
function ScannableEditor(table) {
|
||||
Editor.call(this, table);
|
||||
}
|
||||
|
||||
ScannableEditor.prototype = new Editor();
|
||||
|
||||
ScannableEditor.prototype.getInputHtml = function() {
|
||||
return '<input class="form-control form-control-sm" type="checkbox" checked>';
|
||||
};
|
||||
|
||||
ScannableEditor.prototype.getValue = function() {
|
||||
return this.input.prop('checked');
|
||||
};
|
||||
|
||||
ScannableEditor.prototype.setValue = function(value) {
|
||||
this.input.prop('checked', value);
|
||||
};
|
||||
|
||||
ScannableEditor.prototype.getHtml = function() {
|
||||
return this.getValue()? '✓' : '';
|
||||
};
|
||||
|
||||
$.fn.bookmarktable = function() {
|
||||
var editors = {
|
||||
name: NameEditor,
|
||||
frequency: FrequencyEditor,
|
||||
modulation: ModulationEditor,
|
||||
description: DescriptionEditor
|
||||
description: DescriptionEditor,
|
||||
scannable: ScannableEditor
|
||||
};
|
||||
|
||||
$.each(this, function(){
|
||||
|
|
@ -400,6 +423,7 @@ $.fn.bookmarktable = function() {
|
|||
'<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="description" data-value="' + bookmark.description + '">' + bookmark.description + '</td>' +
|
||||
'<td data-editor="scannable" data-value="' + bookmark.scannable + '">' + (bookmark.scannable? '✓':'') + '</td>' +
|
||||
'<td>' +
|
||||
'<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>' +
|
||||
'</td>' +
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Bookmark(object):
|
|||
self.frequency = j["frequency"]
|
||||
self.modulation = j["modulation"]
|
||||
self.description = j["description"] if "description" in j else ""
|
||||
self.scannable = j["scan"] if "scannable" in j else True
|
||||
self.scannable = j["scannable"] if "scannable" in j else True
|
||||
self.srcFile = srcFile
|
||||
|
||||
def getName(self):
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
|||
<th class="frequency">Frequency</th>
|
||||
<th>Modulation</th>
|
||||
<th>Description</th>
|
||||
<th>Scan</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
{bookmarks}
|
||||
|
|
@ -65,12 +66,14 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
|||
return "{num:g} {suffix}Hz".format(num=num, suffix=suffix)
|
||||
|
||||
mode = Modes.findByModulation(bookmark.getModulation())
|
||||
scan = bookmark.isScannable()
|
||||
return """
|
||||
<tr data-id="{id}">
|
||||
<td data-editor="name" data-value="{name}">{name}</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="description" data-value="{description}">{description}</td>
|
||||
<td data-editor="scannable" data-value="{scannable}">{scannable_check}</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-sm btn-danger bookmark-delete">delete</button>
|
||||
</td>
|
||||
|
|
@ -84,6 +87,8 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
|||
modulation=bookmark.getModulation() if mode is None else mode.modulation,
|
||||
modulation_name=bookmark.getModulation() if mode is None else mode.name,
|
||||
description=bookmark.getDescription(),
|
||||
scannable="true" if scan else "false",
|
||||
scannable_check="✓" if scan else "",
|
||||
)
|
||||
|
||||
def _findBookmark(self, bookmark_id):
|
||||
|
|
@ -101,7 +106,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
|||
return
|
||||
try:
|
||||
data = json.loads(self.get_body().decode("utf-8"))
|
||||
for key in ["name", "frequency", "modulation", "description"]:
|
||||
for key in ["name", "frequency", "modulation", "description", "scannable"]:
|
||||
if key in data:
|
||||
value = data[key]
|
||||
if key == "frequency":
|
||||
|
|
@ -124,6 +129,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController
|
|||
"frequency": int(bookmark_data["frequency"]),
|
||||
"modulation": bookmark_data["modulation"],
|
||||
"description": bookmark_data["description"],
|
||||
"scannable": bookmark_data["scannable"],
|
||||
}
|
||||
bookmark = Bookmark(data)
|
||||
bookmarks.addBookmark(bookmark)
|
||||
|
|
|
|||
Loading…
Reference in New Issue