fix: modal scroll, SSH key textarea, nav full-page, remove OS/Provider

- Fix modal scroll: restructure overlay with scroll/centering wrapper
- Add SSH key textarea + file upload to host modal (authType='key')
- Fix textarea reset on new host (clear via DOM)
- SSH username placeholder instead of default 'root'
- Nav uses plain <a href> instead of HTMX for full-page navigation
- /hosts route returns full page; /hosts/list for HTMX partials
- Remove OS and Provider from host modal, grid card, and list card
- Fix key modal x-data scope for Alpine $dispatch
- Update key_grid to display multi-line key content properly
- Simplify SSH key placeholder format
This commit is contained in:
swanadiva
2026-07-09 18:21:45 +07:00
parent 5445d15aca
commit 56eaf57649
7 changed files with 100 additions and 83 deletions
+36 -41
View File
@@ -4,8 +4,9 @@
@edit-host.window="populate($event.detail); open = true"
@keydown.escape.window="open = false">
<div class="absolute inset-0 bg-black/40 backdrop-blur-sm" @click="open = false"></div>
<div class="absolute inset-0 flex items-center justify-center p-4" x-show="open" x-transition>
<div class="bg-white rounded-2xl max-w-lg w-full border border-outline-variant/30 shadow-2xl max-h-[90vh] overflow-y-auto">
<div class="absolute inset-0 overflow-y-auto p-4" x-show="open" x-transition>
<div class="flex min-h-full items-center justify-center">
<div class="bg-white rounded-2xl max-w-lg w-full border border-outline-variant/30 shadow-2xl max-h-[90vh] overflow-y-auto">
<div class="flex justify-between items-center border-b border-outline-variant/30 p-6 pb-4">
<h3 class="font-bold text-lg text-on-surface" x-text="editing ? 'Edit Host' : 'Add Host'"></h3>
@@ -53,37 +54,6 @@
class="w-full bg-surface-container-low border border-outline-variant/40 rounded-lg py-2.5 px-4 focus:ring-2 focus:ring-primary/20 focus:border-primary focus:outline-none transition-all font-medium text-on-surface">
</div>
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-1.5">
<label class="text-xs font-bold text-on-surface-variant uppercase">Operating System</label>
<select name="os" x-model="form.os"
class="bg-surface-container-low border border-outline-variant/40 rounded-lg py-2 px-3 focus:outline-none focus:border-primary text-sm text-on-surface">
<option value="Ubuntu 22.04">Ubuntu 22.04</option>
<option value="Ubuntu 24.04">Ubuntu 24.04</option>
<option value="Debian 12">Debian 12</option>
<option value="Alpine 3.19">Alpine 3.19</option>
<option value="Fedora 39">Fedora 39</option>
<option value="Rocky 9">Rocky 9</option>
<option value="CentOS 8">CentOS 8</option>
<option value="Other">Other</option>
</select>
</div>
<div class="flex flex-col gap-1.5">
<label class="text-xs font-bold text-on-surface-variant uppercase">Provider</label>
<select name="provider" x-model="form.provider"
class="bg-surface-container-low border border-outline-variant/40 rounded-lg py-2 px-3 focus:outline-none focus:border-primary text-sm text-on-surface">
<option value="AWS US-East">AWS Cloud</option>
<option value="AWS EU-West">AWS EU-West</option>
<option value="DigitalOcean">DigitalOcean</option>
<option value="Hetzner">Hetzner</option>
<option value="GCP US-Central">GCP Cloud</option>
<option value="Vultr">Vultr</option>
<option value="Linode">Linode</option>
<option value="Local">Local</option>
</select>
</div>
</div>
<div class="flex flex-col gap-1.5">
<label class="text-xs font-bold text-on-surface-variant uppercase">Host Purpose / Type</label>
<div class="grid grid-cols-3 gap-2">
@@ -119,6 +89,20 @@
<input type="hidden" name="authType" :value="form.authType">
</div>
<div x-show="form.authType === 'key'" x-cloak class="flex flex-col gap-1.5">
<label class="text-xs font-bold text-on-surface-variant uppercase">SSH Private Key</label>
<textarea name="password" rows="5" placeholder="Paste your SSH private key here...&#10;&#10;-----BEGIN OPENSSH PRIVATE KEY-----&#10;...&#10;-----END OPENSSH PRIVATE KEY-----"
class="w-full bg-surface-container-low border border-outline-variant/40 rounded-lg py-2.5 px-4 focus:ring-2 focus:ring-primary/20 focus:border-primary focus:outline-none transition-all font-mono text-on-surface text-xs resize-none leading-relaxed"></textarea>
<div class="flex items-center gap-3 mt-1">
<label class="flex items-center gap-1.5 text-xs text-on-surface-variant cursor-pointer hover:text-primary transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/></svg>
Or upload a key file
</label>
<input type="file" class="hidden" accept=".pem,.key,.pub,.txt,.ppk" @change="readKeyFile($event)">
<span class="text-[10px] text-outline">.pem .key .ppk</span>
</div>
</div>
<div x-show="form.authType === 'password'" x-cloak class="flex flex-col gap-1.5">
<label class="text-xs font-bold text-on-surface-variant uppercase">Password</label>
<input type="password" name="password" x-model="form.password" placeholder="SSH password"
@@ -140,6 +124,7 @@
</div>
</form>
</div>
</div>
</div>
</div>
@@ -150,18 +135,18 @@ function hostForm() {
editing: false,
hostId: '',
form: {
name: '', ip: '', hostname: '', port: '22', username: 'root',
os: 'Ubuntu 22.04', provider: 'AWS US-East', type: 'api',
authType: 'key', password: '', notes: ''
name: '', ip: '', hostname: '', port: '22', username: '',
type: 'api', authType: 'key', password: '', notes: ''
},
reset() {
this.editing = false;
this.hostId = '';
this.form = {
name: '', ip: '', hostname: '', port: '22', username: 'root',
os: 'Ubuntu 22.04', provider: 'AWS US-East', type: 'api',
authType: 'key', password: '', notes: ''
name: '', ip: '', hostname: '', port: '22', username: '',
type: 'api', authType: 'key', password: '', notes: ''
};
var ta = document.querySelector('#host-modal textarea[name=password]');
if (ta) ta.value = '';
},
populate(host) {
this.editing = true;
@@ -172,13 +157,23 @@ function hostForm() {
hostname: host.Hostname || '',
port: String(host.Port || 22),
username: host.Username || 'root',
os: host.OS || 'Ubuntu 22.04',
provider: host.Provider || 'AWS US-East',
type: host.Type || 'api',
authType: host.AuthType || 'key',
password: host.Password || '',
notes: host.Notes || ''
};
var ta = document.querySelector('#host-modal textarea[name=password]');
if (ta) ta.value = host.Password || '';
},
readKeyFile($event) {
var file = $event.target.files[0];
if (!file) return;
var reader = new FileReader();
var ta = document.querySelector('#host-modal textarea[name=password]');
reader.onload = function(e) {
if (ta) ta.value = e.target.result;
};
reader.readAsText(file);
}
};
}