2222 style =" width : 100% ; margin-bottom : 10px "
2323 @click =" showAddModal"
2424 :loading =" loading"
25- :disabled =" !('createVMSchedule' in $store.getters.apis)" >
26- <template #icon ><plus-outlined /></template > {{ $t('label.schedule.add') }}
25+ :disabled =" !('createVMSchedule' in $store.getters.apis)"
26+ >
27+ <template #icon ><plus-outlined /></template > {{ $t('label.schedule.add') }}
2728 </a-button >
2829 <list-view
2930 :loading =" tabLoading"
3536 @update-selected-columns =" updateSelectedColumns"
3637 @update-vm-schedule =" updateVMSchedule"
3738 @remove-vm-schedule =" removeVMSchedule"
38- @refresh =" this.fetchData" />
39+ @refresh =" this.fetchData"
40+ />
3941 <a-pagination
4042 class =" row-element"
4143 style =" margin-top : 10px "
4244 size =" small"
4345 :current =" page"
4446 :pageSize =" pageSize"
4547 :total =" totalCount"
46- :showTotal =" total => `${$t('label.showing')} ${Math.min(total, 1+ ((page-1)* pageSize))}-${Math.min(page* pageSize, total)} ${$t('label.of')} ${total} ${$t('label.items')}`"
48+ :showTotal =" total => `${$t('label.showing')} ${Math.min(total, 1 + ((page - 1) * pageSize))}-${Math.min(page * pageSize, total)} ${$t('label.of')} ${total} ${$t('label.items')}`"
4749 :pageSizeOptions =" pageSizeOptions"
4850 @change =" changePage"
4951 @showSizeChange =" changePage"
5052 showSizeChanger
51- showQuickJumper >
53+ showQuickJumper
54+ >
5255 <template #buildOptionText =" props " >
5356 <span >{{ props.value }} / {{ $t('label.page') }}</span >
5457 </template >
6063 :title =" $t('label.schedule')"
6164 :maskClosable =" false"
6265 :closable =" true"
63- :footer =" null"
64- @cancel =" closeModal" >
66+ @cancel =" closeModal"
67+ @ok =" submitForm"
68+ >
6569 <a-form
6670 layout =" vertical"
6771 :ref =" formRef"
6872 :model =" form"
6973 :rules =" rules"
7074 @finish =" submitForm"
71- v-ctrl-enter =" submitForm" >
72- <a-form-item name =" description" ref =" description" >
75+ v-ctrl-enter =" submitForm"
76+ >
77+ <a-form-item
78+ name =" description"
79+ ref =" description"
80+ :wrapperCol =" { span: 24 }"
81+ >
7382 <template #label >
74- <tooltip-label :title =" $t('label.description')" :tooltip =" apiParams.description.description" />
83+ <tooltip-label
84+ :title =" $t('label.description')"
85+ :tooltip =" apiParams.description.description"
86+ />
7587 </template >
7688 <a-input
7789 v-model:value =" form.description"
78- v-focus =" true" />
90+ v-focus =" true"
91+ />
7992 </a-form-item >
80- <a-form-item name =" action" ref =" action" >
93+ <a-form-item
94+ name =" action"
95+ ref =" action"
96+ :wrapperCol =" { span: 24 }"
97+ >
8198 <template #label >
82- <tooltip-label :title =" $t('label.action')" :tooltip =" apiParams.action.description" />
99+ <tooltip-label
100+ :title =" $t('label.action')"
101+ :tooltip =" apiParams.action.description"
102+ />
83103 </template >
84104 <a-radio-group
85105 v-model:value =" form.action"
86106 button-style =" solid"
87- :disabled =" isEdit" >
88- <a-radio-button v-for =" action in actions" :key =" action.id" :value =" action.value" >
107+ :disabled =" isEdit"
108+ >
109+ <a-radio-button
110+ v-for =" action in actions"
111+ :key =" action.id"
112+ :value =" action.value"
113+ >
89114 {{ $t(action.label) }}
90115 </a-radio-button >
91116 </a-radio-group >
92117 </a-form-item >
93- <a-form-item name =" schedule" ref =" schedule" >
118+ <a-form-item
119+ name =" timezone"
120+ ref =" timezone"
121+ :wrapperCol =" { span: 24 }"
122+ >
94123 <template #label >
95- <tooltip-label :title =" $t('label.schedule')" :tooltip =" apiParams.schedule.description" />
96- </template >
97- <label >{{ $t('label.advanced.mode') }}</label >
98- <a-switch
99- v-model:checked =" form.useCronFormat"
100- >
101- </a-switch >
102- <br />
103- <span v-if =" !form.useCronFormat" >
104- <cron-ant
105- v-model =" form.schedule"
106- :periods =" periods"
107- :button-props =" { type: 'primary', size: 'small', disabled: form.useCronFormat }"
108- @error =" error=$event" />
109- </span >
110- <span v-if =" form.useCronFormat" >
111- <label >{{ generateHumanReadableSchedule(form.schedule) }}</label >
112- <br />
113- </span >
114- <a-input
115- :addonBefore =" $t('label.cron')"
116- v-model:value =" form.schedule"
117- :disabled =" !form.useCronFormat"
118- v-focus =" true" />
119- </a-form-item >
120- <a-form-item name =" timezone" ref =" timezone" >
121- <template #label >
122- <tooltip-label :title =" $t('label.timezone')" :tooltip =" apiParams.timezone.description" />
124+ <tooltip-label
125+ :title =" $t('label.timezone')"
126+ :tooltip =" apiParams.timezone.description"
127+ />
123128 </template >
124129 <a-select
125130 showSearch
128133 :filterOption =" (input, option) => {
129134 return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
130135 }"
131- :loading =" fetching" >
132- <a-select-option v-for =" opt in timeZoneMap" :key =" opt.id" :label =" opt.name || opt.description" >
136+ :loading =" fetching"
137+ >
138+ <a-select-option
139+ v-for =" opt in timeZoneMap"
140+ :key =" opt.id"
141+ :label =" opt.name || opt.description"
142+ >
133143 {{ opt.name || opt.description }}
134144 </a-select-option >
135145 </a-select >
136146 </a-form-item >
137- <a-form-item name =" startDate" ref =" startDate" >
138- <template #label >
139- <tooltip-label :title =" $t('label.start.date.and.time')" :tooltip =" apiParams.startdate.description" />
140- </template >
141- <a-date-picker
142- v-model:value =" form.startDate"
143- show-time
144- :locale =" this.$i18n.locale"
145- :placeholder =" $t('message.select.start.date.and.time')" />
146- </a-form-item >
147- <a-form-item name =" endDate" ref =" endDate" >
147+ <a-row justify =" space-between" >
148+ <a-col >
149+ <a-form-item
150+ name =" startDate"
151+ ref =" startDate"
152+ >
153+ <template #label >
154+ <tooltip-label
155+ :title =" $t('label.start.date.and.time')"
156+ :tooltip =" apiParams.startdate.description"
157+ />
158+ </template >
159+ <a-date-picker
160+ v-model:value =" form.startDate"
161+ show-time
162+ :locale =" this.$i18n.locale"
163+ :placeholder =" $t('message.select.start.date.and.time')"
164+ />
165+ </a-form-item >
166+ </a-col >
167+ <a-col >
168+ <a-form-item
169+ name =" endDate"
170+ ref =" endDate"
171+ >
172+ <template #label >
173+ <tooltip-label
174+ :title =" $t('label.end.date.and.time')"
175+ :tooltip =" apiParams.enddate.description"
176+ />
177+ </template >
178+ <a-date-picker
179+ v-model:value =" form.endDate"
180+ show-time
181+ :locale =" this.$i18n.locale"
182+ :placeholder =" $t('message.select.end.date.and.time')"
183+ />
184+ </a-form-item >
185+ </a-col >
186+ </a-row >
187+ <a-form-item
188+ name =" schedule"
189+ ref =" schedule"
190+ :wrapperCol =" { span: 24 }"
191+ >
148192 <template #label >
149- <tooltip-label :title =" $t('label.end.date.and.time')" :tooltip =" apiParams.enddate.description" />
193+ <tooltip-label
194+ :title =" $t('label.schedule')"
195+ :tooltip =" apiParams.schedule.description"
196+ />
150197 </template >
151- <a-date-picker
152- v-model:value =" form.endDate"
153- show-time
154- :locale =" this.$i18n.locale"
155- :placeholder =" $t('message.select.end.date.and.time')" />
198+ <a-row
199+ v-if =" !form.useCronFormat"
200+ style =" margin-bottom : 10px ; height : 40px ;"
201+ justify =" space-around"
202+ >
203+ <cron-ant
204+ v-model =" form.schedule"
205+ :periods =" periods"
206+ :button-props =" { type: 'primary', size: 'small', disabled: form.useCronFormat }"
207+ @error =" error = $event"
208+ />
209+ </a-row >
210+ <a-row
211+ v-if =" form.useCronFormat"
212+ style =" margin-bottom : 10px ; height : 40px ;"
213+ justify =" space-around"
214+ >
215+ <label >{{ generateHumanReadableSchedule(form.schedule) }}</label >
216+ </a-row >
217+ <a-row
218+ justify =" space-between"
219+ align =" middle"
220+ >
221+ <a-col >
222+ <label >{{ $t('label.cron.mode') }}</label >
223+ </a-col >
224+ <a-col >
225+ <a-switch v-model:checked =" form.useCronFormat" >
226+ </a-switch >
227+ </a-col >
228+ <a-col :span =" 12" >
229+ <a-input
230+ :addonBefore =" $t('label.cron')"
231+ v-model:value =" form.schedule"
232+ :disabled =" !form.useCronFormat"
233+ v-focus =" true"
234+ />
235+ </a-col >
236+ </a-row >
156237 </a-form-item >
157- <a-form-item name =" enabled" ref =" enabled" >
238+ <a-form-item
239+ name =" enabled"
240+ ref =" enabled"
241+ :wrapperCol =" { span: 24}"
242+ >
158243 <template #label >
159- <tooltip-label :title =" $t('label.enabled')" :tooltip =" apiParams.enabled.description" />
244+ <tooltip-label
245+ :title =" $t('label.enabled')"
246+ :tooltip =" apiParams.enabled.description"
247+ />
160248 </template >
161- <a-switch
162- v-model:checked =" form.enabled" >
163- </a-switch >
249+ <a-switch v-model:checked =" form.enabled" />
164250 </a-form-item >
165- <div :span =" 24" class =" action-button" >
166- <a-button
167- :loading =" loading"
168- @click =" closeModal" >
169- {{ $t('label.cancel') }}
170- </a-button >
171- <a-button
172- :loading =" loading"
173- ref =" submit"
174- type =" primary"
175- htmlType =" submit" >
176- {{ $t('label.ok') }}
177- </a-button >
178- </div >
179251 </a-form >
180252 </a-modal >
181253</template >
@@ -191,7 +263,12 @@ import { mixinForm } from '@/utils/mixin'
191263import { timeZone } from ' @/utils/timezone'
192264import debounce from ' lodash/debounce'
193265import cronstrue from ' cronstrue/i18n'
194- import moment from ' moment-timezone'
266+ import dayjs from ' dayjs'
267+ import utc from ' dayjs/plugin/utc'
268+ import timezone from ' dayjs/plugin/timezone'
269+
270+ dayjs .extend (utc)
271+ dayjs .extend (timezone)
195272
196273export default {
197274 name: ' InstanceSchedules' ,
@@ -323,8 +400,8 @@ export default {
323400 this .isEdit = true
324401 Object .assign (this .form , schedule)
325402 // Some weird issue when we directly pass in the moment with tz object
326- this .form .startDate = moment ( moment ( schedule .startdate ).tz (schedule .timezone ). format ( this . pattern ) )
327- this .form .endDate = schedule .enddate ? moment ( moment (schedule .enddate ).tz (schedule .timezone ). format ( this . pattern )) : ' '
403+ this .form .startDate = dayjs ( schedule .startdate ).tz (schedule .timezone )
404+ this .form .endDate = schedule .enddate ? dayjs ( dayjs (schedule .enddate ).tz (schedule .timezone )) : null
328405 this .showAddModal ()
329406 },
330407 showAddModal () {
@@ -431,7 +508,7 @@ export default {
431508 this .updateColumns ()
432509 },
433510 generateHumanReadableSchedule (schedule ) {
434- return cronstrue .toString (schedule, { locale: this .$i18n .locale , throwExceptionOnParseError: false })
511+ return cronstrue .toString (schedule, { locale: this .$i18n .locale , throwExceptionOnParseError: false , verbose : true })
435512 },
436513 updateColumns () {
437514 this .columns = []
0 commit comments