From d132cdc8ff5909b956903786687a0eaf10d726ea Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 11 Dec 2025 14:29:08 +0000 Subject: [PATCH] feat: Refactor profile edit form to use custom element bindings and improve event handling --- ui/src/app/profile-list.component.html | 49 ++++++++++++++++++++------ ui/src/app/profile-list.component.ts | 40 ++++++++++++++++++++- 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/ui/src/app/profile-list.component.html b/ui/src/app/profile-list.component.html index 9976643..12a29ce 100644 --- a/ui/src/app/profile-list.component.html +++ b/ui/src/app/profile-list.component.html @@ -4,22 +4,51 @@
@if(editingProfile && editingProfile.id === profile.id) {
- - + + + @for(miner of state().manageableMiners; track miner.name) { - {{ miner.name }} + + {{ miner.name }} + } - - - TLS - Huge Pages - Save - Cancel + + + + +
+ + TLS + + + Huge Pages + +
+
+ Save + Cancel +
} @else { {{ profile.name }} ({{ profile.minerType }}) -
+
Edit Delete
diff --git a/ui/src/app/profile-list.component.ts b/ui/src/app/profile-list.component.ts index 608c668..da7e5ef 100644 --- a/ui/src/app/profile-list.component.ts +++ b/ui/src/app/profile-list.component.ts @@ -17,12 +17,50 @@ export class ProfileListComponent { editingProfile: (MiningProfile & { config: any }) | null = null; + // --- Event Handlers for Custom Elements in Edit Form --- + onNameInput(event: Event) { + if (this.editingProfile) { + this.editingProfile.name = (event.target as HTMLInputElement).value; + } + } + + onMinerTypeChange(event: Event) { + if (this.editingProfile) { + this.editingProfile.minerType = (event.target as HTMLSelectElement).value; + } + } + + onPoolInput(event: Event) { + if (this.editingProfile) { + this.editingProfile.config.pool = (event.target as HTMLInputElement).value; + } + } + + onWalletInput(event: Event) { + if (this.editingProfile) { + this.editingProfile.config.wallet = (event.target as HTMLInputElement).value; + } + } + + onTlsChange(event: Event) { + if (this.editingProfile) { + this.editingProfile.config.tls = (event.target as HTMLInputElement).checked; + } + } + + onHugePagesChange(event: Event) { + if (this.editingProfile) { + this.editingProfile.config.hugePages = (event.target as HTMLInputElement).checked; + } + } + deleteProfile(profileId: string) { this.minerService.deleteProfile(profileId).subscribe(); } editProfile(profile: MiningProfile) { - this.editingProfile = { ...profile, config: { ...profile.config } }; + // Create a deep copy to avoid mutating the original profile object during editing + this.editingProfile = JSON.parse(JSON.stringify(profile)); } updateProfile() {