Skip to content

Commit

Permalink
cherry pick bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SudoThijn committed Jan 21, 2025
1 parent 977286b commit 25b1a04
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/modals/Consumer/EditConsumer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export default {
await consumerStore.saveConsumer({
...this.consumerItem,
domains: this.consumerItem.domains.trim().split(/ *, */g), // split on comma's, also take any spaces into consideration
ips: this.consumerItem.ips.trim().split(/ *, */g),
domains: this.consumerItem.domains.trim().split(/ *, */g).filter(Boolean), // split on comma's, also take any spaces into consideration
ips: this.consumerItem.ips.trim().split(/ *, */g).filter(Boolean),
authorizationType: this.authorizationTypeOptions.value.label,
authorizationConfiguration: [['']],
// authorizationConfiguration is unclear as to what it does and why it exists, but to avoid any issues it'll still make a array array string
Expand Down
7 changes: 4 additions & 3 deletions src/modals/JobArgument/DeleteJobArgument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { navigationStore, jobStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import _ from 'lodash'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
Expand Down Expand Up @@ -78,13 +79,13 @@ export default {
deleteJobArgument() {
this.loading = true
const jobItemClone = { ...jobStore.jobItem }
const jobItemClone = _.cloneDeep(jobStore.jobItem)
delete jobItemClone?.arguments[jobStore.jobArgumentKey]
const scheduleAfter = jobStore.jobItem.scheduleAfter ? new Date(jobStore.jobItem.scheduleAfter.date) || '' : null
const scheduleAfter = jobItemClone.scheduleAfter ? new Date(jobItemClone.scheduleAfter.date) || '' : null
const jobItem = {
...jobStore.jobItem,
...jobItemClone,
scheduleAfter,
}
Expand Down
32 changes: 18 additions & 14 deletions src/modals/JobArgument/EditJobArgument.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
NcNoteCard,
NcTextField,
} from '@nextcloud/vue'
import _ from 'lodash'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
export default {
Expand Down Expand Up @@ -131,13 +132,15 @@ export default {
async editJobArgument() {
this.loading = true
const scheduleAfter = jobStore.jobItem.scheduleAfter ? new Date(jobStore.jobItem.scheduleAfter.date) || '' : null
const jobItemClone = _.cloneDeep(jobStore.jobItem)
const scheduleAfter = jobItemClone.scheduleAfter ? new Date(jobItemClone.scheduleAfter.date) || '' : null
const newJobItem = {
...jobStore.jobItem,
...jobItemClone,
scheduleAfter,
arguments: {
...jobStore.jobItem.arguments,
...jobItemClone.arguments,
[this.argumentItem.key]: this.argumentItem.value,
},
}
Expand All @@ -146,17 +149,18 @@ export default {
delete newJobItem.arguments[this.oldKey]
}
try {
await jobStore.saveJob(newJobItem)
// Close modal or show success message
this.success = true
this.loading = false
this.closeTimeoutFunc = setTimeout(this.closeModal, 2000)
} catch (error) {
this.loading = false
this.success = false
this.error = error.message || 'An error occurred while saving the job argument'
}
jobStore.saveJob(newJobItem)
.then(({ response }) => {
this.success = response.ok
this.closeTimeoutFunc = setTimeout(this.closeModal, 2000)
})
.catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while saving the job argument'
})
.finally(() => {
this.loading = false
})
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export default {
description: this.mappingItem.description,
mapping: JSON.parse(this.mappingItem.mapping),
cast: this.mappingItem.cast ? JSON.parse(this.mappingItem.cast) : null,
unset: this.mappingItem.unset.split(/ *, */g),
unset: this.mappingItem.unset.split(/ *, */g).filter(Boolean),
},
inputObject: JSON.parse(this.inputObject.value),
schema: this.schemas.value?.id,
Expand All @@ -451,7 +451,7 @@ export default {
description: this.mappingItem.description,
mapping: JSON.parse(this.mappingItem.mapping),
cast: JSON.parse(this.mappingItem.cast),
unset: this.mappingItem.unset.split(/ *, */g),
unset: this.mappingItem.unset.split(/ *, */g).filter(Boolean),
})
mappingStore.saveMapping(newMappingItem)
Expand Down
2 changes: 1 addition & 1 deletion src/modals/Rule/DeleteRule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ruleStore, navigationStore } from '../../store/store.js'
size="normal"
:can-close="false">
<p v-if="!success">
Do you want to delete <b>{{ ruleStore.ruleItem.name }}</b>? This action cannot be undone.
Do you want to delete <b>{{ ruleStore.ruleItem?.name }}</b>? This action cannot be undone.
</p>

<NcNoteCard v-if="success" type="success">
Expand Down
48 changes: 46 additions & 2 deletions src/modals/Synchronization/EditSynchronization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ import {
NcActions,
NcActionButton,
} from '@nextcloud/vue'
import openLink from '../../services/openLink.js'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
import CloudDownload from 'vue-material-design-icons/CloudDownload.vue'
Expand Down Expand Up @@ -549,7 +550,50 @@ export default {
this.openRegisterLoading = true
console.info('Installing Open Register')
const token = document.querySelector('head[data-requesttoken]').getAttribute('data-requesttoken')
const requesttoken = document.querySelector('head[data-requesttoken]').getAttribute('data-requesttoken')
if (window.location.hostname === 'nextcloud.local') {
await fetch('http://nextcloud.local/index.php/login/confirm', {
headers: {
accept: 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9,nl;q=0.8',
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
requesttoken,
'x-requested-with': 'XMLHttpRequest, XMLHttpRequest',
},
referrerPolicy: 'no-referrer',
body: '{"password":"admin"}',
method: 'POST',
mode: 'cors',
credentials: 'include',
})
}
const forceResponse = await fetch('/index.php/settings/apps/force', {
headers: {
accept: 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9,nl;q=0.8',
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
requesttoken,
'x-requested-with': 'XMLHttpRequest, XMLHttpRequest',
},
referrerPolicy: 'no-referrer',
body: '{"appId":"openregister"}',
method: 'POST',
mode: 'cors',
credentials: 'include',
})
if (!forceResponse.ok) {
console.info('Failed to install Open Register')
this.openRegisterIsAvailable = false
this.openRegisterLoading = false
return
}
const response = await fetch('/index.php/settings/apps/enable', {
headers: {
Expand All @@ -558,7 +602,7 @@ export default {
'cache-control': 'no-cache',
'content-type': 'application/json',
pragma: 'no-cache',
requesttoken: token,
requesttoken,
'x-requested-with': 'XMLHttpRequest, XMLHttpRequest',
},
referrerPolicy: 'no-referrer',
Expand Down
1 change: 0 additions & 1 deletion src/navigation/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { navigationStore } from '../store/store.js'
<MessageTextFastOutline :size="20" />
</template>
</NcAppNavigationItem>
<NcAppNavigationItem name="Events" />
</template>
</NcAppNavigationItem>
<NcAppNavigationItem :active="navigationStore.selected === 'synchronizations'" name="Synchronization" @click="navigationStore.setSelected('synchronizations')">
Expand Down
25 changes: 12 additions & 13 deletions src/store/modules/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const useJobStore = defineStore(
return { response, data }
},
// Create or save a job from store
saveJob(jobItem) {
async saveJob(jobItem) {
if (!jobItem) {
throw new Error('No job item to save')
}
Expand All @@ -197,7 +197,7 @@ export const useJobStore = defineStore(
// Remove the version field
delete jobToSave.version

return fetch(
const response = await fetch(
endpoint,
{
method,
Expand All @@ -207,17 +207,16 @@ export const useJobStore = defineStore(
body: JSON.stringify(jobToSave),
},
)
.then((response) => response.json())
.then((data) => {
this.setJobItem(data)
console.info('Job saved')
// Refresh the job list
return this.refreshJobList()
})
.catch((err) => {
console.error('Error saving job:', err)
throw err
})

console.info('Job saved')

const data = await response.json()
const entity = new Job(data)

this.setJobItem(entity)
this.refreshJobList()

return { response, data, entity }
},
// Export a job
exportJob(jobItem) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Endpoint/EndpointDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default {
const rule = this.rulesList.find(rule => String(rule.id) === String(ruleId))
if (rule) {
ruleStore.setRuleItem(rule)
navigationStore.setView('rule')
navigationStore.setSelected('rules')
}
},
async removeRule(ruleId) {
Expand Down
6 changes: 6 additions & 0 deletions src/views/Endpoint/EndpointsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ import { endpointStore, navigationStore, searchStore } from '../../store/store.j
</template>
Verwijderen
</NcActionButton>
<NcActionButton @click="endpointStore.setEndpointItem(endpoint); navigationStore.setModal('addEndpointRule')">
<template #icon>
<Plus :size="20" />
</template>
Add Rule
</NcActionButton>
</template>
</NcListItem>
</div>
Expand Down
30 changes: 30 additions & 0 deletions src/views/Job/JobsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ import { jobStore, navigationStore, searchStore } from '../../store/store.js'
</template>
Edit
</NcActionButton>
<NcActionButton @click="() => {
jobStore.setJobItem(job)
jobStore.setJobArgumentKey(null)
navigationStore.setModal('editJobArgument')
}">
<template #icon>
<Plus :size="20" />
</template>
Add Argument
</NcActionButton>
<NcActionButton @click="jobStore.setJobItem(job); navigationStore.setModal('testJob')">
<template #icon>
<Update :size="20" />
</template>
Test
</NcActionButton>
<NcActionButton @click="jobStore.setJobItem(job); navigationStore.setModal('runJob')">
<template #icon>
<Play :size="20" />
</template>
Run
</NcActionButton>
<NcActionButton @click="jobStore.setJobItem(job); jobStore.refreshJobLogs()">
<template #icon>
<Sync :size="20" />
</template>
Refresh Logs
</NcActionButton>
<NcActionButton @click="jobStore.exportJob(job)">
<template #icon>
<FileExportOutline :size="20" />
Expand Down Expand Up @@ -97,6 +125,8 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
import FileExportOutline from 'vue-material-design-icons/FileExportOutline.vue'
import FileImportOutline from 'vue-material-design-icons/FileImportOutline.vue'
import Play from 'vue-material-design-icons/Play.vue'
import Sync from 'vue-material-design-icons/Sync.vue'
export default {
name: 'JobsList',
Expand Down
27 changes: 27 additions & 0 deletions src/views/Source/SourcesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@ import { sourceStore, navigationStore, searchStore } from '../../store/store.js'
</template>
Edit
</NcActionButton>
<NcActionButton @click="sourceStore.setSourceItem(source); navigationStore.setModal('testSource')">
<template #icon>
<Sync :size="20" />
</template>
Test
</NcActionButton>
<NcActionButton @click="() => {
sourceStore.setSourceItem(source)
sourceStore.setSourceConfigurationKey(null)
navigationStore.setModal('editSourceConfiguration')
}">
<template #icon>
<Plus :size="20" />
</template>
Add Configuration
</NcActionButton>
<NcActionButton @click="() => {
sourceStore.setSourceItem(source)
sourceStore.setSourceConfigurationKey(null)
navigationStore.setModal('editSourceConfigurationAuthentication')
}">
<template #icon>
<Plus :size="20" />
</template>
Add Authentication
</NcActionButton>
<NcActionButton @click="sourceStore.exportSource(source)">
<template #icon>
<FileExportOutline :size="20" />
Expand Down Expand Up @@ -100,6 +126,7 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
import FileExportOutline from 'vue-material-design-icons/FileExportOutline.vue'
import FileImportOutline from 'vue-material-design-icons/FileImportOutline.vue'
import Sync from 'vue-material-design-icons/Sync.vue'
export default {
name: 'SourcesList',
Expand Down
36 changes: 36 additions & 0 deletions src/views/Synchronization/SynchronizationsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,38 @@ import { synchronizationStore, navigationStore, searchStore } from '../../store/
</template>
Edit
</NcActionButton>
<NcActionButton @click="() => {
synchronizationStore.setSynchronizationItem(synchronization)
synchronizationStore.setSynchronizationSourceConfigKey(null)
navigationStore.setModal('editSynchronizationSourceConfig')
}">
<template #icon>
<DatabaseSettingsOutline :size="20" />
</template>
Add Source Config
</NcActionButton>
<NcActionButton @click="() => {
synchronizationStore.setSynchronizationItem(synchronization)
synchronizationStore.setSynchronizationTargetConfigKey(null)
navigationStore.setModal('editSynchronizationTargetConfig')
}">
<template #icon>
<CardBulletedSettingsOutline :size="20" />
</template>
Add Target Config
</NcActionButton>
<NcActionButton @click="synchronizationStore.setSynchronizationItem(synchronization); navigationStore.setModal('testSynchronization')">
<template #icon>
<Sync :size="20" />
</template>
Test
</NcActionButton>
<NcActionButton @click="synchronizationStore.setSynchronizationItem(synchronization); navigationStore.setModal('runSynchronization')">
<template #icon>
<Play :size="20" />
</template>
Run
</NcActionButton>
<NcActionButton @click="synchronizationStore.exportSynchronization(synchronization)">
<template #icon>
<FileExportOutline :size="20" />
Expand Down Expand Up @@ -97,6 +129,10 @@ import Pencil from 'vue-material-design-icons/Pencil.vue'
import TrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
import FileExportOutline from 'vue-material-design-icons/FileExportOutline.vue'
import FileImportOutline from 'vue-material-design-icons/FileImportOutline.vue'
import DatabaseSettingsOutline from 'vue-material-design-icons/DatabaseSettingsOutline.vue'
import CardBulletedSettingsOutline from 'vue-material-design-icons/CardBulletedSettingsOutline.vue'
import Sync from 'vue-material-design-icons/Sync.vue'
import Play from 'vue-material-design-icons/Play.vue'
export default {
name: 'SynchronizationsList',
Expand Down

0 comments on commit 25b1a04

Please sign in to comment.