mirror of
https://github.com/krateng/maloja.git
synced 2025-06-08 11:22:08 +03:00
Improved feedback for frontend editing
This commit is contained in:
parent
aaa2015601
commit
a7e4a869cc
@ -744,7 +744,8 @@ def merge_tracks(target_id,source_ids):
|
|||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
result = database.merge_tracks(target_id,source_ids)
|
result = database.merge_tracks(target_id,source_ids)
|
||||||
return {
|
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")
|
@api.post("merge_artists")
|
||||||
@ -754,7 +755,8 @@ def merge_artists(target_id,source_ids):
|
|||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
result = database.merge_artists(target_id,source_ids)
|
result = database.merge_artists(target_id,source_ids)
|
||||||
return {
|
return {
|
||||||
"status":"success"
|
"status":"success",
|
||||||
|
"desc":f"{', '.join(src for src in result['sources'])} were merged into {result['target']}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.post("merge_albums")
|
@api.post("merge_albums")
|
||||||
@ -764,7 +766,8 @@ def merge_artists(target_id,source_ids):
|
|||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
result = database.merge_albums(target_id,source_ids)
|
result = database.merge_albums(target_id,source_ids)
|
||||||
return {
|
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")
|
@api.post("associate_albums_to_artist")
|
||||||
|
@ -235,7 +235,8 @@ def merge_artists(target_id,source_ids):
|
|||||||
sources = [sqldb.get_artist(id) for id in source_ids]
|
sources = [sqldb.get_artist(id) for id in source_ids]
|
||||||
target = sqldb.get_artist(target_id)
|
target = sqldb.get_artist(target_id)
|
||||||
log(f"Merging {sources} into {target}")
|
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_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
@ -246,7 +247,8 @@ def merge_tracks(target_id,source_ids):
|
|||||||
sources = [sqldb.get_track(id) for id in source_ids]
|
sources = [sqldb.get_track(id) for id in source_ids]
|
||||||
target = sqldb.get_track(target_id)
|
target = sqldb.get_track(target_id)
|
||||||
log(f"Merging {sources} into {target}")
|
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_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
@ -257,7 +259,8 @@ def merge_albums(target_id,source_ids):
|
|||||||
sources = [sqldb.get_album(id) for id in source_ids]
|
sources = [sqldb.get_album(id) for id in source_ids]
|
||||||
target = sqldb.get_album(target_id)
|
target = sqldb.get_album(target_id)
|
||||||
log(f"Merging {sources} into {target}")
|
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_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
|
@ -331,7 +331,8 @@ function merge() {
|
|||||||
|
|
||||||
callback_func = function(req){
|
callback_func = function(req){
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
window.location.reload();
|
notifyCallback(req);
|
||||||
|
setTimeout(window.location.reload.bind(window.location),1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
notifyCallback(req);
|
notifyCallback(req);
|
||||||
@ -357,18 +358,24 @@ function merge() {
|
|||||||
function associate() {
|
function associate() {
|
||||||
const lcst = window.sessionStorage;
|
const lcst = window.sessionStorage;
|
||||||
var target_entity_types = {artist:['album','track'], album:['track']};
|
var target_entity_types = {artist:['album','track'], album:['track']};
|
||||||
|
var requests_todo = 0;
|
||||||
for (var target_entity_type of target_entity_types[entity_type]) {
|
for (var target_entity_type of target_entity_types[entity_type]) {
|
||||||
var key = "marked_for_associate_" + target_entity_type;
|
var key = "marked_for_associate_" + target_entity_type;
|
||||||
console.log('get',key);
|
|
||||||
var current_stored = (lcst.getItem(key) || '').split(",");
|
var current_stored = (lcst.getItem(key) || '').split(",");
|
||||||
current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x));
|
current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x));
|
||||||
|
|
||||||
if (current_stored.length != 0) {
|
if (current_stored.length != 0) {
|
||||||
|
requests_todo += 1;
|
||||||
callback_func = function(req){
|
callback_func = function(req){
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
//window.location.reload();
|
|
||||||
showValidMergeIcons();
|
showValidMergeIcons();
|
||||||
notifyCallback(req);
|
notifyCallback(req);
|
||||||
|
requests_todo -= 1;
|
||||||
|
if (requests_todo == 0) {
|
||||||
|
setTimeout(window.location.reload.bind(window.location),1000);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
notifyCallback(req);
|
notifyCallback(req);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user