mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2025-03-25 08:38:45 +00:00
Components refactory
This commit is contained in:
parent
2614ad0919
commit
a4db0fb1f3
4 changed files with 42 additions and 44 deletions
|
@ -2,7 +2,7 @@
|
||||||
<h1 class="h2">Logs</h1>
|
<h1 class="h2">Logs</h1>
|
||||||
<div class="btn-toolbar mb-2 mb-md-0">
|
<div class="btn-toolbar mb-2 mb-md-0">
|
||||||
<ul class="nav nav-pills m-3" id="pills-tab" role="tablist">
|
<ul class="nav nav-pills m-3" id="pills-tab" role="tablist">
|
||||||
@for(navbarLink of navbarLinks; track navbarLink.name) {
|
@for(navbarLink of links; track navbarLink.name) {
|
||||||
<li class="nav-item mr-2" role="presentation">
|
<li class="nav-item mr-2" role="presentation">
|
||||||
<button [class]="navbarLink.selected ? 'nav-link active btn-sm' : 'nav-link btn-sm'" [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>
|
<button [class]="navbarLink.selected ? 'nav-link active btn-sm' : 'nav-link btn-sm'" [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>
|
</li>
|
||||||
|
|
|
@ -4,15 +4,16 @@ import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
||||||
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
||||||
import { DaemonService } from '../../core/services';
|
import { DaemonService } from '../../core/services';
|
||||||
import { LogCategories } from '../../../common';
|
import { LogCategories } from '../../../common';
|
||||||
|
import { BasePageComponent } from '../base-page/base-page.component';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-logs',
|
selector: 'app-logs',
|
||||||
templateUrl: './logs.component.html',
|
templateUrl: './logs.component.html',
|
||||||
styleUrl: './logs.component.scss'
|
styleUrl: './logs.component.scss'
|
||||||
})
|
})
|
||||||
export class LogsComponent implements AfterViewInit {
|
export class LogsComponent extends BasePageComponent implements AfterViewInit {
|
||||||
@ViewChild('logTerminal', { read: ElementRef }) public logTerminal?: ElementRef<any>;
|
@ViewChild('logTerminal', { read: ElementRef }) public logTerminal?: ElementRef<any>;
|
||||||
public readonly navbarLinks: NavbarLink[];
|
|
||||||
|
|
||||||
public setLogLevelLevel: number = 0;
|
public setLogLevelLevel: number = 0;
|
||||||
public settingLogLevel: boolean = false;
|
public settingLogLevel: boolean = false;
|
||||||
|
@ -34,17 +35,22 @@ export class LogsComponent implements AfterViewInit {
|
||||||
public setLogHashRateError: string = '';
|
public setLogHashRateError: string = '';
|
||||||
public setLogHashRateSuccess: boolean = false;
|
public setLogHashRateSuccess: boolean = false;
|
||||||
|
|
||||||
constructor(private navbarService: NavbarService, private logsService: LogsService, private daemonService: DaemonService, private ngZone: NgZone) {
|
constructor(navbarService: NavbarService, private logsService: LogsService, private daemonService: DaemonService, private ngZone: NgZone) {
|
||||||
this.logsService.onLog.subscribe((message: string) => {
|
super(navbarService);
|
||||||
|
|
||||||
|
const onLogSub: Subscription = this.logsService.onLog.subscribe((message: string) => {
|
||||||
console.debug(message);
|
console.debug(message);
|
||||||
this.onLog()
|
this.onLog()
|
||||||
});
|
});
|
||||||
this.navbarLinks = [
|
|
||||||
|
this.setLinks([
|
||||||
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', false, 'Overview'),
|
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', false, 'Overview'),
|
||||||
new NavbarLink('pills-set-log-level-tab', '#pills-set-log-level', 'pills-set-log-level', false, 'Set Log Level'),
|
new NavbarLink('pills-set-log-level-tab', '#pills-set-log-level', 'pills-set-log-level', false, 'Set Log Level'),
|
||||||
new NavbarLink('pills-set-log-categories-tab', '#pills-set-log-categories', 'pills-set-log-categories', false, 'Set Log Categories'),
|
new NavbarLink('pills-set-log-categories-tab', '#pills-set-log-categories', 'pills-set-log-categories', false, 'Set Log Categories'),
|
||||||
new NavbarLink('pills-set-log-hash-rate-tab', '#pills-set-log-hash-rate', 'pills-set-log-hash-rate', false, 'Set Log Hash Rate')
|
new NavbarLink('pills-set-log-hash-rate-tab', '#pills-set-log-hash-rate', 'pills-set-log-hash-rate', false, 'Set Log Hash Rate')
|
||||||
];
|
]);
|
||||||
|
|
||||||
|
this.subscriptions.push(onLogSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get lines(): string[] {
|
public get lines(): string[] {
|
||||||
|
@ -80,9 +86,7 @@ export class LogsComponent implements AfterViewInit {
|
||||||
return index; // usa l'indice per tracciare gli elementi
|
return index; // usa l'indice per tracciare gli elementi
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngAfterViewInit(): void {
|
public ngAfterViewInit(): void {
|
||||||
this.navbarService.setLinks(this.navbarLinks);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<h1 class="h2">Network</h1>
|
<h1 class="h2">Network</h1>
|
||||||
<div class="btn-toolbar mb-2 mb-md-0">
|
<div class="btn-toolbar mb-2 mb-md-0">
|
||||||
<ul class="nav nav-pills m-3" id="pills-tab" role="tablist">
|
<ul class="nav nav-pills m-3" id="pills-tab" role="tablist">
|
||||||
@for(navbarLink of navbarLinks; track navbarLink.name) {
|
@for(navbarLink of links; track navbarLink.name) {
|
||||||
<li class="nav-item mr-2" role="presentation">
|
<li class="nav-item mr-2" role="presentation">
|
||||||
<button [class]="navbarLink.selected ? 'nav-link active btn-sm' : 'nav-link btn-sm'" [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>
|
<button [class]="navbarLink.selected ? 'nav-link active btn-sm' : 'nav-link btn-sm'" [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>
|
</li>
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { AfterViewInit, Component, OnDestroy } from '@angular/core';
|
import { AfterViewInit, Component } from '@angular/core';
|
||||||
import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
import { NavbarService } from '../../shared/components/navbar/navbar.service';
|
||||||
import { DaemonDataService, DaemonService } from '../../core/services';
|
import { DaemonDataService, DaemonService } from '../../core/services';
|
||||||
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
|
||||||
import { Chart, ChartData } from 'chart.js/auto'
|
import { Chart, ChartData } from 'chart.js/auto'
|
||||||
import { NetStatsHistoryEntry } from '../../../common';
|
import { NetStatsHistoryEntry } from '../../../common';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
import { BasePageComponent } from '../base-page/base-page.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-network',
|
selector: 'app-network',
|
||||||
templateUrl: './network.component.html',
|
templateUrl: './network.component.html',
|
||||||
styleUrl: './network.component.scss'
|
styleUrl: './network.component.scss'
|
||||||
})
|
})
|
||||||
export class NetworkComponent implements AfterViewInit, OnDestroy {
|
export class NetworkComponent extends BasePageComponent implements AfterViewInit {
|
||||||
public readonly navbarLinks: NavbarLink[];
|
|
||||||
|
|
||||||
private netStatsBytesInChart?: Chart;
|
private netStatsBytesInChart?: Chart;
|
||||||
private netStatsBytesOutChart?: Chart;
|
private netStatsBytesOutChart?: Chart;
|
||||||
|
@ -32,14 +32,13 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
|
||||||
public setLimitSuccess: boolean = false;
|
public setLimitSuccess: boolean = false;
|
||||||
public setLimitError: string = '';
|
public setLimitError: string = '';
|
||||||
|
|
||||||
private subscriptions: Subscription[] = [];
|
constructor(navbarService: NavbarService, private daemonService: DaemonService, private daemonData: DaemonDataService) {
|
||||||
|
super(navbarService);
|
||||||
constructor(private navbarService: NavbarService, private daemonService: DaemonService, private daemonData: DaemonDataService) {
|
this.setLinks([
|
||||||
this.navbarLinks = [
|
|
||||||
new NavbarLink('pills-net-stats-tab', '#pills-net-stats', 'pills-net-stats', false, 'Statistics'),
|
new NavbarLink('pills-net-stats-tab', '#pills-net-stats', 'pills-net-stats', false, 'Statistics'),
|
||||||
new NavbarLink('pills-connections-tab', '#pills-connections', 'connections', false, 'Connetions'),
|
new NavbarLink('pills-connections-tab', '#pills-connections', 'connections', false, 'Connetions'),
|
||||||
new NavbarLink('pills-limits-tab', '#pills-limit', 'pills-limit', false, 'Limit')
|
new NavbarLink('pills-limits-tab', '#pills-limit', 'pills-limit', false, 'Limit')
|
||||||
];
|
]);
|
||||||
|
|
||||||
const netStatsRefreshStartSub: Subscription = this.daemonData.netStatsRefreshEnd.subscribe(() => {
|
const netStatsRefreshStartSub: Subscription = this.daemonData.netStatsRefreshEnd.subscribe(() => {
|
||||||
this.refreshNetStatsHistory();
|
this.refreshNetStatsHistory();
|
||||||
|
@ -49,44 +48,29 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
|
||||||
this.loadConnectionsTable();
|
this.loadConnectionsTable();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.subscriptions.push(netStatsRefreshStartSub, syncEndSub);
|
const daemonStatusSub: Subscription = this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
||||||
|
|
||||||
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
|
|
||||||
if (!running) {
|
if (!running) {
|
||||||
if (this.netStatsBytesInChart) {
|
if (this.netStatsBytesInChart) {
|
||||||
this.netStatsBytesInChart.destroy();
|
this.netStatsBytesInChart.destroy();
|
||||||
this.netStatsBytesInChart = undefined;
|
this.netStatsBytesInChart = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.initNetStatsHistoryChart();
|
||||||
|
this.loadConnectionsTable();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.subscriptions.push(netStatsRefreshStartSub, syncEndSub, daemonStatusSub);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngAfterViewInit(): void {
|
public ngAfterViewInit(): void {
|
||||||
this.navbarService.setLinks(this.navbarLinks);
|
|
||||||
this.initNetStatsHistoryChart();
|
this.initNetStatsHistoryChart();
|
||||||
this.initConnectionsTable();
|
this.loadConnectionsTable();
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnDestroy(): void {
|
|
||||||
this.subscriptions.forEach((sub) => {
|
|
||||||
sub.unsubscribe();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.subscriptions = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private initConnectionsTable(): void {
|
|
||||||
const $table = $('#connectionsTable');
|
|
||||||
$table.bootstrapTable({});
|
|
||||||
$table.bootstrapTable('refreshOptions', {
|
|
||||||
classes: 'table table-bordered table-hover table-dark table-striped'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadConnectionsTable(): void {
|
private loadConnectionsTable(): void {
|
||||||
const $table = $('#connectionsTable');
|
this.loadTable('connectionsTable', this.daemonData.connections);
|
||||||
|
|
||||||
$table.bootstrapTable('load', this.daemonData.connections);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildChartBytesInData(): ChartData {
|
private buildChartBytesInData(): ChartData {
|
||||||
|
@ -141,12 +125,17 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: this.buildChartBytesInData(),
|
data: this.buildChartBytesInData(),
|
||||||
options: {
|
options: {
|
||||||
|
animation: false,
|
||||||
plugins: {
|
plugins: {
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
boxPadding: 3
|
boxPadding: 3
|
||||||
|
},
|
||||||
|
decimation: {
|
||||||
|
enabled: true,
|
||||||
|
algorithm: 'min-max'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,12 +145,17 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: this.buildChartBytesOutData(),
|
data: this.buildChartBytesOutData(),
|
||||||
options: {
|
options: {
|
||||||
|
animation: false,
|
||||||
plugins: {
|
plugins: {
|
||||||
legend: {
|
legend: {
|
||||||
display: false
|
display: false
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
boxPadding: 3
|
boxPadding: 3
|
||||||
|
},
|
||||||
|
decimation: {
|
||||||
|
enabled: true,
|
||||||
|
algorithm: 'min-max'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,5 +210,5 @@ export class NetworkComponent implements AfterViewInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.limiting = false;
|
this.limiting = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue