From 19304cd1ae4e4ba4f6dcf4f1db14de1e4e70c250 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 10 Jan 2022 23:38:56 +0100 Subject: improve item list styling; add payload creation form; exend dialog mechanism --- common/indexeddb.js | 4 +- common/lock.js | 13 ++- html/dialog.html | 4 +- html/dialog.js | 33 ++++-- html/grid.css | 5 + html/item_list.html | 39 +++++-- html/item_list.js | 2 +- html/item_preview.html | 8 +- html/item_preview.js | 4 +- html/payload_create.html | 76 +++++++++++++ html/payload_create.js | 229 +++++++++++++++++++++++++++++++++++++++ test/unit/test_dialog.py | 45 +++++--- test/unit/test_indexeddb.py | 46 +------- test/unit/test_item_list.py | 42 +++---- test/unit/test_payload_create.py | 121 +++++++++++++++++++++ test/unit/utils.py | 53 +++++++++ 16 files changed, 614 insertions(+), 110 deletions(-) create mode 100644 html/payload_create.html create mode 100644 html/payload_create.js create mode 100644 test/unit/test_payload_create.py diff --git a/common/indexeddb.js b/common/indexeddb.js index f9c407a..a18c9be 100644 --- a/common/indexeddb.js +++ b/common/indexeddb.js @@ -313,8 +313,8 @@ async function _save_items(resources, mappings, context) /* * Save given definition of a resource/mapping to IndexedDB. If the definition * (passed as `item`) references files that are not already present in - * IndexedDB, those files should be present as values of the `files_sha256` - * object with keys being of the form `sha256-`. + * IndexedDB, those files should be provided as values of the `files' object + * used to create the transaction context. * * context should be one returned from start_items_transaction() and should be * later passed to finalize_transaction() so that files depended on are added to diff --git a/common/lock.js b/common/lock.js index 8dd2f5b..f577481 100644 --- a/common/lock.js +++ b/common/lock.js @@ -68,9 +68,20 @@ function _lock(lock, cb) { #EXPORT lock => new Promise(resolve => _lock(lock, resolve)) AS lock +function try_lock(lock) +{ + if (lock.free) { + lock.free = false; + return true; + } + + return false; +} +#EXPORT try_lock + function unlock(lock) { if (lock.free) - throw new Error("Attempting to release a free lock"); + throw new Exception("Attempting to release a free lock"); if (lock.queue.length === 0) { lock.free = true; diff --git a/html/dialog.html b/html/dialog.html index d4e69b9..090a76b 100644 --- a/html/dialog.html +++ b/html/dialog.html @@ -53,12 +53,12 @@ margin-bottom: 2em; text-align: center; } - .dialog_main_div { + .dialog_main_view { margin: 1.4em; }