Fix Copy on plain-http hubs, toasts under modal backdrops, shorter install dialog
- copyText (house ui.js): over plain http (a LAN IP or .local name) there is no navigator.clipboard, and the fallback copied an empty string. el() set the textarea's value as an attribute, which textareas ignore. The textarea also sat outside the open modal, where it can't be selected. The fallback now sets .value, works inside the dialog, and reports a failure instead of always toasting success. - toast (house ui.js): goes inside an open modal dialog, above its backdrop, which dimmed it to gray on gray in both themes. - Install dialog: one sentence that holds on any machine, plus the hub address and a link to the install notes; the command is select-all on click. The same ui.js fix is in the web-frontend skill's house assets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
35459b6309
commit
30ce39d5f0
3 changed files with 30 additions and 11 deletions
|
|
@ -19,10 +19,12 @@ function installCommand(info, token) {
|
|||
return `curl -fsSL ${url} | HUB_URL=${hub} PROBE_TOKEN=${token} bash`;
|
||||
}
|
||||
|
||||
const README = 'https://git.neilbantoc.dev/services/network-monitor#2-probes';
|
||||
|
||||
function commandBlock(cmd) {
|
||||
const loopback = /^(localhost|127\.|\[::1\])/.test(location.hostname) && cmd.includes(location.origin);
|
||||
return el('div', { style: 'display:grid;gap:6px' },
|
||||
el('div.cmd', {}, el('pre', {}, cmd), el('button.btn', { type: 'button', onclick: () => copyText(cmd, 'Install command copied') }, 'Copy')),
|
||||
el('div.cmd', {}, el('pre.select-all', {}, cmd), el('button.btn', { type: 'button', onclick: () => copyText(cmd, 'Install command copied') }, 'Copy')),
|
||||
loopback ? el('div.callout.error', {}, `You opened this page at ${location.host}, which other machines can't reach. Replace HUB_URL with the hub's LAN address, or set HUB_PUBLIC_URL in the hub's .env.`) : null);
|
||||
}
|
||||
|
||||
|
|
@ -90,9 +92,10 @@ function list(root, ctx) {
|
|||
function showInstall(p) {
|
||||
const cmd = installCommand(info, p.token);
|
||||
const dlg = modal(`Install “${p.name}”`, el('div', { style: 'display:grid;gap:12px' },
|
||||
el('p', { style: 'margin:0' }, 'Run this on the machine that will be the probe. It starts on boot and keeps running. On a Proxmox node it creates a small LXC container for the probe. On macOS and inside LXC containers it installs as a system service. On other Linux hosts it uses Docker. On Linux it needs root: if you aren’t root, put sudo env before HUB_URL. If the git repo is private, the installer asks for a read-only token.'),
|
||||
el('p', { style: 'margin:0' }, 'Run this on the machine that will be the probe. It installs a service that starts on boot.'),
|
||||
commandBlock(cmd),
|
||||
el('p.small.muted', { style: 'margin:0' }, `The probe reports to ${info.hub_url || location.origin}. If that address isn't reachable from the probe, change HUB_URL in the command. The command is also on the probe's page.`),
|
||||
el('p.small.muted', { style: 'margin:0' }, `Reports to ${(cmd.match(/HUB_URL=(\S+)/) || [])[1]}. The command is also on the probe’s page. `,
|
||||
el('a', { href: README, target: '_blank', rel: 'noopener' }, 'Install notes')),
|
||||
), { wide: true, footer: [el('a.btn', { href: `/probes/${p.id}`, onclick: () => dlg.close() }, 'Open probe'), el('button.btn.primary', { type: 'button', onclick: () => dlg.close() }, 'Done')] });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue