From 68b27fced2faf727e77231782b789ccf387a023d Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 6 Nov 2020 21:42:28 -0800 Subject: [PATCH] Add refresh_or_alert so errors aren't missed. --- frontends/etiquette_flask/static/js/common.js | 11 +++++++++++ frontends/etiquette_flask/templates/album.html | 14 +++++++------- .../etiquette_flask/templates/album_card.html | 2 +- frontends/etiquette_flask/templates/bookmarks.html | 4 ++-- frontends/etiquette_flask/templates/photo.html | 2 +- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/frontends/etiquette_flask/static/js/common.js b/frontends/etiquette_flask/static/js/common.js index c0900a9..ae06694 100644 --- a/frontends/etiquette_flask/static/js/common.js +++ b/frontends/etiquette_flask/static/js/common.js @@ -40,6 +40,17 @@ function refresh() window.location.reload(); } +common.refresh_or_alert = +function refresh_or_alert(response) +{ + if (response.meta.status !== 200) + { + alert(JSON.stringify(response)); + return; + } + window.location.reload(); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // HTTP //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index a4e2ada..ca056a8 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -295,7 +295,7 @@ function add_child(child_id) { return; } - api.albums.add_child(ALBUM_ID, child_id, common.refresh); + api.albums.add_child(ALBUM_ID, child_id, common.refresh_or_alert); } function delete_album_form() @@ -305,18 +305,18 @@ function delete_album_form() function refresh_associated_directories_form() { - api.albums.refresh_directories(ALBUM_ID, common.refresh); + api.albums.refresh_directories(ALBUM_ID, common.refresh_or_alert); } function paste_photo_clipboard() { const photo_ids = Array.from(photo_clipboard.clipboard); - api.albums.add_photos(ALBUM_ID, photo_ids, common.refresh); + api.albums.add_photos(ALBUM_ID, photo_ids, common.refresh_or_alert); } function unpaste_photo_clipboard() { const photo_ids = Array.from(photo_clipboard.clipboard); - api.albums.remove_photos(ALBUM_ID, photo_ids, common.refresh); + api.albums.remove_photos(ALBUM_ID, photo_ids, common.refresh_or_alert); } function rename_ed_on_open(ed, edit_element_map, display_element_map) @@ -450,16 +450,16 @@ function on_album_drag_drop(event) if (parent_id === "root") { - api.albums.remove_child(ALBUM_ID, child_id, common.refresh); + api.albums.remove_child(ALBUM_ID, child_id, common.refresh_or_alert); } else if (ALBUM_ID) { api.albums.add_child(parent_id, child_id, null); - api.albums.remove_child(ALBUM_ID, child_id, common.refresh); + api.albums.remove_child(ALBUM_ID, child_id, common.refresh_or_alert); } else { - api.albums.add_child(parent_id, child_id, common.refresh); + api.albums.add_child(parent_id, child_id, common.refresh_or_alert); } } diff --git a/frontends/etiquette_flask/templates/album_card.html b/frontends/etiquette_flask/templates/album_card.html index b1f8f52..9cf9ee1 100644 --- a/frontends/etiquette_flask/templates/album_card.html +++ b/frontends/etiquette_flask/templates/album_card.html @@ -26,7 +26,7 @@ draggable=true {% if unlink_parent is not none %}