MCPcopy Create free account
hub / github.com/1Panel-dev/MaxKB / getTriggerCycleLabel

Function getTriggerCycleLabel

ui/src/utils/trigger.ts:54–105  ·  view source on GitHub ↗
(data: any)

Source from the content-addressed store, hash-verified

52]
53
54export function getTriggerCycleLabel(data: any) {
55 const { schedule_type, days, time, interval_unit, interval_value } = data
56 if (!schedule_type) return ''
57 const scheduleOption = triggerCycleOptions.find((option) => option.value === schedule_type)
58 if (!scheduleOption) return ''
59 const baseLabel = scheduleOption.label
60 switch (schedule_type) {
61 case 'daily':
62 if (time) {
63 const timeLabel = relatedObject(scheduleOption.children, time.toString(), 'value')?.label
64 return `${baseLabel}/${timeLabel}`
65 }
66 return baseLabel
67
68 case 'weekly':
69 if (days && time) {
70 const dayOption:any = scheduleOption.children.find(
71 (day) => day.value.toString() === days.toString(),
72 )
73 if (dayOption) {
74 const timeLabel = relatedObject(dayOption.children, time.toString(), 'value')?.label
75 return `${baseLabel}/${dayOption.label}/${timeLabel}`
76 }
77 }
78 return baseLabel
79
80 case 'monthly':
81 if (days && time) {
82 const dayOption:any = scheduleOption.children.find(
83 (day) => day.value.toString() === days.toString(),
84 )
85 if (dayOption) {
86 const timeLabel = relatedObject(dayOption.children, time.toString(), 'value')?.label
87 return `${baseLabel}/${dayOption.label}/${timeLabel}`
88 }
89 }
90 return baseLabel
91
92 case 'interval':
93 if (interval_unit) {
94 const unitOption:any = scheduleOption.children.find((unit) => unit.value === interval_unit)
95 if (unitOption) {
96 const intervalLabel = relatedObject(unitOption.children, interval_value, 'value')?.label
97 return `${baseLabel}/${unitOption.label}/${intervalLabel}`
98 }
99 }
100 return baseLabel
101
102 default:
103 return baseLabel
104 }
105}

Callers

nothing calls this directly

Calls 3

relatedObjectFunction · 0.90
findMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected