feat: Host CRUD complete — edit, full form fields, connect, toast
- Add UpdateHost handler + PUT /hosts/:id route
- CreateHost now accepts all fields (port, username, auth, notes)
- host_modal.html: full form with port, username, auth type toggle, edit mode
- host_list.html: edit button dispatches edit-host event with host data
- Connect button links to /terminal?host={id} for pre-selection
- Terminal page reads selected host from query param
- Toast notification system via Alpine.js events
- Add default template function for fallback values
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
document.addEventListener('alpine:init', () => {
|
||||
const el = document.getElementById('hosts-data');
|
||||
const hostOptions = el ? JSON.parse(el.textContent) : [];
|
||||
const selEl = document.getElementById('selected-host');
|
||||
const selectedHostId = selEl ? JSON.parse(selEl.textContent) : '';
|
||||
|
||||
function processCommand(cmd, tabName) {
|
||||
const lines = [];
|
||||
@@ -86,9 +88,15 @@ document.addEventListener('alpine:init', () => {
|
||||
},
|
||||
|
||||
addTab() {
|
||||
const host = hostOptions.length > 0
|
||||
? hostOptions[Math.floor(Math.random() * hostOptions.length)]
|
||||
: { id: 'h1', name: 'localhost', ip: '127.0.0.1' };
|
||||
let host;
|
||||
if (selectedHostId) {
|
||||
host = hostOptions.find(h => h.id === selectedHostId) || hostOptions[0];
|
||||
}
|
||||
if (!host) {
|
||||
host = hostOptions.length > 0
|
||||
? hostOptions[Math.floor(Math.random() * hostOptions.length)]
|
||||
: { id: 'h1', name: 'localhost', ip: '127.0.0.1' };
|
||||
}
|
||||
const id = 'tab-' + Date.now() + '-' + Math.random().toString(36).slice(2, 6);
|
||||
this.tabs.push({ id, name: host.name, host: host.ip, connected: true });
|
||||
this.activeTab = this.tabs.length - 1;
|
||||
|
||||
Reference in New Issue
Block a user