"}]});
});
}
@@ -344,4 +372,25 @@ export class PagesComponent implements OnInit {
}
fileReader.readAsText(file);
}
+
+ loadRemote()
+ {
+ if (!this.remoteLoader) return;
+ this.blockedMenu = true;
+ this.progress = true;
+ this.cdr.detectChanges();
+ this.remoteLoader.loadRemoteData().subscribe({next: value => {
+ this.blockedMenu = false;
+ this.progress = false;
+ // if (value?.profiles)
+ // this.profiles = value.profiles;
+ this.cdr.detectChanges();
+ }, error: error => {
+ console.error("Error during remote extraction", error);
+ this.blockedMenu = false;
+ this.progress = false;
+ this.messageService.add({severity:'error', summary:'Error during remote extraction'});
+ this.cdr.detectChanges();
+ }});
+ }
}
diff --git a/src/app/remote-registration/remote-registration.component.html b/src/app/remote-registration/remote-registration.component.html
index d079f87..66d9fe6 100644
--- a/src/app/remote-registration/remote-registration.component.html
+++ b/src/app/remote-registration/remote-registration.component.html
@@ -34,7 +34,7 @@
-
+
{{remote.remote_name}} (selected)
diff --git a/src/app/remote-widget/remote-widget.component.html b/src/app/remote-widget/remote-widget.component.html
index df10728..ac21474 100644
--- a/src/app/remote-widget/remote-widget.component.html
+++ b/src/app/remote-widget/remote-widget.component.html
@@ -25,9 +25,9 @@
-
+
-
diff --git a/src/app/remote-widget/remote-widget.component.ts b/src/app/remote-widget/remote-widget.component.ts
index a94e5ef..199a432 100644
--- a/src/app/remote-widget/remote-widget.component.ts
+++ b/src/app/remote-widget/remote-widget.component.ts
@@ -48,14 +48,13 @@ import {DropdownOverComponent} from "../controls/dropdown-over/dropdown-over.com
export class RemoteWidgetComponent implements OnInit {
@Input() visible = true;
@Input() scale = 0.8;
- protected readonly Math = Math;
-
- minimized = false;
+ @Input() minimized = false;
+ @Input() remote: Remote | undefined;
remoteState: RemoteState | undefined;
mediaEntity: MediaEntityState | undefined;
mediaEntities: MediaEntityState[] = [];
- selectedRemote: Remote | undefined;
activities: Activity[] = [];
+ protected readonly Math = Math;
constructor(private server:ServerService, protected remoteWebsocketService: RemoteWebsocketService, private cdr:ChangeDetectorRef) { }
@@ -76,8 +75,8 @@ export class RemoteWidgetComponent implements OnInit {
this.cdr.detectChanges();
});
this.server.remote$.subscribe(remote => {
- this.selectedRemote = remote;
- this.server.getRemoteBattery(this.selectedRemote).subscribe(batteryInfo => {
+ this.remote = remote;
+ this.server.getRemoteBattery(this.remote).subscribe(batteryInfo => {
this.remoteState = {batteryInfo};
this.cdr.detectChanges();
})
@@ -88,14 +87,14 @@ export class RemoteWidgetComponent implements OnInit {
loadActivities()
{
- if (!this.selectedRemote) return;
- this.server.getRemoteActivities(this.selectedRemote).subscribe(activities => {
+ if (!this.remote) return;
+ this.server.getRemoteActivities(this.remote).subscribe(activities => {
this.activities = activities;
activities.forEach(activity => {
if (activity.attributes?.state && activity.attributes.state === "ON"
- && this.selectedRemote && activity.entity_id)
+ && this.remote && activity.entity_id)
{
- this.server.getRemoteActivity(this.selectedRemote, activity.entity_id).subscribe(activity => {
+ this.server.getRemoteActivity(this.remote, activity.entity_id).subscribe(activity => {
const existingActivity = this.activities.find(item => item.entity_id === activity.entity_id);
if (!existingActivity)
this.activities.push(activity);
@@ -105,7 +104,7 @@ export class RemoteWidgetComponent implements OnInit {
activity.options?.included_entities?.forEach(entity => {
if (entity.entity_type !== "media_player") return; //TODO add other entities
if (this.mediaEntities.find(item => item.entity_id === entity.entity_id)) return;
- if (this.selectedRemote && entity.entity_id)
+ if (this.remote && entity.entity_id)
{
this.remoteWebsocketService.updateEntity(entity.entity_id);
}
diff --git a/src/app/server.service.ts b/src/app/server.service.ts
index 968c218..a013b45 100644
--- a/src/app/server.service.ts
+++ b/src/app/server.service.ts
@@ -296,32 +296,27 @@ export class ServerService {
getRemoteProfiles(remote: Remote): Observable
{
- const profiles: Profile[] = [];
- let obs = this.http.get(`/api/remote/${remote.address}/profiles`).pipe(
+ return this.http.get(`/api/remote/${remote.address}/profiles`).pipe(
mergeMap(profiles => {
- return from(profiles);
- }),
- mergeMap(profile => {
- return forkJoin([
- this.http.get(`/api/remote/${remote.address}/profiles/${profile.profile_id}/pages`).pipe(map(pages => {
- profile.pages = pages;
- })),
- this.http.get(`/api/remote/${remote.address}/profiles/${profile.profile_id}/groups`).pipe(map(groups => {
- profile.groups = groups;
- })),
- ]).pipe(map(groups => {
- return profile;
+ console.log("Profiles", profiles);
+ return from(profiles).pipe(mergeMap(profile => {
+ return forkJoin([
+ this.http.get(`/api/remote/${remote.address}/profiles/${profile.profile_id}/pages`).pipe(map(pages => {
+ profile.pages = pages;
+ })),
+ this.http.get(`/api/remote/${remote.address}/profiles/${profile.profile_id}/groups`).pipe(map(groups => {
+ profile.groups = groups;
+ })),
+ ]).pipe(map(groups => {
+ console.log("Update profile", profile);
+ return profiles;
+ }))
}))
- }),
- map(profileData => {
- profiles.push(profileData);
- return profileData;
- }))
- return forkJoin([obs]).pipe(map(results => {
+ })).pipe(map(profiles => {
this.profiles = profiles;
this.profiles$.next(profiles);
- return results;
- }))
+ return profiles;
+ }));
}
getRemoteMacros(remote: Remote): Observable
|