Minor fixes

This commit is contained in:
argenius 2024-11-12 17:37:33 +01:00
parent 16a0694f29
commit 3e117ac488
17 changed files with 139 additions and 35 deletions

View file

@ -38,7 +38,7 @@
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js",
"node_modules/bootstrap-table/dist/bootstrap-table.min.js"
],
"styles": [

View file

@ -311,12 +311,10 @@ function isConnectedToWiFi(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
network.get_active_interface((err: any | null, obj: { name: string, ip_address: string, mac_address: string, type: string, netmask: string, gateway_ip: string }) => {
if (err) {
console.error("Errore durante il controllo della connessione Wi-Fi:", err);
console.error(err);
reject(err);
}
else {
console.log('isConnectedToWifi:');
console.log(obj);
resolve(obj.type == 'Wireless');
}
})

12
app/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "monerod-gui",
"version": "0.1.2",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "monerod-gui",
"version": "0.1.2",
"version": "1.0.0",
"dependencies": {
"adm-zip": "^0.5.16",
"applescript": "^1.0.0",
@ -19,7 +19,7 @@
"winreg": "^1.2.5"
},
"devDependencies": {
"@types/adm-zip": "^0.5.5",
"@types/adm-zip": "^0.5.6",
"@types/auto-launch": "^5.0.5",
"@types/battery-level": "^3.0.2",
"@types/pidusage": "^2.0.5",
@ -63,9 +63,9 @@
}
},
"node_modules/@types/adm-zip": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.5.tgz",
"integrity": "sha512-YCGstVMjc4LTY5uK9/obvxBya93axZOVOyf2GSUulADzmLhYE45u2nAssCs/fWBs1Ifq5Vat75JTPwd5XZoPJw==",
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.6.tgz",
"integrity": "sha512-lRlcSLg5Yoo7C2H2AUiAoYlvifWoCx/se7iUNiCBTfEVVYFVn+Tr9ZGed4K73tYgLe9O4PjdJvbxlkdAOx/qiw==",
"dev": true,
"dependencies": {
"@types/node": "*"

View file

@ -21,7 +21,7 @@
"winreg": "^1.2.5"
},
"devDependencies": {
"@types/adm-zip": "^0.5.5",
"@types/adm-zip": "^0.5.6",
"@types/auto-launch": "^5.0.5",
"@types/battery-level": "^3.0.2",
"@types/pidusage": "^2.0.5",

5
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "monerod-gui",
"version": "0.1.2",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "monerod-gui",
"version": "0.1.2",
"version": "1.0.0",
"funding": [
{
"type": "individual",
@ -24,6 +24,7 @@
"@angular/platform-browser": "18.2.11",
"@angular/platform-browser-dynamic": "18.2.11",
"@angular/router": "18.2.11",
"@popperjs/core": "2.11.8",
"bootstrap": "5.3.3",
"bootstrap-icons": "1.11.3",
"bootstrap-table": "1.23.5",

View file

@ -85,6 +85,7 @@
"@angular/platform-browser": "18.2.11",
"@angular/platform-browser-dynamic": "18.2.11",
"@angular/router": "18.2.11",
"@popperjs/core": "2.11.8",
"bootstrap": "5.3.3",
"bootstrap-icons": "1.11.3",
"bootstrap-table": "1.23.5",

View file

@ -59,7 +59,7 @@ export class DaemonTrayService {
console.debug(event);
this.disableAllItems();
this.daemonService.quit().then(() => this.disableAllItems()).catch((error: any) => console.error(error));
this.daemonService.quit().then().catch((error: any) => console.error(error));
});
window.electronAPI.onTrayStartSync((event: any) => {

View file

@ -37,13 +37,7 @@ export abstract class BasePageComponent implements AfterContentInit, OnDestroy {
const $table = $(`#${id}`);
$table.bootstrapTable({
search: true,
showSearchButton: true,
showColumnsSearch: true,
showColumns: true,
pagination: true
});
$table.bootstrapTable({});
$table.bootstrapTable('refreshOptions', {
classes: 'table table-bordered table-hover table-dark table-striped'
});

View file

@ -166,7 +166,7 @@
<div *ngIf="synchronized" class="row d-flex justify-content-center">
<h2><i class="bi bi-speedometer m-4"></i> Current Hashrate: {{networkHashRate}} GH/s</h2>
<h2><i class="bi bi-speedometer m-4"></i> Current Hashrate: {{networkHashRate}}</h2>
<canvas class="my-4 w-100" id="netHashRateChart" width="900" height="380"></canvas>
</div>

View file

@ -98,10 +98,32 @@ export class MiningComponent extends BasePageComponent implements AfterViewInit,
return this.daemonData.altChains;
}
public get networkHashRate(): number {
const origValue = this.daemonData.info ? this.daemonData.info.gigaHashRate : 0;
return parseFloat(origValue.toFixed(2));
public get networkHashRate(): string {
const info = this.daemonData.info;
if (!info) {
return "0 GH/s";
}
const origGHs = parseFloat(info.gigaHashRate.toFixed(2));
const origMHs = parseFloat(info.megaHashRate.toFixed(2));
const origKHs = parseFloat(info.kiloHashRate.toFixed(2));
const origHs = parseFloat(info.hashRate.toFixed(2));
if (origGHs >= 1) {
return `${origGHs} GH/s`;
}
else if (origMHs >= 1) {
return `${origMHs} MH/s`;
}
else if (origKHs >= 1) {
return `${origKHs} KH/s`;
}
else if (origHs >= 1) {
return `${origHs} H/s`;
}
return "0 GH/s";
}
private netHashRateChart?: Chart;

View file

@ -80,6 +80,10 @@ export class NetworkComponent extends BasePageComponent implements AfterViewInit
}
public async refreshConnectionsTable(): Promise<void> {
if (!await this.daemonService.isRunning()) {
return;
}
this.refreshingConnectionsTable = true;
try {

View file

@ -84,6 +84,10 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
}
public async refreshPeerListTable(): Promise<void> {
if (!await this.daemonService.isRunning()) {
return;
}
this.refreshingPeerList = true;
try {
@ -100,6 +104,10 @@ export class PeersComponent extends BasePageComponent implements AfterViewInit {
}
public async refreshPublicNodesTable(): Promise<void> {
if (!await this.daemonService.isRunning()) {
return;
}
this.refreshingPublicNodes = true;
try {

View file

@ -670,11 +670,6 @@
<input type="number" min="0" class="form-control" id="block-download-max-size" placeholder="" [(ngModel)]="currentSettings.blockDownloadMaxSize" [ngModelOptions]="{standalone: true}">
<small class="text-body-secondary">Set maximum size of block download queue in bytes (0 for default)</small>
</div>
<div class="col-md-4">
<label for="db-sync-mode" class="form-label">Database sync mode</label>
<input type="text" class="form-control" id="db-sync-mode" placeholder="fast:async:250000000bytes" [(ngModel)]="currentSettings.dbSyncMode" [ngModelOptions]="{standalone: true}">
</div>
<div class="form-check form-switch col-md-12">
<label for="sync-period-enabled" class="form-check-label">Sync Period Enabled</label>
@ -699,6 +694,44 @@
</div>
<hr class="my-4">
<div class="row g-3">
<h4 class="mb-3">Database Sync Mode</h4>
<div class="col-md-2">
<label for="db-sync-mode-speed" class="form-label"></label>
<select class="form-select" id="db-sync-mode-speed" (ngModelChange)="refreshSyncMode()" [(ngModel)]="databaseSyncSpeed" [ngModelOptions]="{standalone: true}">
<option [ngValue]="'safe'" [selected]="databaseSyncSpeed === 'safe'">Safe</option>
<option [ngValue]="'fast'" [selected]="databaseSyncSpeed === 'fast'">Fast</option>
<option [ngValue]="'fastest'" [selected]="databaseSyncSpeed === 'fastest'">Fastest</option>
</select>
</div>
<div class="col-md-2">
<label for="db-sync-mode" class="form-label"></label>
<select class="form-select" id="db-sync-mode" (ngModelChange)="refreshSyncMode()" [(ngModel)]="databaseSyncMode" [ngModelOptions]="{standalone: true}">
<option [ngValue]="'sync'" [selected]="databaseSyncMode === 'sync'">Sync</option>
<option [ngValue]="'async'" [selected]="databaseSyncMode === 'async'">Async</option>
</select>
</div>
<div class="col-md-4">
<label for="db-sync-mode-n-bytes-or-blocks" class="form-label"></label>
<input type="number" min="0" class="form-control" id="db-sync-mode-n-bytes-or-blocks" placeholder="" (ngModelChange)="refreshSyncMode()" [(ngModel)]="databaseSyncNBytesOrBlocks" [ngModelOptions]="{standalone: true}">
<small class="text-body-secondary">Number of bytes/blocks</small>
</div>
<div class="col-md-2">
<label for="db-sync-n-per-mode" class="form-label"></label>
<select class="form-select" id="db-sync-n-per-mode" (ngModelChange)="refreshSyncMode()" [(ngModel)]="databaseSyncNPerMode" [ngModelOptions]="{standalone: true}">
<option [ngValue]="'bytes'" [selected]="databaseSyncNPerMode === 'bytes'">Bytes</option>
<option [ngValue]="'blocks'" [selected]="databaseSyncNPerMode === 'blocks'">Blocks</option>
</select>
</div>
</div>
</form>
</div>
</div>

View file

@ -26,6 +26,15 @@ export class SettingsComponent {
public networkType: 'mainnet' | 'testnet' | 'stagenet' = 'mainnet';
public successMessage: string = '';
public databaseSyncSpeed: 'safe' | 'fast' | 'fastest' = 'fast';
public databaseSyncMode: 'sync' | 'async' = 'async';
public databaseSyncNBytesOrBlocks: number = 250000000;
public databaseSyncNPerMode: 'bytes' | 'blocks' = 'bytes';
private get dbSyncMode(): string {
return `${this.databaseSyncSpeed}:${this.databaseSyncMode}:${this.databaseSyncNBytesOrBlocks}${this.databaseSyncNPerMode}`;
}
constructor(private daemonService: DaemonService, private electronService: ElectronService, private ngZone: NgZone) {
this.loading = true;
@ -61,14 +70,46 @@ export class SettingsComponent {
public isAppImage: boolean = true;
public refreshSyncMode(): void {
this.currentSettings.dbSyncMode = this.dbSyncMode;
}
private initSyncMode(): void {
if (!this.currentSettings) {
return;
}
const dbSyncMode = this.currentSettings.dbSyncMode;
if (dbSyncMode == '') {
return;
}
const cmps = dbSyncMode.split(":");
if (cmps.length != 3) {
return;
}
const speed: 'safe' | 'fast' | 'fastest' = (cmps[0] == 'safe' || cmps[0] == 'fast' || cmps[0] == 'fastest') ? cmps[0] : 'fast';
const mode: 'sync' | 'async' = (cmps[1] == 'sync' || cmps[1] == 'async') ? cmps[1] : 'async';
const nPerMode: 'bytes' | 'blocks' = cmps[2].endsWith('blocks') ? 'blocks' : 'bytes';
const n: number = parseInt(cmps[2].replace(nPerMode, ''));
this.databaseSyncSpeed = speed;
this.databaseSyncMode = mode;
this.databaseSyncNPerMode = nPerMode;
this.databaseSyncNBytesOrBlocks = n;
}
private async load(): Promise<void> {
console.log("getting settings");
this.originalSettings = await this.daemonService.getSettings();
this.currentSettings = this.originalSettings.clone();
this.initSyncMode();
this.loading = false;
this.isAppImage = await this.electronService.isAppImage();
this.networkType = this.currentSettings.mainnet ? 'mainnet' : this.currentSettings.testnet ? 'testnet' : this.currentSettings.stagenet ? 'stagenet' : 'mainnet';
}

View file

@ -21,7 +21,9 @@ export class DaemonNotRunningComponent implements OnDestroy {
return this.statusService.daemonRunning;
}
public daemonConfigured: boolean = true;
public get daemonConfigured(): boolean {
return this.statusService.daemonConfigured;
}
public get disablingSync(): boolean {
return this.statusService.disablingSync;

View file

@ -9,7 +9,6 @@ import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { NavbarComponent } from './components/navbar/navbar.component';
import 'jquery';
import 'bootstrap';
import 'bootstrap-table';

View file

@ -1,6 +1,7 @@
$primary: #ff5733;
@import "/node_modules/bootstrap/scss/bootstrap";
@import "/node_modules/bootstrap-table/dist/bootstrap-table.min.css";
.bi {
display: inline-block;