feat(vm): SSH-nøkkel-knapp + modal i opax.html — GET /vm/ssh-key
This commit is contained in:
parent
afc878b37e
commit
0e066d8d13
|
|
@ -521,7 +521,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="vm-running">RUNNING</div>
|
<div class="vm-running">RUNNING</div>
|
||||||
<div class="vm-actions">
|
<div class="vm-actions">
|
||||||
<a class="vm-btn" href="https://ssh.cloud.google.com/v2/ssh/projects/propane-will-491900-m5/zones/us-central1-b/instances/osvauco-dev-vm" target="_blank">🔗 SSH</a>
|
<a class="vm-btn" href="https://ssh.cloud.google.com/v2/ssh/projects/propane-will-491900-m5/zones/us-central1-b/instances/osvauco-dev-vm" target="_blank">🔗 SSH</a><button class="vm-btn" onclick="showSshKey('osvauco-dev-vm')">🔑 SSH-nøkkel</button</a>
|
||||||
<a class="vm-btn" href="https://console.cloud.google.com/compute/instancesDetail/zones/us-central1-b/instances/osvauco-dev-vm?project=propane-will-491900-m5" target="_blank">⚙ GCP</a>
|
<a class="vm-btn" href="https://console.cloud.google.com/compute/instancesDetail/zones/us-central1-b/instances/osvauco-dev-vm?project=propane-will-491900-m5" target="_blank">⚙ GCP</a>
|
||||||
<button class="vm-btn stop" onclick="confirmVmStop()">⏹ Stop</button>
|
<button class="vm-btn stop" onclick="confirmVmStop()">⏹ Stop</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1050,7 +1050,7 @@ async function termKey(e){
|
||||||
default: try{ const r=await fetch('/terminal/exec',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({command:cmd})}) const d=await r.json() if(d.stdout) tprint(d.stdout,'ok') if(d.stderr) tprint(d.stderr,'err') if(d.returncode!==0&&!d.stdout&&!d.stderr) tprint('Exit '+d.returncode,'err') }catch(err){ tprint('Feil: '+err.message,'err') }
|
default: try{ const r=await fetch('/terminal/exec',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({command:cmd})}) const d=await r.json() if(d.stdout) tprint(d.stdout,'ok') if(d.stderr) tprint(d.stderr,'err') if(d.returncode!==0&&!d.stdout&&!d.stderr) tprint('Exit '+d.returncode,'err') }catch(err){ tprint('Feil: '+err.message,'err') }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function confirmVmStop(){
|
async function showSshKey(vm){ const r=await fetch('/vm/ssh-key?vm='+vm) const d=await r.json() const key=d.ssh_public_key||d.error||'Ingen nøkkel funnet' let m=document.getElementById('ssh-key-modal') if(!m){ m=document.createElement('div') m.id='ssh-key-modal' m.style.cssText='position:fixed;inset:0;background:rgba(0,0,0,.7);z-index:9999;display:flex;align-items:center;justify-content:center' m.innerHTML='<div style="background:var(--bg-2);border:1px solid var(--border);border-radius:12px;padding:24px;max-width:600px;width:90%;position:relative"><h3 style="margin:0 0 12px">🔑 SSH Public Key — '+vm+'</h3><textarea readonly style="width:100%;height:120px;background:var(--bg-3);border:1px solid var(--border);border-radius:6px;padding:8px;color:var(--text);font-family:var(--mono);font-size:11px;resize:none" id="ssh-key-txt"></textarea><div style="display:flex;gap:8px;margin-top:12px"><button onclick="navigator.clipboard.writeText(document.getElementById(\'ssh-key-txt\').value);this.textContent=\'✅ Kopiert!\'" style="background:var(--accent);color:#000;border:none;border-radius:6px;padding:8px 16px;cursor:pointer;font-weight:600">📋 Kopier</button><button onclick="document.getElementById(\'ssh-key-modal\').remove()" style="background:var(--bg-3);border:1px solid var(--border);border-radius:6px;padding:8px 16px;cursor:pointer">Lukk</button></div></div>' document.body.appendChild(m) } document.getElementById('ssh-key-txt').value=key m.style.display='flex' } function confirmVmStop(){
|
||||||
if(!confirm('⚠️ Stop osvauco-dev-vm? Du mister SSH-tilgang til den startes igjen.')) return
|
if(!confirm('⚠️ Stop osvauco-dev-vm? Du mister SSH-tilgang til den startes igjen.')) return
|
||||||
tprint('→ Stopper VM via: bash scripts/stop-osvauco-dev-vm.sh','info')
|
tprint('→ Stopper VM via: bash scripts/stop-osvauco-dev-vm.sh','info')
|
||||||
go('terminal')
|
go('terminal')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user