more settings

This commit is contained in:
everoddandeven 2024-09-23 22:17:26 +02:00
parent ba8b471958
commit cd600e06cd
9 changed files with 189 additions and 9 deletions

View file

@ -42,6 +42,7 @@ import { ElectronService } from '../electron/electron.service';
providedIn: 'root'
})
export class DaemonService {
private daemonRunning?: boolean;
private readonly configFilePath: string = './config';
private url: string = "http://127.0.0.1:28081";
//private url: string = "http://node2.monerodevs.org:28089";
@ -81,17 +82,23 @@ export class DaemonService {
}, 500)
}
public async isRunning(): Promise<boolean> {
public async isRunning(force: boolean = false): Promise<boolean> {
try {
if (!force && this.daemonRunning != undefined) {
return this.daemonRunning;
}
const response = await this.callJsonRpc(new EmptyRpcRequest());
console.log(response);
return true;
this.daemonRunning = true;
}
catch(error) {
console.error(error);
return false;
this.daemonRunning = false;
}
return this.daemonRunning;
}
public async getBlockCount(): Promise<BlockCount> {

View file

@ -64,8 +64,8 @@ export class DetailComponent implements OnInit, AfterViewInit {
this.isLoading = true;
this.navbarLinks = [
new NavbarLink('pills-home-tab', '#pills-home', 'pills-home', true, 'Overview'),
new NavbarLink('pills-profile-tab', '#pills-profile', 'pills-profile', false, 'Peers')
new NavbarLink('pills-home-tab', '#pills-home', 'pills-home', true, 'Overview', true),
new NavbarLink('pills-profile-tab', '#pills-profile', 'pills-profile', false, 'Peers', true)
];
this.cards = [];
@ -142,9 +142,13 @@ export class DetailComponent implements OnInit, AfterViewInit {
this.daemonRunning = await this.daemonService.isRunning();
if (!this.daemonRunning) {
this.navbarService.disableNavbarLinks();
this.isLoading = false;
return;
}
this.navbarService.enableNavbarLinks();
const $table = $('#table');
this.syncInfo = await this.daemonService.syncInfo();

View file

@ -81,6 +81,13 @@ export class MiningComponent implements AfterViewInit {
private async load(): Promise<void> {
try {
const running = await this.daemonService.isRunning();
if (!running) {
this.coreBusy = false;
throw new Error("Daemon not running");
}
this.minerData = await this.daemonService.getMinerData();
this.majorVersion = this.minerData.majorVersion;
this.height = this.minerData.height;
@ -94,8 +101,11 @@ export class MiningComponent implements AfterViewInit {
const $table = $('#chainsTable');
$table.bootstrapTable('load', this.getChains());
this.coreBusy = false;
this.navbarService.enableNavbarLinks();
}
catch(error) {
this.navbarService.disableNavbarLinks();
if (error instanceof CoreIsBusyError) {
this.coreBusy = true;
}
@ -106,7 +116,6 @@ export class MiningComponent implements AfterViewInit {
private createCards(): Card[] {
if (this.coreBusy) {
return [
new Card('Error', 'Core is busy')
]
}
return [

View file

@ -7,7 +7,7 @@
<ul class="nav nav-pills" id="pills-tab" role="tablist">
@for(navbarLink of navbarLinks; track navbarLink.name) {
<li class="nav-item mr-2" role="presentation">
<button [class]="navbarLink.selected ? 'nav-link active' : 'nav-link'" [id]="navbarLink.id" data-bs-toggle="pill" [attr.data-bs-target]="navbarLink.target" type="button" role="tab" [attr.aria-controls]="navbarLink.controls" [attr.aria-selected]="navbarLink.selected">{{navbarLink.name}}</button>
<button [class]="navbarLink.selected ? 'nav-link active' : 'nav-link'" [id]="navbarLink.id" data-bs-toggle="pill" [attr.data-bs-target]="navbarLink.target" type="button" role="tab" [attr.aria-controls]="navbarLink.controls" [attr.aria-selected]="navbarLink.selected" [disabled]="navbarLink.disabled">{{navbarLink.name}}</button>
</li>
}
<!--

View file

@ -6,13 +6,15 @@ export class NavbarLink {
public controls: string;
public selected: boolean;
public name: string;
public disabled: boolean;
constructor(id: string, target: string, controls: string, selected: boolean, name: string) {
constructor(id: string, target: string, controls: string, selected: boolean, name: string, disabled: boolean = false) {
this.id = id;
this.target = target;
this.controls = controls;
this.selected = selected;
this.name = name;
this.disabled = disabled;
}
}

View file

@ -25,4 +25,12 @@ export class NavbarService {
this.setNavbarLinks([]);
}
public disableNavbarLinks(): void {
this._navbarLinks.forEach((link) => link.disabled = true);
}
public enableNavbarLinks(): void {
this._navbarLinks.forEach((link) => link.disabled = false);
}
}

View file

@ -221,6 +221,69 @@
</div>
</div>
<div class="tab-pane fade" id="pills-p2p" role="tabpanel" aria-labelledby="pills-p2p-tab" tabindex="0">
<div class="row g-5 m-2">
<div class="col-md-7 col-lg-10">
<h4 class="mb-3">General</h4>
<div class="row gy-3">
<div class="form-check form-switch col-md-6">
<label for="allow-local-ip" class="form-check-label">Allow local IP</label>
<input class="form-control form-check-input" type="checkbox" role="switch" id="allow-local-ip">
<br>
<small class="text-body-secondary">Allow local ip add to peer list, mostly in debug process</small>
</div>
<div class="form-check form-switch col-md-6">
<label for="p2p-ignore-ipv4" class="form-check-label">Ignore IPv4</label>
<input class="form-control form-check-input" type="checkbox" role="switch" id="p2p-ignore-ipv4">
<br>
<small class="text-body-secondary">Ignore unsuccessful IPv4 bind for P2P</small>
</div>
<div class="col-md-6">
<label for="p2p-bind-ip" class="form-label">Bind IP</label>
<input type="text" class="form-control" id="p2p-bind-ip" placeholder="0.0.0.0">
<small class="text-body-secondary">Interface for p2p network protocol</small>
</div>
<div class="col-md-6">
<label for="p2p-bind-port" class="form-label">Bind port</label>
<input type="number" class="form-control" id="p2p-bind-port" placeholder="18080">
<small class="text-body-secondary">18080 for mainnet, 28080 for testnet, 38080 for stagenet</small>
</div>
<div class="col-md-6">
<label for="p2p-external-port" class="form-label">External port</label>
<input type="number" class="form-control" id="p2p-external-port" placeholder="18080">
<small class="text-body-secondary">External port for p2p network protocol (if port forwarding used with NAT)</small>
</div>
<hr class="my-4">
<div class="row g-3">
<h4 class="mb-3">IPv6</h4>
<div class="col-md-6">
<label for="p2p-bind-ipv6-address" class="form-label">Bind IPv6 address</label>
<input type="text" class="form-control" id="p2p-bind-ipv6-address" placeholder="::1">
<small class="text-body-secondary">Specify IPv6 address to bind RPC server</small>
</div>
<div class="col-md-6">
<label for="p2p-bind-port-ipv6" class="form-label">Bind IPv6 port</label>
<input type="number" class="form-control" id="p2p-bind-port-ipv6" placeholder="18080">
<small class="text-body-secondary">18080 for mainnet, 28080 for testnet, 38080 for stagenet</small>
</div>
</div>
<hr class="my-4">
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-blockchain" role="tabpanel" aria-labelledby="pills-blockchain-tab" tabindex="0">
<div class="row g-5 m-2">
<div class="col-md-7 col-lg-10">
@ -380,6 +443,91 @@
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-mining" role="tabpanel" aria-labelledby="pills-mining-tab" tabindex="0">
<div class="row g-5 m-2">
<div class="col-md-7 col-lg-10">
<form class="needs-validation" novalidate="">
<div class="row g-3">
<h4 class="mb-3">Background mining</h4>
<div class="form-check form-switch col-md-6">
<label for="bg-mining-enable" class="form-check-label">Enabled</label>
<input class="form-control form-check-input" type="checkbox" role="switch" id="bg-mining-enable">
<br>
<small class="text-body-secondary">Enable background mining</small>
</div>
<div class="form-check form-switch col-md-6">
<label for="bg-mining-ignore-battery" class="form-check-label">Ignore battery</label>
<input class="form-control form-check-input" type="checkbox" role="switch" id="bg-mining-ignore-battery">
<br>
<small class="text-body-secondary">Reduce blockchain disk usage</small>
</div>
<div class="col-md-4">
<label for="bg-mining-min-idle-interval" class="form-label">Minimum idle interval</label>
<input type="number" class="form-control" id="bg-mining-min-idle-interval" placeholder="" value="">
<small class="text-body-secondary">Specify min lookback interval in seconds for determining idle state</small>
</div>
<div class="col-md-4">
<label for="bg-mining-idle-threshold" class="form-label">Idle threshold</label>
<input type="number" class="form-control" id="bg-mining-idle-threshold" placeholder="" value="">
<small class="text-body-secondary">Specify minimum avg idle percentage over lookback interval</small>
</div>
<div class="col-md-4">
<label for="bg-mining-miner-target" class="form-label">Miner target</label>
<input type="number" class="form-control" id="bg-mining-miner-target" placeholder="">
<small class="text-body-secondary">Specify maximum percentage cpu use by miners</small>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-logs" role="tabpanel" aria-labelledby="pills-logs-tab" tabindex="0">
<div class="row g-5 m-2">
<div class="col-md-7 col-lg-10">
<form class="needs-validation" novalidate="">
<div class="row g-3">
<h4 class="mb-3">General</h4>
<div class="col-md-4">
<label for="log-level" class="form-label">Log level</label>
<select class="form-select" id="log-level">
<option value="0">Info</option>
<option value="1">Warning</option>
<option value="2">Debug</option>
<option value="3">Error</option>
<option value="4">Trace</option>
</select>
</div>
<div class="col-md-4">
<label for="max-log-file-size" class="form-label">Max log file size</label>
<input type="number" class="form-control" id="max-log-file-size" placeholder="104850000" value="">
<small class="text-body-secondary">Specify maximum log file size [B]</small>
</div>
<div class="col-md-4">
<label for="max-log-files" class="form-label">Max log files</label>
<input type="number" class="form-control" id="max-log-files" placeholder="50" value="">
<small class="text-body-secondary">Specify maximum number of rotated log files to be saved (no limit by setting to 0)</small>
</div>
</div>
</form>
</div>
</div>
</div>
<hr class="my-4">
<button class="w-50 btn btn-primary btn-lg" type="submit">Save</button>

View file

@ -19,7 +19,7 @@ export class SettingsComponent implements AfterViewInit {
new NavbarLink('pills-p2p-tab', '#pills-p2p', 'pills-p2p', false, 'P2P'),
new NavbarLink('pills-blockchain-tab', '#pills-blockchain', 'pills-blockchain', false, 'Blockchain'),
new NavbarLink('pills-mining-tab', '#pills-mining', 'pills-mining', false, 'Mining'),
new NavbarLink('pills-log-tab', '#pills-log', 'pills-log', false, 'Logs')
new NavbarLink('pills-logs-tab', '#pills-logs', 'pills-logs', false, 'Logs')
];
this.router.events.subscribe((event) => {

View file

@ -2,4 +2,6 @@ export abstract class RPCRequest {
public abstract readonly method: string;
public abstract readonly restricted: boolean;
public abstract toDictionary(): { [key: string]: any };
}