mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-05-05 21:50:44 +08:00
Reference check-cx UI: INTELLIGENCE MONITOR hero + 3-column card grid with 60-point timeline bars. Backend: - Add PrimaryPingLatencyMs + Timeline[60] to UserMonitorView - ListRecentHistoryForMonitors: batch CTE + ROW_NUMBER() window query - indexLatestByModel / indexAvailabilityByModel helpers Frontend: - 7 new components: ProviderIcon, MonitorMetricPair, MonitorAvailabilityRow, MonitorTimeline, MonitorHero, MonitorCard, MonitorCardGrid - ChannelStatusView 381→~180 lines (delegated to subcomponents) - AbortController reload concurrency protection - HSL 0-120° availability color mapping - Replace emoji with Icon component (bolt / globe) - i18n: monitorCommon.* shared namespace, channelStatus.hero.* Bump VERSION to 0.1.114.24
84 lines
2.0 KiB
TypeScript
84 lines
2.0 KiB
TypeScript
/**
|
|
* User-facing Channel Monitor API endpoints
|
|
* Read-only views for end users to inspect channel availability/status.
|
|
*/
|
|
|
|
import { apiClient } from './client'
|
|
import type { Provider, MonitorStatus } from './admin/channelMonitor'
|
|
|
|
export type { Provider, MonitorStatus } from './admin/channelMonitor'
|
|
|
|
export interface UserMonitorExtraModel {
|
|
model: string
|
|
status: MonitorStatus
|
|
latency_ms: number | null
|
|
}
|
|
|
|
export interface MonitorTimelinePoint {
|
|
status: MonitorStatus
|
|
latency_ms: number | null
|
|
ping_latency_ms: number | null
|
|
checked_at: string
|
|
}
|
|
|
|
export interface UserMonitorView {
|
|
id: number
|
|
name: string
|
|
provider: Provider
|
|
group_name: string
|
|
primary_model: string
|
|
primary_status: MonitorStatus
|
|
primary_latency_ms: number | null
|
|
primary_ping_latency_ms: number | null
|
|
availability_7d: number
|
|
extra_models: UserMonitorExtraModel[]
|
|
timeline: MonitorTimelinePoint[]
|
|
}
|
|
|
|
export interface UserMonitorListResponse {
|
|
items: UserMonitorView[]
|
|
}
|
|
|
|
export interface UserMonitorModelDetail {
|
|
model: string
|
|
latest_status: MonitorStatus
|
|
latest_latency_ms: number | null
|
|
availability_7d: number
|
|
availability_15d: number
|
|
availability_30d: number
|
|
avg_latency_7d_ms: number | null
|
|
}
|
|
|
|
export interface UserMonitorDetail {
|
|
id: number
|
|
name: string
|
|
provider: Provider
|
|
group_name: string
|
|
models: UserMonitorModelDetail[]
|
|
}
|
|
|
|
/**
|
|
* List all monitor views available to the current user.
|
|
*/
|
|
export async function list(options?: { signal?: AbortSignal }): Promise<UserMonitorListResponse> {
|
|
const { data } = await apiClient.get<UserMonitorListResponse>('/channel-monitors', {
|
|
signal: options?.signal,
|
|
})
|
|
return data
|
|
}
|
|
|
|
/**
|
|
* Get detailed status (multi-window availability + latency) for a single monitor.
|
|
*/
|
|
export async function status(id: number): Promise<UserMonitorDetail> {
|
|
const { data } = await apiClient.get<UserMonitorDetail>(`/channel-monitors/${id}/status`)
|
|
return data
|
|
}
|
|
|
|
export const channelMonitorUserAPI = {
|
|
list,
|
|
status,
|
|
}
|
|
|
|
export default channelMonitorUserAPI
|