Add alertresponse to a lot of callback functions.

master
voussoir 2020-11-06 22:50:05 -08:00
parent 0a31dad196
commit 12ee2adedf
5 changed files with 75 additions and 28 deletions

View File

@ -329,9 +329,16 @@ function rename_ed_on_save(ed, edit_element_map, display_element_map)
{
function callback(response)
{
if (response.meta.status != 200)
ed.hide_spinner();
if (! response.meta.json_ok)
{
ed.show_error("Status: " + response.meta.status);
alert(JSON.stringify(response));
return;
}
if ("error_type" in response.data)
{
ed.show_error(response.data.error_message);
return;
}

View File

@ -209,6 +209,7 @@ function request_more_divs()
{
if (response.meta.status !== 200)
{
alert(JSON.stringify(response));
return;
}
for (photo_id in response.data)
@ -238,6 +239,11 @@ photo_clipboard.on_save_hooks.push(my_clipboard_load_save_hook);
function add_remove_tag_callback(response)
{
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
const tagname = response.data.tagname;
const message_area = document.getElementById("message_area");
let message_positivity;
@ -309,6 +315,11 @@ const refresh_metadata_button = document.getElementById("refresh_metadata_button
function refresh_metadata_callback(response)
{
window[refresh_metadata_button.dataset.spinnerCloser]();
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
if ("error_type" in response.data)
{
const message_area = document.getElementById("message_area");
@ -337,6 +348,11 @@ function refresh_metadata_form()
function set_unset_searchhidden_callback(response)
{
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
const message_area = document.getElementById("message_area");
let message_positivity;
let message_text;

View File

@ -124,6 +124,11 @@ function register_form(event)
function login_register_callback(response)
{
if (! response.json_ok)
{
alert(JSON.stringify(response));
return;
}
if ("error_type" in response.data)
{
common.create_message_bubble(message_area, "message_negative", response.data.error_message);

View File

@ -299,8 +299,8 @@ function add_photo_tag_form()
function add_photo_tag_callback(response)
{
add_remove_photo_tag_callback(response);
if (response.meta.status !== 200)
const abort = add_remove_photo_tag_callback(response);
if (abort)
{
return;
}
@ -335,8 +335,8 @@ function remove_photo_tag_form(photo_id, tagname)
function remove_photo_tag_callback(response)
{
add_remove_photo_tag_callback(response);
if (response.meta.status !== 200)
const abort = add_remove_photo_tag_callback(response);
if (abort)
{
return;
}
@ -353,12 +353,19 @@ function remove_photo_tag_callback(response)
function add_remove_photo_tag_callback(response)
{
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
let message_text;
let message_positivity;
let abort;
if ("error_type" in response.data)
{
message_positivity = "message_negative";
message_text = response.data.error_message;
abort = true;
}
else
{
@ -373,12 +380,10 @@ function add_remove_photo_tag_callback(response)
{
message_text = "Removed tag " + tagname;
}
else
{
return;
}
abort = false;
}
common.create_message_bubble(message_area, message_positivity, message_text, 8000);
return abort;
}
function delete_photo_form()
@ -400,20 +405,26 @@ function generate_thumbnail_for_video_form()
function generate_thumbnail_callback(response)
{
const generate_thumbnail_button = document.getElementById("generate_thumbnail_button");
window[generate_thumbnail_button.dataset.spinnerCloser]();
if (! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
if (response.meta.status == 200)
{
common.create_message_bubble(message_area, "message_positive", "Thumbnail captured", 8000);
}
else if (response.meta.json_ok)
else if ("error_type" in response.data)
{
common.create_message_bubble(message_area, "message_negative", response.data.error_message, 8000);
}
else
{
alert(JSON.stringify(response));
return;
}
const generate_thumbnail_button = document.getElementById("generate_thumbnail_button");
window[generate_thumbnail_button.dataset.spinnerCloser]();
}
function refresh_metadata_form()

View File

@ -329,6 +329,12 @@ function remove_synonym_form(event)
function tag_action_callback(response)
{
if (response.meta.status !== 200)
{
alert(JSON.stringify(response));
return;
}
let datas = response.data;
if (!Array.isArray(datas))
{
@ -387,10 +393,13 @@ function rename_ed_on_save(ed, edit_element_map, display_element_map)
{
function callback(response)
{
console.log(response);
ed.hide_spinner();
if (response.meta.status == 200)
if (response.meta.status !== 200)
{
alert(JSON.stringify(response));
return;
}
const new_name = response.data.name;
const new_description = response.data.description;
document.title = new_name + " | Tags";
@ -405,7 +414,6 @@ function rename_ed_on_save(ed, edit_element_map, display_element_map)
description_display.classList.add("hidden");
}
}
}
const name_display = display_element_map["name"];
const name_editor = edit_element_map["name"];