feat(ui): pass profileId in navigation
- Updated `navigateToProfiles` in `MainLayoutComponent` to pass `profileId` as a query parameter. - Updated `ProfilesComponent` to read the `id` query parameter and set `editingProfileId` accordingly.
This commit is contained in:
parent
99e18ee24c
commit
2621e89c68
2 changed files with 13 additions and 4 deletions
|
|
@ -127,8 +127,7 @@ export class MainLayoutComponent implements AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToProfiles(profileId: string) {
|
navigateToProfiles(profileId: string) {
|
||||||
// TODO: Could pass profileId via query params or state
|
this.router.navigate(['/', 'profiles'], { queryParams: { id: profileId } });
|
||||||
this.router.navigate(['/', 'profiles']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToConsole(minerName: string) {
|
navigateToConsole(minerName: string) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Component, inject, signal } from '@angular/core';
|
import { Component, inject, signal, OnInit } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { MinerService } from '../../miner.service';
|
import { MinerService } from '../../miner.service';
|
||||||
import { NotificationService } from '../../notification.service';
|
import { NotificationService } from '../../notification.service';
|
||||||
import { ProfileCreateComponent } from '../../profile-create.component';
|
import { ProfileCreateComponent } from '../../profile-create.component';
|
||||||
|
|
@ -555,9 +556,10 @@ import { ProfileCreateComponent } from '../../profile-create.component';
|
||||||
}
|
}
|
||||||
`]
|
`]
|
||||||
})
|
})
|
||||||
export class ProfilesComponent {
|
export class ProfilesComponent implements OnInit {
|
||||||
private minerService = inject(MinerService);
|
private minerService = inject(MinerService);
|
||||||
private notifications = inject(NotificationService);
|
private notifications = inject(NotificationService);
|
||||||
|
private route = inject(ActivatedRoute);
|
||||||
state = this.minerService.state;
|
state = this.minerService.state;
|
||||||
|
|
||||||
showCreateForm = signal(false);
|
showCreateForm = signal(false);
|
||||||
|
|
@ -571,6 +573,14 @@ export class ProfilesComponent {
|
||||||
|
|
||||||
profiles = () => this.state().profiles;
|
profiles = () => this.state().profiles;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.route.queryParams.subscribe(params => {
|
||||||
|
if (params['id']) {
|
||||||
|
this.editingProfileId.set(params['id']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isRunning(profileId: string): boolean {
|
isRunning(profileId: string): boolean {
|
||||||
return this.state().runningMiners.some(m => m.profile_id === profileId);
|
return this.state().runningMiners.some(m => m.profile_id === profileId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue