feat!: release v2 (#6545)
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386
-139176
No files matched your search
@@ -6,6 +6,7 @@ import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
|
||||
import type { IntegrationInput, IntegrationTestingInput } from "../base/integration";
|
||||
import { Integration } from "../base/integration";
|
||||
import type { IntegrationHttpAuthentication } from "../http-auth";
|
||||
import type { SessionStore } from "../base/session-store";
|
||||
import { createSessionStore } from "../base/session-store";
|
||||
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
||||
@@ -27,38 +28,35 @@ export class OpenMediaVaultIntegration extends Integration implements ISystemHea
|
||||
this.sessionStore = createSessionStore(integration);
|
||||
}
|
||||
|
||||
public override async getHttpAuthenticationAsync(): Promise<IntegrationHttpAuthentication> {
|
||||
const session = await this.getSessionAsync();
|
||||
if (session.type === "cookie") {
|
||||
const cookie = `${session.loginToken};${session.sessionId}`;
|
||||
return { headers: { Cookie: cookie }, redactValues: [cookie, session.loginToken, session.sessionId] };
|
||||
}
|
||||
return {
|
||||
headers: { "X-OPENMEDIAVAULT-SESSIONID": session.sessionId },
|
||||
redactValues: [session.sessionId],
|
||||
};
|
||||
}
|
||||
|
||||
public async getSystemInfoAsync(): Promise<SystemHealthMonitoring> {
|
||||
const systemResponses = await this.makeAuthenticatedRpcCallAsync("system", "getInformation");
|
||||
const fileSystemResponse = await this.makeAuthenticatedRpcCallAsync(
|
||||
"filesystemmgmt",
|
||||
"enumerateMountedFilesystems",
|
||||
{ includeroot: true },
|
||||
);
|
||||
const fileSystem = await this.getFileSystemsAsync();
|
||||
const smartResponse = await this.makeAuthenticatedRpcCallAsync("smart", "enumerateDevices");
|
||||
const cpuTempResponse = await this.makeAuthenticatedRpcCallAsync("cputemp", "get");
|
||||
|
||||
const systemResult = systemInformationSchema.safeParse(await systemResponses.json());
|
||||
const fileSystemResult = fileSystemSchema.safeParse(await fileSystemResponse.json());
|
||||
const smartResult = smartSchema.safeParse(await smartResponse.json());
|
||||
const cpuTempResult = cpuTempSchema.safeParse(await cpuTempResponse.json());
|
||||
|
||||
if (!systemResult.success) {
|
||||
throw new Error("Invalid system information response");
|
||||
}
|
||||
if (!fileSystemResult.success) {
|
||||
throw new Error("Invalid file system response");
|
||||
}
|
||||
if (!smartResult.success) {
|
||||
throw new Error("Invalid SMART information response");
|
||||
}
|
||||
|
||||
const fileSystem = fileSystemResult.data.response.map((fileSystem) => ({
|
||||
deviceName: fileSystem.devicename,
|
||||
used: fileSystem.used,
|
||||
available: fileSystem.available.toString(),
|
||||
percentage: fileSystem.percentage,
|
||||
}));
|
||||
|
||||
const smart = smartResult.data.response.map((smart) => ({
|
||||
deviceName: smart.devicename,
|
||||
temperature: smart.temperature,
|
||||
@@ -90,11 +88,39 @@ export class OpenMediaVaultIntegration extends Integration implements ISystemHea
|
||||
};
|
||||
}
|
||||
|
||||
public async listStorageVolumesAsync(): Promise<{ value: string; label: string }[]> {
|
||||
const fileSystem = await this.getFileSystemsAsync();
|
||||
const { id: integrationId, name: integrationName } = this.integration;
|
||||
|
||||
return fileSystem.map(({ deviceName }) => ({
|
||||
value: `${integrationId}:${deviceName}`,
|
||||
label: `${deviceName} (${integrationName})`,
|
||||
}));
|
||||
}
|
||||
|
||||
protected async testingAsync(input: IntegrationTestingInput): Promise<TestingResult> {
|
||||
await this.getSessionAsync(input.fetchAsync);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
private async getFileSystemsAsync(): Promise<SystemHealthMonitoring["fileSystem"]> {
|
||||
const response = await this.makeAuthenticatedRpcCallAsync("filesystemmgmt", "enumerateMountedFilesystems", {
|
||||
includeroot: true,
|
||||
});
|
||||
const result = fileSystemSchema.safeParse(await response.json());
|
||||
|
||||
if (!result.success) {
|
||||
throw new Error("Invalid file system response");
|
||||
}
|
||||
|
||||
return result.data.response.map((fileSystem) => ({
|
||||
deviceName: fileSystem.devicename,
|
||||
used: fileSystem.used,
|
||||
available: fileSystem.available.toString(),
|
||||
percentage: fileSystem.percentage,
|
||||
}));
|
||||
}
|
||||
|
||||
private async makeAuthenticatedRpcCallAsync(
|
||||
serviceName: string,
|
||||
method: string,
|
||||
|
||||
Reference in new issue
Block a user