Add endpoints set_searchhidden, unset_searchhidden and checkbox.

master
voussoir 2020-09-09 20:51:15 -07:00
parent 4569e7848c
commit 8d2af3255b
3 changed files with 47 additions and 0 deletions

View File

@ -193,6 +193,20 @@ def post_batch_photos_refresh_metadata():
response = post_photo_refresh_metadata_core(photo_ids=request.form['photo_ids']) response = post_photo_refresh_metadata_core(photo_ids=request.form['photo_ids'])
return response return response
@decorators.catch_etiquette_exception
@site.route('/photo/<photo_id>/set_searchhidden', methods=['POST'])
def post_photo_set_searchhidden(photo_id):
photo = common.P_photo(photo_id, response_type='json')
photo.set_searchhidden(True)
return jsonify.make_json_response({})
@decorators.catch_etiquette_exception
@site.route('/photo/<photo_id>/unset_searchhidden', methods=['POST'])
def post_photo_unset_searchhidden(photo_id):
photo = common.P_photo(photo_id, response_type='json')
photo.set_searchhidden(False)
return jsonify.make_json_response({})
@decorators.catch_etiquette_exception @decorators.catch_etiquette_exception
def post_batch_photos_searchhidden_core(photo_ids, searchhidden): def post_batch_photos_searchhidden_core(photo_ids, searchhidden):
if isinstance(photo_ids, str): if isinstance(photo_ids, str):

View File

@ -272,6 +272,20 @@ function remove_tag(photo_id, tagname, callback)
common.post(url, data, callback); common.post(url, data, callback);
} }
api.photos.set_searchhidden =
function set_searchhidden(photo_id, callback)
{
const url = `/photo/${photo_id}/set_searchhidden`;
common.post(url, null, callback);
}
api.photos.unset_searchhidden =
function unset_searchhidden(photo_id, callback)
{
const url = `/photo/${photo_id}/unset_searchhidden`;
common.post(url, null, callback);
}
api.photos.callback_go_to_search = api.photos.callback_go_to_search =
function callback_go_to_albums(response) function callback_go_to_albums(response)
{ {

View File

@ -195,6 +195,12 @@
<li><a href="{{photo|file_link}}?download=true&original_filename=true">Download as original filename</a></li> <li><a href="{{photo|file_link}}?download=true&original_filename=true">Download as original filename</a></li>
<li><a href="{{photo|file_link}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li> <li><a href="{{photo|file_link}}?download=true">Download as {{photo.id}}.{{photo.extension}}</a></li>
<li><button id="refresh_metadata_button" class="green_button button_with_spinner" onclick="return refresh_metadata_form();">refresh</button></li> <li><button id="refresh_metadata_button" class="green_button button_with_spinner" onclick="return refresh_metadata_form();">refresh</button></li>
<li>
<label>
<input type="checkbox" {%if photo.searchhidden%}checked{%endif%} onchange="return set_searchhidden_form(event);"
/>Hidden from search
</label>
</li>
<li> <li>
<label> <label>
<input type="checkbox" class="photo_card_selector_checkbox" data-photo-id="{{photo.id}}" onchange="return photo_clipboard.on_photo_select(event);" <input type="checkbox" class="photo_card_selector_checkbox" data-photo-id="{{photo.id}}" onchange="return photo_clipboard.on_photo_select(event);"
@ -356,6 +362,19 @@ function refresh_metadata_form()
api.photos.refresh_metadata(PHOTO_ID, common.refresh); api.photos.refresh_metadata(PHOTO_ID, common.refresh);
} }
function set_searchhidden_form(event)
{
let checkbox = event.target;
if (checkbox.checked)
{
api.photos.set_searchhidden(PHOTO_ID);
}
else
{
api.photos.unset_searchhidden(PHOTO_ID);
}
}
var ZOOM_BG_URL = "url('{{photo|file_link}}')"; var ZOOM_BG_URL = "url('{{photo|file_link}}')";
function enable_hoverzoom(event) function enable_hoverzoom(event)
{ {