From 8b5cf9983e997f9f89885dc785b5a9bdf3feb80a Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 18 Apr 2021 21:15:02 +0200 Subject: [PATCH] display a hint if no bookmarks are in the system --- htdocs/lib/settings/BookmarkTable.js | 2 ++ owrx/controllers/settings/bookmarks.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/lib/settings/BookmarkTable.js b/htdocs/lib/settings/BookmarkTable.js index 1a15981..48f48f1 100644 --- a/htdocs/lib/settings/BookmarkTable.js +++ b/htdocs/lib/settings/BookmarkTable.js @@ -261,6 +261,7 @@ $.fn.bookmarktable = function() { $(this).on('click', '.bookmark-add', function() { if ($table.find('tr[data-id="new"]').length) return; + $table.find('.emptytext').remove(); var row = $(''); var inputs = Object.fromEntries( @@ -371,6 +372,7 @@ $.fn.bookmarktable = function() { contentType: 'application/json', method: 'POST' }).done(function(data){ + $table.find('.emptytext').remove(); var modes = $table.data('modes'); if (data.length && data.length == selected.length) { $table.append(data.map(function(obj, index) { diff --git a/owrx/controllers/settings/bookmarks.py b/owrx/controllers/settings/bookmarks.py index 8f99497..771f120 100644 --- a/owrx/controllers/settings/bookmarks.py +++ b/owrx/controllers/settings/bookmarks.py @@ -22,7 +22,12 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController return variables def render_table(self): - bookmarks = Bookmarks.getSharedInstance() + bookmarks = Bookmarks.getSharedInstance().getBookmarks() + emptyText = """ + + No bookmarks in storage. You can add new bookmarks using the buttons below. + + """ return """ @@ -35,7 +40,7 @@ class BookmarksController(AuthorizationMixin, BreadcrumbMixin, WebpageController {bookmarks}
""".format( - bookmarks="".join(self.render_bookmark(b) for b in bookmarks.getBookmarks()), + bookmarks="".join(self.render_bookmark(b) for b in bookmarks) if bookmarks else emptyText, modes=json.dumps({m.modulation: m.name for m in Modes.getAvailableModes()}), )