mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-25 23:03:47 +01:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { Container } from "@/models/Container";
|
|
|
|
type LogContext = {
|
|
streamConfig: { stdout: boolean; stderr: boolean };
|
|
containers: Container[];
|
|
loadingMore: boolean;
|
|
hasComplexLogs: boolean;
|
|
};
|
|
|
|
// export for testing
|
|
export const loggingContextKey = Symbol("loggingContext") as InjectionKey<LogContext>;
|
|
const searchParams = new URLSearchParams(window.location.search);
|
|
const stdout = searchParams.has("stdout") ? searchParams.get("stdout") === "true" : true;
|
|
const stderr = searchParams.has("stderr") ? searchParams.get("stderr") === "true" : true;
|
|
|
|
export const provideLoggingContext = (containers: Ref<Container[]>) => {
|
|
provide(
|
|
loggingContextKey,
|
|
reactive({
|
|
streamConfig: { stdout, stderr },
|
|
containers,
|
|
loadingMore: false,
|
|
hasComplexLogs: false,
|
|
}),
|
|
);
|
|
};
|
|
|
|
export const useLoggingContext = () => {
|
|
const context = inject(
|
|
loggingContextKey,
|
|
reactive({
|
|
streamConfig: { stdout: true, stderr: true },
|
|
containers: [],
|
|
loadingMore: false,
|
|
hasComplexLogs: false,
|
|
}),
|
|
);
|
|
|
|
return toRefs(context);
|
|
};
|