Skip to content

Commit

Permalink
Feature author clean phrase (#199)
Browse files Browse the repository at this point in the history
* Admin for AuthorCleanPhrases
  • Loading branch information
TomasHermanek authored Jan 15, 2025
1 parent 824981d commit 0c3526e
Show file tree
Hide file tree
Showing 41 changed files with 1,559 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ NOTIFICATION_WEBSOCKET_URL=ws://notification-server.anzusystems.local/ws
COOKIES_REFRESH_TOKEN_EXISTS_NAME=anz_rte
COOKIES_JWT_PAYLOAD_NAME=anz_jp
LOGOUT_CORE_DAM_URL=http://core-dam.anzusystems.local/api/auth/logout
DAM_AUTHOR_CLEAN_PHRASE_TEST_SAMPLE=photo: Author Name / AgencyA - Photograph
3 changes: 2 additions & 1 deletion public/config.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"dam": {
"apiUrl": "${DAM_API_URL}",
"apiTimeout": 30,
"imageUrl": "${DAM_IMAGE_URL}"
"imageUrl": "${DAM_IMAGE_URL}",
"authorCleanPhraseTestSample": "${DAM_AUTHOR_CLEAN_PHRASE_TEST_SAMPLE}"
},
"notification": {
"enabled": ${NOTIFICATION_ENABLED},
Expand Down
8 changes: 8 additions & 0 deletions src/components/system/sidebar/SidebarMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ const { t } = useI18n()
data-cy="job-settings"
/>
</Acl>
<Acl :permission="ACL.DAM_AUTHOR_CLEAN_PHRASE_UI">
<VListItem
:to="{ name: ROUTE.DAM.AUTHOR_CLEAN_PHRASE.LIST }"
prepend-icon="mdi-spray-bottle"
:title="t('sidebar.settings.authorCleanPhrase')"
data-cy="job-settings"
/>
</Acl>
<Acl :permission="ACL.DAM_LOG_UI">
<VListItem
:to="{ name: ROUTE.COMMON.LOG.LIST }"
Expand Down
5 changes: 5 additions & 0 deletions src/composables/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export const ACL = {
DAM_PODCAST_EPISODE_UPDATE: 'dam_podcastEpisode_update',
DAM_PODCAST_EPISODE_READ: 'dam_podcastEpisode_read',
DAM_PODCAST_EPISODE_DELETE: 'dam_podcastEpisode_delete',
DAM_AUTHOR_CLEAN_PHRASE_CREATE: 'dam_authorCleanPhrase_create',
DAM_AUTHOR_CLEAN_PHRASE_UPDATE: 'dam_authorCleanPhrase_update',
DAM_AUTHOR_CLEAN_PHRASE_READ: 'dam_authorCleanPhrase_read',
DAM_AUTHOR_CLEAN_PHRASE_DELETE: 'dam_authorCleanPhrase_delete',
DAM_ASSET_EXTERNAL_PROVIDER_ACCESS: 'dam_assetExternalProvider_access',
DAM_DISTRIBUTION_ACCESS: 'dam_distribution_access',
DAM_USER_UI: 'dam_user_ui',
Expand All @@ -97,6 +101,7 @@ export const ACL = {
DAM_VIDEO_SHOW_EPISODE_UI: 'dam_videoShowEpisode_ui',
DAM_PODCAST_UI: 'dam_podcast_ui',
DAM_PODCAST_EPISODE_UI: 'dam_podcastEpisode_ui',
DAM_AUTHOR_CLEAN_PHRASE_UI: 'dam_authorCleanPhrase_ui',
DAM_LOG_UI: 'dam_log_ui',
DAM_JOB_UI: 'dam_job_ui',
} as const
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en/breadcrumb.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"job": {
"list": "Jobs",
"detail": "Job"
},
"authorCleanPhrase": {
"list": "Phrases",
"detail": "Phrase",
"edit": "Phrase"
}
},
"anzuUser": {
Expand Down
41 changes: 41 additions & 0 deletions src/locales/en/coreDam/authorCleanPhrase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"model": {
"id": "ID",
"phrase": "Phrase",
"authorReplacement": "Replace by author",
"type": "Type",
"mode": "Mode",
"position": "Position",
"flags": {
"wordBoundary": "Separate word"
}
},
"filter": {
"id": "ID",
"phrase": "Phrase",
"type": "Type",
"mode": "Mode"
},
"button": {
"create": "Create",
"playground": "Playground"
},
"meta": {
"playground": "Phrase testing",
"test": "Test"
},
"dto": {
"name": "Name",
"authorNames": "Author strings",
"authors": "Authors"
},
"mode": {
"split": "Split",
"remove": "Remove",
"replace": "Replace"
},
"type": {
"word": "Word",
"regex": "Regular expression"
}
}
3 changes: 2 additions & 1 deletion src/locales/en/error/apiValidation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"error_invalid_key": "error_invalid_key error",
"error_invalid_licence": "error_invalid_licence error"
"error_invalid_licence": "error_invalid_licence error",
"error_invalid_ext_system": "error_invalid_ext_system error"
}
3 changes: 2 additions & 1 deletion src/locales/en/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"distributionCategorySelect": "Distribution Categories Selects",
"log": "Logs",
"beta": "Beta",
"job": "System jobs"
"job": "System jobs",
"authorCleanPhrase": "Author clean"
}
}
2 changes: 2 additions & 0 deletions src/locales/sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import breadcrumb from '@/locales/sk/breadcrumb.json'
import audioFile from '@/locales/sk/coreDam/audioFile.json'
import videoFile from '@/locales/sk/coreDam/videoFile.json'
import anzuUser from '@/locales/sk/common/anzuUser.json'
import authorCleanPhrase from '@/locales/sk/coreDam/authorCleanPhrase.json'

export default {
common: {
Expand Down Expand Up @@ -61,6 +62,7 @@ export default {
videoShowEpisode,
audioFile,
videoFile,
authorCleanPhrase,
},
auth,
sidebar,
Expand Down
5 changes: 5 additions & 0 deletions src/locales/sk/breadcrumb.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"job": {
"list": "Systémové úlohy",
"detail": "Systémová úloha"
},
"authorCleanPhrase": {
"list": "Pravidlá",
"detail": "Pravidlo",
"edit": "Pravidlo"
}
},
"anzuUser": {
Expand Down
41 changes: 41 additions & 0 deletions src/locales/sk/coreDam/authorCleanPhrase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"model": {
"id": "ID",
"phrase": "Fráza",
"authorReplacement": "Nahraď autorom",
"type": "Typ frázy",
"mode": "Operácia frázy",
"position": "Poradie",
"flags": {
"wordBoundary": "Samostatné slovo"
}
},
"filter": {
"id": "ID",
"phrase": "Fráza",
"type": "Typ frázy",
"mode": "Operácia frázy"
},
"button": {
"create": "Vytvoriť",
"playground": "Ihrisko"
},
"meta": {
"playground": "Testovanie pravidiel",
"test": "Testuj"
},
"dto": {
"name": "Text",
"authorNames": "Reťazce autorov",
"authors": "Autori"
},
"mode": {
"split": "Rozdelenie",
"remove": "Odstránenie",
"replace": "Nahradenie"
},
"type": {
"word": "Slovo",
"regex": "Regulárny výraz"
}
}
3 changes: 2 additions & 1 deletion src/locales/sk/error/apiValidation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"error_invalid_key": "Neplatný kľúč.",
"error_invalid_licence": "Neplatná licencia."
"error_invalid_licence": "Neplatná licencia.",
"error_invalid_ext_system": "Neplatný externý systém"
}
3 changes: 2 additions & 1 deletion src/locales/sk/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"distributionCategorySelect": "Výbery kategórie distribúcií",
"log": "Logy",
"beta": "Beta",
"job": "Systémové úlohy"
"job": "Systémové úlohy",
"authorCleanPhrase": "Čistenie autorov"
}
}
53 changes: 53 additions & 0 deletions src/model/coreDam/factory/AuthorCleanPhraseFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { IntegerId } from '@anzusystems/common-admin'
import { dateTimeNow } from '@anzusystems/common-admin'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import type { AuthorCleanPhrase, AuthorCleanResultDto, AuthorNameDto } from '@/types/coreDam/AuthorCleanPhrase'
import { ENTITY } from '@/services/api/coreDam/AuthorCleanPhraseApi'
import { AuthorCleanPhraseModeDefault } from '@/model/coreDam/valueObject/AuthorCleanPhraseMode'
import { AuthorCleanPhraseTypeDefault } from '@/model/coreDam/valueObject/AuthorCleanPhraseType'
import { envConfig } from '@/services/EnvConfigService'

const DEFAULT_POSITION = 100

export function useAuthorCleanPhraseFactory() {
const createDefault = (extSystemId: IntegerId): AuthorCleanPhrase => {
return {
id: 0,
authorReplacement: null,
extSystem: extSystemId,
phrase: '',
position: DEFAULT_POSITION,
flags: {
wordBoundary: false,
},
mode: AuthorCleanPhraseModeDefault,
type: AuthorCleanPhraseTypeDefault,
modifiedAt: dateTimeNow(),
createdAt: dateTimeNow(),
createdBy: 0,
modifiedBy: 0,
_resourceName: ENTITY,
_system: SYSTEM_CORE_DAM,
}
}

const createAuthorNameDto = (): AuthorNameDto => {
return {
name: envConfig.dam.authorCleanPhraseTestSample
}
}

const createAuthorCleanResultDto = (): AuthorCleanResultDto => {
return {
name: '',
authors: [],
authorNames: []
}
}

return {
createAuthorNameDto,
createAuthorCleanResultDto,
createDefault,
}
}
25 changes: 25 additions & 0 deletions src/model/coreDam/filter/AuthorCleanPhraseFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { reactive } from 'vue'
import { makeFilterHelper } from '@anzusystems/common-admin'
import { SYSTEM_CORE_DAM } from '@/model/systems'
import { ENTITY } from '@/services/api/coreDam/AuthorCleanPhraseApi'

const makeFilter = makeFilterHelper(SYSTEM_CORE_DAM, ENTITY)

const filter = reactive({
id: {
...makeFilter({ name: 'id' }),
},
phrase: {
...makeFilter({ name: 'phrase' }),
},
mode: {
...makeFilter({ name: 'mode' }),
},
type: {
...makeFilter({ name: 'type' }),
},
})

export function useAuthorCleanPhraseListFilter() {
return filter
}
40 changes: 40 additions & 0 deletions src/model/coreDam/valueObject/AuthorCleanPhraseMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import type { ValueObjectOption } from '@anzusystems/common-admin'

export const AuthorCleanPhraseMode = {
Remove: 'remove',
Replace: 'replace',
Split: 'split',
} as const

export type AuthorCleanPhraseModeType = (typeof AuthorCleanPhraseMode)[keyof typeof AuthorCleanPhraseMode]
export const AuthorCleanPhraseModeDefault = AuthorCleanPhraseMode.Remove

export function useAuthorCleanPhraseModeTypes() {
const { t } = useI18n()

const authorCleanPhraseModeOptions = ref<ValueObjectOption<AuthorCleanPhraseModeType>[]>([
{
value: AuthorCleanPhraseMode.Remove,
title: t('coreDam.authorCleanPhrase.mode.remove'),
},
{
value: AuthorCleanPhraseMode.Replace,
title: t('coreDam.authorCleanPhrase.mode.replace'),
},
{
value: AuthorCleanPhraseMode.Split,
title: t('coreDam.authorCleanPhrase.mode.split'),
},
])

const getAuthorCleanPhraseModeOption = (value: AuthorCleanPhraseModeType) => {
return authorCleanPhraseModeOptions.value.find((item) => item.value === value)
}

return {
authorCleanPhraseModeOptions,
getAuthorCleanPhraseModeOption,
}
}
35 changes: 35 additions & 0 deletions src/model/coreDam/valueObject/AuthorCleanPhraseType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import type { ValueObjectOption } from '@anzusystems/common-admin'

export const AuthorCleanPhraseType = {
Word: 'word',
Regex: 'regex',
} as const

export type AuthorCleanPhraseTypeType = (typeof AuthorCleanPhraseType)[keyof typeof AuthorCleanPhraseType]
export const AuthorCleanPhraseTypeDefault = AuthorCleanPhraseType.Word

export function useAuthorCleanPhraseTypeTypes() {
const { t } = useI18n()

const authorCleanPhraseTypeOptions = ref<ValueObjectOption<AuthorCleanPhraseTypeType>[]>([
{
value: AuthorCleanPhraseType.Word,
title: t('coreDam.authorCleanPhrase.type.word'),
},
{
value: AuthorCleanPhraseType.Regex,
title: t('coreDam.authorCleanPhrase.type.regex'),
},
])

const getAuthorCleanPhraseTypeOption = (value: AuthorCleanPhraseTypeType) => {
return authorCleanPhraseTypeOptions.value.find((item) => item.value === value)
}

return {
authorCleanPhraseTypeOptions,
getAuthorCleanPhraseTypeOption,
}
}
2 changes: 2 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { jobRoutes } from '@/router/routes/coreDam/job'
import HomepageView from '@/views/system/HomepageView.vue'
import { ANotFoundView } from '@anzusystems/common-admin'
import { assetLicenceGroupRoutes } from '@/router/routes/coreDam/assetLicenceGroup'
import { authorCleanPhraseRoutes } from '@/router/routes/coreDam/authorCleanPhrase'

const vueRouter = createRouter({
history: createWebHistory(),
Expand All @@ -46,6 +47,7 @@ const vueRouter = createRouter({
...keywordRoutes,
...distributionCategoryRoutes,
...distributionCategorySelectRoutes,
...authorCleanPhraseRoutes,
...podcastRoutes,
...videoShowRoutes,
...jobRoutes,
Expand Down
5 changes: 5 additions & 0 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ const routes = {
DETAIL: 'videoShowEpisode_detail',
EDIT: 'videoShowEpisode_edit',
},
AUTHOR_CLEAN_PHRASE: {
DETAIL: 'authorCleanPhrase_detail',
EDIT: 'authorCleanPhrase_edit',
LIST: 'authorCleanPhrase_list',
},
},
SYSTEM: {
HOMEPAGE: 'homepage',
Expand Down
Loading

0 comments on commit 0c3526e

Please sign in to comment.