Browse Source

[Fix][UI] Fix bug where crontab special of month and year (#11661)

3.1.0-release
Devosend 2 years ago committed by GitHub
parent
commit
769a20e986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      dolphinscheduler-ui/src/components/crontab/common.ts
  2. 19
      dolphinscheduler-ui/src/components/crontab/index.tsx
  3. 17
      dolphinscheduler-ui/src/components/crontab/modules/day.tsx
  4. 70
      dolphinscheduler-ui/src/components/crontab/modules/time.tsx
  5. 9
      dolphinscheduler-ui/src/components/crontab/types.ts

39
dolphinscheduler-ui/src/components/crontab/common.ts

@ -16,6 +16,7 @@
*/ */
import _ from 'lodash' import _ from 'lodash'
import type { ISpecialSelect } from './types'
const timeI18n = { const timeI18n = {
second: { second: {
@ -190,4 +191,40 @@ const isWeek = (str: string) => {
return flag return flag
} }
export { isStr, isWeek, timeI18n, week, specificWeek, lastWeeks } const range = (start: number, stop: number, step = 1) =>
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step)
const specificList: ISpecialSelect = {
60: _.map(range(0, 59), (v) => {
return {
value: v + '',
label: v + ''
}
}),
24: _.map(range(0, 23), (v) => {
return {
value: v + '',
label: v + ''
}
}),
12: _.map(range(1, 12), (v) => {
return {
value: v + '',
label: v + ''
}
}),
year: _.map(range(2018, 2030), (v) => {
return {
value: v + '',
label: v + ''
}
}),
day: _.map(range(1, 31), (v) => {
return {
value: v + '',
label: v + ''
}
})
}
export { isStr, isWeek, timeI18n, week, specificWeek, lastWeeks, specificList }

19
dolphinscheduler-ui/src/components/crontab/index.tsx

@ -93,18 +93,27 @@ export default defineComponent({
<CrontabTime <CrontabTime
v-model:timeValue={this.secondRef} v-model:timeValue={this.secondRef}
timeI18n={timeI18n.second} timeI18n={timeI18n.second}
timeSpecial={60}
timeMin={0}
timeMax={59}
/> />
</NTabPane> </NTabPane>
<NTabPane name='minute' tab={t('crontab.minute')}> <NTabPane name='minute' tab={t('crontab.minute')}>
<CrontabTime <CrontabTime
v-model:timeValue={this.minuteRef} v-model:timeValue={this.minuteRef}
timeI18n={timeI18n.minute} timeI18n={timeI18n.minute}
timeSpecial={60}
timeMin={0}
timeMax={59}
/> />
</NTabPane> </NTabPane>
<NTabPane name='hour' tab={t('crontab.hour')}> <NTabPane name='hour' tab={t('crontab.hour')}>
<CrontabTime <CrontabTime
v-model:timeValue={this.hourRef} v-model:timeValue={this.hourRef}
timeI18n={timeI18n.hour} timeI18n={timeI18n.hour}
timeSpecial={24}
timeMin={0}
timeMax={23}
/> />
</NTabPane> </NTabPane>
<NTabPane name='day' tab={t('crontab.day')}> <NTabPane name='day' tab={t('crontab.day')}>
@ -117,12 +126,22 @@ export default defineComponent({
<CrontabTime <CrontabTime
v-model:timeValue={this.monthRef} v-model:timeValue={this.monthRef}
timeI18n={timeI18n.month} timeI18n={timeI18n.month}
timeSpecial={12}
timeMin={0}
timeMax={12}
/> />
</NTabPane> </NTabPane>
<NTabPane name='year' tab={t('crontab.year')}> <NTabPane name='year' tab={t('crontab.year')}>
<CrontabTime <CrontabTime
v-model:timeValue={this.yearRef} v-model:timeValue={this.yearRef}
timeI18n={timeI18n.year} timeI18n={timeI18n.year}
timeSpecial={'year'}
timeMin={0}
timeMax={2030}
intervalPerform={1}
intervalStart={2019}
cycleStart={2019}
cycleEnd={2019}
/> />
</NTabPane> </NTabPane>
</NTabs> </NTabs>

17
dolphinscheduler-ui/src/components/crontab/modules/day.tsx

@ -18,7 +18,14 @@
import { defineComponent, onMounted, PropType, ref, watch } from 'vue' import { defineComponent, onMounted, PropType, ref, watch } from 'vue'
import { NInputNumber, NRadio, NRadioGroup, NSelect } from 'naive-ui' import { NInputNumber, NRadio, NRadioGroup, NSelect } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { isStr, isWeek, week, specificWeek, lastWeeks } from '../common' import {
isStr,
isWeek,
week,
specificWeek,
lastWeeks,
specificList
} from '../common'
import styles from '../index.module.scss' import styles from '../index.module.scss'
const props = { const props = {
@ -39,11 +46,6 @@ export default defineComponent({
setup(props, ctx) { setup(props, ctx) {
const { t } = useI18n() const { t } = useI18n()
const options = Array.from({ length: 60 }, (x, i) => ({
label: i.toString(),
value: i
}))
const weekOptions = week.map((v) => ({ const weekOptions = week.map((v) => ({
label: t(v.label), label: t(v.label),
value: v.value value: v.value
@ -430,7 +432,6 @@ export default defineComponent({
onMounted(() => analyticalValue()) onMounted(() => analyticalValue())
return { return {
options,
weekOptions, weekOptions,
lastWeekOptions, lastWeekOptions,
radioRef, radioRef,
@ -551,7 +552,7 @@ export default defineComponent({
<NSelect <NSelect
style={{ width: '300px' }} style={{ width: '300px' }}
multiple multiple
options={this.options} options={specificList.day}
placeholder={t('crontab.specific_day_tip')} placeholder={t('crontab.specific_day_tip')}
v-model:value={this.WkspecificDayRef} v-model:value={this.WkspecificDayRef}
onUpdateValue={this.onWkspecificDay} onUpdateValue={this.onWkspecificDay}

70
dolphinscheduler-ui/src/components/crontab/modules/time.tsx

@ -20,10 +20,38 @@ import { defineComponent, onMounted, PropType, ref, toRefs, watch } from 'vue'
import { NInputNumber, NRadio, NRadioGroup, NSelect } from 'naive-ui' import { NInputNumber, NRadio, NRadioGroup, NSelect } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { ICrontabI18n } from '../types' import { ICrontabI18n } from '../types'
import { isStr } from '../common' import { isStr, specificList } from '../common'
import styles from '../index.module.scss' import styles from '../index.module.scss'
const props = { const props = {
timeMin: {
type: Number as PropType<number>,
default: 0
},
timeMax: {
type: Number as PropType<number>,
default: 60
},
intervalPerform: {
type: Number as PropType<number>,
default: 5
},
intervalStart: {
type: Number as PropType<number>,
default: 3
},
cycleStart: {
type: Number as PropType<number>,
default: 1
},
cycleEnd: {
type: Number as PropType<number>,
default: 1
},
timeSpecial: {
type: Number as PropType<number | string>,
default: 60
},
timeValue: { timeValue: {
type: String as PropType<string>, type: String as PropType<string>,
default: '*' default: '*'
@ -46,11 +74,11 @@ export default defineComponent({
const timeRef = ref() const timeRef = ref()
const radioRef = ref() const radioRef = ref()
const intervalStartRef = ref(0) const intervalStartRef = ref(props.intervalStart)
const intervalPerformRef = ref(0) const intervalPerformRef = ref(props.intervalPerform)
const specificTimesRef = ref<Array<number>>([]) const specificTimesRef = ref<Array<number>>([])
const cycleStartRef = ref(0) const cycleStartRef = ref(props.cycleStart)
const cycleEndRef = ref(0) const cycleEndRef = ref(props.cycleEnd)
/** /**
* Parse parameter value * Parse parameter value
@ -73,8 +101,10 @@ export default defineComponent({
// Positive integer (times) // Positive integer (times)
if ( if (
($timeVal.length === 1 && _.isInteger(parseInt($timeVal))) || ($timeVal.length === 1 ||
($timeVal.length === 2 && _.isInteger(parseInt($timeVal))) $timeVal.length === 2 ||
$timeVal.length === 4) &&
_.isInteger(parseInt($timeVal))
) { ) {
radioRef.value = 'specificTime' radioRef.value = 'specificTime'
specificTimesRef.value = [parseInt($timeVal)] specificTimesRef.value = [parseInt($timeVal)]
@ -232,9 +262,9 @@ export default defineComponent({
<div class={styles['item-text']}>{t(this.timeI18n!.every)}</div> <div class={styles['item-text']}>{t(this.timeI18n!.every)}</div>
<div class={styles['number-input']}> <div class={styles['number-input']}>
<NInputNumber <NInputNumber
defaultValue={0} defaultValue={5}
min={0} min={this.timeMin}
max={59} max={this.timeMax}
v-model:value={this.intervalPerformRef} v-model:value={this.intervalPerformRef}
onUpdateValue={this.onIntervalPerform} onUpdateValue={this.onIntervalPerform}
/> />
@ -244,9 +274,9 @@ export default defineComponent({
</div> </div>
<div class={styles['number-input']}> <div class={styles['number-input']}>
<NInputNumber <NInputNumber
defaultValue={0} defaultValue={3}
min={0} min={this.timeMin}
max={59} max={this.timeMax}
v-model:value={this.intervalStartRef} v-model:value={this.intervalStartRef}
onUpdateValue={this.onIntervalStart} onUpdateValue={this.onIntervalStart}
/> />
@ -261,7 +291,7 @@ export default defineComponent({
<div class={styles['select-input']}> <div class={styles['select-input']}>
<NSelect <NSelect
multiple multiple
options={this.options} options={specificList[this.timeSpecial]}
placeholder={t(this.timeI18n!.specificTimeTip)} placeholder={t(this.timeI18n!.specificTimeTip)}
v-model:value={this.specificTimesRef} v-model:value={this.specificTimesRef}
onUpdateValue={this.onSpecificTimes} onUpdateValue={this.onSpecificTimes}
@ -275,9 +305,9 @@ export default defineComponent({
<div>{t(this.timeI18n!.cycleFrom)}</div> <div>{t(this.timeI18n!.cycleFrom)}</div>
<div class={styles['number-input']}> <div class={styles['number-input']}>
<NInputNumber <NInputNumber
defaultValue={0} defaultValue={1}
min={0} min={this.timeMin}
max={59} max={this.timeMax}
v-model:value={this.cycleStartRef} v-model:value={this.cycleStartRef}
onUpdateValue={this.onCycleStart} onUpdateValue={this.onCycleStart}
/> />
@ -285,9 +315,9 @@ export default defineComponent({
<div>{t(this.timeI18n!.to)}</div> <div>{t(this.timeI18n!.to)}</div>
<div class={styles['number-input']}> <div class={styles['number-input']}>
<NInputNumber <NInputNumber
defaultValue={0} defaultValue={1}
min={0} min={this.timeMin}
max={59} max={this.timeMax}
v-model:value={this.cycleEndRef} v-model:value={this.cycleEndRef}
onUpdateValue={this.onCycleEnd} onUpdateValue={this.onCycleEnd}
/> />

9
dolphinscheduler-ui/src/components/crontab/types.ts

@ -27,4 +27,11 @@ interface ICrontabI18n {
time: string time: string
} }
export { ICrontabI18n } interface ISpecialSelect {
[key: number | string]: {
label: string
value: string
}[]
}
export { ICrontabI18n, ISpecialSelect }

Loading…
Cancel
Save