micronode

This commit is contained in:
Kukks
2024-01-17 09:07:18 +01:00
parent d27a31ee8e
commit cfcaa17e94
24 changed files with 2388 additions and 11 deletions

View File

@@ -0,0 +1,66 @@
@inject MicroNodeService MicroNodeService;
@using BTCPayServer.Plugins.MicroNode
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Abstractions.TagHelpers
@model BTCPayServer.Models.StoreViewModels.LightningNodeViewModel
@{
var storeId = Model.StoreId;
if (Model.CryptoCode != "BTC")
{
return;
}
var client = await MicroNodeService.GetStoreSettings(storeId);
}
<div id="MicroNodeSetup" class="pt-3 tab-pane fade" role="tabpanel" aria-labelledby="LightningNodeType-MicroNode">
@if (client is not null)
{
}
else
{
<a asp-action="Configure" asp-controller="MicroNode" asp-route-storeId="@storeId">MicroNode needs to be configured beforehand.</a>
}
</div>
@if (client is not null)
{
<script>
const typePrefix = 'type=micro;key=@client.Key';
const triggerEl = document.getElementById('LightningNodeType-MicroNode')
const connStringEl = document.getElementById('ConnectionString')
const connString = connStringEl.value;
const isMicro = connString.startsWith(typePrefix);
if (isMicro) {
// deactivate currently active tab and activate Breez tab
const activeEl = document.querySelector('input[name="LightningNodeType"]:checked')
if (activeEl) {
activeEl.removeAttribute('checked')
activeEl.setAttribute('aria-selected', 'false')
document.querySelector('#LightningNodeTypeTabs .tab-pane.active').classList.remove('active', 'show')
triggerEl.setAttribute('checked', 'checked')
triggerEl.setAttribute('aria-selected', 'true')
document.getElementById('MicroNodeSetup').classList.add('active', 'show')
}
}
document.addEventListener('DOMContentLoaded', () => {
if (isBreez) {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.checked = true
tabTrigger.show()
}
delegate('change', 'input[name="LightningNodeType"]', e => {
const activeEl = document.querySelector('input[name="LightningNodeType"]:checked')
if (activeEl.id === "LightningNodeType-MicroNode"){
connStringEl.value =typePrefix;
}
})
})
</script>
}

View File

@@ -0,0 +1,19 @@
@inject MicroNodeService MicroNodeService;
@using BTCPayServer.Plugins.MicroNode
@model BTCPayServer.Models.StoreViewModels.LightningNodeViewModel
@if (Model.CryptoCode != "BTC")
{
return;
}
@{
var client = await MicroNodeService.GetStoreSettings(Model.StoreId);
var storeId = Model.StoreId;
}
@if (client is null)
{
<a asp-action="Configure" asp-controller="MicroNode" asp-route-storeId="@storeId" value="Custom" type="radio" id="LightningNodeType-MicroNode" role="tab" aria-controls="MicroNodeSetup" aria-selected="false" name="LightningNodeType" ><label for="LightningNodeType-MicroNode">Configure Micro Node</label></a>
}else{
<input value="Custom" type="radio" id="LightningNodeType-MicroNode" data-bs-toggle="pill" data-bs-target="#MicroNodeSetup" role="tab" aria-controls="MicroNodeSetup" aria-selected="false" name="LightningNodeType">
<label for="LightningNodeType-MicroNode">Use Micro node</label>}

View File

@@ -0,0 +1,31 @@
@using BTCPayServer.Abstractions.Contracts
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Client
@using BTCPayServer.Plugins.MicroNode
@using Microsoft.AspNetCore.Mvc.TagHelpers
@inject IScopeProvider ScopeProvider
@inject MicroNodeService MicroNodeService
@{
var storeId = ScopeProvider.GetCurrentStoreId();
}
@if (!string.IsNullOrEmpty(storeId))
{
var masters = (await MicroNodeService.GetMasterSettings()).Select(m => new SelectListItem(m.Value.Name, m.Key)).ToArray();
@if (masters.Any())
{
<li class="nav-item">
<a permission="@Policies.CanModifyStoreSettings" asp-controller="MicroNode" asp-action="Configure" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("MicroNode")" id="Nav-MicroNode">
<span>MicroNode</span>
</a>
</li>
}
<li class="nav-item">
<a permission="@Policies.CanModifyStoreSettings" asp-controller="MicroNode" asp-action="ConfigureMaster" asp-route-storeId="@storeId" class="nav-link @ViewData.IsActivePage("MicroNodeMaster")" id="Nav-MicroNodeMaster">
<span>MicroNode Master</span>
</a>
</li>
}