Improved feedback for frontend editing

This commit is contained in:
krateng 2023-08-13 03:21:13 +02:00
parent aaa2015601
commit a7e4a869cc
3 changed files with 22 additions and 9 deletions

View File

@ -744,7 +744,8 @@ def merge_tracks(target_id,source_ids):
"""Internal Use Only"""
result = database.merge_tracks(target_id,source_ids)
return {
"status":"success"
"status":"success",
"desc":f"{', '.join(src['title'] for src in result['sources'])} were merged into {result['target']['title']}"
}
@api.post("merge_artists")
@ -754,7 +755,8 @@ def merge_artists(target_id,source_ids):
"""Internal Use Only"""
result = database.merge_artists(target_id,source_ids)
return {
"status":"success"
"status":"success",
"desc":f"{', '.join(src for src in result['sources'])} were merged into {result['target']}"
}
@api.post("merge_albums")
@ -764,7 +766,8 @@ def merge_artists(target_id,source_ids):
"""Internal Use Only"""
result = database.merge_albums(target_id,source_ids)
return {
"status":"success"
"status":"success",
"desc":f"{', '.join(src['albumtitle'] for src in result['sources'])} were merged into {result['target']['albumtitle']}"
}
@api.post("associate_albums_to_artist")

View File

@ -235,7 +235,8 @@ def merge_artists(target_id,source_ids):
sources = [sqldb.get_artist(id) for id in source_ids]
target = sqldb.get_artist(target_id)
log(f"Merging {sources} into {target}")
result = sqldb.merge_artists(target_id,source_ids)
sqldb.merge_artists(target_id,source_ids)
result = {'sources':sources,'target':target}
dbcache.invalidate_entity_cache()
dbcache.invalidate_caches()
@ -246,7 +247,8 @@ def merge_tracks(target_id,source_ids):
sources = [sqldb.get_track(id) for id in source_ids]
target = sqldb.get_track(target_id)
log(f"Merging {sources} into {target}")
result = sqldb.merge_tracks(target_id,source_ids)
sqldb.merge_tracks(target_id,source_ids)
result = {'sources':sources,'target':target}
dbcache.invalidate_entity_cache()
dbcache.invalidate_caches()
@ -257,7 +259,8 @@ def merge_albums(target_id,source_ids):
sources = [sqldb.get_album(id) for id in source_ids]
target = sqldb.get_album(target_id)
log(f"Merging {sources} into {target}")
result = sqldb.merge_albums(target_id,source_ids)
sqldb.merge_albums(target_id,source_ids)
result = {'sources':sources,'target':target}
dbcache.invalidate_entity_cache()
dbcache.invalidate_caches()

View File

@ -331,7 +331,8 @@ function merge() {
callback_func = function(req){
if (req.status == 200) {
window.location.reload();
notifyCallback(req);
setTimeout(window.location.reload.bind(window.location),1000);
}
else {
notifyCallback(req);
@ -357,18 +358,24 @@ function merge() {
function associate() {
const lcst = window.sessionStorage;
var target_entity_types = {artist:['album','track'], album:['track']};
var requests_todo = 0;
for (var target_entity_type of target_entity_types[entity_type]) {
var key = "marked_for_associate_" + target_entity_type;
console.log('get',key);
var current_stored = (lcst.getItem(key) || '').split(",");
current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x));
if (current_stored.length != 0) {
requests_todo += 1;
callback_func = function(req){
if (req.status == 200) {
//window.location.reload();
showValidMergeIcons();
notifyCallback(req);
requests_todo -= 1;
if (requests_todo == 0) {
setTimeout(window.location.reload.bind(window.location),1000);
}
}
else {
notifyCallback(req);