Skip to content

Commit

Permalink
Added metadata via external source
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Aug 19, 2024
1 parent f18f4fb commit 039d266
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 57 deletions.
9 changes: 8 additions & 1 deletion lib/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
use OCP\AppFramework\Http\ContentSecurityPolicy;

class DashboardController extends Controller
{
Expand All @@ -22,11 +23,17 @@ public function __construct($appName, IRequest $request)
public function page(?string $getParameter)
{
try {
return new TemplateResponse(
$response =new TemplateResponse(
$this->appName,
'index',
[]
);

$csp = new ContentSecurityPolicy();
$csp->addAllowedConnectDomain('*');
$response->setContentSecurityPolicy($csp);

return $response;
} catch (\Exception $e) {
return new TemplateResponse(
$this->appName,
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/attachment/DeleteAttachmentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import { publicationStore, navigationStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
Expand Down Expand Up @@ -99,7 +98,7 @@ export default {
...publicationStore.publicationItem,
attachments: [...this.filterdAttachments],
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/publication/ArchivePublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { navigationStore, publicationStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import ArchivePlusOutline from 'vue-material-design-icons/ArchivePlusOutline.vue'
Expand Down Expand Up @@ -80,7 +79,7 @@ export default {
body: JSON.stringify({
...publicationStore.publicationItem,
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/publication/DepublishPublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { navigationStore, publicationStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import PublishOff from 'vue-material-design-icons/PublishOff.vue'
Expand Down Expand Up @@ -81,7 +80,7 @@ export default {
body: JSON.stringify({
...publicationStore.publicationItem,
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/publication/PublishPublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { navigationStore, publicationStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Publish from 'vue-material-design-icons/Publish.vue'
Expand Down Expand Up @@ -80,7 +79,7 @@ export default {
body: JSON.stringify({
...publicationStore.publicationItem,
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
3 changes: 1 addition & 2 deletions src/dialogs/publicationData/DeletePublicationDataDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { navigationStore, publicationStore } from '../../store/store.js'

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import Cancel from 'vue-material-design-icons/Cancel.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
Expand Down Expand Up @@ -81,7 +80,7 @@ export default {
body: JSON.stringify({
...publicationStore.publicationItem,
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
3 changes: 1 addition & 2 deletions src/modals/attachment/AddAttachmentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ import { navigationStore, publicationStore } from '../../store/store.js'
<script>
import { NcButton, NcLoadingIcon, NcModal, NcNoteCard, NcTextArea, NcTextField } from '@nextcloud/vue'
import { useFileSelection } from './../../composables/UseFileSelection.js'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import { ref } from 'vue'
Expand Down Expand Up @@ -191,7 +190,7 @@ export default {
...publicationStore.publicationItem,
attachments: [...publicationStore.publicationItem.attachments, response.data.id],
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
8 changes: 3 additions & 5 deletions src/modals/publicationData/AddPublicationDataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export default {
}
}
console.log('test')
return {
inputLabel: 'Publicatie type eigenschap',
options: Object.values(publicationStore.publicationMetaData?.properties)
Expand Down Expand Up @@ -164,16 +162,16 @@ export default {
this.error = err
})
},
fetchMetaData(metadataId, loading) {
fetchMetaData(metaDataUrl, loading) {
if (loading) { this.metaDataLoading = true }
fetch(`/index.php/apps/opencatalogi/api/metadata/${metadataId}`, {
fetch(`/index.php/apps/opencatalogi/api/metadata?source=${metaDataUrl}`, {
method: 'GET',
})
.then((response) => {
response.json().then((data) => {
this.metadata = data
this.metadata = data.results[0]
})
if (loading) { this.metaDataLoading = false }
})
Expand Down
3 changes: 1 addition & 2 deletions src/modals/publicationData/EditPublicationDataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
NcLoadingIcon,
NcNoteCard,
} from '@nextcloud/vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
Expand Down Expand Up @@ -186,7 +185,7 @@ export default {
...publicationStore.publicationItem,
id: publicationStore.publicationItem.id,
catalogi: publicationStore.publicationItem.catalogi.id,
metaData: getMetaDataId(publicationStore.publicationItem.metaData),
metaData: publicationStore.publicationItem.metaData,
}),
},
)
Expand Down
52 changes: 15 additions & 37 deletions src/views/publications/PublicationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ import { ref } from 'vue'
import { NcActionButton, NcActions, NcButton, NcListItem, NcLoadingIcon, NcNoteCard, NcSelectTags } from '@nextcloud/vue'
import { useFileSelection } from './../../composables/UseFileSelection.js'
import { BTab, BTabs } from 'bootstrap-vue'
import { getMetaDataId } from './../../services/getMetaDataId.js'
import VueApexCharts from 'vue-apexcharts'
// Icons
Expand Down Expand Up @@ -488,7 +487,7 @@ export default {
if (!this.upToDate || JSON.stringify(newPublicationItem) !== JSON.stringify(oldPublicationItem)) {
this.publication = publicationStore.publicationItem
this.fetchCatalogi(publicationStore.publicationItem.catalogi.id)
// this.fetchMetaData(publicationStore.publicationItem.metaData)
this.fetchMetaData(publicationStore.publicationItem.metaData)
publicationStore.publicationItem && this.fetchData(publicationStore.publicationItem.id)
}
},
Expand All @@ -500,7 +499,7 @@ export default {
this.publication = publicationStore.publicationItem
this.fetchCatalogi(this.publication.catalogi?.id, true)
// this.fetchMetaData(publicationStore.publicationItem.metaData, true)
this.fetchMetaData(publicationStore.publicationItem.metaData, true)
publicationStore.publicationItem && this.fetchData(publicationStore.publicationItem.id)
},
Expand Down Expand Up @@ -543,45 +542,24 @@ export default {
if (loading) { this.catalogiLoading = false }
})
},
fetchMetaData(metadataId, loading) {
fetchMetaData(metaDataUrl, loading) {
if (loading) { this.metaDataLoading = true }
console.log('metadataID', metadataId)
const incomingUrl = new URL(metadataId)
if (incomingUrl.host === window.location.host) {
const id = getMetaDataId(metadataId)
fetch(`/index.php/apps/opencatalogi/api/metadata/${id}`, {
method: 'GET',
})
.then((response) => {
response.json().then((data) => {
this.metadata = data
publicationStore.setPublicationMetaData(data)
})
if (loading) { this.metaDataLoading = false }
})
.catch((err) => {
console.error(err)
if (loading) { this.metaDataLoading = false }
fetch(`/index.php/apps/opencatalogi/api/metadata?source=${metaDataUrl}`, {
method: 'GET',
})
.then((response) => {
response.json().then((data) => {
this.metadata = data.results[0]
publicationStore.setPublicationMetaData(data.results[0])
})
}
if (incomingUrl.host !== window.location.host) {
fetch(incomingUrl, {
method: 'GET',
if (loading) { this.metaDataLoading = false }
})
.catch((err) => {
console.error(err)
if (loading) { this.metaDataLoading = false }
})
.then((response) => {
response.json().then((data) => {
this.metadata = data
publicationStore.setPublicationMetaData(data)
})
if (loading) { this.metaDataLoading = false }
})
.catch((err) => {
console.error(err)
if (loading) { this.metaDataLoading = false }
})
}
},
getTime() {
Expand Down

0 comments on commit 039d266

Please sign in to comment.