Skip to content

Commit ef669b0

Browse files
committed
Use latest YASGUI directly
1 parent dd6bf93 commit ef669b0

File tree

3 files changed

+147
-88
lines changed

3 files changed

+147
-88
lines changed

jena-fuseki2/jena-fuseki-ui/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"@fortawesome/free-solid-svg-icons": "^6.2.0",
2323
"@fortawesome/vue-fontawesome": "^3.0.1",
2424
"@popperjs/core": "^2.11.6",
25-
"@triply/yasqe": "^4.2.27",
26-
"@triply/yasr": "^4.2.27",
25+
"@triply/yasgui": "^4.2.28",
2726
"@vue/compat": "^3.2.39",
2827
"axios": "^0.27.2",
2928
"bootstrap": "^5.2.1",

jena-fuseki2/jena-fuseki-ui/src/views/dataset/Query.vue

Lines changed: 50 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@
164164
</div>
165165
<div class="row">
166166
<div class="col-sm-12">
167-
<div id="yasqe"></div>
168-
</div>
169-
<div class="col-sm-12">
170-
<div id="yasr"></div>
167+
<div id="yasgui"></div>
171168
</div>
172169
</div>
173170
</div>
@@ -180,8 +177,7 @@
180177

181178
<script>
182179
import Menu from '@/components/dataset/Menu.vue'
183-
import Yasqe from '@triply/yasqe'
184-
import Yasr from '@triply/yasr'
180+
import Yasgui from '@triply/yasgui'
185181
import { createShareableLink } from '@/utils/query'
186182
import { nextTick } from 'vue'
187183
import currentDatasetMixin from '@/mixins/current-dataset'
@@ -264,53 +260,49 @@ export default {
264260
}
265261
},
266262
263+
yasgui: null,
264+
267265
created () {
268-
this.yasqe = null
269-
this.yasr = null
270266
this.$nextTick(() => {
271-
setTimeout(() => {
272-
const vm = this
267+
const yasguiElement = document.getElementById('yasgui')
268+
yasguiElement.innerHTML = ''
273269
274-
document.getElementById('yasr').innerHTML = ''
275-
document.getElementById('yasqe').innerHTML = ''
270+
// Save current hash: https://github.com/TriplyDB/Yasgui/issues/167#issuecomment-1437158547
271+
const hash = location.hash
276272
277-
// results area
278-
vm.yasr = new Yasr(
279-
document.getElementById('yasr'),
280-
{
281-
// we do not want to save the results, otherwise we will have query results showing in different
282-
// dataset views
283-
persistenceId: null
284-
}
285-
)
286-
// Curried function to create shareable links. YASQE expects a function
287-
// that accepts only an instance of YASQE.
288-
const curriedCreateShareableLink = yasqe => {
289-
return createShareableLink(yasqe.getValue(), vm.$route.path)
290-
}
291-
// query editor
273+
// Curried function to create shareable links. YASQE expects a function
274+
// that accepts only an instance of YASQE.
275+
const curriedCreateShareableLink = yasqe => {
276+
return createShareableLink(yasqe.getValue(), this.$route.path)
277+
}
278+
279+
this.$options.yasgui = new Yasgui(yasguiElement, {
280+
yasr: {
281+
persistenceId: null,
282+
},
292283
// NOTE: the full screen functionality was removed from YASQE: https://github.com/Triply-Dev/YASGUI.YASQE-deprecated/issues/139#issuecomment-573656137
293-
vm.yasqe = new Yasqe(
294-
document.getElementById('yasqe'),
295-
{
296-
showQueryButton: true,
297-
resizeable: true,
298-
requestConfig: {
299-
endpoint: this.$fusekiService.getFusekiUrl(this.currentDatasetUrl)
300-
},
301-
createShareableLink: curriedCreateShareableLink
302-
}
303-
)
304-
vm.yasqe.on('queryResponse', (yasqe, response, duration) => {
305-
vm.yasqe.saveQuery()
306-
vm.yasr.setResponse(response, duration)
307-
})
308-
if (this.$route.query.query !== undefined) {
309-
vm.setQuery(this.$route.query.query)
284+
yasqe: {
285+
showQueryButton: true,
286+
resizeable: true,
287+
requestConfig: {
288+
endpoint: this.$fusekiService.getFusekiUrl(this.currentDatasetUrl)
289+
},
290+
createShareableLink: curriedCreateShareableLink
310291
}
311-
this.syncYasqePrefixes()
312-
this.loading = false
313-
}, 300)
292+
})
293+
// Restore hash
294+
location.hash = hash
295+
296+
// this.$options.yasgui.on('queryResponse', (yasqe, response, duration) => {
297+
// this.$options.yasgui.saveQuery()
298+
// this.$options.yasgui.setResponse(response, duration)
299+
// })
300+
// if (this.$route.query.query !== undefined) {
301+
// this.setQuery(this.$route.query.query)
302+
// }
303+
// this.syncYasqePrefixes()
304+
305+
this.loading = false
314306
})
315307
},
316308
@@ -331,18 +323,18 @@ export default {
331323
this.currentDatasetUrl = val
332324
},
333325
currentDatasetUrl: function (val, oldVal) {
334-
if (this.yasqe) {
335-
this.yasqe.options.requestConfig.endpoint = this.$fusekiService.getFusekiUrl(val)
326+
if (this.$options.yasgui) {
327+
this.$options.yasgui.setEndpoint(this.$fusekiService.getFusekiUrl(val))
336328
}
337329
},
338330
contentTypeSelect: function (val, oldVal) {
339-
if (this.yasqe) {
340-
this.yasqe.options.requestConfig.acceptHeaderSelect = this.contentTypeSelect
331+
if (this.$options.yasgui) {
332+
this.$options.yasgui.options.requestConfig.acceptHeaderSelect = this.contentTypeSelect
341333
}
342334
},
343335
contentTypeGraph: function (val, oldVal) {
344-
if (this.yasqe) {
345-
this.yasqe.options.requestConfig.acceptHeaderGraph = this.contentTypeGraph
336+
if (this.$options.yasgui) {
337+
this.$options.yasgui.options.requestConfig.acceptHeaderGraph = this.contentTypeGraph
346338
}
347339
}
348340
},
@@ -354,7 +346,7 @@ export default {
354346
// trigger a popup/alert by modifying the query passed, looks like YASQE does
355347
// the query cleaning before displaying it.
356348
// See: https://github.com/payloadbox/xss-payload-list
357-
this.yasqe.setValue(query)
349+
this.$options.yasgui.setValue(query)
358350
this.syncYasqePrefixes()
359351
},
360352
getPrefixBadgeVariant (prefix) {
@@ -364,7 +356,7 @@ export default {
364356
return 'light'
365357
},
366358
syncYasqePrefixes () {
367-
const prefixes = this.yasqe.getPrefixesFromQuery()
359+
const prefixes = this.$options.yasgui.getPrefixesFromQuery()
368360
this.currentQueryPrefixes = []
369361
for (const uri of Object.values(prefixes)) {
370362
this.currentQueryPrefixes.push(uri)
@@ -375,10 +367,10 @@ export default {
375367
[prefix.text]: prefix.uri
376368
}
377369
if (this.currentQueryPrefixes.includes(prefix.uri)) {
378-
this.yasqe.removePrefixes(newPrefix)
370+
this.$options.yasgui.removePrefixes(newPrefix)
379371
this.currentQueryPrefixes.splice(this.currentQueryPrefixes.indexOf(prefix.uri), 1)
380372
} else {
381-
this.yasqe.addPrefixes(newPrefix)
373+
this.$options.yasgui.addPrefixes(newPrefix)
382374
this.currentQueryPrefixes.push(prefix.uri)
383375
}
384376
}
@@ -387,31 +379,5 @@ export default {
387379
</script>
388380

389381
<style lang="scss">
390-
@import '~@triply/yasqe/build/yasqe.min.css';
391-
@import '~@triply/yasr/build/yasr.min.css';
392-
393-
// N.B: these were copied from an old release of YASR due to this
394-
// change: https://github.com/TriplyDB/Yasgui/commit/19521998f035e718d3f1d5cfa6073ce2e34242e7
395-
// for more: https://github.com/apache/jena/pull/1153
396-
.yasr table.dataTable {
397-
border: 1px solid rgb(217, 217, 217);
398-
border-image-source: initial;
399-
border-image-slice: initial;
400-
border-image-repeat: initial;
401-
tbody {
402-
tr {
403-
td {
404-
border-top: 1px solid #ddd;
405-
}
406-
&:last-of-type {
407-
td {
408-
border-bottom: 1px solid #ddd;
409-
}
410-
}
411-
&:nth-child(even) {
412-
background-color: #f9f9f9;
413-
}
414-
}
415-
}
416-
}
382+
@import '@triply/yasgui/build/yasgui.min.css';
417383
</style>

0 commit comments

Comments
 (0)