Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update frontend to use camelcased api #672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions main/http_server/axe-os/src/app/components/edit/edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

</ng-container>

<div class="col-12" *ngIf="form.get('overheat_mode')?.value === 1">
<div class="col-12" *ngIf="form.get('overheatMode')?.value === 1">
<button pButton type="button" label="Disable Overheat Mode"
class="p-button-danger w-full py-3"
(click)="disableOverheatMode()">
Expand All @@ -113,35 +113,35 @@

<div class="col-12 md:col-4">
<div class="field-checkbox">
<p-checkbox name="flipscreen" formControlName="flipscreen" inputId="flipscreen"
<p-checkbox name="flipscreen" formControlName="flipScreen" inputId="flipscreen"
[binary]="true"></p-checkbox>
<label for="flipscreen">Flip Screen</label>
</div>
</div>

<div class="col-12">
<div class="field-checkbox">
<p-checkbox name="invertfanpolarity" formControlName="invertfanpolarity" inputId="invertfanpolarity"
<p-checkbox name="invertfanpolarity" formControlName="invertFanPolarity" inputId="invertfanpolarity"
[binary]="true"></p-checkbox>
<label for="invertfanpolarity">Invert Fan Polarity</label>
</div>
</div>
<div class="col-12">
<div class="field-checkbox">
<p-checkbox name="autofanspeed" formControlName="autofanspeed" inputId="autofanspeed"
<p-checkbox name="autofanspeed" formControlName="autoFanSpeed" inputId="autofanspeed"
[binary]="true"></p-checkbox>
<label for="autofanspeed">Automatic Fan Control</label>
</div>
</div>

<div *ngIf="form.controls['autofanspeed'].value != true">
<div class="col-12" *ngIf="form.controls['autofanspeed'].value != true">
<label>Fan Speed {{form.controls['fanspeed'].value}}%
<b *ngIf="form.controls['fanspeed'].value < 33" style="color:red">Danger: Could Cause
Overheating</b> <b *ngIf="form.controls['fanspeed'].value == 100" style="color: #F2A900">S19
<div *ngIf="form.controls['autoFanSpeed'].value != true">
<div class="col-12" *ngIf="form.controls['autoFanSpeed'].value != true">
<label>Fan Speed {{form.controls['fanSpeed'].value}}%
<b *ngIf="form.controls['fanSpeed'].value < 33" style="color:red">Danger: Could Cause
Overheating</b> <b *ngIf="form.controls['fanSpeed'].value == 100" style="color: #F2A900">S19
Simulator</b></label>

<p-slider formControlName="fanspeed"></p-slider>
<p-slider formControlName="fanSpeed"></p-slider>
</div>
</div>

Expand Down
24 changes: 12 additions & 12 deletions main/http_server/axe-os/src/app/components/edit/edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ export class EditComponent implements OnInit, OnDestroy {
takeUntil(this.destroy$)
)
.subscribe(info => {
this.ASICModel = info.ASICModel;
this.ASICModel = info.asicModel;
this.form = this.fb.group({
flipscreen: [info.flipscreen == 1],
invertscreen: [info.invertscreen == 1],
flipScreen: [info.flipScreen == 1],
invertScreen: [info.invertScreen == 1],
stratumURL: [info.stratumURL, [
Validators.required,
Validators.pattern(/^(?!.*stratum\+tcp:\/\/).*$/),
Expand All @@ -165,20 +165,20 @@ export class EditComponent implements OnInit, OnDestroy {
fallbackStratumPassword: ['password', [Validators.required]],
coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
invertfanpolarity: [info.invertfanpolarity == 1, [Validators.required]],
fanspeed: [info.fanspeed, [Validators.required]],
overheat_mode: [info.overheat_mode, [Validators.required]]
autoFanSpeed: [info.autoFanSpeed == 1, [Validators.required]],
invertFanPolarity: [info.invertFanPolarity == 1, [Validators.required]],
fanSpeed: [info.fanSpeed, [Validators.required]],
overheatMode: [info.overheatMode, [Validators.required]]
});

this.form.controls['autofanspeed'].valueChanges.pipe(
startWith(this.form.controls['autofanspeed'].value),
this.form.controls['autoFanSpeed'].valueChanges.pipe(
startWith(this.form.controls['autoFanSpeed'].value),
takeUntil(this.destroy$)
).subscribe(autofanspeed => {
if (autofanspeed) {
this.form.controls['fanspeed'].disable();
this.form.controls['fanSpeed'].disable();
} else {
this.form.controls['fanspeed'].enable();
this.form.controls['fanSpeed'].enable();
}
});
});
Expand Down Expand Up @@ -234,7 +234,7 @@ export class EditComponent implements OnInit, OnDestroy {
}

disableOverheatMode() {
this.form.patchValue({ overheat_mode: 0 });
this.form.patchValue({ overheatMode: 0 });
this.updateSystem();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h4>Loading...</h4>
</ng-template>
<ng-container *ngIf="info$ | async as info; else loading">
<!-- Temp warning alert -->
<p-message *ngIf="info.overheat_mode" severity="error" styleClass="w-full mb-4 py-4 border-round-xl"
<p-message *ngIf="info.overheatMode" severity="error" styleClass="w-full mb-4 py-4 border-round-xl"
text="Bitaxe has overheated - See settings">
</p-message>

Expand All @@ -19,7 +19,7 @@ <h4>Loading...</h4>
<div class="flex justify-content-between mb-3">
<div>
<span class="block text-500 font-medium mb-3">Hash Rate</span>
<div class="text-900 font-medium text-xl">{{info.hashRate * 1000000000 | hashSuffix}}
<div class="text-900 font-medium text-xl">{{info.hashrate * 1000000000 | hashSuffix}}
</div>
</div>
</div>
Expand All @@ -36,7 +36,7 @@ <h4>Loading...</h4>
<div>
<span class="block text-500 font-medium mb-3">Efficiency</span>
<div class="text-900 font-medium text-xl">
<td>{{info.power / (info.hashRate/1000) | number: '1.2-2'}} <small>J/TH</small>
<td>{{info.power / (info.hashrate/1000) | number: '1.2-2'}} <small>J/TH</small>
</td>
</div>
</div>
Expand Down Expand Up @@ -167,8 +167,8 @@ <h6>Voltage Regulator Temperature <span style="float: right;">{{info.vrTemp}}&de
High Temperature</span>
</div>
<div class="col-12">
<h6>Fan Speed<span style="float: right;">{{info.fanspeed}}% ({{info.fanrpm}} RPM)</span></h6>
<p-progressBar [value]="info.fanspeed" [style]="{ height: '6px' }" >
<h6>Fan Speed<span style="float: right;">{{info.fanSpeed}}% ({{info.fanRPM}} RPM)</span></h6>
<p-progressBar [value]="info.fanSpeed" [style]="{ height: '6px' }" >
<ng-template pTemplate="content" let-value></ng-template>
</p-progressBar>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class HomeComponent {
return this.systemService.getInfo()
}),
tap(info => {
this.hashrateData.push(info.hashRate * 1000000000);
this.hashrateData.push(info.hashrate * 1000000000);
this.temperatureData.push(info.temp);

this.dataLabel.push(new Date().getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h5>Overview</h5>
<table *ngIf="info$ | async as info">
<tr>
<td>Model:</td>
<td>{{info.ASICModel}}</td>
<td>{{info.asicModel}}</td>
</tr>
<tr>
<td>Uptime:</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export class SettingsComponent {

this.info$.pipe(this.loadingService.lockUIUntilComplete())
.subscribe(info => {
this.ASICModel = info.ASICModel;
this.ASICModel = info.asicModel;
this.form = this.fb.group({
flipscreen: [info.flipscreen == 1],
invertscreen: [info.invertscreen == 1],
flipScreen: [info.flipScreen == 1],
invertScreen: [info.invertScreen == 1],
stratumURL: [info.stratumURL, [
Validators.required,
Validators.pattern(/^(?!.*stratum\+tcp:\/\/).*$/),
Expand All @@ -76,18 +76,18 @@ export class SettingsComponent {
stratumPassword: ['*****', [Validators.required]],
coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
invertfanpolarity: [info.invertfanpolarity == 1, [Validators.required]],
fanspeed: [info.fanspeed, [Validators.required]],
autoFanSpeed: [info.autoFanSpeed == 1, [Validators.required]],
invertFanPolarity: [info.invertFanPolarity == 1, [Validators.required]],
fanSpeed: [info.fanSpeed, [Validators.required]],
});

this.form.controls['autofanspeed'].valueChanges.pipe(
startWith(this.form.controls['autofanspeed'].value)
this.form.controls['autoFanSpeed'].valueChanges.pipe(
startWith(this.form.controls['autoFanSpeed'].value)
).subscribe(autofanspeed => {
if (autofanspeed) {
this.form.controls['fanspeed'].disable();
this.form.controls['fanSpeed'].disable();
} else {
this.form.controls['fanspeed'].enable();
this.form.controls['fanSpeed'].enable();
}
});
});
Expand All @@ -112,10 +112,10 @@ export class SettingsComponent {
form.coreVoltage = parseInt(form.coreVoltage);

// bools to ints
form.flipscreen = form.flipscreen == true ? 1 : 0;
form.invertscreen = form.invertscreen == true ? 1 : 0;
form.invertfanpolarity = form.invertfanpolarity == true ? 1 : 0;
form.autofanspeed = form.autofanspeed == true ? 1 : 0;
form.flipScreen = form.flipScreen == true ? 1 : 0;
form.invertScreen = form.invertScreen == true ? 1 : 0;
form.invertFanPolarity = form.invertFanPolarity == true ? 1 : 0;
form.autoFanSpeed = form.autoFanSpeed == true ? 1 : 0;

if (form.stratumPassword === '*****') {
delete form.stratumPassword;
Expand All @@ -136,7 +136,7 @@ export class SettingsComponent {
otaUpdate(event: FileUploadHandlerEvent) {
const file = event.files[0];
this.firmwareUpload.clear(); // clear the file upload component

if (file.name != 'esp-miner.bin') {
this.toastrService.error('Incorrect file, looking for esp-miner.bin.', 'Error');
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<div class="flex flex-column sm:flex-row w-full gap-2 xl:gap-4 mt-4 mb-4">
<div class="card mb-0 w-full text-center p-4">
Total Hash Rate: <span class="text-primary">{{totals.hashRate * 1000000000 | hashSuffix}}</span>
Total Hash Rate: <span class="text-primary">{{totals.hashrate * 1000000000 | hashSuffix}}</span>
</div>
<div class="card mb-0 w-full text-center p-4">
Total Power: <span class="text-primary">{{totals.power | number: '1.1-1'}} <small>W</small></span>
Expand Down Expand Up @@ -66,7 +66,7 @@
<a class="text-primary" [href]="'http://'+axe.IP" target="_blank">{{axe.IP}}</a>
<div class="text-sm">{{axe.hostname}}</div>
</td>
<td>{{axe.hashRate * 1000000000 | hashSuffix}}</td>
<td>{{axe.hashrate * 1000000000 | hashSuffix}}</td>
<td>{{axe.uptimeSeconds | dateAgo: {intervals: 2} }}</td>
<td>
<div class="w-min cursor-pointer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
public refreshIntervalTime = 30;
public refreshTimeSet = 30;

public totals: { hashRate: number, power: number, bestDiff: string } = { hashRate: 0, power: 0, bestDiff: '0' };
public totals: { hashrate: number, power: number, bestDiff: string } = { hashrate: 0, power: 0, bestDiff: '0' };

public isRefreshing = false;

Expand Down Expand Up @@ -108,7 +108,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
mergeMap(ipAddr =>
this.httpClient.get(`http://${ipAddr}/api/system/info`).pipe(
map(result => {
if ('hashRate' in result) {
if ('hashrate' in result) {
return {
IP: ipAddr,
...result
Expand Down Expand Up @@ -152,7 +152,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
}

this.systemService.getInfo(`http://${newIp}`).subscribe((res) => {
if (res.ASICModel) {
if (res.asicModel) {
this.swarm.push({ IP: newIp, ...res });
this.swarm = this.swarm.sort(this.sortByIp.bind(this));
this.localStorageService.setObject(SWARM_DATA, this.swarm);
Expand Down Expand Up @@ -211,7 +211,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
const existingDevice = this.swarm.find(axeOs => axeOs.IP === ipAddr);
return of({
...existingDevice,
hashRate: 0,
hashrate: 0,
sharesAccepted: 0,
power: 0,
voltage: 0,
Expand Down Expand Up @@ -264,7 +264,7 @@ export class SwarmComponent implements OnInit, OnDestroy {
}

private calculateTotals() {
this.totals.hashRate = this.swarm.reduce((sum, axe) => sum + (axe.hashRate || 0), 0);
this.totals.hashrate = this.swarm.reduce((sum, axe) => sum + (axe.hashrate || 0), 0);
this.totals.power = this.swarm.reduce((sum, axe) => sum + (axe.power || 0), 0);
const maxDiff = Math.max(...this.swarm.map(axe => this.convertBestDiffToNumber(axe.bestDiff)));
this.totals.bestDiff = this.formatBestDiff(maxDiff);
Expand Down
18 changes: 9 additions & 9 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SystemService {
current: 2237.5,
temp: 60,
vrTemp: 45,
hashRate: 475,
hashrate: 475,
bestDiff: "0",
bestSessionDiff: "0",
freeHeap: 200504,
Expand All @@ -42,7 +42,7 @@ export class SystemService {
uptimeSeconds: 38,
asicCount: 1,
smallCoreCount: 672,
ASICModel: eASICModel.BM1366,
asicModel: eASICModel.BM1366,
stratumURL: "public-pool.io",
stratumPort: 21496,
fallbackStratumURL: "test.public-pool.io",
Expand All @@ -54,16 +54,16 @@ export class SystemService {
version: "2.0",
idfVersion: "v5.1.2",
boardVersion: "204",
flipscreen: 1,
invertscreen: 0,
invertfanpolarity: 1,
autofanspeed: 1,
fanspeed: 100,
fanrpm: 0,
flipScreen: 1,
invertScreen: 0,
invertFanPolarity: 1,
autoFanSpeed: 1,
fanSpeed: 100,
fanRPM: 0,

boardtemp1: 30,
boardtemp2: 40,
overheat_mode: 0
overheatMode: 0
}
).pipe(delay(1000));
}
Expand Down
18 changes: 9 additions & 9 deletions main/http_server/axe-os/src/models/ISystemInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { eASICModel } from './enum/eASICModel';

export interface ISystemInfo {

flipscreen: number;
invertscreen: number;
flipScreen: number;
invertScreen: number;
power: number,
voltage: number,
current: number,
temp: number,
vrTemp: number,
hashRate: number,
hashrate: number,
bestDiff: string,
bestSessionDiff: string,
freeHeap: number,
Expand All @@ -23,7 +23,7 @@ export interface ISystemInfo {
uptimeSeconds: number,
asicCount: number,
smallCoreCount: number,
ASICModel: eASICModel,
asicModel: eASICModel,
stratumURL: string,
stratumPort: number,
fallbackStratumURL: string,
Expand All @@ -35,13 +35,13 @@ export interface ISystemInfo {
version: string,
idfVersion: string,
boardVersion: string,
invertfanpolarity: number,
autofanspeed: number,
fanspeed: number,
fanrpm: number,
invertFanPolarity: number,
autoFanSpeed: number,
fanSpeed: number,
fanRPM: number,
coreVoltageActual: number,

boardtemp1?: number,
boardtemp2?: number,
overheat_mode: number
overheatMode: number
}