Merge pull request #359 from mrv777/master

fix: Add overheat alert, knob colors & max, chart dots & label #342
This commit is contained in:
Skot
2024-09-27 22:36:35 -05:00
committed by GitHub
5 changed files with 63 additions and 36 deletions

View File

@@ -21,8 +21,7 @@ import { ANSIPipe } from './pipes/ansi.pipe';
import { DateAgoPipe } from './pipes/date-ago.pipe'; import { DateAgoPipe } from './pipes/date-ago.pipe';
import { HashSuffixPipe } from './pipes/hash-suffix.pipe'; import { HashSuffixPipe } from './pipes/hash-suffix.pipe';
import { PrimeNGModule } from './prime-ng.module'; import { PrimeNGModule } from './prime-ng.module';
import { MessageModule } from 'primeng/message';
const components = [ const components = [
AppComponent, AppComponent,
@@ -55,7 +54,8 @@ const components = [
BrowserAnimationsModule, BrowserAnimationsModule,
CommonModule, CommonModule,
PrimeNGModule, PrimeNGModule,
AppLayoutModule AppLayoutModule,
MessageModule
], ],
providers: [ providers: [
{ provide: LocationStrategy, useClass: HashLocationStrategy }, { provide: LocationStrategy, useClass: HashLocationStrategy },

View File

@@ -157,28 +157,20 @@
</div> </div>
</div> </div>
<div class="col-12 md:col-4"> <div class="col-12">
<div class="field-checkbox"> <div class="field-checkbox">
<p-checkbox name="invertfanpolarity" formControlName="invertfanpolarity" inputId="invertfanpolarity" <p-checkbox name="invertfanpolarity" formControlName="invertfanpolarity" inputId="invertfanpolarity"
[binary]="true"></p-checkbox> [binary]="true"></p-checkbox>
<label for="invertfanpolarity">Invert Fan Polarity</label> <label for="invertfanpolarity">Invert Fan Polarity</label>
</div> </div>
</div> </div>
<div class="col-12 md:col-4"> <div class="col-12">
<div class="field-checkbox"> <div class="field-checkbox">
<p-checkbox name="autofanspeed" formControlName="autofanspeed" inputId="autofanspeed" <p-checkbox name="autofanspeed" formControlName="autofanspeed" inputId="autofanspeed"
[binary]="true"></p-checkbox> [binary]="true"></p-checkbox>
<label for="autofanspeed">Automatic Fan Control</label> <label for="autofanspeed">Automatic Fan Control</label>
</div> </div>
</div> </div>
<div class="col-12 md:col-4" *ngIf="form.get('overheat_mode')?.value === 1">
<div class="field-checkbox">
<p-checkbox name="overheat_mode" formControlName="overheat_mode" inputId="overheat_mode"
[binary]="true"></p-checkbox>
<label for="overheat_mode">Disable Overheat Mode. Make sure to reset Frequency and Voltage</label>
</div>
</div>
<div *ngIf="form.controls['autofanspeed'].value != true"> <div *ngIf="form.controls['autofanspeed'].value != true">
<div class="col-12" *ngIf="form.controls['autofanspeed'].value != true"> <div class="col-12" *ngIf="form.controls['autofanspeed'].value != true">
@@ -190,6 +182,15 @@
<p-slider formControlName="fanspeed"></p-slider> <p-slider formControlName="fanspeed"></p-slider>
</div> </div>
</div> </div>
<div class="col-12" *ngIf="form.get('overheat_mode')?.value === 1">
<div class="field-checkbox">
<p-checkbox name="overheat_mode" formControlName="overheat_mode" inputId="overheat_mode"
[binary]="true"></p-checkbox>
<label for="overheat_mode" style="color: #ff0000;">Disable Overheat Mode. Make sure to reset Frequency and Voltage</label>
</div>
</div>
<div class="mt-2"> <div class="mt-2">
<button pButton [disabled]="form.invalid" (click)="updateSystem()" <button pButton [disabled]="form.invalid" (click)="updateSystem()"
class="btn btn-primary mr-2">Save</button> class="btn btn-primary mr-2">Save</button>

View File

@@ -1,13 +1,19 @@
<ng-template #loading> <ng-template #loading>
<h4>Loading...</h4> <h4>Loading...</h4>
</ng-template> </ng-template>
<ng-container> <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"
text="Bitaxe has overheated - See settings">
</p-message>
<div class="grid" *ngIf="info$ | async as info; else loading"> <div class="grid" *ngIf="info$ | async as info; else loading">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="grid mb-4"> <div class="grid mb-4">
<div class="col-12 lg:col-6 xl:col-3"> <div class="col-12 md:col-6 xl:col-3">
<div class="card mb-0"> <div class="card mb-0">
<div class="flex justify-content-between mb-3"> <div class="flex justify-content-between mb-3">
<div> <div>
@@ -28,7 +34,7 @@
</ng-container> </ng-container>
</div> </div>
</div> </div>
<div class="col-12 lg:col-6 xl:col-3"> <div class="col-12 md:col-6 xl:col-3">
<div class="card mb-0"> <div class="card mb-0">
<div class="flex justify-content-between mb-3"> <div class="flex justify-content-between mb-3">
<div> <div>
@@ -44,7 +50,7 @@
<span class="text-500">rejected</span> <span class="text-500">rejected</span>
</div> </div>
</div> </div>
<div class="col-12 lg:col-6 xl:col-3"> <div class="col-12 md:col-6 xl:col-3">
<div class="card mb-0"> <div class="card mb-0">
<div class="flex justify-content-between mb-3"> <div class="flex justify-content-between mb-3">
<div> <div>
@@ -63,7 +69,7 @@
<span class="text-500">since last week</span> --> <span class="text-500">since last week</span> -->
</div> </div>
</div> </div>
<div class="col-12 lg:col-6 xl:col-3"> <div class="col-12 md:col-6 xl:col-3">
<div class="card mb-0"> <div class="card mb-0">
<div class="flex justify-content-between mb-3"> <div class="flex justify-content-between mb-3">
<div> <div>
@@ -95,14 +101,15 @@
<h5>Power</h5> <h5>Power</h5>
<div class="grid text-center"> <div class="grid text-center">
<div class="col-4"> <div class="col-4">
<p-knob [min]="3" [max]="50" [readonly]="true" [(ngModel)]="info.power" <p-knob [min]="3" [max]="maxPower" [readonly]="true" [(ngModel)]="info.power"
valueTemplate="{value}W"></p-knob> valueTemplate="{value}W"></p-knob>
Power Power
</div> </div>
<div class="col-4"> <div class="col-4">
<p-knob [min]="4.5" [max]="5.5" [readonly]="true" [(ngModel)]="info.voltage" <p-knob [min]="4.5" [max]="5.5" [readonly]="true" [(ngModel)]="info.voltage"
valueTemplate="{value}V"></p-knob> valueTemplate="{value}V"
[valueColor]="info.voltage < 4.8 ? '#ff0000' : 'var(--primary-color, Black)'"></p-knob>
Input Voltage Input Voltage
<span class="danger" *ngIf="info.voltage < 4.8">&nbsp; Danger: Low voltage</span> <span class="danger" *ngIf="info.voltage < 4.8">&nbsp; Danger: Low voltage</span>
</div> </div>
@@ -122,8 +129,10 @@
<h5>Heat</h5> <h5>Heat</h5>
<div class="grid text-center"> <div class="grid text-center">
<div class="col-6"> <div class="col-6">
<p-knob [min]="20" [max]="75" [readonly]="true" [(ngModel)]="info.temp" <p-knob [min]="20" [max]="maxTemp" [readonly]="true" [(ngModel)]="info.temp"
valueTemplate="{value}C"></p-knob> valueTemplate="{value}C"
[valueColor]="info.temp >= 70 ? '#ff0000' : 'var(--primary-color, Black)'">
</p-knob>
ASIC Temperature ASIC Temperature
<span class="danger" *ngIf="info.temp >= 70">&nbsp; <span class="danger" *ngIf="info.temp >= 70">&nbsp;
@@ -132,7 +141,8 @@
</div> </div>
<div class="col-6" *ngIf="info.vrTemp > 0"> <div class="col-6" *ngIf="info.vrTemp > 0">
<p-knob [min]="20" [max]="145" [readonly]="true" [(ngModel)]="info.vrTemp" <p-knob [min]="20" [max]="145" [readonly]="true" [(ngModel)]="info.vrTemp"
valueTemplate="{value}C"></p-knob> valueTemplate="{value}C"
[valueColor]="info.vrTemp >= 105 ? '#ff0000' : 'var(--primary-color, Black)'"></p-knob>
Voltage Regulator Temperature Voltage Regulator Temperature
<span class="danger" *ngIf="info.vrTemp >= 105">&nbsp; <span class="danger" *ngIf="info.vrTemp >= 105">&nbsp;
@@ -172,7 +182,7 @@
<h5>Performance</h5> <h5>Performance</h5>
<div class="grid text-center"> <div class="grid text-center">
<div class="col-6"> <div class="col-6">
<p-knob [min]="100" [max]="800" [readonly]="true" [(ngModel)]="info.frequency" <p-knob [min]="100" [max]="maxFrequency" [readonly]="true" [(ngModel)]="info.frequency"
valueTemplate="{value}Mhz"></p-knob> valueTemplate="{value}Mhz"></p-knob>
ASIC Frequency ASIC Frequency
</div> </div>

View File

@@ -12,7 +12,6 @@ import { ISystemInfo } from 'src/models/ISystemInfo';
}) })
export class HomeComponent { export class HomeComponent {
public info$: Observable<ISystemInfo>; public info$: Observable<ISystemInfo>;
public quickLink$: Observable<string | undefined>; public quickLink$: Observable<string | undefined>;
@@ -24,11 +23,14 @@ export class HomeComponent {
public dataData: number[] = []; public dataData: number[] = [];
public chartData?: any; public chartData?: any;
public maxPower: number = 50;
public maxTemp: number = 75;
public maxFrequency: number = 800;
constructor( constructor(
private systemService: SystemService private systemService: SystemService
) { ) {
const documentStyle = getComputedStyle(document.documentElement); const documentStyle = getComputedStyle(document.documentElement);
const textColor = documentStyle.getPropertyValue('--text-color'); const textColor = documentStyle.getPropertyValue('--text-color');
const textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); const textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
@@ -45,8 +47,9 @@ export class HomeComponent {
fill: false, fill: false,
backgroundColor: primaryColor, backgroundColor: primaryColor,
borderColor: primaryColor, borderColor: primaryColor,
tension: .4, tension: 0,
pointRadius: 1, pointRadius: 2,
pointHoverRadius: 5,
borderWidth: 1 borderWidth: 1
}, },
@@ -61,7 +64,19 @@ export class HomeComponent {
labels: { labels: {
color: textColor color: textColor
} }
} },
tooltip: {
callbacks: {
label: function(tooltipItem: any) {
let label = tooltipItem.dataset.label || '';
if (label) {
label += ': ';
}
label += HashSuffixPipe.transform(tooltipItem.raw);
return label;
}
}
},
}, },
scales: { scales: {
x: { x: {
@@ -110,12 +125,14 @@ export class HomeComponent {
this.chartData.labels = this.dataLabel; this.chartData.labels = this.dataLabel;
this.chartData.datasets[0].data = this.dataData; this.chartData.datasets[0].data = this.dataData;
this.chartData = { this.chartData = {
...this.chartData ...this.chartData
}; };
this.maxPower = Math.max(50, info.power);
this.maxTemp = Math.max(75, info.temp);
this.maxFrequency = Math.max(800, info.frequency);
}), }),
map(info => { map(info => {
info.power = parseFloat(info.power.toFixed(1)) info.power = parseFloat(info.power.toFixed(1))
@@ -156,12 +173,7 @@ export class HomeComponent {
}) })
) )
} }
} }

View File

@@ -26,6 +26,10 @@ export class HashSuffixPipe implements PipeTransform {
const scaledValue = value / Math.pow(1000, power); const scaledValue = value / Math.pow(1000, power);
const suffix = suffixes[power]; const suffix = suffixes[power];
if (scaledValue < 10) {
return scaledValue.toFixed(2) + suffix;
}
return scaledValue.toFixed(1) + suffix; return scaledValue.toFixed(1) + suffix;
} }