diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/node-page.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/node-page.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/node-page.js b/packages/meshbay-hub/src/meshbay_hub/static/node-page.js index 9d230c1..04f4abc 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/node-page.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/node-page.js @@ -6,7 +6,7 @@ import { t } from './i18n.js'; import { ask } from './ask.js'; import * as platform from './platform.js'; import { Icon } from './icon.js'; -import { HUB } from './hub-client.js'; +import { HUB, session } from './hub-client.js'; // ── Node management (D5) ──────────────────────────────────────────────────── // @@ -108,6 +108,9 @@ function NodeServicePanel({ onChanged, token, username }) { const KNOWN_STATES = ['active', 'inactive', 'failed', 'activating', 'deactivating']; const stateKey = KNOWN_STATES.includes(info.activeState) ? info.activeState : 'unknown'; const running = info.activeState === 'active' || info.activeState === 'activating'; + // A node process that does not answer ('unknown': on its way up or down, or + // stuck) is still one to stop -- only "nothing there" takes Stop away. + const stoppable = info.activeState !== 'inactive'; const dot = info.activeState === 'active' ? 'online' : info.activeState === 'failed' ? 'offline' : 'unknown'; const label = info.installed ? t('node.service_state_' + stateKey) @@ -132,7 +135,7 @@ function NodeServicePanel({ onChanged, token, username }) { onClick=${() => act('start', () => platform.node.start({ hubUrl: HUB, username, token }))}> ${busy === 'start' ? t('node.service_starting') : t('node.service_start')}</button> ${info.installed && html` - <button class="btn btn-small btn-secondary" disabled=${!!busy || !running} + <button class="btn btn-small btn-secondary" disabled=${!!busy || !stoppable} onClick=${() => act('stop', () => platform.node.service.stop())}> ${busy === 'stop' ? t('node.service_stopping') : t('node.service_stop')}</button> <button class="btn btn-small btn-secondary" disabled=${!!busy} @@ -520,13 +523,17 @@ export function NodePage({ groups, token, username }) { setPairBusy(true); setPairStatus(''); try { + // An operator code is redeemed over MNP, with the account's identity in + // a group -- this page has no transport. It used to store the code where + // nothing read it and say "Paired successfully", and the banner came back + // on the next refresh. Queued the way the Create Group wizard queues it: + // the next group of this node to open redeems it. const result = await nodeOp('pairOperator'); if (result && result.code) { await platform.node.setPairingCode(result.code); + session.pendingJoinCode = result.code; } - setPairStatus('paired'); - setOperatorPaired(true); - await refresh(); + setPairStatus('pending'); } catch (err) { setPairStatus(platform.bridgeMessage(err)); } finally { @@ -712,15 +719,15 @@ export function NodePage({ groups, token, username }) { </div> <${NodeServicePanel} onChanged=${fetchStatus} token=${token} username=${username} /> ${actionMsg && html`<div class="node-message">${actionMsg}</div>`} - ${operatorPaired === false && html` + ${operatorPaired === false && nodeGroups.length > 0 && html` <div class="node-pair-banner"> <p>${t('node.pair_needed')}</p> <button class="btn btn-primary btn-small" disabled=${pairBusy} onClick=${doPairOperator}> ${pairBusy ? t('node.settings_saving') : t('node.pair_button')}</button> - ${pairStatus === 'paired' - ? html`<p class="success-msg">${t('node.pair_success')}</p>` + ${pairStatus === 'pending' + ? html`<p class="success-msg">${t('node.pair_pending')}</p>` : pairStatus ? html`<p class="error-msg">${pairStatus}</p>` : null} </div> `} |