diff --git a/web/.env b/web/.env index 62c225a5e..97c813de8 100644 --- a/web/.env +++ b/web/.env @@ -783,6 +783,14 @@ QUOTA_WARNING_THRESHOLD=75% # QUOTA_CRITICAL_THRESHOLD=95% +# Services that have been running for too long are displayed on the "My Services" page +# with a warning alerting the user that the service has been running for "too long". +# This parameter allows you to define what "too long" means in your Onyxia instance. +# +# Default: 168 hours (7 days) +# +RUNNING_TIME_THRESHOLD_HOURS=168 + # This parameter controls if the configurations tabs should be expanded by default # when the user navigates to the launcher page: # https://github.com/InseeFrLab/onyxia/assets/6702424/a1c5597e-82e5-4532-8a9f-ed3ab7cc1d45 diff --git a/web/src/env.ts b/web/src/env.ts index f16da1f42..c4e3ac755 100644 --- a/web/src/env.ts +++ b/web/src/env.ts @@ -117,7 +117,7 @@ export const { env, injectTransferableEnvsInQueryParams } = createParsedEnvs([ envName: "SPLASHSCREEN_LOGO_SCALE_FACTOR", isUsedInKeycloakTheme: false, validateAndParseOrGetDefault: ({ envValue, envName }) => { - assert(envValue !== "Should have default in .env"); + assert(envValue !== "", "Should have default in .env"); const parsedValue = Number(envValue); @@ -1097,6 +1097,19 @@ export const { env, injectTransferableEnvsInQueryParams } = createParsedEnvs([ return n / 100; } }, + { + envName: "RUNNING_TIME_THRESHOLD_HOURS", + isUsedInKeycloakTheme: false, + validateAndParseOrGetDefault: ({ envValue, envName }) => { + assert(envValue !== "", "Should have default in .env"); + + const parsedValue = Number(envValue); + + assert(!isNaN(parsedValue), `${envName} is not a number`); + + return parsedValue; + } + }, { envName: "QUOTA_CRITICAL_THRESHOLD", isUsedInKeycloakTheme: false, diff --git a/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx b/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx index 319862d11..929a7b5d5 100644 --- a/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx +++ b/web/src/ui/pages/myServices/MyServicesCards/MyServicesCard/MyServicesCard.tsx @@ -21,13 +21,14 @@ import type { Service } from "core/usecases/serviceManagement"; import { assert, type Equals } from "tsafe/assert"; import { TextField, TextFieldProps } from "onyxia-ui/TextField"; import MuiLink from "@mui/material/Link"; +import { env } from "env"; -const runningTimeThreshold = 7 * 24 * 3600 * 1000; +const THRESHOLD_MS = 1000 * 60 * 60 * env.RUNNING_TIME_THRESHOLD_HOURS; function getDoesHaveBeenRunningForTooLong(params: { startTime: number }): boolean { const { startTime } = params; - return Date.now() - startTime > runningTimeThreshold; + return Date.now() - startTime > THRESHOLD_MS; } export type Props = { diff --git a/web/src/vite-env.d.ts b/web/src/vite-env.d.ts index f53f9c4eb..066ffd259 100644 --- a/web/src/vite-env.d.ts +++ b/web/src/vite-env.d.ts @@ -52,6 +52,7 @@ type ImportMetaEnv = { SAMPLE_DATASET_URL: string QUOTA_WARNING_THRESHOLD: string QUOTA_CRITICAL_THRESHOLD: string + RUNNING_TIME_THRESHOLD_HOURS: string SERVICE_CONFIGURATION_EXPANDED_BY_DEFAULT: string S3_DOCUMENTATION_LINK: string VAULT_DOCUMENTATION_LINK: string