wiz status page
This commit is contained in:
parent
0afe29b99b
commit
6da5577b27
3 changed files with 71 additions and 31 deletions
|
|
@ -148,23 +148,28 @@ export class Wizard {
|
||||||
relay_url_CustomCheck: relay => relay !== '',
|
relay_url_CustomCheck: relay => relay !== '',
|
||||||
})
|
})
|
||||||
if (err != null) { throw new Error(err.message) }
|
if (err != null) { throw new Error(err.message) }
|
||||||
if (this.IsInitialized() || this.pendingConfig !== null) {
|
|
||||||
throw new Error("already initialized")
|
|
||||||
}
|
|
||||||
const pendingConfig = { sourceName: req.source_name, relayUrl: req.relay_url, automateLiquidity: req.automate_liquidity, pushBackupsToNostr: req.push_backups_to_nostr }
|
const pendingConfig = { sourceName: req.source_name, relayUrl: req.relay_url, automateLiquidity: req.automate_liquidity, pushBackupsToNostr: req.push_backups_to_nostr }
|
||||||
|
|
||||||
// Also update the application name in the database
|
// If already initialized, treat as idempotent update: persist name/avatar and env settings, do not block.
|
||||||
try {
|
if (this.IsInitialized()) {
|
||||||
const appsList = await this.storage.applicationStorage.GetApplications()
|
try {
|
||||||
const defaultNames = ['wallet', 'wallet-test', this.settings.defaultAppName]
|
const appsList = await this.storage.applicationStorage.GetApplications()
|
||||||
const existingDefaultApp = appsList.find(app => defaultNames.includes(app.name))
|
const defaultNames = ['wallet', 'wallet-test', this.settings.defaultAppName]
|
||||||
if (existingDefaultApp) {
|
const existingDefaultApp = appsList.find(app => defaultNames.includes(app.name)) || appsList[0]
|
||||||
await this.storage.applicationStorage.UpdateApplication(existingDefaultApp, { name: req.source_name, avatar_url: (req as any).avatar_url || existingDefaultApp.avatar_url })
|
if (existingDefaultApp) {
|
||||||
|
await this.storage.applicationStorage.UpdateApplication(existingDefaultApp, { name: req.source_name, avatar_url: (req as any).avatar_url || (existingDefaultApp as any).avatar_url })
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.log(`Error updating app info: ${(e as Error).message}`)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
this.updateEnvFile(pendingConfig)
|
||||||
this.log(`Error updating app name: ${(e as Error).message}`)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First-time configuration flow
|
||||||
|
if (this.pendingConfig !== null) {
|
||||||
|
throw new Error("already initializing")
|
||||||
|
}
|
||||||
this.updateEnvFile(pendingConfig)
|
this.updateEnvFile(pendingConfig)
|
||||||
this.configQueue.forEach(q => q.res(true))
|
this.configQueue.forEach(q => q.res(true))
|
||||||
this.configQueue = []
|
this.configQueue = []
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,27 @@
|
||||||
$(() => {
|
$(() => {
|
||||||
|
const postConfig = async (updates) => {
|
||||||
|
try {
|
||||||
|
const stateRes = await fetch('/wizard/service_state')
|
||||||
|
if (stateRes.status !== 200) return false
|
||||||
|
const s = await stateRes.json()
|
||||||
|
const body = {
|
||||||
|
source_name: updates.source_name ?? (s.source_name || s.provider_name || ''),
|
||||||
|
relay_url: updates.relay_url ?? (s.relay_url || (s.relays && s.relays[0]) || ''),
|
||||||
|
automate_liquidity: s.automate_liquidity || false,
|
||||||
|
push_backups_to_nostr: s.push_backups_to_nostr || false,
|
||||||
|
avatar_url: s.avatar_url || ''
|
||||||
|
}
|
||||||
|
const res = await fetch('/wizard/config', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
})
|
||||||
|
if (res.status !== 200) return false
|
||||||
|
const j = await res.json().catch(() => ({}))
|
||||||
|
if (j && j.status && j.status !== 'OK') return false
|
||||||
|
return true
|
||||||
|
} catch { return false }
|
||||||
|
}
|
||||||
$("#show-reset").click(() => {
|
$("#show-reset").click(() => {
|
||||||
$("#reset-content").text('Reset the administrator account if you lost access via the Dashboard.');
|
$("#reset-content").text('Reset the administrator account if you lost access via the Dashboard.');
|
||||||
$("#reset-box").show();
|
$("#reset-box").show();
|
||||||
|
|
@ -18,9 +41,13 @@ $(() => {
|
||||||
});
|
});
|
||||||
$("#save-show-nodey").click(() => {
|
$("#save-show-nodey").click(() => {
|
||||||
var targetInputVal = $('input[name="show-nodey"]').val()
|
var targetInputVal = $('input[name="show-nodey"]').val()
|
||||||
$('#show-nodey-text').text(targetInputVal)
|
postConfig({ source_name: targetInputVal }).then(ok => {
|
||||||
$('.show-nodey').hide()
|
if (ok) {
|
||||||
$('#show-nodey-text').show()
|
$('#show-nodey-text').text(targetInputVal)
|
||||||
|
}
|
||||||
|
$('.show-nodey').hide()
|
||||||
|
$('#show-nodey-text').show()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
$("#cancel-show-nodey").click(() => {
|
$("#cancel-show-nodey").click(() => {
|
||||||
$('.show-nodey').hide()
|
$('.show-nodey').hide()
|
||||||
|
|
@ -38,9 +65,13 @@ $(() => {
|
||||||
});
|
});
|
||||||
$("#save-show-nostr").click(() => {
|
$("#save-show-nostr").click(() => {
|
||||||
var targetInputVal = $('input[name="show-nostr"]').val()
|
var targetInputVal = $('input[name="show-nostr"]').val()
|
||||||
$('#show-nostr-text').text(targetInputVal)
|
postConfig({ relay_url: targetInputVal }).then(ok => {
|
||||||
$('.show-nostr').hide()
|
if (ok) {
|
||||||
$('#show-nostr-text').show()
|
$('#show-nostr-text').text(targetInputVal)
|
||||||
|
}
|
||||||
|
$('.show-nostr').hide()
|
||||||
|
$('#show-nostr-text').show()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
$("#cancel-show-nostr").click(() => {
|
$("#cancel-show-nostr").click(() => {
|
||||||
$('.show-nostr').hide()
|
$('.show-nostr').hide()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<img src="img/pub_logo.png" width="38px" height="auto" alt="Lightning Pub logo" />
|
<img src="img/pub_logo.png" width="38px" height="auto" alt="Lightning Pub logo" />
|
||||||
<img src="img/LightningPub.png" height="33px" alt="Lightning Pub logo" />
|
<img src="img/LightningPub.png" height="26px" alt="Lightning Pub logo" />
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
|
@ -157,20 +157,24 @@
|
||||||
}
|
}
|
||||||
const j = await res.json()
|
const j = await res.json()
|
||||||
console.log(j)
|
console.log(j)
|
||||||
if (j.status !== 'OK') {
|
// Map fields from service state
|
||||||
document.getElementById('errorText').innerText = "failed to get state info" + j.reason
|
const name = j.source_name || j.provider_name || 'Unknown'
|
||||||
return
|
const relayUrl = j.relay_url || (j.relays && j.relays[0]) || ''
|
||||||
}
|
const admin = j.admin_npub || ''
|
||||||
document.getElementById("show-nodey-text").innerHTML = j.provider_name
|
const lndStateNum = typeof j.lnd_state === 'number' ? j.lnd_state : 0
|
||||||
document.getElementById("show-nostr-text").innerHTML = j.relays[0]
|
const lndText = lndStateNum === 2 ? 'ONLINE' : (lndStateNum === 1 ? 'SYNCING' : 'OFFLINE')
|
||||||
document.getElementById("adminNpub").innerText = j.admin_npub
|
const lndDot = lndStateNum === 2 ? 'green-dot' : (lndStateNum === 1 ? 'yellow-dot' : 'red-dot')
|
||||||
document.getElementById("relayStatus").innerHTML = `<span class="${j.relay_connected ? 'green-dot' : 'red-dot'}">●</span> ${j.relay_connected ? 'Connected' : 'Disconnected'}`
|
const relayConnected = !!relayUrl
|
||||||
document.getElementById("lndStatus").innerHTML = `<span class="${j.lnd_state === 'ONLINE' ? 'green-dot' : 'red-dot'}">●</span> ${j.lnd_state}`
|
document.getElementById("show-nodey-text").innerHTML = name
|
||||||
|
document.getElementById("show-nostr-text").innerHTML = relayUrl || '—'
|
||||||
|
document.getElementById("adminNpub").innerText = admin
|
||||||
|
document.getElementById("relayStatus").innerHTML = `<span class="${relayConnected ? 'green-dot' : 'red-dot'}">●</span> ${relayConnected ? 'Connected' : 'Disconnected'}`
|
||||||
|
document.getElementById("lndStatus").innerHTML = `<span class="${lndDot}">●</span> ${lndText}`
|
||||||
document.getElementById("watchdog-status").innerHTML = `<span class="${j.watchdog_ok ? 'green-dot' : 'red-dot'}">●</span> ${j.watchdog_ok ? 'No Alerts' : 'ALERT!!'}`
|
document.getElementById("watchdog-status").innerHTML = `<span class="${j.watchdog_ok ? 'green-dot' : 'red-dot'}">●</span> ${j.watchdog_ok ? 'No Alerts' : 'ALERT!!'}`
|
||||||
document.getElementById("inviteLinkHttp").href = `https://my.shockwallet.app/#/sources?addSource=${j.nprofile}`
|
document.getElementById("inviteLinkHttp").href = `https://my.shockwallet.app/#/sources?addSource=${j.nprofile}`
|
||||||
document.getElementById("inviteLinkHttp").innerHTML = `https://my.shockwallet.app/#/sources?addSource=${j.nprofile}`
|
document.getElementById("inviteLinkHttp").innerHTML = `https://my.shockwallet.app/#/sources?addSource=${j.nprofile}`
|
||||||
document.querySelector('input[name="show-nodey"]').placeholder = j.provider_name;
|
document.querySelector('input[name="show-nodey"]').placeholder = name;
|
||||||
document.title = j.provider_name;
|
document.title = name;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fetchInfo()
|
fetchInfo()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue