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

fix: Show custom values in dropdown if set #578

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,70 +67,18 @@
</div>
</div>

<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1366">

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="frequency">Frequency</label>
<div class="col-12 md:col-10">
<p-dropdown [options]="BM1366DropdownFrequency" optionLabel="name" optionValue="value"
formControlName="frequency"></p-dropdown>
</div>
</div>


<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="coreVoltage">Core Voltage</label>
<p-dropdown class="col-12 md:col-10" [options]="BM1366CoreVoltage" optionLabel="name"
optionValue="value" formControlName="coreVoltage"></p-dropdown>
</div>

</ng-container>

<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1368">

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="frequency">Frequency</label>
<div class="col-12 md:col-10">
<p-dropdown [options]="BM1368DropdownFrequency" optionLabel="name" optionValue="value"
formControlName="frequency"></p-dropdown>
</div>
</div>

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="coreVoltage">Core Voltage</label>
<p-dropdown class="col-12 md:col-10" [options]="BM1368CoreVoltage" optionLabel="name"
optionValue="value" formControlName="coreVoltage"></p-dropdown>
</div>
</ng-container>
<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1370">

<ng-container *ngIf="!devToolsOpen && [eASICModel.BM1366, eASICModel.BM1368, eASICModel.BM1370, eASICModel.BM1397].includes(ASICModel)">
<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="frequency">Frequency</label>
<div class="col-12 md:col-10">
<p-dropdown [options]="BM1370DropdownFrequency" optionLabel="name" optionValue="value"
<p-dropdown [options]="getDropdownFrequency()" optionLabel="name" optionValue="value"
formControlName="frequency"></p-dropdown>
</div>
</div>

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="coreVoltage">Core Voltage</label>
<p-dropdown class="col-12 md:col-10" [options]="BM1370CoreVoltage" optionLabel="name"
optionValue="value" formControlName="coreVoltage"></p-dropdown>
</div>
</ng-container>
<ng-container *ngIf="!devToolsOpen && ASICModel == eASICModel.BM1397">

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="frequency">Frequency</label>

<p-dropdown class="col-12 md:col-10" [options]="BM1397DropdownFrequency" optionLabel="name"
optionValue="value" formControlName="frequency"></p-dropdown>

</div>

<div class="field grid p-fluid">
<label class="col-12 mb-2 md:col-2 md:mb-0" htmlFor="coreVoltage">Core Voltage</label>
<p-dropdown class="col-12 md:col-10" [options]="BM1397CoreVoltage" optionLabel="name"
<p-dropdown class="col-12 md:col-10" [options]="getCoreVoltage()" optionLabel="name"
optionValue="value" formControlName="coreVoltage"></p-dropdown>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export class EditComponent implements OnInit {
private fb: FormBuilder,
private systemService: SystemService,
private toastr: ToastrService,
private toastrService: ToastrService,
private loadingService: LoadingService
) {

Expand Down Expand Up @@ -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;
}

}
Loading