From 26951eea0a4f9bfa9b4e2f38ee3212f150b13020 Mon Sep 17 00:00:00 2001 From: mrv777 Date: Thu, 12 Dec 2024 13:23:29 -0600 Subject: [PATCH 1/2] fix: Show custom values in dropdown if set --- .../app/components/edit/edit.component.html | 58 +------------------ .../src/app/components/edit/edit.component.ts | 55 +++++++++++++++++- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.html b/main/http_server/axe-os/src/app/components/edit/edit.component.html index 8211d66c..74917e6a 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.html +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.html @@ -67,70 +67,18 @@ - - -
- -
- -
-
- - -
- - -
- -
- - - -
- -
- -
-
- -
- - -
-
- - +
-
- -
-
- - -
- - - - -
- -
- -
diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.ts b/main/http_server/axe-os/src/app/components/edit/edit.component.ts index 8e207c18..4dbd0d27 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.ts +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.ts @@ -120,7 +120,6 @@ export class EditComponent implements OnInit { private fb: FormBuilder, private systemService: SystemService, private toastr: ToastrService, - private toastrService: ToastrService, private loadingService: LoadingService ) { @@ -247,4 +246,58 @@ export class EditComponent implements OnInit { }); } + getDropdownFrequency() { + // Get base frequency options based on ASIC model + let options = []; + switch(this.ASICModel) { + case this.eASICModel.BM1366: options = [...this.BM1366DropdownFrequency]; break; + case this.eASICModel.BM1368: options = [...this.BM1368DropdownFrequency]; break; + case this.eASICModel.BM1370: options = [...this.BM1370DropdownFrequency]; break; + case this.eASICModel.BM1397: options = [...this.BM1397DropdownFrequency]; break; + default: return []; + } + + // Get current frequency value from form + const currentFreq = this.form?.get('frequency')?.value; + + // If current frequency exists and isn't in the options + if (currentFreq && !options.some(opt => opt.value === currentFreq)) { + options.push({ + name: `${currentFreq} (Custom)`, + value: currentFreq + }); + // Sort options by frequency value + options.sort((a, b) => a.value - b.value); + } + + return options; + } + + getCoreVoltage() { + // Get base voltage options based on ASIC model + let options = []; + switch(this.ASICModel) { + case this.eASICModel.BM1366: options = [...this.BM1366CoreVoltage]; break; + case this.eASICModel.BM1368: options = [...this.BM1368CoreVoltage]; break; + case this.eASICModel.BM1370: options = [...this.BM1370CoreVoltage]; break; + case this.eASICModel.BM1397: options = [...this.BM1397CoreVoltage]; break; + default: return []; + } + + // Get current voltage value from form + const currentVoltage = this.form?.get('coreVoltage')?.value; + + // If current voltage exists and isn't in the options + if (currentVoltage && !options.some(opt => opt.value === currentVoltage)) { + options.push({ + name: `${currentVoltage} (Custom)`, + value: currentVoltage + }); + // Sort options by voltage value + options.sort((a, b) => a.value - b.value); + } + + return options; + } + } From 87a1d88a21d5d3655576bc3f1b3973f4b180cb0f Mon Sep 17 00:00:00 2001 From: mrv777 Date: Thu, 12 Dec 2024 13:56:25 -0600 Subject: [PATCH 2/2] fix: Memory leak & checkDevTools binding --- .../src/app/components/edit/edit.component.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/main/http_server/axe-os/src/app/components/edit/edit.component.ts b/main/http_server/axe-os/src/app/components/edit/edit.component.ts index 4dbd0d27..007b3f19 100644 --- a/main/http_server/axe-os/src/app/components/edit/edit.component.ts +++ b/main/http_server/axe-os/src/app/components/edit/edit.component.ts @@ -1,8 +1,8 @@ import { HttpErrorResponse } from '@angular/common/http'; -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, OnDestroy } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { ToastrService } from 'ngx-toastr'; -import { startWith } from 'rxjs'; +import { startWith, Subject, takeUntil } from 'rxjs'; import { LoadingService } from 'src/app/services/loading.service'; import { SystemService } from 'src/app/services/system.service'; import { eASICModel } from 'src/models/enum/eASICModel'; @@ -12,7 +12,7 @@ import { eASICModel } from 'src/models/enum/eASICModel'; templateUrl: './edit.component.html', styleUrls: ['./edit.component.scss'] }) -export class EditComponent implements OnInit { +export class EditComponent implements OnInit, OnDestroy { public form!: FormGroup; @@ -116,20 +116,24 @@ export class EditComponent implements OnInit { { name: '1300', value: 1300 }, ]; + private destroy$ = new Subject(); + constructor( private fb: FormBuilder, private systemService: SystemService, private toastr: ToastrService, private loadingService: LoadingService ) { - - window.addEventListener('resize', this.checkDevTools); + window.addEventListener('resize', this.checkDevTools.bind(this)); this.checkDevTools(); - } + ngOnInit(): void { this.systemService.getInfo(this.uri) - .pipe(this.loadingService.lockUIUntilComplete()) + .pipe( + this.loadingService.lockUIUntilComplete(), + takeUntil(this.destroy$) + ) .subscribe(info => { this.ASICModel = info.ASICModel; this.form = this.fb.group({ @@ -168,7 +172,8 @@ export class EditComponent implements OnInit { }); this.form.controls['autofanspeed'].valueChanges.pipe( - startWith(this.form.controls['autofanspeed'].value) + startWith(this.form.controls['autofanspeed'].value), + takeUntil(this.destroy$) ).subscribe(autofanspeed => { if (autofanspeed) { this.form.controls['fanspeed'].disable(); @@ -179,8 +184,13 @@ export class EditComponent implements OnInit { }); } + ngOnDestroy(): void { + window.removeEventListener('resize', this.checkDevTools.bind(this)); + this.destroy$.next(); + this.destroy$.complete(); + } - private checkDevTools = () => { + private checkDevTools(): void { if ( window.outerWidth - window.innerWidth > 160 || window.outerHeight - window.innerHeight > 160 @@ -189,7 +199,7 @@ export class EditComponent implements OnInit { } else { this.devToolsOpen = false; } - }; + } public updateSystem() {