fix(modules): enhance ModuleDetailComponent with additional queries and UI updates
CI / changes (push) Successful in 11s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 1m3s
CI / go (push) Has been skipped
CI / bird2 (push) Has been skipped
CI / release (push) Successful in 4m4s
CI / changes (push) Successful in 11s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 1m3s
CI / go (push) Has been skipped
CI / bird2 (push) Has been skipped
CI / release (push) Successful in 4m4s
Updated the ModuleDetailComponent to include new queries for communities and DoH profiles, improving data handling. Added a module type alert function for better user guidance and refined the UI to display module type in a more user-friendly manner. Removed unused components and streamlined the refresh functionality for better performance.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { ModuleRow } from '@/types/api'
|
||||
|
||||
export function formatDateTime(value: string | null | undefined): string {
|
||||
if (typeof value !== 'string' || value.trim().length === 0) return '—'
|
||||
const parsed = new Date(value)
|
||||
if (Number.isNaN(parsed.getTime())) return '—'
|
||||
return parsed.toLocaleString('ru-RU')
|
||||
}
|
||||
|
||||
export function moduleIntervalLabel(moduleRow: ModuleRow): string {
|
||||
const cron = typeof moduleRow.cron_expr === 'string' ? moduleRow.cron_expr.trim() : ''
|
||||
const raw = moduleRow.refresh_interval_sec as unknown
|
||||
const interval =
|
||||
typeof raw === 'number'
|
||||
? raw
|
||||
: typeof raw === 'string' && raw.trim().length > 0
|
||||
? Number(raw)
|
||||
: null
|
||||
const intervalLabel = interval !== null && Number.isFinite(interval) ? `${interval}с` : ''
|
||||
if (cron && intervalLabel) return `${intervalLabel} (${cron})`
|
||||
if (cron) return cron
|
||||
if (intervalLabel) return intervalLabel
|
||||
return '—'
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { BgpCommunity, DohProfile, ModuleRow } from '@/types/api'
|
||||
|
||||
export const NONE_OPTION = '__none__'
|
||||
|
||||
export function communityLabel(id: string | null | undefined, communities: BgpCommunity[]): string {
|
||||
if (!id) return '—'
|
||||
const c = communities.find((x) => x.id === id)
|
||||
if (!c) return `${id.slice(0, 8)}…`
|
||||
const t = c.title?.trim()
|
||||
return t || c.community
|
||||
}
|
||||
|
||||
export function communityOptionLabel(c: BgpCommunity): string {
|
||||
const t = c.title?.trim()
|
||||
return t || c.community
|
||||
}
|
||||
|
||||
export function nullableSelectValue(value: string | null | undefined): string {
|
||||
if (value === null || value === undefined || value === '') return NONE_OPTION
|
||||
return value
|
||||
}
|
||||
|
||||
export function fromNullableSelect(value: string): string | null {
|
||||
if (value === NONE_OPTION || value === '') return null
|
||||
return value
|
||||
}
|
||||
|
||||
export function moduleDohProfileIds(modRow: ModuleRow | null): string[] {
|
||||
if (!modRow) return []
|
||||
if (modRow.doh_profile_ids?.length) return modRow.doh_profile_ids
|
||||
return modRow.doh_profile_id ? [modRow.doh_profile_id] : []
|
||||
}
|
||||
|
||||
export function dohProfileLabel(id: string, dohProfiles: DohProfile[]): string {
|
||||
const p = dohProfiles.find((d) => d.id === id)
|
||||
return p ? (p.name?.trim() ? `${p.name} (${p.url})` : p.url) : `${id.slice(0, 8)}…`
|
||||
}
|
||||
|
||||
export function normalizeCdnSourceKind(k: string): 'plaintext' | 'json' {
|
||||
return k.trim().toLowerCase() === 'json' ? 'json' : 'plaintext'
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { DohResolverPolicy } from '@/types/api'
|
||||
|
||||
export function dohPolicyRu(policy: DohResolverPolicy | string | null | undefined): string {
|
||||
switch (policy) {
|
||||
case 'primary_only':
|
||||
return 'Только первый'
|
||||
case 'failover':
|
||||
return 'Резервирование'
|
||||
case 'union':
|
||||
return 'Объединение'
|
||||
default:
|
||||
return 'Только первый'
|
||||
}
|
||||
}
|
||||
|
||||
export function moduleTypeRu(type: string): string {
|
||||
switch (type) {
|
||||
case 'AS_PREFIXES':
|
||||
return 'AS (номера)'
|
||||
case 'CDN_CIDRS':
|
||||
return 'CDN CIDR'
|
||||
case 'DOMAINS':
|
||||
return 'Домены'
|
||||
case 'IP_RANGES':
|
||||
return 'IP-диапазоны'
|
||||
default:
|
||||
return type
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user