Skip to content

Commit

Permalink
Merge pull request #348 from lblod/feature/regulatory-statements-file…
Browse files Browse the repository at this point in the history
…-service

Use file service from regulatory-statements application in order to fetch template
  • Loading branch information
elpoelma authored Oct 20, 2022
2 parents b8b1bf3 + 8b9db4d commit 89f76ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
15 changes: 6 additions & 9 deletions app/services/regulatory-attachments-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ export default class RegulatoryAttachmentsFetcher extends Service {
PREFIX schema: <http://schema.org/>
select distinct * where {
?publishedContainer a ext:PublishedRegulatoryAttachmentContainer;
mu:uuid ?uuid;
ext:currentVersion ?container.
?container dct:title ?title.
?reglement ext:publishedVersion ?publishedContainer.
ext:currentVersion ?publishedAttachment.
?publishedAttachment dct:title ?title.
?publishedAttachment ext:content/mu:uuid ?fileId.
OPTIONAL {
?reglement schema:validThrough ?validThrough.
?publishedContainer schema:validThrough ?validThrough.
}
FILTER( ! BOUND(?validThrough) || ?validThrough > NOW())
}
Expand All @@ -56,14 +55,12 @@ export default class RegulatoryAttachmentsFetcher extends Service {
const json = yield response.json();
const bindings = json.results.bindings;
const templates = bindings.map((binding) => ({
container: binding.container.value,
title: binding.title.value,
reload: async (template) => {
const response = await fetch(
`${config.regulatoryStatementPreviewEndpoint}/${binding.uuid.value}`
`${config.regulatoryStatementFileEndpoint}/${binding.fileId.value}/download`
);
const json = await response.json();
template.body = json.content;
template.body = await response.text();
},
}));
return templates;
Expand Down
9 changes: 3 additions & 6 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ module.exports = function (environment) {
rootURL: '/',
locationType: 'auto',
regulatoryStatementEndpoint: '{{REGULATORY_STATEMENT_ENDPOINT}}',
regulatoryStatementPreviewEndpoint:
'{{REGULATORY_STATEMENT_PREVIEW_ENDPOINT}}',
regulatoryStatementFileEndpoint: '{{REGULATORY_STATEMENT_FILE_ENDPOINT}}',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
Expand Down Expand Up @@ -97,10 +96,8 @@ module.exports = function (environment) {
'https://dev.roadsigns.lblod.info/sparql';
ENV.templateVariablePlugin.endpoint =
'https://dev.roadsigns.lblod.info/sparql';
ENV.regulatoryStatementEndpoint =
'https://dev.reglementairebijlagen.lblod.info/sparql';
ENV.regulatoryStatementPreviewEndpoint =
'https://dev.reglementairebijlagen.lblod.info/preview/regulatory-attachment-container';
ENV.regulatoryStatementEndpoint = 'http://localhost/sparql';
ENV.regulatoryStatementFileEndpoint = 'http://localhost/files';
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
Expand Down

0 comments on commit 89f76ee

Please sign in to comment.