diff --git a/static/backup.html b/static/backup.html deleted file mode 100644 index 5bf0d5c9..00000000 --- a/static/backup.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - Lightning.Pub - - - - - - -
- Lightning Pub logo - Lightning Pub logo -
- -
-
- -

Choose a Recovery Method

-

- New Node! 🎉 It's important - to backup your keys. -

-
- -
- -
-
-
- In addition to your seed phrase, you also need channel details to recover funds should your node experience a - hardware failure. -
-
-
- It's important always to have the latest version of this file. Fortunately, it's small enough to automatically - store on the Nostr relay. -
-
-
- If you did not choose the developers relay, be sure your relay has - adequate storage policies to hold NIP78 events. -
-
-
- - -
-
-
-
- - -
-
-
-

-
- -
-
- - - - - - - - \ No newline at end of file diff --git a/static/index.html b/static/index.html index c66c1a0c..40778249 100644 --- a/static/index.html +++ b/static/index.html @@ -8,6 +8,8 @@ + + Lightning.Pub @@ -21,41 +23,144 @@
-
-

Setup your Pub

-

-

+
+
+

Setup your Pub

+

+

+
+ +
+ +
+
+ Give this node a name that wallet users will see: + +
+ +
+ If you want to use a specific Nostr relay, enter it now: + +
+ +
+ +
+ +
+ +
+

+
+ + +
-
- -
-
- Give this node a name that wallet users will see: - + + +
@@ -71,75 +176,8 @@
Need Help? - + + \ No newline at end of file diff --git a/static/js/backup.js b/static/js/backup.js deleted file mode 100644 index 3aed2b25..00000000 --- a/static/js/backup.js +++ /dev/null @@ -1,10 +0,0 @@ -$(() => { - $('input[name="backup-option"]').change(() => { - const nextButton = $("#next-button"); - if ($('input[name="backup-option"]:checked').length > 0) { - nextButton.removeClass("hidden-button"); - } else { - nextButton.addClass("hidden-button"); - } - }); -}); diff --git a/static/js/liquidity.js b/static/js/liquidity.js deleted file mode 100644 index 4418542a..00000000 --- a/static/js/liquidity.js +++ /dev/null @@ -1,9 +0,0 @@ -$(() => { - $("#show-question").click(() => { - $("#question-content").show(); - }); - - $("#close-question").click(() => { - $("#question-content").hide(); - }); -}); diff --git a/static/js/wizard.js b/static/js/wizard.js new file mode 100644 index 00000000..bb73e1d1 --- /dev/null +++ b/static/js/wizard.js @@ -0,0 +1,147 @@ +$(() => { + // Page sections + const pages = { + node: $('#page-node'), + liquidity: $('#page-liquidity'), + backup: $('#page-backup') + }; + + // Inputs + const nodeNameInput = $("#nodeName"); + const relayUrlInput = $("#relayUrl"); + const customCheckbox = $("#customCheckbox"); + const automateLiquidityRadio = $("#automate"); + const manualLiquidityRadio = $("#manual"); + const backupNostrRadio = $("#backup"); + const manualBackupRadio = $("#manual-backup"); + + // Buttons + const toLiquidityBtn = $("#liquidityBtn"); + const toBackupBtn = $("#backupBtn"); + const finishBtn = $("#next-button"); + const backToNodeBtn = $("#back-to-node"); + const backToLiquidityBtn = $("#back-to-liquidity"); + + // Error text + const errorTextNode = $("#errorText"); + const errorTextLiquidity = $("#errorTextLiquidity"); + const errorTextBackup = $("#errorTextBackup"); + + // Liquidity question mark + $("#show-question").click(() => $("#question-content").show()); + $("#close-question").click(() => $("#question-content").hide()); + + const showPage = (pageToShow) => { + Object.values(pages).forEach(page => page.hide()); + pageToShow.show(); + }; + + // Navigation + toLiquidityBtn.click(() => { + const nodeName = nodeNameInput.val(); + const relayUrl = relayUrlInput.val(); + const useDefaultRelay = customCheckbox.prop('checked'); + if (!nodeName) { + errorTextNode.text("Please enter a node name"); + return; + } + if (!useDefaultRelay && !relayUrl) { + errorTextNode.text("Please enter a relay URL or check the default relay box"); + return; + } + errorTextNode.text(""); + showPage(pages.liquidity); + }); + + toBackupBtn.click(() => { + if (!automateLiquidityRadio.prop('checked') && !manualLiquidityRadio.prop('checked')) { + errorTextLiquidity.text('Please select an option'); + return; + } + errorTextLiquidity.text(""); + showPage(pages.backup); + }); + + backToNodeBtn.click(() => showPage(pages.node)); + backToLiquidityBtn.click(() => showPage(pages.liquidity)); + + // Final submission + finishBtn.click(async () => { + if (!backupNostrRadio.prop('checked') && !manualBackupRadio.prop('checked')) { + errorTextBackup.text('Please select an option'); + return; + } + errorTextBackup.text(""); + + const relayUrl = customCheckbox.prop('checked') ? 'wss://relay.lightning.pub' : relayUrlInput.val(); + + const req = { + source_name: nodeNameInput.val(), + relay_url: relayUrl, + automate_liquidity: automateLiquidityRadio.prop('checked'), + push_backups_to_nostr: backupNostrRadio.prop('checked'), + }; + + try { + const res = await fetch("/wizard/config", { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(req) + }); + if (!res.ok) { + const j = await res.json(); + throw new Error(j.reason || "Failed to start service"); + } + location.href = 'connect.html'; + } catch (err) { + errorTextBackup.text(err.message); + } + }); + + const syncRelayState = () => { + relayUrlInput.prop('disabled', customCheckbox.prop('checked')); + if (customCheckbox.prop('checked')) { + relayUrlInput.val(''); + } + }; + + customCheckbox.on('change', syncRelayState); + relayUrlInput.on('input', () => { + if (relayUrlInput.val()) { + customCheckbox.prop('checked', false); + syncRelayState(); + } + }); + + // Initial state load + fetch("/wizard/state").then(res => res.json()).then(data => { + if (data.admin_linked) { + location.href = 'status.html'; + } else if (data.config_sent) { + location.href = 'connect.html'; + } else { + // Pre-populate from service state + fetch("/wizard/service-state").then(res => res.json()).then(state => { + nodeNameInput.val(state.source_name); + if (state.relay_url === 'wss://relay.lightning.pub') { + customCheckbox.prop('checked', true); + } else { + relayUrlInput.val(state.relay_url); + } + syncRelayState(); + + if (state.automate_liquidity) { + automateLiquidityRadio.prop('checked', true); + } else { + manualLiquidityRadio.prop('checked', true); + } + + if (state.push_backups_to_nostr) { + backupNostrRadio.prop('checked', true); + } else { + manualBackupRadio.prop('checked', true); + } + }); + } + }); +}); diff --git a/static/liquidity.html b/static/liquidity.html deleted file mode 100644 index 3a19ebf1..00000000 --- a/static/liquidity.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - Lightning.Pub - - - - - - -
- Lightning Pub logo - Lightning Pub logo -
- -
-
- -

Manage Node Liquidity

-

- How do you want to manage Lightning channels? -

-
- -
- -
-
- - -
-
- - -
-
-

-
- -
-
- - - - - - - \ No newline at end of file