Add photo/refresh_metadata endpoint and button
This commit is contained in:
		
							parent
							
								
									75ee476abf
								
							
						
					
					
						commit
						d71d7b03c2
					
				
					 2 changed files with 28 additions and 3 deletions
				
			
		|  | @ -675,6 +675,14 @@ def post_photo_remove_tag(photoid): | ||||||
|     ''' |     ''' | ||||||
|     return post_photo_add_remove_tag_core(photoid, request.form['tagname'], 'remove') |     return post_photo_add_remove_tag_core(photoid, request.form['tagname'], 'remove') | ||||||
| 
 | 
 | ||||||
|  | @site.route('/photo/<photoid>/refresh_metadata', methods=['POST']) | ||||||
|  | def post_photo_refresh_metadata(photoid): | ||||||
|  |     ''' | ||||||
|  |     Refresh the file metadata. | ||||||
|  |     ''' | ||||||
|  |     photo = P_photo(photoid, response_type='json') | ||||||
|  |     photo.reload_metadata() | ||||||
|  |     return jsonify.make_json_response({}) | ||||||
| 
 | 
 | ||||||
| def post_tag_create_delete_core(tagname, function): | def post_tag_create_delete_core(tagname, function): | ||||||
|     try: |     try: | ||||||
|  |  | ||||||
|  | @ -107,6 +107,10 @@ | ||||||
|     max-height: 100%; |     max-height: 100%; | ||||||
|     width: 100%; |     width: 100%; | ||||||
| } | } | ||||||
|  | #refresh_metadata_button | ||||||
|  | { | ||||||
|  |     font-size: 11px; | ||||||
|  | } | ||||||
| </style> | </style> | ||||||
| </head> | </head> | ||||||
| 
 | 
 | ||||||
|  | @ -133,7 +137,10 @@ | ||||||
|         </ul> |         </ul> | ||||||
| 
 | 
 | ||||||
|         <!-- METADATA & DOWNLOAD --> |         <!-- METADATA & DOWNLOAD --> | ||||||
|         <h4>File info</h4> |         <h4> | ||||||
|  |             File info | ||||||
|  |             <button id="refresh_metadata_button" class="add_tag_button" onclick="refresh_metadata('{{photo.id}}');">refresh</button> | ||||||
|  |         </h4> | ||||||
|         <ul id="metadata"> |         <ul id="metadata"> | ||||||
|         {% if photo.author_id %} |         {% if photo.author_id %} | ||||||
|             {% set author = photo.author() %} |             {% set author = photo.author() %} | ||||||
|  | @ -203,7 +210,7 @@ function add_photo_tag(photoid, tagname, callback) | ||||||
| { | { | ||||||
|     if (tagname === ""){return} |     if (tagname === ""){return} | ||||||
|     var url = "/photo/" + photoid + "/add_tag"; |     var url = "/photo/" + photoid + "/add_tag"; | ||||||
|     data = new FormData(); |     var data = new FormData(); | ||||||
|     data.append("tagname", tagname); |     data.append("tagname", tagname); | ||||||
|     return post(url, data, callback); |     return post(url, data, callback); | ||||||
| } | } | ||||||
|  | @ -211,7 +218,7 @@ function remove_photo_tag(photoid, tagname, callback) | ||||||
| { | { | ||||||
|     if (tagname === ""){return} |     if (tagname === ""){return} | ||||||
|     var url = "/photo/" + photoid + "/remove_tag"; |     var url = "/photo/" + photoid + "/remove_tag"; | ||||||
|     data = new FormData(); |     var data = new FormData(); | ||||||
|     data.append("tagname", tagname); |     data.append("tagname", tagname); | ||||||
|     return post(url, data, callback); |     return post(url, data, callback); | ||||||
| } | } | ||||||
|  | @ -222,6 +229,8 @@ function submit_tag(callback) | ||||||
| } | } | ||||||
| function receive_callback(response) | function receive_callback(response) | ||||||
| { | { | ||||||
|  |     var message_text; | ||||||
|  |     var message_positivity; | ||||||
|     var tagname = response["tagname"]; |     var tagname = response["tagname"]; | ||||||
|     if ("error" in response) |     if ("error" in response) | ||||||
|     { |     { | ||||||
|  | @ -248,6 +257,14 @@ function receive_callback(response) | ||||||
|     create_message_bubble(message_area, message_positivity, message_text, 8000); |     create_message_bubble(message_area, message_positivity, message_text, 8000); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function refresh_metadata(photoid) | ||||||
|  | { | ||||||
|  |     var url= "/photo/" + photoid + "/refresh_metadata"; | ||||||
|  |     var data = new FormData(); | ||||||
|  |     post(url, data); | ||||||
|  |     setTimeout(function(){location.reload();}, 2000); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function enable_hoverzoom() | function enable_hoverzoom() | ||||||
| { | { | ||||||
|     console.log("enable"); |     console.log("enable"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue