From ea9fc98e64306d9d483f5c0ea4a0baf5dd3dd9db Mon Sep 17 00:00:00 2001 From: DerDavidBohl Date: Thu, 4 Sep 2025 14:31:49 +0200 Subject: [PATCH] Added System Information --- .../api/GiteaDeploymentsController.java | 2 +- .../DeploymentsConfigurationProvider.java | 2 +- .../dirigent/system/SystemInformation.java | 5 ++++ .../api/SystemInformationController.java | 25 +++++++++++++++++++ frontend/src/app/overview/api.service.ts | 5 ++++ .../src/app/overview/overview.component.html | 6 ++++- .../src/app/overview/overview.component.ts | 5 ++++ .../src/app/overview/system-information.d.ts | 5 ++++ frontend/src/index.html | 2 +- 9 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 backend/src/main/java/org/davidbohl/dirigent/system/SystemInformation.java create mode 100644 backend/src/main/java/org/davidbohl/dirigent/system/api/SystemInformationController.java create mode 100644 frontend/src/app/overview/system-information.d.ts diff --git a/backend/src/main/java/org/davidbohl/dirigent/deployments/api/GiteaDeploymentsController.java b/backend/src/main/java/org/davidbohl/dirigent/deployments/api/GiteaDeploymentsController.java index eeb321f..9e58aee 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/deployments/api/GiteaDeploymentsController.java +++ b/backend/src/main/java/org/davidbohl/dirigent/deployments/api/GiteaDeploymentsController.java @@ -16,7 +16,7 @@ public class GiteaDeploymentsController { private final ApplicationEventPublisher applicationEventPublisher; - @Value("${dirigent.deployments.git.url}") + @Value("${dirigent.deployments.git.url:}") private String configUrl; public GiteaDeploymentsController(ApplicationEventPublisher applicationEventPublisher) { diff --git a/backend/src/main/java/org/davidbohl/dirigent/deployments/config/DeploymentsConfigurationProvider.java b/backend/src/main/java/org/davidbohl/dirigent/deployments/config/DeploymentsConfigurationProvider.java index 14cfa86..9e4cba3 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/deployments/config/DeploymentsConfigurationProvider.java +++ b/backend/src/main/java/org/davidbohl/dirigent/deployments/config/DeploymentsConfigurationProvider.java @@ -14,7 +14,7 @@ public class DeploymentsConfigurationProvider { private final GitService gitService; - @Value("${dirigent.deployments.git.url}") + @Value("${dirigent.deployments.git.url:}") private String gitUrl; public DeploymentsConfigurationProvider(GitService gitService) { diff --git a/backend/src/main/java/org/davidbohl/dirigent/system/SystemInformation.java b/backend/src/main/java/org/davidbohl/dirigent/system/SystemInformation.java new file mode 100644 index 0000000..972ae0b --- /dev/null +++ b/backend/src/main/java/org/davidbohl/dirigent/system/SystemInformation.java @@ -0,0 +1,5 @@ +package org.davidbohl.dirigent.system; + +public record SystemInformation(String instanceName, String gitUrl) { + +} diff --git a/backend/src/main/java/org/davidbohl/dirigent/system/api/SystemInformationController.java b/backend/src/main/java/org/davidbohl/dirigent/system/api/SystemInformationController.java new file mode 100644 index 0000000..4132a46 --- /dev/null +++ b/backend/src/main/java/org/davidbohl/dirigent/system/api/SystemInformationController.java @@ -0,0 +1,25 @@ +package org.davidbohl.dirigent.system.api; + +import org.davidbohl.dirigent.system.SystemInformation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController() +@RequestMapping(path = "/api/v1/system-information") +public class SystemInformationController { + + @Value("${dirigent.instanceName:'Unknown Instance'}") + private String instanceName; + + + @Value("${dirigent.deployments.git.url:}") + private String gitUrl; + + @GetMapping() + public SystemInformation get() { + return new SystemInformation(instanceName, gitUrl); + } + +} diff --git a/frontend/src/app/overview/api.service.ts b/frontend/src/app/overview/api.service.ts index b9e5d2e..effb270 100644 --- a/frontend/src/app/overview/api.service.ts +++ b/frontend/src/app/overview/api.service.ts @@ -2,6 +2,7 @@ import {Injectable} from '@angular/core'; import {Observable, ReplaySubject} from 'rxjs'; import {Deployment} from './deploymentState'; import {HttpClient} from '@angular/common/http'; +import { SystemInformation } from './system-information'; @Injectable({ providedIn: 'root' @@ -25,6 +26,10 @@ export class ApiService { return this.http.get>('api/v1/deployments'); } + getSystemInformation(): Observable { + return this.http.get('api/v1/system-information'); + } + stopDeployment(deploymentState: Deployment): Observable { return this.http.post(`api/v1/deployments/${deploymentState.name}/stop`, {}); } diff --git a/frontend/src/app/overview/overview.component.html b/frontend/src/app/overview/overview.component.html index 83fa6f6..5c791c1 100644 --- a/frontend/src/app/overview/overview.component.html +++ b/frontend/src/app/overview/overview.component.html @@ -1,6 +1,9 @@
-

Your Deployments ({{ (deployments$ | async)?.length}})

+

Deployments@{{ (systemInformation$ | async)?.instanceName }} ({{ (deployments$ | async)?.length}})

+
Search... @@ -66,3 +69,4 @@
+ diff --git a/frontend/src/app/overview/overview.component.ts b/frontend/src/app/overview/overview.component.ts index 8127eff..9dcfb25 100644 --- a/frontend/src/app/overview/overview.component.ts +++ b/frontend/src/app/overview/overview.component.ts @@ -25,6 +25,7 @@ import {AsyncPipe} from '@angular/common'; import {FormsModule} from '@angular/forms'; import {MatSort, MatSortHeader, Sort} from '@angular/material/sort'; import {MatFormField, MatInput, MatLabel} from '@angular/material/input'; +import { SystemInformation } from './system-information'; @Component({ selector: 'app-overview', @@ -67,12 +68,16 @@ export class OverviewComponent implements OnInit { deployments$: Observable>; tableDataSource$: Observable>; filterValues$: Observable; + systemInformation$: Observable; displayedColumns = ['actions', 'name', 'state', 'message']; readonly dialog = inject(MatDialog); constructor(private apiService: ApiService) { + + this.systemInformation$ = apiService.getSystemInformation(); + this.deployments$ = this.apiService.deploymentStates$.pipe( distinctUntilChanged((prev, curr) => JSON.stringify(prev) === JSON.stringify(curr)) ); diff --git a/frontend/src/app/overview/system-information.d.ts b/frontend/src/app/overview/system-information.d.ts new file mode 100644 index 0000000..3b23b41 --- /dev/null +++ b/frontend/src/app/overview/system-information.d.ts @@ -0,0 +1,5 @@ + +export interface SystemInformation { + instanceName: string; + gitUrl: string; +} diff --git a/frontend/src/index.html b/frontend/src/index.html index 70fd275..4eb4729 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -2,7 +2,7 @@ - DirigentFrontend + Dirigent