From aaaed9748d8e5b1f716bbb461a6b83bbf763c6fd Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Wed, 26 Mar 2025 15:23:30 +0100 Subject: [PATCH] Initial display of OpenWrt Ethernet interfaces --- .../src/app/backend-communication.service.ts | 20 ++++++++++++++ .../app/dashboard/dashboard.component.html | 27 +++++++++++++++++-- .../src/app/dashboard/dashboard.component.ts | 6 +++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/web-frontend/src/app/backend-communication.service.ts b/web-frontend/src/app/backend-communication.service.ts index d745580..1ed1821 100644 --- a/web-frontend/src/app/backend-communication.service.ts +++ b/web-frontend/src/app/backend-communication.service.ts @@ -109,4 +109,24 @@ export class BackendCommunicationService { }) ); } + + getOpenWrtIpAddresses(): Observable { + return this.http.get(this.urlPrefix + '/api/get_openwrt_ip_addresses').pipe( + tap(response => console.log('Fetched OpenWrt IP addresses: ', response)), + map(response => { + let tmpEthernetInterfaces= ''; + if (response['combined_output'] !== '\n') { + try { + response['combined_output'] = JSON.parse(response['combined_output']); + tmpEthernetInterfaces = response['combined_output']; + } catch (error) { + //console.error('Error parsing combined_output:', error); + } + } + return { + ethernetInterfaces: tmpEthernetInterfaces, + }; + }) + ); + } } diff --git a/web-frontend/src/app/dashboard/dashboard.component.html b/web-frontend/src/app/dashboard/dashboard.component.html index 95d1f37..a4d4f4d 100644 --- a/web-frontend/src/app/dashboard/dashboard.component.html +++ b/web-frontend/src/app/dashboard/dashboard.component.html @@ -9,7 +9,7 @@ @if (openwrtVersion) { - computer + router {{ openwrtVersion }} @@ -27,7 +27,7 @@ - Attached hardware + Attached devices @@ -55,5 +55,28 @@ + + + + + + Ethernet interfaces + + + + @if (ethernetInterfaces) { + @for (ethernetInterface of ethernetInterfaces; track ethernetInterface) { + + settings_ethernet + {{ ethernetInterface.ifname }}: {{ ethernetInterface.address }} + + } + } @else { + + } + + + + diff --git a/web-frontend/src/app/dashboard/dashboard.component.ts b/web-frontend/src/app/dashboard/dashboard.component.ts index b959c92..c9863ef 100644 --- a/web-frontend/src/app/dashboard/dashboard.component.ts +++ b/web-frontend/src/app/dashboard/dashboard.component.ts @@ -33,6 +33,8 @@ export class DashboardComponent { usb?: string[]; pci?: string[]; + ethernetInterfaces?: any; + constructor(private service: BackendCommunicationService) { this.service.pollOpenWrtInfo().subscribe(response => { this.openwrtVersion = response.version; @@ -45,5 +47,9 @@ export class DashboardComponent { this.usb = response.usb; this.pci = response.pci; }); + + this.service.getOpenWrtIpAddresses().subscribe(response => { + this.ethernetInterfaces = response.ethernetInterfaces; + }); } }