Skip to content

Commit

Permalink
Added support to jobs jobImageCopy and jobAuthorCurrentOptimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Hermanek committed Dec 2, 2024
1 parent 9a34163 commit 08d1f5a
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/locales/en/coreDam/job.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"model": {
"podcastId": "Podcast Id",
"fullSync": "Full synchronization"
"fullSync": "Full synchronization",
"authorId": "Author Id",
"processAll": "Process all",
"licence": "Licence"
},
"jobResource": {
"jobPodcastSynchronizer": "Podcast synchronizer"
"jobPodcastSynchronizer": "Podcast synchronizer",
"jobAuthorCurrentOptimize": "Author current optimize",
"jobImageCopy": "Image copy"
}
}
9 changes: 7 additions & 2 deletions src/locales/sk/coreDam/job.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"model": {
"podcastId": "Podcast Id",
"fullSync": "Plná synchronizácia"
"fullSync": "Plná synchronizácia",
"authorId": "Autor ID",
"processAll": "Spracuj všetko",
"licence": "Licencia Id"
},
"jobResource": {
"jobPodcastSynchronizer": "Podcastový synchronizátor"
"jobPodcastSynchronizer": "Podcastový synchronizátor",
"jobAuthorCurrentOptimize": "Optimalizácia autorov",
"jobImageCopy": "Kopírovanie obrázkov"
}
}
19 changes: 17 additions & 2 deletions src/model/coreDam/factory/JobFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { SYSTEM_CORE_DAM } from '@/model/systems'
import { useCommonJobFactory } from '@anzusystems/common-admin'
import type { JobPodcastSynchronizer } from '@/types/coreDam/Job'
import { JOB_RESOURCE_PODCAST_SYNCHRONIZER } from '@/model/coreDam/valueObject/JobResource'
import type { JobAuthorCurrentOptimize, JobImageCopy, JobPodcastSynchronizer } from '@/types/coreDam/Job'
import {
JOB_AUTHOR_CURRENT_OPTIMIZE,
JOB_RESOURCE_IMAGE_COPY,
JOB_RESOURCE_PODCAST_SYNCHRONIZER
} from '@/model/coreDam/valueObject/JobResource'

export function useJobFactory() {
const { createBase } = useCommonJobFactory()
Expand All @@ -15,7 +19,18 @@ export function useJobFactory() {
}
}

const createAuthorCurrentOptimize = (): JobAuthorCurrentOptimize => {
return {
...createBase(JOB_AUTHOR_CURRENT_OPTIMIZE, SYSTEM_CORE_DAM),
...{
processAll: false,
authorId: null,
},
}
}

return {
createPodcastSynchronizer,
createAuthorCurrentOptimize,
}
}
12 changes: 11 additions & 1 deletion src/model/coreDam/valueObject/JobResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { type JobBaseResource, useJobBaseResource } from '@anzusystems/common-ad
import { useI18n } from 'vue-i18n'

export const JOB_RESOURCE_PODCAST_SYNCHRONIZER = 'jobPodcastSynchronizer'
export const JOB_AUTHOR_CURRENT_OPTIMIZE = 'jobAuthorCurrentOptimize'
export const JOB_RESOURCE_IMAGE_COPY = 'jobImageCopy'

export type JobResource = typeof JOB_RESOURCE_PODCAST_SYNCHRONIZER | JobBaseResource
export type JobResource = typeof JOB_RESOURCE_PODCAST_SYNCHRONIZER | typeof JOB_RESOURCE_IMAGE_COPY | typeof JOB_AUTHOR_CURRENT_OPTIMIZE| JobBaseResource

export function useJobResource() {
const { t } = useI18n()
Expand All @@ -13,5 +15,13 @@ export function useJobResource() {
title: t('coreDam.job.jobResource.jobPodcastSynchronizer'),
value: 'jobPodcastSynchronizer',
},
{
title: t('coreDam.job.jobResource.jobImageCopy'),
value: 'jobImageCopy',
},
{
title: t('coreDam.job.jobResource.jobAuthorCurrentOptimize'),
value: 'jobAuthorCurrentOptimize',
},
])
}
34 changes: 32 additions & 2 deletions src/types/coreDam/Job.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
import type { DocIdNullable, JobBase, JobUserDataDelete } from '@anzusystems/common-admin'
import type {
DocIdNullable,
IntegerId,
IntegerIdNullable,
JobBase,
JobUserDataDelete
} from '@anzusystems/common-admin'
import type { JobResource } from '@/model/coreDam/valueObject/JobResource'

export interface JobPodcastSynchronizer extends JobBase<JobResource> {
podcastId: DocIdNullable
fullSync: boolean
}

export type Job = JobUserDataDelete | JobPodcastSynchronizer
export interface JobImageCopy extends JobBase<JobResource> {
licence: DocIdNullable
}

export interface JobImageCopyItem {
id: IntegerId
sourceAssetId: DocIdNullable
targetAssetId: DocIdNullable
status: AssetFileCopyStatus
job: IntegerIdNullable
}

export enum AssetFileCopyStatus {
Exists = 'exists',
Copy = 'copy',
NotAllowed = 'notAllowed',
Unassigned = 'unassigned',
}

export interface JobAuthorCurrentOptimize extends JobBase<JobResource> {
processAll: boolean
authorId: DocIdNullable
}

export type Job = JobUserDataDelete | JobPodcastSynchronizer | JobImageCopy
12 changes: 11 additions & 1 deletion src/views/coreDam/job/JobDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import { useJobDetailActions } from '@/views/coreDam/job/composables/jobActions'
import ActionbarWrapper from '@/components/wrappers/ActionbarWrapper.vue'
import JobDetailPodcastSynchronizer from '@/views/coreDam/job/components/JobDetailPodcastSynchronizer.vue'
import JobDetailUserDataDelete from '@/views/coreDam/job/components/JobDetailUserDataDelete.vue'
import { JOB_RESOURCE_PODCAST_SYNCHRONIZER } from '@/model/coreDam/valueObject/JobResource'
import {
JOB_AUTHOR_CURRENT_OPTIMIZE,
JOB_RESOURCE_IMAGE_COPY,
JOB_RESOURCE_PODCAST_SYNCHRONIZER
} from '@/model/coreDam/valueObject/JobResource'
import JobAuthorCurrentOptimize from '@/views/coreDam/job/components/JobAuthorCurrentOptimize.vue'
import JobImageCopy from '@/views/coreDam/job/components/JobImageCopy.vue'
const { detailLoading, fetchData, resetStore, job } = useJobDetailActions()
Expand All @@ -30,6 +36,10 @@ const jobComponent = computed(() => {
switch (job.value._resourceName) {
case JOB_RESOURCE_PODCAST_SYNCHRONIZER:
return JobDetailPodcastSynchronizer
case JOB_AUTHOR_CURRENT_OPTIMIZE:
return JobAuthorCurrentOptimize
case JOB_RESOURCE_IMAGE_COPY:
return JobImageCopy
case JOB_RESOURCE_USER_DATA_DELETE:
return JobDetailUserDataDelete
default:
Expand Down
42 changes: 42 additions & 0 deletions src/views/coreDam/job/components/JobAuthorCurrentOptimize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script lang="ts" setup>
import { ABooleanValue, AJobDetailCommon, ARow, useI18n } from '@anzusystems/common-admin'
import type { JobAuthorCurrentOptimize, JobPodcastSynchronizer } from '@/types/coreDam/Job'
import JobResourceChip from '@/views/coreDam/job/components/JobResourceChip.vue'
withDefaults(
defineProps<{
job: JobAuthorCurrentOptimize
loading?: boolean
}>(),
{
loading: false,
}
)
const { t } = useI18n()
</script>

<template>
<VRow>
<VCol cols="6">
<AJobDetailCommon
:job="job"
:loading="loading"
>
<template #resource-name>
<JobResourceChip :value="job._resourceName" />
</template>
</AJobDetailCommon>
</VCol>
<VCol cols="6">
<template v-if="!loading">
<ARow :title="t('coreDam.job.model.authorId')">
{{ job.authorId }}
</ARow>
<ARow :title="t('coreDam.job.model.processAll')">
<ABooleanValue :value="job.processAll" />
</ARow>
</template>
</VCol>
</VRow>
</template>
4 changes: 4 additions & 0 deletions src/views/coreDam/job/components/JobCreateButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { useI18n } from 'vue-i18n'
import { ADialogToolbar, AFormValueObjectOptionsSelect, JOB_RESOURCE_USER_DATA_DELETE } from '@anzusystems/common-admin'
import { computed, ref } from 'vue'
import {
JOB_AUTHOR_CURRENT_OPTIMIZE,
JOB_RESOURCE_PODCAST_SYNCHRONIZER,
type JobResource,
useJobResource,
} from '@/model/coreDam/valueObject/JobResource'
import JobCreateFormPodcastSynchronizer from '@/views/coreDam/job/components/JobCreateFormPodcastSynchronizer.vue'
import JobCreateFormUserDataDelete from '@/views/coreDam/job/components/JobCreateFormUserDataDelete.vue'
import JobCreateFormDefault from '@/views/coreDam/job/components/JobCreateFormDefault.vue'
import JobCreateFormAuthorCurrentOptimize from '@/views/coreDam/job/components/JobCreateFormAuthorCurrentOptimize.vue'
withDefaults(
defineProps<{
Expand Down Expand Up @@ -39,6 +41,8 @@ const jobComponent = computed(() => {
return JobCreateFormUserDataDelete
case JOB_RESOURCE_PODCAST_SYNCHRONIZER:
return JobCreateFormPodcastSynchronizer
case JOB_AUTHOR_CURRENT_OPTIMIZE:
return JobCreateFormAuthorCurrentOptimize
default:
console.error('Unsupported type.')
return JobCreateFormDefault
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<script lang="ts" setup>
import {
AFormTextField,
ARow, DamDistributionRequirementStrategy,
type JobUserDataDelete,
useAlerts,
useCommonJobFactory,
useJobApi,
useValidate,
} from '@anzusystems/common-admin'
import { useI18n } from 'vue-i18n'
import { computed, ref } from 'vue'
import { damClient } from '@/services/api/clients/damClient'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import useVuelidate from '@vuelidate/core'
import type { JobAuthorCurrentOptimize } from '@/types/coreDam/Job'
import { useJobFactory } from '@/model/coreDam/factory/JobFactory'
const emit = defineEmits<{
(e: 'onSuccess'): void
(e: 'closeDialog'): void
}>()
const buttonLoading = ref(false)
const { createAuthorCurrentOptimize } = useJobFactory()
const job = ref<JobAuthorCurrentOptimize>(createAuthorCurrentOptimize())
const { t } = useI18n()
const onCancel = () => {
emit('closeDialog')
}
const { createJob } = useJobApi<JobAuthorCurrentOptimize>(damClient, SYSTEM_CORE_DAM)
const { showRecordWas, showErrorsDefault, showValidationError } = useAlerts()
const { required, minValue } = useValidate()
const rules = computed(() => {
if (!job.value.processAll) {
return {
authorId: {
required,
minValue: minValue(1),
}
}
}
return {}
})
const v$ = useVuelidate(rules, { job })
const onConfirm = async () => {
try {
buttonLoading.value = true
v$.value.$touch()
if (v$.value.$invalid) {
showValidationError()
buttonLoading.value = false
return
}
await createJob(job.value)
showRecordWas('created')
emit('onSuccess')
} catch (error) {
showErrorsDefault(error)
} finally {
buttonLoading.value = false
emit('closeDialog')
}
}
</script>

<template>
<VCardText>
<ARow>
<AFormTextField
v-model="job.authorId"
:label="t('coreDam.job.model.authorId')"
data-cy="authorId"
/>
</ARow>
<ARow>
<VSwitch
v-model="job.processAll"
:label="t('coreDam.job.model.processAll')"
data-cy="processAll"
/>
</ARow>
</VCardText>
<VCardActions>
<VSpacer />
<ABtnTertiary @click.stop="onCancel">
{{ t('common.button.cancel') }}
</ABtnTertiary>
<ABtnPrimary
:loading="buttonLoading"
@click.stop="onConfirm"
>
{{ t('common.button.create') }}
</ABtnPrimary>
</VCardActions>
</template>
39 changes: 39 additions & 0 deletions src/views/coreDam/job/components/JobImageCopy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts" setup>
import { ABooleanValue, AJobDetailCommon, ARow, useI18n } from '@anzusystems/common-admin'
import type { JobImageCopy, JobImageCopyItem, JobPodcastSynchronizer } from '@/types/coreDam/Job'
import JobResourceChip from '@/views/coreDam/job/components/JobResourceChip.vue'
withDefaults(
defineProps<{
job: JobImageCopy
loading?: boolean
}>(),
{
loading: false,
}
)
const { t } = useI18n()
</script>

<template>
<VRow>
<VCol cols="6">
<AJobDetailCommon
:job="job"
:loading="loading"
>
<template #resource-name>
<JobResourceChip :value="job._resourceName" />
</template>
</AJobDetailCommon>
</VCol>
<VCol cols="6">
<template v-if="!loading">
<ARow :title="t('coreDam.job.model.licence')">
{{ job.licence }}
</ARow>
</template>
</VCol>
</VRow>
</template>

0 comments on commit 08d1f5a

Please sign in to comment.