Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into theme-overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Wilson committed Nov 1, 2024
2 parents d18b3b6 + e0090fd commit aa16c01
Show file tree
Hide file tree
Showing 7 changed files with 328 additions and 165 deletions.
62 changes: 48 additions & 14 deletions main/http_server/axe-os/src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export class HomeComponent {

public chartOptions: any;
public dataLabel: number[] = [];
public dataData: number[] = [];
public hashrateData: number[] = [];
public temperatureData: number[] = [];
public dataDataAverage: number[] = [];
public chartData?: any;

Expand All @@ -39,32 +40,49 @@ export class HomeComponent {
const surfaceBorder = documentStyle.getPropertyValue('--surface-border');
const primaryColor = documentStyle.getPropertyValue('--primary-color');

console.log(primaryColor)

this.chartData = {
labels: [],
datasets: [
{
type: 'line',
label: 'Hashrate',
data: [],
fill: false,
backgroundColor: primaryColor,
backgroundColor: primaryColor + '30',
borderColor: primaryColor,
tension: 0,
pointRadius: 2,
pointHoverRadius: 5,
borderWidth: 1
borderWidth: 1,
yAxisID: 'y',
fill: true,
},
{
type: 'line',
label: 'Average Hashrate',
data: [],
fill: false,
backgroundColor: textColorSecondary,
borderColor: textColorSecondary,
backgroundColor: primaryColor + '30',
borderColor: primaryColor + '30',
tension: 0,
pointRadius: 0,
borderWidth: 2,
borderDash: [5, 5]
borderDash: [5, 5],
yAxisID: 'y',
},
{
type: 'line',
label: 'ASIC Temp',
data: [],
fill: false,
backgroundColor: textColorSecondary,
borderColor: textColorSecondary,
tension: 0,
pointRadius: 2,
pointHoverRadius: 5,
borderWidth: 1,
yAxisID: 'y2',
}
]
};
Expand All @@ -80,7 +98,7 @@ export class HomeComponent {
},
tooltip: {
callbacks: {
label: function(tooltipItem: any) {
label: function (tooltipItem: any) {
let label = tooltipItem.dataset.label || '';
if (label) {
label += ': ';
Expand Down Expand Up @@ -115,6 +133,19 @@ export class HomeComponent {
color: surfaceBorder,
drawBorder: false
}
},
y2: {
type: 'linear',
display: true,
position: 'right',
ticks: {
color: textColorSecondary
},
grid: {
drawOnChartArea: false,
color: surfaceBorder
},
suggestedMax: 80
}
}
};
Expand All @@ -126,20 +157,23 @@ export class HomeComponent {
return this.systemService.getInfo()
}),
tap(info => {
this.dataData.push(info.hashRate * 1000000000);
this.hashrateData.push(info.hashRate * 1000000000);
this.temperatureData.push(info.temp);

this.dataLabel.push(new Date().getTime());

if (this.dataData.length >= 720) {
this.dataData.shift();
if (this.hashrateData.length >= 720) {
this.hashrateData.shift();
this.dataLabel.shift();
}

this.chartData.labels = this.dataLabel;
this.chartData.datasets[0].data = this.dataData;
this.chartData.datasets[0].data = this.hashrateData;
this.chartData.datasets[2].data = this.temperatureData;

// Calculate average hashrate and fill the array with the same value for the average line
const averageHashrate = this.calculateAverage(this.dataData);
this.chartData.datasets[1].data = Array(this.dataData.length).fill(averageHashrate);
const averageHashrate = this.calculateAverage(this.hashrateData);
this.chartData.datasets[1].data = Array(this.hashrateData.length).fill(averageHashrate);

this.chartData = {
...this.chartData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<div class="card">

<form [formGroup]="form">
<div class="field grid p-fluid">
<label htmlFor="ip" class="col-12 mb-2 md:col-2 md:mb-0">AxeOS Device IP</label>
<div class="col-12 md:col-10">
<label htmlFor="ip" class="col-12 mb-2 md:col-4 md:mb-0">Manual Addition</label>
<div class="col-12 md:col-8">
<p-inputGroup>
<input pInputText id="ip" formControlName="ip" type="text" />
<button pButton (click)="add()" [disabled]="form.invalid">Add</button>
<input pInputText id="manualAddIp" formControlName="manualAddIp" type="text" />
<button pButton [disabled]="form.invalid" (click)="add()">Add</button>
</p-inputGroup>

</div>
</div>

</form>
</div>
<button style="margin-right: 1rem;" pButton (click)="scanNetwork()" [disabled]="scanning">{{scanning ? 'Scanning...' : 'Automatic Scan'}}</button>
<button pButton severity="secondary" (click)="refreshList()" [disabled]="scanning">Refresh List ({{refreshIntervalTime}})</button>
<div>
<button pButton (click)="refresh()">Refresh</button>
</div>
<div>
<table cellspacing="0" cellpadding="0" *ngIf="swarm$ | async as swarm">
<table cellspacing="0" cellpadding="0" >
<tr>
<th>IP</th>
<th>Hash Rate</th>
Expand All @@ -31,17 +31,17 @@
<th>Restart</th>
<th>Remove</th>
</tr>
<ng-container *ngFor="let axeOs$ of swarm">
<tr *ngIf="axeOs$ | async as axe">
<td><a [href]="'http://'+axe.ip" target="_blank">{{axe.ip}}</a></td>
<ng-container *ngFor="let axe of swarm">
<tr>
<td><a [href]="'http://'+axe.IP" target="_blank">{{axe.IP}}</a></td>
<td>{{axe.hashRate * 1000000000 | hashSuffix}}</td>
<td>{{axe.uptimeSeconds | dateAgo}}</td>
<td>{{axe.sharesAccepted | number: '1.0-0'}}</td>
<td>{{axe.power | number: '1.2-2'}} <small>W</small> </td>
<td>{{axe.temp}}°<small>C</small></td>
<td>{{axe.bestDiff}}</td>
<td>{{axe.version}}</td>
<td><p-button icon="pi pi-pencil" pp-button (click)="edit(axe)"></p-button></td>
<td><p-button icon="pi pi-pencil" pp-button (click)="edit(axe)"></p-button></td>
<td><p-button icon="pi pi-sync" pp-button severity="danger" (click)="restart(axe)"></p-button></td>
<td><p-button icon="pi pi-trash" pp-button severity="secondary" (click)="remove(axe)"></p-button></td>
</tr>
Expand All @@ -52,6 +52,6 @@
<div class="modal-backdrop" *ngIf="showEdit" (click)="showEdit = false"></div>
<div class="modal card" *ngIf="showEdit">
<div class="close" (click)="showEdit = false">&#10006;</div>
<h1>{{selectedAxeOs.ip}}</h1>
<app-edit [uri]="'http://' + selectedAxeOs.ip"></app-edit>
<h1>{{selectedAxeOs.IP}}</h1>
<app-edit [uri]="'http://' + selectedAxeOs.IP"></app-edit>
</div>
Loading

0 comments on commit aa16c01

Please sign in to comment.