Skip to content

Commit

Permalink
Minor fixes, hash rate chart, refactory about page
Browse files Browse the repository at this point in the history
  • Loading branch information
everoddandeven committed Nov 6, 2024
1 parent 49ab64c commit 920a9cf
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 85 deletions.
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"node_modules/bootstrap-table/dist/bootstrap-table.min.js"
],
"styles": [
"src/styles.scss",
"node_modules/bootstrap-icons/font/bootstrap-icons.css",
"node_modules/bootstrap-table/dist/bootstrap-table.min.css"
"node_modules/bootstrap-table/dist/bootstrap-table.min.css",
"src/styles.scss"
],
"customWebpackConfig": {
"path": "./angular.webpack.js",
Expand Down
19 changes: 15 additions & 4 deletions app/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app, BrowserWindow, ipcMain, screen, dialog, Tray, Menu, MenuItemConstructorOptions,
IpcMainInvokeEvent, Notification, NotificationConstructorOptions
IpcMainInvokeEvent, Notification, NotificationConstructorOptions, clipboard,
} from 'electron';
import { ChildProcessWithoutNullStreams, exec, ExecException, spawn } from 'child_process';
import * as path from 'path';
Expand Down Expand Up @@ -254,7 +254,11 @@ function createWindow(): BrowserWindow {
return win;
}

const createSplashWindow = async (): Promise<BrowserWindow> => {
const createSplashWindow = async (): Promise<BrowserWindow | undefined> => {

if (os.platform() == 'win32') {
return undefined;
}

const window = new BrowserWindow({
width: 480,
Expand Down Expand Up @@ -713,8 +717,11 @@ try {
await new Promise<void>((resolve, reject) => {
try {
setTimeout(() => {
splash.close();
if (!minimized) win?.show();
if (splash) splash.close();
if (!minimized) {
win?.show();
win?.maximize();
}
resolve();
}, 2600);
}
Expand Down Expand Up @@ -1030,6 +1037,10 @@ try {
win?.webContents.send('on-is-app-image', isAppImage ? true : false);
});

ipcMain.handle('copy-to-clipboard', (event: IpcMainInvokeEvent, content: string) => {
clipboard.writeText(content, "selection");
});

} catch (e) {
// Catch Error
console.error(e);
Expand Down
3 changes: 3 additions & 0 deletions app/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
copyToClipboard: (content) => {
ipcRenderer.invoke('copy-to-clipboard', content);
},
onTrayStartDaemon: (callback) => {
ipcRenderer.on('on-tray-start-daemon', callback);
},
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions src/app/core/services/daemon/daemon-data.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter, Injectable, NgZone } from '@angular/core';
import { DaemonService } from './daemon.service';
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, ProcessStats, PublicNode, SyncInfo, TimeUtils, TxBacklogEntry, TxPool, TxPoolStats } from '../../../../common';
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetHashRateHistory, NetStats, NetStatsHistory, PeerInfo, ProcessStats, PublicNode, SyncInfo, TimeUtils, TxBacklogEntry, TxPool, TxPoolStats } from '../../../../common';
import { ElectronService } from '../electron/electron.service';

@Injectable({
Expand Down Expand Up @@ -42,6 +42,8 @@ export class DaemonDataService {
private _netStatsHistory: NetStatsHistory = new NetStatsHistory();
private _gettingNetStats: boolean = false;

private _hashRateHistory: NetHashRateHistory = new NetHashRateHistory();

private _miningStatus?: MiningStatus;
private _gettingMiningStatus: boolean = false;

Expand Down Expand Up @@ -81,6 +83,7 @@ export class DaemonDataService {

this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
this.ngZone.run(() => {
this._hashRateHistory = new NetHashRateHistory();
if (running) {
this._daemonRunning = true;
this.startLoop();
Expand Down Expand Up @@ -253,6 +256,10 @@ export class DaemonDataService {
return this._gettingTxPoolStats;
}

public get netHashRateHistory(): NetHashRateHistory {
return this._hashRateHistory;
}

public setRefreshTimeout(ms: number = 5000): void {
this.refreshTimeoutMs = ms;
}
Expand Down Expand Up @@ -356,14 +363,7 @@ export class DaemonDataService {

try {
const settings = await this.daemonService.getSettings();

const updateInfo = await this.daemonService.checkUpdate()

if (updateInfo.update && settings.upgradeAutomatically) {
await this.daemonService.upgrade();
return;
}


const syncAlreadyDisabled = this.daemonService.settings.noSync;

if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) {
Expand Down Expand Up @@ -440,9 +440,17 @@ export class DaemonDataService {
this._daemonInfo = await this.daemonService.getInfo();
this._gettingDaemonInfo = false;

if (this._daemonInfo.synchronized) {
this._hashRateHistory.add(this._daemonInfo.gigaHashRate);
}

if (this.daemonService.settings.upgradeAutomatically && this._daemonInfo.updateAvailable) {
await this.daemonService.upgrade();
return;
const updateInfo = await this.daemonService.checkUpdate()

if (updateInfo.update) {
await this.daemonService.upgrade();
return;
}
}

this._gettingSyncInfo = true;
Expand Down
93 changes: 60 additions & 33 deletions src/app/pages/about/about.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ <h1 class="h2">About</h1>
<div class="tab-pane fade show active" id="pills-overview" role="tabpanel" aria-labelledby="pills-overview-tab" tabindex="0">
<div class="container mt-5">
<div class="card shadow-lg border-0">

<div class="card-header bg-primary text-white text-center">
<h3 class="card-title mb-0">Monerod GUI</h3>
</div>

<div class="card-body">
<h5 class="card-subtitle mb-2 text-muted">Version: {{ guiVersion }}</h5>
<p class="card-text">
Expand All @@ -32,51 +34,76 @@ <h5 class="card-subtitle mb-2 text-muted">Version: {{ guiVersion }}</h5>
<br>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. </p>

<div class="row mt-4">
<div class="col-md-12">
<h6>Donations</h6>
<div class="card">
<div class="card-body">
<ul class="list-group">
<li class="list-group-item text-center">
<h4>XMR</h4>
<br>
<p class="text-center">
<img src="assets/donations/xmr.png" width="200" height="200"/><br>
<br>
<code>84Q1SdQgFWaEWRn5KcvSPCQUa3NF39EJ3HPCTaiM86RHLLftqgTZpkP24jXrK5YpeedWbQAjHcFcDLpFJfr9TypfAU7pPjA</code>
</p>
</li>
<li class="list-group-item text-center">
<h4>BTC</h4>
<br>
<p class="text-center">
<img src="assets/donations/btc.png" width="200" height="200"/><br>
<br>
<code>bc1qndc2lesy0sse9vj33a35pnfrqz4znlhhs58vfp</code>
</p>

</li>
</ul>
</div>
</div>
</div>
<div class="card-footer text-muted d-flex justify-content-between align-items-center">
<span>&copy; 2024 Monerod GUI</span>
</div>
</div>
</div>
</div>

</div>

<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab" tabindex="0">
<div class="container mt-5">
<div class="card shadow-lg border-0">

<div class="card-header bg-primary text-white text-center">
<h3 class="card-title mb-0">Contact</h3>
</div>

<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item"><i class="bi bi-github fs-4 m-4"></i> <strong>GitHub:</strong> https://github.com/everoddandeven/monerod-gui</li>
<li class="list-group-item"><i class="bi bi-chat-square-quote fs-4 m-4"></i> <strong>Matrix:</strong> &#64;everoddandeven:monero.social</li>
<li class="list-group-item"><i class="bi bi-envelope fs-4 m-4"></i> <strong>Email:</strong> everoddandeven&#64;protonmail.com</li>
<li class="list-group-item"><i class="bi bi-signal fs-4 m-4"></i><strong>Signal:</strong> &#64;everoddandeven.01</li>
</ul>
</div>
<div class="card-footer text-muted d-flex justify-content-between align-items-center">
<span>&copy; 2024 Monerod GUI</span>
<div>
</div>

</div>
</div>

</div>

<div class="tab-pane fade" id="pills-donate" role="tabpanel" aria-labelledby="pills-donate-tab" tabindex="0">
<div class="container mt-5">
<div class="card shadow-lg border-0">

<div class="card-header bg-primary text-white text-center">
<h3 class="card-title mb-0">Donate</h3>
</div>

<div class="card-body">
<ul class="list-group">
<li class="list-group-item text-center">

<div class="col-md-2 mx-auto">
<select class="form-select" id="log-level" [(ngModel)]="donateCrypto" [ngModelOptions]="{standalone: true}">
<option [ngValue]="'XMR'">XMR</option>
<option [ngValue]="'BTC'">BTC</option>
</select>
</div>

<br>
<p *ngIf="donateCrypto === 'XMR'" class="text-center">
<img src="assets/donations/xmr.png" width="200" height="200"/><br>
<br>
<code>{{XMRAddress}}</code>
</p>
<p *ngIf="donateCrypto === 'BTC'" class="text-center">
<img src="assets/donations/btc.png" width="200" height="200"/><br>
<br>
<code>{{BTCAddress}}</code>
</p>
<button *ngIf="!addressCopied" type="button" class="btn btn-secondary btn-sm" (click)="copyAddressToClipboard()"><i class="bi bi-clipboard"></i> Copy to clipboard</button>
<button *ngIf="addressCopied" type="button" class="btn btn-success btn-sm" ><i class="bi bi-clipboard-check"></i> Copied to clipboard</button>
</li>
</ul>
</div>

</div>
</div>

</div>

</div>
18 changes: 17 additions & 1 deletion src/app/pages/about/about.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import { DaemonService } from '../../core/services';
})
export class AboutComponent {
public readonly links: NavbarLink[] = [
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', true, 'Overview')
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', true, 'License', false),
new NavbarLink('pills-contact-tab', '#pills-contact', 'pills-contact', false, 'Contact', false),
new NavbarLink('pills-donate-tab', '#pills-donate', 'pills-donate', false, 'Donate', false)
];

public donateCrypto: 'XMR' | 'BTC' = 'XMR';
public readonly XMRAddress: string = '84Q1SdQgFWaEWRn5KcvSPCQUa3NF39EJ3HPCTaiM86RHLLftqgTZpkP24jXrK5YpeedWbQAjHcFcDLpFJfr9TypfAU7pPjA';
public readonly BTCAddress: string = 'bc1qndc2lesy0sse9vj33a35pnfrqz4znlhhs58vfp';
public addressCopied: boolean = false;

public get guiVersion(): string {
return this.daemonService.getGuiVersion();
}
Expand All @@ -20,5 +27,14 @@ export class AboutComponent {

}

public copyAddressToClipboard(): void {
window.electronAPI.copyToClipboard(this.donateCrypto == 'XMR' ? this.XMRAddress : this.BTCAddress);
this.addressCopied = true;

setTimeout(() => {
this.addressCopied = false;
}, 1500);
}

}

15 changes: 8 additions & 7 deletions src/app/pages/logs/logs.component.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.terminal {
max-height: 700px;
overflow-y: auto;
font-family: monospace;
border: 1px solid #333;
border-radius: 5px;
}
max-height: 600px;
overflow-y: auto;
font-family: monospace;
border: 1px solid #333;
border-radius: 5px;
}

.terminal-output {
white-space: pre-wrap;
white-space: pre-wrap;
font-size: small;
}
Loading

0 comments on commit 920a9cf

Please sign in to comment.