Skip to content

Commit

Permalink
General improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
everoddandeven committed Oct 17, 2024
1 parent 0e5c483 commit 8c3a62d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/app/core/services/daemon/daemon-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,19 @@ export class DaemonDataService {


this._gettingIsBlockchainPruned = true;
//if (firstRefresh) this._isBlockchainPruned = (await this.daemonService.pruneBlockchain(true)).pruned;

const settings = await this.daemonService.getSettings();
this._isBlockchainPruned = settings.pruneBlockchain;
/*
if (firstRefresh) {
this.daemonService.pruneBlockchain(true).then((info) => {
this._isBlockchainPruned = info.pruned;
}).catch((error) => {
console.error(error);
});
}
*/

this._gettingIsBlockchainPruned = false;

if (this._daemonInfo.synchronized) await this.refreshAltChains();
Expand Down
19 changes: 18 additions & 1 deletion src/app/core/services/daemon/daemon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,24 @@ export class DaemonService {
window.electronAPI.monitorMonerod();

return await getProcessStatsPromise;
}
}

private _quitting: boolean = false;

public get quitting(): boolean {
return this._quitting;
}

public async quit(): Promise<void> {
this._quitting = true;
const running: boolean = await this.isRunning();

if (running) {
await this.stopDaemon();
}

window.electronAPI.quit();
}

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<div *ngIf="!daemonRunning || stoppingDaemon || restartingDaemon" class="h-100 p-5 text-bg-dark rounded-3 m-4 text-center">
<h2 *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && daemonConfigured"><i class="bi bi-exclamation-diamond m-4"></i> Daemon not running</h2>
<h2 *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && !daemonConfigured"><i class="bi bi-exclamation-diamond m-4"></i> Daemon not configured or installed</h2>
<h2 *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && daemonConfigured && !quittingDaemon"><i class="bi bi-exclamation-diamond m-4"></i> Daemon not running</h2>
<h2 *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && !daemonConfigured && !quittingDaemon"><i class="bi bi-exclamation-diamond m-4"></i> Daemon not configured or installed</h2>
<h2 *ngIf="restartingDaemon && !upgrading"><i class="bi bi-arrow-clockwise m-4"></i> Daemon restarting</h2>
<h2 *ngIf="stoppingDaemon && !upgrading"><i class="bi bi-stop-fill m-4"></i> Daemon is stopping</h2>
<h2 *ngIf="stoppingDaemon && !upgrading && !quittingDaemon"><i class="bi bi-stop-fill m-4"></i> Daemon is stopping</h2>
<h2 *ngIf="upgrading"><i class="bi bi-cloud-download m-4"></i> Daemon is upgrading</h2>
<h2 *ngIf="quittingDaemon"><i class="bi bi-power m-4"></i> Daemon is quiting</h2>

<p *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && daemonConfigured && !upgrading">Start monero daemon</p>
<p *ngIf="!startingDaemon && !startingDaemon && !stoppingDaemon && !restartingDaemon && !daemonConfigured && !upgrading">Configure or install monero daemon</p>
<p *ngIf="!daemonRunning && !startingDaemon && !stoppingDaemon && !restartingDaemon && daemonConfigured && !upgrading && !quittingDaemon">Start monero daemon</p>
<p *ngIf="!startingDaemon && !startingDaemon && !stoppingDaemon && !restartingDaemon && !daemonConfigured && !upgrading && !quittingDaemon">Configure or install monero daemon</p>

<h2 *ngIf="startingDaemon"><i class="bi bi-play-fill m-4"></i> Daemon is starting</h2>
<p *ngIf="startingDaemon">Starting monero daemon</p>
<p *ngIf="restartingDaemon">Restarting monero daemon</p>
<p *ngIf="upgrading">Upgrading monero daemon to latest version</p>
<p *ngIf="quittingDaemon">Quiting monero daemon</p>

<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && daemonConfigured" class="btn btn-outline-light" type="button" (click)="startDaemon()"><i class="bi bi-play-fill"></i> Start</button>
<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && daemonConfigured && !quittingDaemon" class="btn btn-outline-light" type="button" (click)="startDaemon()"><i class="bi bi-play-fill"></i> Start</button>
<button *ngIf="startingDaemon" class="btn btn-outline-light" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Starting monerod
Expand All @@ -24,18 +26,23 @@ <h2 *ngIf="startingDaemon"><i class="bi bi-play-fill m-4"></i> Daemon is startin
Restarting monerod
</button>

<button *ngIf="stoppingDaemon" class="btn btn-outline-light" type="button" disabled>
<button *ngIf="stoppingDaemon && !quittingDaemon" class="btn btn-outline-light" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Stopping monerod
</button>

<button *ngIf="quittingDaemon" class="btn btn-outline-light" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Quiting monerod
</button>

<button *ngIf="upgrading" class="btn btn-outline-light" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
{{ progressStatus }}
</button>

&nbsp;
<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading" routerLink="/settings" class="btn btn-outline-light" type="button"><i class="bi bi-gear"></i> Configure</button>
<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && !quittingDaemon" routerLink="/settings" class="btn btn-outline-light" type="button"><i class="bi bi-gear"></i> Configure</button>
&nbsp;
<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && !daemonConfigured" routerLink="/version" class="btn btn-outline-light" type="button"><i class="bi bi-arrow-down-circle"></i> Install</button>
<button *ngIf="!startingDaemon && !stoppingDaemon && !restartingDaemon && !upgrading && !daemonConfigured && !quittingDaemon" routerLink="/version" class="btn btn-outline-light" type="button"><i class="bi bi-arrow-down-circle"></i> Install</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import { DaemonDataService, MoneroInstallerService } from '../../../core/service
export class DaemonNotRunningComponent {

public get upgrading(): boolean {
return this.installer.upgrading;
return this.installer.upgrading && !this.quittingDaemon;
}

public get daemonRunning(): boolean {
return this.daemonData.running && !this.startingDaemon && !this.stoppingDaemon && !this.restartingDaemon && !this.upgrading;
return this.daemonData.running && !this.startingDaemon && !this.stoppingDaemon && !this.restartingDaemon && !this.upgrading && !this.quittingDaemon;
}

public daemonConfigured: boolean = true;

public get startingDaemon(): boolean {
return this.daemonService.starting && !this.restartingDaemon && !this.stoppingDaemon && !this.upgrading;
return this.daemonService.starting && !this.restartingDaemon && !this.stoppingDaemon && !this.upgrading && !this.quittingDaemon;
}

public get stoppingDaemon(): boolean{
return this.daemonData.stopping && !this.restartingDaemon && !this.startingDaemon && !this.upgrading;
return this.daemonData.stopping && !this.restartingDaemon && !this.startingDaemon && !this.upgrading && !this.quittingDaemon;
}

public get restartingDaemon(): boolean {
return this.daemonService.restarting && ! this.upgrading;
return this.daemonService.restarting && ! this.upgrading && !this.quittingDaemon;
}

public get progressStatus(): string {
Expand All @@ -41,6 +41,10 @@ export class DaemonNotRunningComponent {
return progress.status;
}

public get quittingDaemon(): boolean {
return this.daemonService.quitting;
}

constructor(private installer: MoneroInstallerService, private daemonData: DaemonDataService, private daemonService: DaemonService, private ngZone: NgZone) {
this.daemonService.getSettings().then((settings) => {
this.daemonConfigured = settings.monerodPath != '';
Expand Down
8 changes: 4 additions & 4 deletions src/app/shared/components/navbar/navbar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@
</span>

<ul class="navbar-nav flex-row">
<li *ngIf="!running && !stopping && !starting && !restarting" class="nav-item text-nowrap">
<li *ngIf="!quitting && !running && !stopping && !starting && !restarting" class="nav-item text-nowrap">
<button class="btn btn-outline-secondary px-3 text-white" type="button" data-bs-toggle="collapse" aria-expanded="false" aria-label="Start daemon" (click)="startDaemon()">
<i class="bi bi-play-fill"></i>
</button>
&nbsp;
</li>

<li *ngIf="running && !stopping && !starting" class="nav-item text-nowrap">
<li *ngIf="!quitting && running && !stopping && !starting" class="nav-item text-nowrap">
<button class="btn btn-outline-secondary px-3 text-white" type="button" data-bs-toggle="collapse" aria-expanded="false" aria-label="Stop daemon" (click)="stopDaemon()">
<i class="bi bi-stop-fill"></i>
</button>
&nbsp;
</li>

<li *ngIf="running && !stopping && !starting" class="nav-item text-nowrap">
<li *ngIf="!quitting && running && !stopping && !starting" class="nav-item text-nowrap">
<button class="btn btn-outline-secondary px-3 text-white" type="button" data-bs-toggle="collapse" aria-expanded="false" aria-label="Restart daemon" (click)="restartDaemon()">
<i class="bi bi-arrow-clockwise"></i>
</button>
&nbsp;
</li>

<li class="nav-item text-nowrap">
<button class="btn btn-outline-secondary px-3 text-white" type="button" data-bs-toggle="offcanvas" aria-label="Quit" [disabled]="stopping || starting" (click)="quit()">
<button class="btn btn-outline-secondary px-3 text-white" type="button" data-bs-toggle="offcanvas" aria-label="Quit" [disabled]="stopping || starting || quitting || restarting" (click)="quit()">
<i class="bi bi-power"></i>
</button>
&nbsp;
Expand Down
12 changes: 5 additions & 7 deletions src/app/shared/components/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export class NavbarComponent {

private _running: boolean = false;

public get quitting(): boolean {
return this.daemonService.quitting;
}

public get navbarLinks(): NavbarLink[] {
return this.navbarService.links;
}
Expand Down Expand Up @@ -72,12 +76,6 @@ export class NavbarComponent {
}

public async quit(): Promise<void> {
const running: boolean = await this.daemonService.isRunning();

if (running) {
await this.stopDaemon();
}

window.electronAPI.quit();
await this.daemonService.quit();
}
}
1 change: 1 addition & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ declare global {
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
unsubscribeOnMonerodStarted: () => void;
onMoneroClose: (callback: (event: any, code: number) => void) => void;
onMoneroStdout: (callbak: (event: any, out: string) => void) => void;
isWifiConnected: () => void;
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
selectFolder: () => void;
Expand Down

0 comments on commit 8c3a62d

Please sign in to comment.