-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add priority and scheduledAt to jobs. (#163)
Add priority and scheduledAt to jobs.
- Loading branch information
sakulb
authored
Jan 22, 2024
1 parent
8657326
commit e8aa811
Showing
10 changed files
with
162 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import type { JobBase } from '@/types/Job' | ||
import { useJobPriority } from '@/components/job/composables/jobPriority' | ||
import ARow from '@/components/ARow.vue' | ||
import AFormDatetimePicker from '@/components/form/AFormDatetimePicker.vue' | ||
import { useI18n } from 'vue-i18n' | ||
const modelValue = defineModel<JobBase>({ required: true }) | ||
const { priorityLabels, getPriorityColor } = useJobPriority() | ||
const sliderColor = computed(() => { | ||
return getPriorityColor(modelValue.value.priority) | ||
}) | ||
const { t } = useI18n() | ||
</script> | ||
|
||
<template> | ||
<ARow> | ||
<AFormDatetimePicker | ||
v-model="modelValue.scheduledAt" | ||
:label="t('common.job.model.scheduledAt')" | ||
/> | ||
</ARow> | ||
<ARow> | ||
<VSlider | ||
v-model="modelValue.priority" | ||
:ticks="priorityLabels" | ||
:max="2" | ||
step="1" | ||
show-ticks="always" | ||
tick-size="3" | ||
:color="sliderColor" | ||
/> | ||
</ARow> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import { useJobPriority } from '@/components/job/composables/jobPriority' | ||
import AChipNoLink from '@/components/AChipNoLink.vue' | ||
const props = defineProps<{ | ||
priority: number | ||
}>() | ||
const { getPriorityLabel, getPriorityColor } = useJobPriority() | ||
const priorityColor = computed(() => { | ||
return getPriorityColor(props.priority) | ||
}) | ||
const priorityLabel = computed(() => { | ||
return getPriorityLabel(props.priority) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<AChipNoLink | ||
:color="priorityColor" | ||
> | ||
{{ priorityLabel }} | ||
</AChipNoLink> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { computed } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
import { objectGetValueByPath } from '@/lib' | ||
|
||
export const useJobPriority = () => { | ||
const { t } = useI18n() | ||
const priorityLabels = computed(() => { | ||
return { | ||
0: t('common.job.meta.priority.low'), | ||
1: t('common.job.meta.priority.medium'), | ||
2: t('common.job.meta.priority.high'), | ||
} | ||
}) | ||
|
||
const getPriorityColor = (priority: Number): string => { | ||
switch (priority) { | ||
case 0: return 'amber' | ||
case 1: return 'primary' | ||
case 2: return 'red' | ||
default: return 'default' | ||
} | ||
} | ||
|
||
const getPriorityLabel = (priority: Number): string => { | ||
return objectGetValueByPath(priorityLabels.value, priority.toString()) ?? priority.toString() | ||
} | ||
|
||
return { | ||
priorityLabels, | ||
getPriorityColor, | ||
getPriorityLabel, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters