Files
Athena-Deck/soulx-singer-ui.js

11 lines
3.0 KiB
JavaScript

window.SoulXSingerUI=(()=>{
function render(){const view=document.querySelector('#view');if(view.querySelector('#soulx-singer-page'))return;
view.innerHTML='<div id="soulx-singer-page"><h1>SoulX-Singer</h1><p>Reinen Gesang anhand einer Referenzstimme umwandeln, ohne Stimmtraining; die native Laufzeit und GPU steuert Athena Deck.</p><section class="card"><h2>SoulX-Singer einrichten</h2><p id="ap-status"></p><button id="ap-install">Laufzeit und Basisgewichte installieren</button><button id="ap-cancel" class="secondary">Installation abbrechen</button><details><summary>Installationsausgabe</summary><pre id="ap-log" style="white-space:pre-wrap;max-height:300px;overflow:auto"></pre></details></section><section class="card"><h2>Ausführung</h2><label>GPU für SoulX-Singer<select id="ap-device"><option value="3060">RTX 3060</option><option value="5080">RTX 5080</option></select></label><button id="ap-save">GPU speichern</button><p id="ap-state"></p><a id="ap-link" class="link" target="_blank" rel="noopener">Unsere SoulX-Singer-Oberfläche öffnen →</a><p>Vor einem Auftrag SoulX-Singer in Stimmwerkzeuge → Profile aktivieren und Steuerung → Stimmwerkzeuge starten. Immer nur ein Stimmwerkzeug-Profil aktiv.</p><p>Gewichte und Zusatzkomponenten werden aus ihren fest hinterlegten Originalquellen wiederhergestellt. Eigene Referenzaufnahmen und Ergebnisse separat sichern.</p></section><p id="ap-error" role="alert"></p></div>';
const root=view.firstChild,el=id=>root.querySelector('#'+id);el('ap-link').href=DeckLinks.url(8138,'/');let dirty=false;el('ap-device').onchange=()=>dirty=true;
async function api(path,data){const r=await fetch('/api/v1/'+path,data?{method:'POST',headers:{'Content-Type':'application/json','X-Athena-Deck':'1'},body:JSON.stringify(data)}:{});const d=await r.json();if(!r.ok)throw Error(d.error||'Aktion fehlgeschlagen.');return d;}
async function poll(){if(!root.isConnected)return;try{const s=await api('soulx-singer-runtime'),a=await api('soulx-singer');if(!root.isConnected)return;el('ap-status').textContent=s.job?.phase||(s.installed?'SoulX-Singer installiert.':'Laufzeit fehlt.');el('ap-install').disabled=s.installed||s.job?.state==='running';el('ap-cancel').disabled=s.job?.state!=='running';el('ap-state').textContent=a.active?'SoulX-Singer-Auftrag läuft.':a.selected_profile?'Aktives Profil: '+a.selected_profile:'Noch kein SoulX-Singer-Profil aktiv.';if(!dirty)el('ap-device').value=a.device;if(s.job)el('ap-log').textContent=(await api('soulx-singer-runtime/log')).text;}catch(e){el('ap-error').textContent=e.message;}if(root.isConnected)setTimeout(poll,3000);}
for(const [id,path] of [['ap-install','soulx-singer-runtime/install'],['ap-cancel','soulx-singer-runtime/cancel']])el(id).onclick=async()=>{try{await api(path,{});}catch(e){el('ap-error').textContent=e.message;}};
el('ap-save').onclick=async()=>{try{await api('soulx-singer/configure',{device:el('ap-device').value});dirty=false;}catch(e){el('ap-error').textContent=e.message;}};poll();
}return {render};
})();