Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed feedback on synchronization test #81

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ public function getAllObjectsFromApi(Synchronization $synchronization, ?bool $is
// Make the initial API call
$response = $this->callService->call(source: $source, endpoint: $endpoint, method: 'GET', config: $config)->getResponse();
$body = json_decode($response['body'], true);
if (empty($body) === true) {
// @todo log that we got a empty response
return [];
}
$objects = array_merge($objects, $this->getAllObjectsFromArray(array: $body, synchronization: $synchronization));

// Return a single object or empty array if in test mode
Expand Down
2 changes: 1 addition & 1 deletion src/modals/Modals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { navigationStore } from '../store/store.js'
<DeleteMappingUnset v-if="navigationStore.modal === 'deleteMappingUnset'" />
<DeleteSynchronization />
<EditSynchronization v-if="navigationStore.modal === 'editSynchronization'" />
<TestSynchronization />
<TestSynchronization v-if="navigationStore.modal === 'testSynchronization'" />
<EditJobArgument />
<DeleteJobArgument />
<EditSourceConfiguration />
Expand Down
71 changes: 33 additions & 38 deletions src/modals/Synchronization/TestSynchronization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { synchronizationStore, navigationStore } from '../../store/store.js'
</script>

<template>
<NcModal v-if="navigationStore.modal === 'testSynchronization'"
ref="modalRef"
<NcModal ref="modalRef"
label-id="testSynchronization"
@close="closeModal">
<div class="modalContent">
Expand All @@ -14,30 +13,36 @@ import { synchronizationStore, navigationStore } from '../../store/store.js'
<NcLoadingIcon :size="64" name="Running synchronization test" />
</div>

<NcNoteCard v-if="response?.ok" type="success">
<p>The connection to the synchronization was successful.</p>
<NcNoteCard v-if="success === false" type="error">
<p>An error occurred while testing the synchronization.</p>
</NcNoteCard>
<NcNoteCard v-if="!response?.ok || error" type="error">
<p>
An error occurred while testing the connection: {{
synchronizationStore.synchronizationTest
? synchronizationStore.synchronizationTest.message

<div v-if="success !== null">
<NcNoteCard v-if="response?.ok" type="success">
<p>The connection to the synchronization was successful.</p>
</NcNoteCard>
<NcNoteCard v-if="!response?.ok || error" type="error">
<p>
An error occurred while testing the connection: {{
synchronizationStore.synchronizationTest
? synchronizationStore.synchronizationTest.message
: synchronizationStore.synchronizationTest.error
: response?.statusMessage
? response?.statusMessage
: `${response?.status} - ${response?.statusText}`
}}
</p>
</NcNoteCard>
? synchronizationStore.synchronizationTest.message
: synchronizationStore.synchronizationTest.error
: response?.statusMessage
? response?.statusMessage
: `${response?.status} - ${response?.statusText}`
}}
</p>
</NcNoteCard>

<div v-if="response">
<p><b>Status:</b> {{ response?.statusText }} ({{ response?.status }})</p>
<p><b>Response time:</b> {{ response?.responseTime ?? 'Onbekend' }} (Milliseconds)</p>
<p><b>Size:</b> {{ response?.size ?? 'Onbekend' }} (Bytes)</p>
<p><b>Remote IP:</b> {{ response?.remoteIp }}</p>
<p><b>Headers:</b> {{ response?.headers }}</p>
<p><b>Body:</b> {{ response?.body }}</p>
<div v-if="response">
<p><b>Status:</b> {{ response?.statusText }} ({{ response?.status }})</p>
<p><b>Response time:</b> {{ response?.responseTime ?? 'Onbekend' }} (Milliseconds)</p>
<p><b>Size:</b> {{ response?.size ?? 'Onbekend' }} (Bytes)</p>
<p><b>Remote IP:</b> {{ response?.remoteIp ?? 'Onbekend' }}</p>
<p><b>Headers:</b> {{ response?.headers }}</p>
<p><b>Body:</b> {{ response?.body }}</p>
</div>
</div>
</div>
</NcModal>
Expand All @@ -59,39 +64,29 @@ export default {
},
data() {
return {
response: null,
success: null,
loading: false,
error: false,
updated: false,
response: null,
}
},
updated() {
if (navigationStore.modal === 'testSynchronization' && !this.updated) {
this.testSynchronization()
this.updated = true
}
mounted() {
this.testSynchronization()
},
methods: {
closeModal() {
navigationStore.setModal(false)
synchronizationStore.synchronizationTest = null
this.success = null
this.loading = false
this.error = false
this.updated = false
},
async testSynchronization() {
this.success = null
this.loading = true
this.error = false
synchronizationStore.testSynchronization()
.then(({ response }) => {
this.response = response
this.success = response.ok
this.error = false
response.ok && this.closeModal()
}).catch((error) => {
this.success = false
this.error = error.message || 'An error occurred while testing the synchronization'
Expand Down
Loading