mirror of
https://codeberg.org/diginaut/digimarks.git
synced 2026-02-04 07:00:26 +01:00
Correctly update bookmark form, and show HTTP status on error
This commit is contained in:
@@ -39,6 +39,7 @@ async def set_information_from_source(bookmark: Bookmark, request: Request) -> B
|
||||
str(bookmark.url), headers={'User-Agent': DIGIMARKS_USER_AGENT}
|
||||
)
|
||||
bookmark.http_status = result.status_code
|
||||
logger.info('HTTP status code %s for %s', bookmark.http_status, bookmark.url)
|
||||
except httpx.HTTPError as err:
|
||||
# For example, "MissingSchema: Invalid URL 'abc': No schema supplied. Perhaps you meant http://abc?"
|
||||
logger.error('Exception when trying to retrieve title for %s. Error: %s', bookmark.url, str(err))
|
||||
|
||||
@@ -219,12 +219,13 @@ document.addEventListener('alpine:init', () => {
|
||||
'title': '',
|
||||
'note': '',
|
||||
'tags': '',
|
||||
'http_status': 0,
|
||||
'strip_params': false
|
||||
}
|
||||
},
|
||||
async startAddingBookmark() {
|
||||
/* Open 'add bookmark' page */
|
||||
console.log('Start adding bookmark');
|
||||
console.log('Open "add bookmark" modal');
|
||||
this.resetEditBookmark();
|
||||
// this.show_bookmark_details = true;
|
||||
const editFormDialog = document.getElementById("editFormDialog");
|
||||
@@ -254,20 +255,19 @@ document.addEventListener('alpine:init', () => {
|
||||
console.log('Got response');
|
||||
console.log(response);
|
||||
console.log(data);
|
||||
if (data.ok) {
|
||||
if (response.ok) {
|
||||
this.bookmarkToEdit.url_hash = data.url_hash;
|
||||
this.bookmarkToEdit.url = data.url;
|
||||
this.bookmarkToEdit.title = data.title;
|
||||
this.bookmarkToEdit.note = data.note;
|
||||
this.bookmarkToEdit.tags = data.tags;
|
||||
this.bookmarkToEdit.http_status = data.http_status;
|
||||
} else {
|
||||
console.log('Error occurred');
|
||||
this.bookmarkToEditError = data.detail;
|
||||
}
|
||||
// this.bookmarkToEditError = 'lolwut';
|
||||
} catch (error) {
|
||||
// enter your logic for when there is an error (ex. error toast)
|
||||
|
||||
// enter logic for when there is an error (ex. error toast)
|
||||
console.log('error occurred');
|
||||
console.log(error);
|
||||
this.bookmarkToEditError = error.detail;
|
||||
|
||||
@@ -192,6 +192,10 @@
|
||||
<input id="bookmark_url" type="text" name="bookmark_url" placeholder="url"
|
||||
x-on:change.debounce="$store.digimarks.bookmarkURLChanged()"
|
||||
x-model="$store.digimarks.bookmarkToEdit.url">
|
||||
<p x-show="$store.digimarks.bookmarkToEdit.http_status > 202"
|
||||
x-text="'HTTP statuscode: ' + $store.digimarks.bookmarkToEdit.http_status" x-cloak
|
||||
class="error"></p>
|
||||
<p>
|
||||
</fieldset>
|
||||
<fieldset class="form-group">
|
||||
<label for="bookmark_title">Title</label>
|
||||
|
||||
Reference in New Issue
Block a user