try wizard state
This commit is contained in:
parent
d1c3d4e4a4
commit
9c1dd8db6e
2 changed files with 39 additions and 20 deletions
|
|
@ -40,21 +40,40 @@ export class Wizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
GetServiceState = async (): Promise<WizardTypes.ServiceStateResponse> => {
|
GetServiceState = async (): Promise<WizardTypes.ServiceStateResponse> => {
|
||||||
const apps = await this.storage.applicationStorage.GetApplications()
|
try {
|
||||||
const appNamesList = apps.map(app => app.name).join(', ')
|
const apps = await this.storage.applicationStorage.GetApplications()
|
||||||
return {
|
const appNamesList = apps.map(app => app.name).join(', ')
|
||||||
admin_npub: this.adminManager.GetAdminNpub(),
|
return {
|
||||||
http_url: this.settings.serviceUrl,
|
admin_npub: this.adminManager.GetAdminNpub(),
|
||||||
lnd_state: WizardTypes.LndState.OFFLINE,
|
http_url: this.settings.serviceUrl,
|
||||||
nprofile: this.nprofile,
|
lnd_state: WizardTypes.LndState.OFFLINE,
|
||||||
provider_name: appNamesList,
|
nprofile: this.nprofile,
|
||||||
relay_connected: false,
|
provider_name: appNamesList,
|
||||||
relays: this.relays,
|
relay_connected: false,
|
||||||
watchdog_ok: false,
|
relays: this.relays,
|
||||||
source_name: this.settings.defaultAppName,
|
watchdog_ok: false,
|
||||||
relay_url: this.settings.nostrRelaySettings.relays[0] || '',
|
source_name: appNamesList || this.settings.defaultAppName,
|
||||||
automate_liquidity: this.settings.liquiditySettings.liquidityProviderPub !== 'null',
|
relay_url: this.settings.nostrRelaySettings.relays[0] || '',
|
||||||
push_backups_to_nostr: this.settings.pushBackupsToNostr,
|
automate_liquidity: this.settings.liquiditySettings.liquidityProviderPub !== 'null',
|
||||||
|
push_backups_to_nostr: this.settings.pushBackupsToNostr,
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.log(`Error in GetServiceState: ${(e as Error).message}`)
|
||||||
|
// Return a default/error state that is still valid JSON to prevent client-side parse errors
|
||||||
|
return {
|
||||||
|
admin_npub: '',
|
||||||
|
http_url: '',
|
||||||
|
lnd_state: WizardTypes.LndState.OFFLINE,
|
||||||
|
nprofile: '',
|
||||||
|
provider_name: 'Error loading state',
|
||||||
|
relay_connected: false,
|
||||||
|
relays: [],
|
||||||
|
watchdog_ok: false,
|
||||||
|
source_name: 'Error',
|
||||||
|
relay_url: '',
|
||||||
|
automate_liquidity: false,
|
||||||
|
push_backups_to_nostr: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WizardState = async (): Promise<WizardTypes.StateResponse> => {
|
WizardState = async (): Promise<WizardTypes.StateResponse> => {
|
||||||
|
|
|
||||||
|
|
@ -122,21 +122,21 @@ $(() => {
|
||||||
} else {
|
} else {
|
||||||
// Pre-populate from service state
|
// Pre-populate from service state
|
||||||
fetch("/wizard/service-state").then(res => res.json()).then(state => {
|
fetch("/wizard/service-state").then(res => res.json()).then(state => {
|
||||||
nodeNameInput.val(state.sourceName);
|
nodeNameInput.val(state.source_name);
|
||||||
if (state.relayUrl === 'wss://relay.lightning.pub') {
|
if (state.relay_url === 'wss://relay.lightning.pub') {
|
||||||
customCheckbox.prop('checked', true);
|
customCheckbox.prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
relayUrlInput.val(state.relayUrl);
|
relayUrlInput.val(state.relay_url);
|
||||||
}
|
}
|
||||||
syncRelayState();
|
syncRelayState();
|
||||||
|
|
||||||
if (state.automateLiquidity) {
|
if (state.automate_liquidity) {
|
||||||
automateLiquidityRadio.prop('checked', true);
|
automateLiquidityRadio.prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
manualLiquidityRadio.prop('checked', true);
|
manualLiquidityRadio.prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.pushBackupsToNostr) {
|
if (state.push_backups_to_nostr) {
|
||||||
backupNostrRadio.prop('checked', true);
|
backupNostrRadio.prop('checked', true);
|
||||||
} else {
|
} else {
|
||||||
manualBackupRadio.prop('checked', true);
|
manualBackupRadio.prop('checked', true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue