From d0fbe5df248dd7c3f2f8bd0d0f42e302c54117b5 Mon Sep 17 00:00:00 2001 From: Thijn Date: Thu, 14 Nov 2024 16:20:23 +0100 Subject: [PATCH] finished source config and target config key-value pairs --- .../synchronization/synchronization.ts | 8 +- .../synchronization/synchronization.types.ts | 4 +- src/modals/Modals.vue | 12 ++ .../DeleteSynchronizationSourceConfig.vue | 127 +++++++++++++++ .../EditSynchronizationSourceConfig.vue | 152 ++++++++++++++++++ .../DeleteSynchronizationTargetConfig.vue | 127 +++++++++++++++ .../EditSynchronizationTargetConfig.vue | 152 ++++++++++++++++++ src/store/modules/synchronization.js | 50 +++--- .../SynchronizationDetails.vue | 91 ++++++++++- 9 files changed, 692 insertions(+), 31 deletions(-) create mode 100644 src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue create mode 100644 src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue create mode 100644 src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue create mode 100644 src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue diff --git a/src/entities/synchronization/synchronization.ts b/src/entities/synchronization/synchronization.ts index 700367e5..c9bac364 100644 --- a/src/entities/synchronization/synchronization.ts +++ b/src/entities/synchronization/synchronization.ts @@ -12,7 +12,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati public sourceType: string public sourceHash: string public sourceTargetMapping: string - public sourceConfig: object + public sourceConfig: Record public sourceLastChanged: string public sourceLastChecked: string public sourceLastSynced: string @@ -20,7 +20,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati public targetType: string public targetHash: string public targetSourceMapping: string - public targetConfig: object + public targetConfig: Record public targetLastChanged: string public targetLastChecked: string public targetLastSynced: string @@ -64,7 +64,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati sourceType: z.string(), sourceHash: z.string(), sourceTargetMapping: z.string(), - sourceConfig: z.object({}), + sourceConfig: z.record(z.string(), z.string()), sourceLastChanged: z.string(), sourceLastChecked: z.string(), sourceLastSynced: z.string(), @@ -72,7 +72,7 @@ export class Synchronization extends ReadonlyBaseClass implements TSynchronizati targetType: z.string(), targetHash: z.string(), targetSourceMapping: z.string(), - targetConfig: z.object({}), + targetConfig: z.record(z.string(), z.string()), targetLastChanged: z.string(), targetLastChecked: z.string(), targetLastSynced: z.string(), diff --git a/src/entities/synchronization/synchronization.types.ts b/src/entities/synchronization/synchronization.types.ts index e2e59bfd..7dcf47a1 100644 --- a/src/entities/synchronization/synchronization.types.ts +++ b/src/entities/synchronization/synchronization.types.ts @@ -6,7 +6,7 @@ export type TSynchronization = { sourceType: string sourceHash: string sourceTargetMapping: string - sourceConfig: object + sourceConfig: Record sourceLastChanged: string sourceLastChecked: string sourceLastSynced: string @@ -14,7 +14,7 @@ export type TSynchronization = { targetType: string targetHash: string targetSourceMapping: string - targetConfig: object + targetConfig: Record targetLastChanged: string targetLastChecked: string targetLastSynced: string diff --git a/src/modals/Modals.vue b/src/modals/Modals.vue index 8b6165f6..337b4675 100644 --- a/src/modals/Modals.vue +++ b/src/modals/Modals.vue @@ -34,6 +34,10 @@ import { navigationStore } from '../store/store.js' + + + + @@ -68,6 +72,10 @@ import DeleteMappingCast from './mappingCast/DeleteMappingCast.vue' import ViewJobLog from './Log/ViewJobLog.vue' import ViewSynchronizationLog from './Log/ViewSynchronizationLog.vue' import ViewSynchronizationContract from './Log/ViewSynchronizationContract.vue' +import EditSynchronizationSourceConfig from './SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue' +import DeleteSynchronizationSourceConfig from './SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue' +import EditSynchronizationTargetConfig from './SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue' +import DeleteSynchronizationTargetConfig from './SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue' export default { name: 'Modals', @@ -102,6 +110,10 @@ export default { ViewJobLog, ViewSynchronizationLog, ViewSynchronizationContract, + EditSynchronizationSourceConfig, + DeleteSynchronizationSourceConfig, + EditSynchronizationTargetConfig, + DeleteSynchronizationTargetConfig, }, setup() { return { diff --git a/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue b/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue new file mode 100644 index 00000000..fb95139d --- /dev/null +++ b/src/modals/SynchronizationSourceConfig/DeleteSynchronizationSourceConfig.vue @@ -0,0 +1,127 @@ + + + + + + + diff --git a/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue b/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue new file mode 100644 index 00000000..ea113058 --- /dev/null +++ b/src/modals/SynchronizationSourceConfig/EditSynchronizationSourceConfig.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue b/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue new file mode 100644 index 00000000..1541c217 --- /dev/null +++ b/src/modals/SynchronizationTargetConfig/DeleteSynchronizationTargetConfig.vue @@ -0,0 +1,127 @@ + + + + + + + diff --git a/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue b/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue new file mode 100644 index 00000000..621638e2 --- /dev/null +++ b/src/modals/SynchronizationTargetConfig/EditSynchronizationTargetConfig.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/store/modules/synchronization.js b/src/store/modules/synchronization.js index 75c966e5..797e7258 100644 --- a/src/store/modules/synchronization.js +++ b/src/store/modules/synchronization.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import { defineStore } from 'pinia' import { Synchronization } from '../../entities/index.js' @@ -9,26 +8,36 @@ export const useSynchronizationStore = defineStore('synchronization', { synchronizationContracts: [], synchronizationTest: null, synchronizationLogs: [], + synchronizationSourceConfigKey: null, + synchronizationTargetConfigKey: null, }), actions: { setSynchronizationItem(synchronizationItem) { this.synchronizationItem = synchronizationItem && new Synchronization(synchronizationItem) - console.log('Active synchronization item set to ' + synchronizationItem) + console.info('Active synchronization item set to ' + synchronizationItem) }, setSynchronizationList(synchronizationList) { this.synchronizationList = synchronizationList.map( (synchronizationItem) => new Synchronization(synchronizationItem), ) - console.log('Synchronization list set to ' + synchronizationList.length + ' items') + console.info('Synchronization list set to ' + synchronizationList.length + ' items') }, setSynchronizationContracts(synchronizationContracts) { this.synchronizationContracts = synchronizationContracts - console.log('Synchronization contracts set to ' + synchronizationContracts?.length + ' items') + console.info('Synchronization contracts set to ' + synchronizationContracts?.length + ' items') }, setSynchronizationLogs(synchronizationLogs) { this.synchronizationLogs = synchronizationLogs - console.log('Synchronization logs set to ' + synchronizationLogs?.length + ' items') + console.info('Synchronization logs set to ' + synchronizationLogs?.length + ' items') + }, + setSynchronizationSourceConfigKey(key) { + this.synchronizationSourceConfigKey = key + console.info('Synchronization source config key set to ' + key) + }, + setSynchronizationTargetConfigKey(key) { + this.synchronizationTargetConfigKey = key + console.info('Synchronization target config key set to ' + key) }, /* istanbul ignore next */ // ignore this for Jest until moved into a service @@ -127,7 +136,7 @@ export const useSynchronizationStore = defineStore('synchronization', { throw new Error('No synchronization item to delete') } - console.log('Deleting synchronization...') + console.info('Deleting synchronization...') const endpoint = `/index.php/apps/openconnector/api/synchronizations/${this.synchronizationItem.id}` @@ -143,12 +152,12 @@ export const useSynchronizationStore = defineStore('synchronization', { }) }, // Create or save a synchronization from store - saveSynchronization(synchronizationItem) { + async saveSynchronization(synchronizationItem) { if (!synchronizationItem) { throw new Error('No synchronization item to save') } - console.log('Saving synchronization...') + console.info('Saving synchronization...') const isNewSynchronization = !synchronizationItem?.id const endpoint = isNewSynchronization @@ -156,7 +165,7 @@ export const useSynchronizationStore = defineStore('synchronization', { : `/index.php/apps/openconnector/api/synchronizations/${synchronizationItem.id}` const method = isNewSynchronization ? 'POST' : 'PUT' - return fetch( + const response = await fetch( endpoint, { method, @@ -166,17 +175,16 @@ export const useSynchronizationStore = defineStore('synchronization', { body: JSON.stringify(synchronizationItem), }, ) - .then((response) => response.json()) - .then((data) => { - this.setSynchronizationItem(data) - console.log('Synchronization saved') - this.refreshSynchronizationList() - }) - .catch((err) => { - console.error('Error saving synchronization:', err) - throw err - }) + console.info('Synchronization saved') + + const data = await response.json() + const entity = new Synchronization(data) + + this.setSynchronizationItem(entity) + this.refreshSynchronizationList() + + return { response, data, entity } }, // Test a synchronization async testSynchronization() { @@ -184,7 +192,7 @@ export const useSynchronizationStore = defineStore('synchronization', { throw new Error('No synchronization item to test') } - console.log('Testing synchronization...') + console.info('Testing synchronization...') const endpoint = `/index.php/apps/openconnector/api/synchronizations-test/${this.synchronizationItem.id}` @@ -198,7 +206,7 @@ export const useSynchronizationStore = defineStore('synchronization', { const data = await response.json() this.synchronizationTest = data - console.log('Synchronization tested') + console.info('Synchronization tested') this.refreshSynchronizationLogs() return { response, data } diff --git a/src/views/Synchronization/SynchronizationDetails.vue b/src/views/Synchronization/SynchronizationDetails.vue index c2920f2c..34af78bd 100644 --- a/src/views/Synchronization/SynchronizationDetails.vue +++ b/src/views/Synchronization/SynchronizationDetails.vue @@ -21,6 +21,18 @@ import { synchronizationStore, navigationStore, logStore } from '../../store/sto Edit + + + Add Source Config + + + + Add Target Config +