Fix library refresh behavior
This commit is contained in:
parent
3dad82d992
commit
de895dd7f8
1 changed files with 18 additions and 1 deletions
|
|
@ -120,6 +120,23 @@ function normalizeJob(j) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function refreshAssets() {
|
||||||
|
const raw = await apiFetch('/assets?limit=500');
|
||||||
|
const list = Array.isArray(raw) ? raw : (raw.assets || []);
|
||||||
|
const projectMap = {};
|
||||||
|
(window.ZAMPP_DATA.PROJECTS || []).forEach(function(p) { projectMap[p.id] = p.name; });
|
||||||
|
const normalized = list.map(function(a) { return normalizeAsset(a, projectMap); });
|
||||||
|
window.ZAMPP_DATA.ASSETS = normalized;
|
||||||
|
if (window.ZAMPP_DATA.PROJECTS && window.ZAMPP_DATA.PROJECTS.length) {
|
||||||
|
const counts = {};
|
||||||
|
list.forEach(function(a) { if (a.project_id) counts[a.project_id] = (counts[a.project_id] || 0) + 1; });
|
||||||
|
window.ZAMPP_DATA.PROJECTS = window.ZAMPP_DATA.PROJECTS.map(function(p) {
|
||||||
|
return { ...p, assets: counts[p.id] || 0 };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
const [projectsR, assetsR, recordersR, jobsR, clusterR, usersR, binsR, meR] = await Promise.allSettled([
|
const [projectsR, assetsR, recordersR, jobsR, clusterR, usersR, binsR, meR] = await Promise.allSettled([
|
||||||
apiFetch('/projects'),
|
apiFetch('/projects'),
|
||||||
|
|
@ -251,7 +268,7 @@ async function exportSequenceEDL(sequenceId, filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.ZAMPP_API = {
|
window.ZAMPP_API = {
|
||||||
fetch: apiFetch, loadData, fmtDuration, fmtSize, fmtRelative,
|
fetch: apiFetch, loadData, refreshAssets, fmtDuration, fmtSize, fmtRelative,
|
||||||
getSequences, createSequence, getSequence, updateSequence,
|
getSequences, createSequence, getSequence, updateSequence,
|
||||||
deleteSequence, syncSequenceClips, exportSequenceEDL,
|
deleteSequence, syncSequenceClips, exportSequenceEDL,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue