wizard use state
This commit is contained in:
parent
77efe1eae7
commit
248744dc3d
12 changed files with 751 additions and 406 deletions
|
|
@ -94,6 +94,15 @@
|
|||
|
||||
<script src="js/backup.js"></script>
|
||||
<script>
|
||||
fetch("/wizard/service-state").then(res => res.json()).then(state => {
|
||||
if (state.push_backups_to_nostr) {
|
||||
document.getElementById('backup').checked = true;
|
||||
} else {
|
||||
document.getElementById('manual-backup').checked = true;
|
||||
}
|
||||
document.getElementById('next-button').classList.remove('hidden-button');
|
||||
});
|
||||
|
||||
const sendConfig = async () => {
|
||||
const req = {
|
||||
source_name: localStorage.getItem("wizard/nodeName"),
|
||||
|
|
|
|||
|
|
@ -94,6 +94,28 @@
|
|||
location.href = 'liquidity.html'
|
||||
}
|
||||
|
||||
const nodeNameInput = document.getElementById("nodeName");
|
||||
const relayUrlInput = document.getElementById("relayUrl");
|
||||
const customCheckbox = document.getElementById("customCheckbox");
|
||||
|
||||
const syncRelayState = () => {
|
||||
if (customCheckbox.checked) {
|
||||
relayUrlInput.value = '';
|
||||
relayUrlInput.disabled = true;
|
||||
} else {
|
||||
relayUrlInput.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
customCheckbox.addEventListener('change', syncRelayState);
|
||||
|
||||
relayUrlInput.addEventListener('input', () => {
|
||||
if (relayUrlInput.value) {
|
||||
customCheckbox.checked = false;
|
||||
syncRelayState();
|
||||
}
|
||||
});
|
||||
|
||||
fetch("/wizard/state").then((res) => {
|
||||
if (res.status === 200) {
|
||||
res.json().then((data) => {
|
||||
|
|
@ -103,6 +125,16 @@
|
|||
location.href = 'connect.html'
|
||||
} else {
|
||||
console.log("ready to initialize")
|
||||
// Pre-populate from service state if not configured
|
||||
fetch("/wizard/service-state").then(res => res.json()).then(state => {
|
||||
nodeNameInput.value = state.source_name;
|
||||
if (state.relay_url === 'wss://relay.lightning.pub') {
|
||||
customCheckbox.checked = true;
|
||||
} else {
|
||||
relayUrlInput.value = state.relay_url;
|
||||
}
|
||||
syncRelayState();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,14 @@
|
|||
</footer>
|
||||
<script src="js/liquidity.js"></script>
|
||||
<script>
|
||||
fetch("/wizard/service-state").then(res => res.json()).then(state => {
|
||||
if (state.automate_liquidity) {
|
||||
document.getElementById('automate').checked = true;
|
||||
} else {
|
||||
document.getElementById('manual').checked = true;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("backupBtn").onclick = (e) => {
|
||||
const automate = document.getElementById('automate').checked
|
||||
const manual = document.getElementById('manual').checked
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue