Add refresh_or_alert so errors aren't missed.

This commit is contained in:
voussoir 2020-11-06 21:42:28 -08:00
parent 8d7f97a996
commit 68b27fced2
5 changed files with 22 additions and 11 deletions

View file

@ -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 ////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -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);
}
}
</script>

View file

@ -26,7 +26,7 @@ draggable=true
{% if unlink_parent is not none %}
<button
class="remove_child_button button_with_confirm red_button"
data-onclick="return api.albums.remove_child('{{unlink_parent.id}}', '{{album.id}}', common.refresh);"
data-onclick="return api.albums.remove_child('{{unlink_parent.id}}', '{{album.id}}', common.refresh_or_alert);"
data-prompt="Remove child?"
data-holder-class="remove_child_button"
data-confirm-class="red_button"

View file

@ -108,13 +108,13 @@ function create_bookmark_form()
{
return;
}
return api.bookmarks.create(url, title, common.refresh);
return api.bookmarks.create(url, title, common.refresh_or_alert);
}
function delete_bookmark_form(event)
{
const id = event.target.closest(".bookmark_card").dataset.id;
api.bookmarks.delete(id, common.refresh);
api.bookmarks.delete(id, common.refresh_or_alert);
}
function on_open(ed, edit_element_map)

View file

@ -418,7 +418,7 @@ function generate_thumbnail_callback(response)
function refresh_metadata_form()
{
api.photos.refresh_metadata(PHOTO_ID, common.refresh);
api.photos.refresh_metadata(PHOTO_ID, common.refresh_or_alert);
}
function set_searchhidden_form()