UPDATE
This commit is contained in:
@@ -2,10 +2,73 @@ import { apiClient } from '../client'
|
||||
|
||||
const PREFIX = '/api/farm-alerts'
|
||||
|
||||
export interface FarmAlertsSummary {
|
||||
tracker?: Record<string, unknown>
|
||||
timeline?: Record<string, unknown>
|
||||
recommendations?: Record<string, unknown>
|
||||
export interface FarmAlertRequestItem {
|
||||
alert_id: string
|
||||
level: string
|
||||
title: string
|
||||
message: string
|
||||
suggested_action?: string
|
||||
source_metric_type?: string
|
||||
timestamp?: string | null
|
||||
payload?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface FarmAlertTrackerItem {
|
||||
metric_type?: string
|
||||
title?: string
|
||||
current_value?: number
|
||||
threshold_value?: number
|
||||
severity?: string
|
||||
duration?: string
|
||||
timestamp?: string
|
||||
domain?: string
|
||||
unit?: string
|
||||
icon?: string
|
||||
summary?: string
|
||||
recommended_action?: string
|
||||
explanation?: string
|
||||
}
|
||||
|
||||
export interface FarmAlertNotificationItem {
|
||||
id: number
|
||||
uuid: string
|
||||
farm_uuid: string
|
||||
since_id: number
|
||||
endpoint?: string
|
||||
title: string
|
||||
message: string
|
||||
level: string
|
||||
suggested_action?: string
|
||||
source_alert_id?: string
|
||||
source_metric_type?: string
|
||||
payload?: Record<string, unknown>
|
||||
is_read: boolean
|
||||
metadata?: Record<string, unknown>
|
||||
created_at: string
|
||||
updated_at?: string
|
||||
}
|
||||
|
||||
export interface FarmAlertsTrackerPayload {
|
||||
totalAlerts?: number
|
||||
alerts?: FarmAlertTrackerItem[]
|
||||
alertStats?: Array<Record<string, unknown>>
|
||||
alertClusters?: Array<Record<string, unknown>>
|
||||
mostCriticalIssue?: FarmAlertTrackerItem | null
|
||||
prioritizedAlertSummaries?: string[]
|
||||
recommendedOperationalActions?: string[]
|
||||
humanReadableExplanations?: string[]
|
||||
}
|
||||
|
||||
export interface FarmAlertsTrackerResponse {
|
||||
farm_uuid: string
|
||||
service_id: string
|
||||
tracker: FarmAlertsTrackerPayload
|
||||
headline?: string
|
||||
overview?: string
|
||||
status_level?: string
|
||||
notifications?: FarmAlertNotificationItem[]
|
||||
raw_llm_response?: string
|
||||
structured_context?: Record<string, unknown>
|
||||
}
|
||||
|
||||
interface ApiResponse<T> {
|
||||
@@ -25,9 +88,19 @@ function extract<T>(res: ApiResponse<T> | T): T {
|
||||
}
|
||||
|
||||
export const farmAlertsService = {
|
||||
async getTracker(farmUuid: string): Promise<Record<string, unknown>> {
|
||||
const res = await apiClient.get<ApiResponse<Record<string, unknown>> | Record<string, unknown>>(
|
||||
`${PREFIX}/tracker/?farm_uuid=${encodeURIComponent(farmUuid)}`
|
||||
async analyzeTracker(
|
||||
payload: { farmUuid: string; alerts?: FarmAlertRequestItem[] },
|
||||
): Promise<FarmAlertsTrackerResponse> {
|
||||
const requestBody = {
|
||||
farm_uuid: payload.farmUuid,
|
||||
...(payload.alerts?.length ? { alerts: payload.alerts } : {}),
|
||||
}
|
||||
|
||||
const res = await apiClient.post<
|
||||
ApiResponse<FarmAlertsTrackerResponse> | FarmAlertsTrackerResponse
|
||||
>(
|
||||
`${PREFIX}/tracker/`,
|
||||
requestBody,
|
||||
)
|
||||
return extract(res)
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ const AppFullCalendar = styled('div')(({ theme }: { theme: Theme }) => ({
|
||||
position: 'relative',
|
||||
borderRadius: 'var(--mui-shape-borderRadius)',
|
||||
'& .fc': {
|
||||
width: '100%',
|
||||
zIndex: 1,
|
||||
|
||||
'.fc-col-header, .fc-daygrid-body, .fc-scrollgrid-sync-table, .fc-timegrid-body, .fc-timegrid-body table': {
|
||||
|
||||
Reference in New Issue
Block a user