📚 AtmoSwing Web Viewer Docs

← Back to Home

Contexts

Files


Modules

contexts/WorkspaceContext

React context for managing workspace (region) selection and associated forecast data. Handles workspace selection, URL synchronization, and workspace-specific data loading.

contexts/SynthesisContext

Provides lead time arrays (daily & sub-daily), target date selection and per-method synthesis data. Parses total synthesis responses to derive lead resolution structure.

contexts/SnackbarContext

React context for managing application-wide notification snackbars. Provides a queue-based system for displaying temporary messages to users.

contexts/SelectedEntityContext

React context for managing the currently selected forecast entity (station/point). Automatically resets selection when workspace changes.

contexts/MethodsContext

React context for managing forecast methods and configurations. Fetches available methods, manages selection, and provides normalized method tree.

contexts/ForecastsContext

Composite provider combining all forecast-related contexts. Re-exports convenient hooks for accessing forecast functionality.

contexts/ForecastValuesContext

Fetches and exposes forecast values (normalized + raw) for entities based on current selection. Handles lead time resolution, availability detection, and percentile/normalization parameters.

contexts/ForecastSessionContext

Manages the active forecast date, base date, percentile/normalization parameters and shifting logic. Provides helper functions to restore last available forecast and shift base date by hour increments.

contexts/EntitiesContext

Manages fetching and caching of forecast entities (stations/points) and relevant subsets. Handles automatic clearing on workspace or configuration changes and derives cache keys.

contexts/ConfigContext

React context for managing runtime configuration.

This context fetches /config.json at startup and makes configuration values available throughout the application via the useConfig hook.

contexts/WorkspaceContext

React context for managing workspace (region) selection and associated forecast data. Handles workspace selection, URL synchronization, and workspace-specific data loading.

contexts/WorkspaceContext.WorkspaceProvider(props) ⇒ React.ReactElement

Provider component for workspace management. Manages workspace selection, URL synchronization, and workspace-specific data loading.

Kind: static method of contexts/WorkspaceContext

Param Type Description
props Object Component props
props.children React.ReactNode Child components

contexts/WorkspaceContext.useWorkspace() ⇒ Object | string | function | Object | boolean | Error | string

Hook to access workspace context.

Kind: static method of contexts/WorkspaceContext
Returns: Object - Workspace context valuestring - returns.workspace - Current workspace keyfunction - returns.setWorkspace - Function to change workspaceObject - returns.workspaceData - Workspace data including last forecast dateboolean - returns.loading - Loading stateError - returns.error - Error if loading failedstring - returns.invalidWorkspaceKey - Invalid workspace key from URL (if any)
Example

const { workspace, setWorkspace, workspaceData } = useWorkspace();
console.log('Current workspace:', workspace);
setWorkspace('newWorkspace');

contexts/SynthesisContext

Provides lead time arrays (daily & sub-daily), target date selection and per-method synthesis data. Parses total synthesis responses to derive lead resolution structure.

contexts/SynthesisContext.useSynthesis ⇒ Object | Array | Array | string | number | Date | null | function | Array | boolean | Error | null

Hook to access synthesis context.

Kind: static constant of contexts/SynthesisContext
Returns: Object - Synthesis state and helpersArray - returns.dailyLeads - Array of daily lead recordsArray - returns.subDailyLeads - Array of sub-daily lead recordsstring - returns.leadResolution - 'daily' or 'sub'number - returns.selectedLead - Selected lead indexDate | null - returns.selectedTargetDate - Selected target date objectfunction - returns.selectTargetDate - Helper to select target date with preferenceArray - returns.perMethodSynthesis - Baseline per-method normalized synthesis valuesboolean - returns.perMethodSynthesisLoading - Loading state for per-method dataError | null - returns.perMethodSynthesisError - Error for per-method data

contexts/SnackbarContext

React context for managing application-wide notification snackbars. Provides a queue-based system for displaying temporary messages to users.

contexts/SnackbarContext.useSnackbar ⇒ Object | function | function | function | Array

Hook to access snackbar functionality. Must be used within a SnackbarProvider.

Kind: static constant of contexts/SnackbarContext
Returns: Object - Snackbar context valuefunction - returns.enqueueSnackbar - Add a new snackbarfunction - returns.closeSnackbar - Close a snackbarfunction - returns.removeSnackbar - Remove a snackbarArray - returns.snackbars - Array of active snackbars
Throws:

Example

const { enqueueSnackbar } = useSnackbar();
enqueueSnackbar('Success!', { variant: 'success' });

contexts/SnackbarContext.SnackbarProvider ⇒ React.ReactElement

Provider component for snackbar notifications. Manages a queue of snackbar messages and provides methods to add, close, and remove them.

Kind: static constant of contexts/SnackbarContext

Param Type Description
props Object Component props
props.children React.ReactNode Child components

Example

<SnackbarProvider>
  <App />
</SnackbarProvider>

contexts/SelectedEntityContext

React context for managing the currently selected forecast entity (station/point). Automatically resets selection when workspace changes.

contexts/SelectedEntityContext.useSelectedEntity ⇒ Object | string | number | null | function

Hook to access the selected entity context.

Kind: static constant of contexts/SelectedEntityContext
Returns: Object - Selected entity context valuestring | number | null - returns.selectedEntityId - Currently selected entity ID, or nullfunction - returns.setSelectedEntityId - Function to set the selected entity ID
Example

const { selectedEntityId, setSelectedEntityId } = useSelectedEntity();
setSelectedEntityId(123); // Select entity with ID 123
console.log(selectedEntityId); // Logs: 123

contexts/SelectedEntityContext.SelectedEntityProvider(props) ⇒ React.ReactElement

Provider component for selected entity state management. Tracks which forecast entity is currently selected and resets on workspace change.

Kind: static method of contexts/SelectedEntityContext

Param Type Description
props Object Component props
props.children React.ReactNode Child components

contexts/MethodsContext

React context for managing forecast methods and configurations. Fetches available methods, manages selection, and provides normalized method tree.

contexts/MethodsContext.useMethods ⇒ Object | Array | boolean | Error | Object | function

Hook to access methods context.

Kind: static constant of contexts/MethodsContext
Returns: Object - Methods context valueArray - returns.methodConfigTree - Normalized tree of methods with nested configsboolean - returns.methodsLoading - Loading state for methods fetchError - returns.methodsError - Error if methods fetch failedObject - returns.selectedMethodConfig - Currently selected method and configfunction - returns.setSelectedMethodConfig - Function to set method/config selection
Example

const { methodConfigTree, selectedMethodConfig, setSelectedMethodConfig } = useMethods();
// Select first method
setSelectedMethodConfig({ method: methodConfigTree[0], config: null });

contexts/MethodsContext.MethodsProvider(props) ⇒ React.ReactElement

Provider component for forecast methods and configurations. Manages method selection with workspace scoping and auto-selection.

Kind: static method of contexts/MethodsContext

Param Type Description
props Object Component props
props.children React.ReactNode Child components

contexts/ForecastsContext

Composite provider combining all forecast-related contexts. Re-exports convenient hooks for accessing forecast functionality.

contexts/ForecastsContext.useMethods ⇒ Object

Hook to access methods context. Re-export from MethodsContext.

Kind: static constant of contexts/ForecastsContext
Returns: Object - Methods context value

contexts/ForecastsContext.useEntities ⇒ Object

Hook to access entities context. Re-export from EntitiesContext.

Kind: static constant of contexts/ForecastsContext
Returns: Object - Entities context value

contexts/ForecastsContext.useSynthesis ⇒ Object

Hook to access synthesis context. Re-export from SynthesisContext.

Kind: static constant of contexts/ForecastsContext
Returns: Object - Synthesis context value

contexts/ForecastsContext.useForecastValues ⇒ Object

Hook to access forecast values context. Re-export from ForecastValuesContext.

Kind: static constant of contexts/ForecastsContext
Returns: Object - Forecast values context value

contexts/ForecastsContext.useForecastParameters ⇒ Object | number | function | string | function

Hook to access forecast parameters (percentile and normalization).

Kind: static constant of contexts/ForecastsContext
Returns: Object - Forecast parametersnumber - returns.percentile - Current percentile valuefunction - returns.setPercentile - Set percentilestring - returns.normalizationRef - Normalization referencefunction - returns.setNormalizationRef - Set normalization reference

contexts/ForecastsContext.useSelectedEntity ⇒ Object

Hook to access selected entity context. Re-export from SelectedEntityContext.

Kind: static constant of contexts/ForecastsContext
Returns: Object - Selected entity context value

contexts/ForecastsContext.ForecastsProvider(props) ⇒ React.ReactElement

Composite provider wrapping all forecast-related contexts.

Kind: static method of contexts/ForecastsContext

Param Type
props Object
props.children React.ReactNode

contexts/ForecastValuesContext

Fetches and exposes forecast values (normalized + raw) for entities based on current selection. Handles lead time resolution, availability detection, and percentile/normalization parameters.

contexts/ForecastValuesContext.useForecastValues ⇒ Object | Object | Object | boolean | Error | null | boolean

Hook to access forecast values context.

Kind: static constant of contexts/ForecastValuesContext
Returns: Object - Forecast values stateObject - returns.forecastValues - Map entityId -> raw forecast valueObject - returns.forecastValuesNorm - Map entityId -> normalized forecast valueboolean - returns.forecastLoading - Loading stateError | null - returns.forecastError - Error during fetchboolean - returns.forecastUnavailable - Flag when data deemed unavailable (e.g., no leads)

contexts/ForecastValuesContext.ForecastValuesProvider(props) ⇒ React.ReactElement

ForecastValuesProvider component.

Kind: static method of contexts/ForecastValuesContext

Param Type
props Object
props.children React.ReactNode

contexts/ForecastSessionContext

Manages the active forecast date, base date, percentile/normalization parameters and shifting logic. Provides helper functions to restore last available forecast and shift base date by hour increments.

contexts/ForecastSessionContext.useForecastSession ⇒ Object | string | null | Date | null | number | function | number | string | function | function | function | boolean | boolean | number

Hook to access forecast session context.

Kind: static constant of contexts/ForecastSessionContext
Returns: Object - Forecast session state and helpersstring | null - returns.activeForecastDate - Raw active forecast date stringDate | null - returns.forecastBaseDate - Parsed base date objectnumber - returns.percentile - Selected percentile (e.g., 90)function - returns.setPercentile - Setter for percentilenumber | string - returns.normalizationRef - Normalization reference valuefunction - returns.setNormalizationRef - Setter for normalization referencefunction - returns.shiftForecastBaseDate - Shift search function for base datefunction - returns.restoreLastAvailableForecast - Restore last workspace forecastboolean - returns.baseDateSearchFailed - Flag when shift search failsboolean - returns.baseDateSearching - Whether shift search is in progressnumber - returns.resetVersion - Incrementing version to trigger dependent resets

contexts/ForecastSessionContext.ForecastSessionProvider(props) ⇒ React.ReactElement

ForecastSessionProvider component. Initializes forecast session state from workspace data and exposes shifting & restore helpers.

Kind: static method of contexts/ForecastSessionContext

Param Type
props Object
props.children React.ReactNode

contexts/EntitiesContext

Manages fetching and caching of forecast entities (stations/points) and relevant subsets. Handles automatic clearing on workspace or configuration changes and derives cache keys.

contexts/EntitiesContext.useEntities ⇒ Object | Array | boolean | Error | null | Set.<(string|number)> | null | string | string | null

Hook to access entities context.

Kind: static constant of contexts/EntitiesContext
Returns: Object - Entities context valueArray - returns.entities - Array of entity objectsboolean - returns.entitiesLoading - Loading stateError | null - returns.entitiesError - Error during entity fetchSet.<(string|number)> | null - returns.relevantEntities - Set of relevant entity IDs or nullstring - returns.entitiesWorkspace - Workspace key used for entitiesstring | null - returns.entitiesKey - Cache key used for the request

contexts/EntitiesContext.EntitiesProvider(props) ⇒ React.ReactElement

EntitiesProvider component. Fetches entity list and relevant entity IDs for the selected method/config.

Kind: static method of contexts/EntitiesContext

Param Type
props Object
props.children React.ReactNode

contexts/ConfigContext

React context for managing runtime configuration.

This context fetches /config.json at startup and makes configuration values available throughout the application via the useConfig hook.

contexts/ConfigContext.ConfigProvider(props) ⇒ React.ReactElement

Provider component that fetches and manages runtime configuration.

Fetches /config.json on mount with cache: no-store to ensure fresh config. Merges normalized config into the shared config object and provides it via context.

Kind: static method of contexts/ConfigContext

Param Type Description
props Object
props.children React.ReactNode Child components

contexts/ConfigContext.useConfig() ⇒ Object

Hook to access runtime configuration.

Kind: static method of contexts/ConfigContext
Returns: Object - Configuration object with __workspacesLoaded flag
Example

const config = useConfig();
if (config.__workspacesLoaded) {
  console.log('Workspaces:', config.workspaces);
}