Let endpoint return new values of queuefile_ext, download_dir.

This commit is contained in:
voussoir 2021-09-15 18:55:14 -07:00
parent bf1bbe8748
commit ec402dcd0b
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 34 additions and 7 deletions

View file

@ -187,7 +187,9 @@ def post_set_download_directory(channel_id):
}
return flasktools.make_json_response(exc, status=400)
return flasktools.make_json_response({})
abspath = channel.download_directory.absolute_path if channel.download_directory else None
response = {'download_directory': abspath}
return flasktools.make_json_response(response)
@site.route('/channel/<channel_id>/set_queuefile_extension', methods=['POST'])
def post_set_queuefile_extension(channel_id):
@ -196,4 +198,5 @@ def post_set_queuefile_extension(channel_id):
channel.set_queuefile_extension(extension)
return flasktools.make_json_response({})
response = {'queuefile_extension': channel.queuefile_extension}
return flasktools.make_json_response(response)

View file

@ -630,11 +630,12 @@ function set_autorefresh_form(event)
function set_autorefresh_callback(response)
{
set_autorefresh_spinner.hide();
if (response.meta.status != 200)
{
alert(JSON.stringify(response));
return;
}
set_autorefresh_spinner.hide();
}
function set_download_directory_form(event)
@ -645,11 +646,22 @@ function set_download_directory_form(event)
function set_download_directory_callback(response)
{
if (response.meta.status != 200)
window[set_download_directory_button.dataset.spinnerCloser]();
if (response.meta.status != 200 || ! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
const download_directory = response.data.download_directory;
if (download_directory === null)
{
set_download_directory_input.value = "";
}
else
{
set_download_directory_input.value = download_directory;
}
window[set_download_directory_button.dataset.spinnerCloser]();
}
function set_queuefile_extension_form(event)
@ -660,11 +672,23 @@ function set_queuefile_extension_form(event)
function set_queuefile_extension_callback(response)
{
if (response.meta.status != 200)
window[set_queuefile_extension_button.dataset.spinnerCloser]();
if (response.meta.status != 200 || ! response.meta.json_ok)
{
alert(JSON.stringify(response));
return;
}
window[set_queuefile_extension_button.dataset.spinnerCloser]();
const extension = response.data.queuefile_extension;
if (extension === null)
{
set_queuefile_extension_input.value = "";
}
else
{
set_queuefile_extension_input.value = extension;
}
}
if (CHANNEL_ID)