Skip to content

Commit 07a198f

Browse files
committed
feat(Settings): display system information
1 parent 377f491 commit 07a198f

File tree

8 files changed

+130
-300
lines changed

8 files changed

+130
-300
lines changed

admin/app/controllers/settings_controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export default class SettingsController {
99
) { }
1010

1111
async system({ inertia }: HttpContext) {
12-
// const services = await this.systemService.getServices();
12+
const systemInfo = await this.systemService.getSystemInfo();
1313
return inertia.render('settings/system', {
14-
// system: {
15-
// services
16-
// }
14+
system: {
15+
info: systemInfo
16+
}
1717
});
1818
}
1919

admin/app/controllers/system_controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export default class SystemController {
1111
private dockerService: DockerService
1212
) { }
1313

14+
async getSystemInfo({ }: HttpContext) {
15+
return await this.systemService.getSystemInfo();
16+
}
17+
1418
async getServices({ }: HttpContext) {
1519
return await this.systemService.getServices({ installedOnly: true });
1620
}

admin/app/services/system_service.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import Service from "#models/service"
22
import { inject } from "@adonisjs/core";
33
import { DockerService } from "#services/docker_service";
44
import { ServiceSlim } from "../../types/services.js";
5+
import logger from "@adonisjs/core/services/logger";
6+
import si from 'systeminformation';
7+
import { SystemInformationResponse } from "../../types/system.js";
58

69
@inject()
710
export class SystemService {
@@ -41,4 +44,25 @@ export class SystemService {
4144
return toReturn;
4245

4346
}
47+
48+
async getSystemInfo(): Promise<SystemInformationResponse | undefined> {
49+
try {
50+
const [cpu, mem, os, disk] = await Promise.all([
51+
si.cpu(),
52+
si.mem(),
53+
si.osInfo(),
54+
si.diskLayout()
55+
]);;
56+
57+
return {
58+
cpu,
59+
mem,
60+
os,
61+
disk
62+
};
63+
} catch (error) {
64+
logger.error('Error getting system info:', error);
65+
return undefined;
66+
}
67+
}
4468
}

admin/inertia/pages/settings/system.tsx

Lines changed: 60 additions & 296 deletions
Large diffs are not rendered by default.

admin/package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"react-adonis-transmit": "^1.0.1",
9393
"react-dom": "^19.1.0",
9494
"reflect-metadata": "^0.2.2",
95+
"systeminformation": "^5.27.7",
9596
"tailwindcss": "^4.1.10",
9697
"yaml": "^2.8.0"
9798
},

admin/start/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ router.group(() => {
4343
}).prefix('/api/docs')
4444

4545
router.group(() => {
46+
router.get('/info', [SystemController, 'getSystemInfo'])
4647
router.get('/services', [SystemController, 'getServices'])
4748
router.post('/services/affect', [SystemController, 'affectService'])
4849
router.post('/services/install', [SystemController, 'installService'])

admin/types/system.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Systeminformation } from "systeminformation"
2+
3+
4+
export type SystemInformationResponse = {
5+
cpu: Systeminformation.CpuData
6+
mem: Systeminformation.MemData
7+
os: Systeminformation.OsData
8+
disk: Systeminformation.DiskLayoutData[]
9+
}

0 commit comments

Comments
 (0)