Added System Information

This commit is contained in:
DerDavidBohl
2025-09-04 14:31:49 +02:00
parent 6225841ac7
commit ea9fc98e64
9 changed files with 53 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -0,0 +1,5 @@
package org.davidbohl.dirigent.system;
public record SystemInformation(String instanceName, String gitUrl) {
}

View File

@@ -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);
}
}

View File

@@ -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<Array<Deployment>>('api/v1/deployments');
}
getSystemInformation(): Observable<SystemInformation> {
return this.http.get<SystemInformation>('api/v1/system-information');
}
stopDeployment(deploymentState: Deployment): Observable<void> {
return this.http.post<void>(`api/v1/deployments/${deploymentState.name}/stop`, {});
}

View File

@@ -1,6 +1,9 @@
<div class="space-y-4">
<h2 class="text-2xl">Your Deployments (<strong>{{ (deployments$ | async)?.length}}</strong>)</h2>
<h2 class="text-2xl">Deployments&#64;{{ (systemInformation$ | async)?.instanceName }} (<strong>{{ (deployments$ | async)?.length}}</strong>)</h2>
<div>
<a [href]="(systemInformation$ | async)?.gitUrl" target="_blank">View Source</a>
</div>
<div class="md:grid md:grid-cols-5">
<mat-form-field class="w-full md:col-span-2">
<mat-label>Search...</mat-label>
@@ -66,3 +69,4 @@
</table>
</div>

View File

@@ -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<Array<Deployment>>;
tableDataSource$: Observable<Array<Deployment>>;
filterValues$: Observable<string[]>;
systemInformation$: Observable<SystemInformation>;
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))
);

View File

@@ -0,0 +1,5 @@
export interface SystemInformation {
instanceName: string;
gitUrl: string;
}

View File

@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>DirigentFrontend</title>
<title>Dirigent</title>
<base href="/">
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link href="icon-no-background.svg" rel="icon" type="image/svg+xml">