164
164
</div >
165
165
<div class =" row" >
166
166
<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 >
171
168
</div >
172
169
</div >
173
170
</div >
180
177
181
178
<script >
182
179
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'
185
181
import { createShareableLink } from ' @/utils/query'
186
182
import { nextTick } from ' vue'
187
183
import currentDatasetMixin from ' @/mixins/current-dataset'
@@ -264,53 +260,49 @@ export default {
264
260
}
265
261
},
266
262
263
+ yasgui: null ,
264
+
267
265
created () {
268
- this .yasqe = null
269
- this .yasr = null
270
266
this .$nextTick (() => {
271
- setTimeout (() => {
272
- const vm = this
267
+ const yasguiElement = document . getElementById ( ' yasgui ' )
268
+ yasguiElement . innerHTML = ' '
273
269
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
276
272
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
+ },
292
283
// 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
310
291
}
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
314
306
})
315
307
},
316
308
@@ -331,18 +323,18 @@ export default {
331
323
this .currentDatasetUrl = val
332
324
},
333
325
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) )
336
328
}
337
329
},
338
330
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
341
333
}
342
334
},
343
335
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
346
338
}
347
339
}
348
340
},
@@ -354,7 +346,7 @@ export default {
354
346
// trigger a popup/alert by modifying the query passed, looks like YASQE does
355
347
// the query cleaning before displaying it.
356
348
// See: https://github.com/payloadbox/xss-payload-list
357
- this .yasqe .setValue (query)
349
+ this .$options . yasgui .setValue (query)
358
350
this .syncYasqePrefixes ()
359
351
},
360
352
getPrefixBadgeVariant (prefix ) {
@@ -364,7 +356,7 @@ export default {
364
356
return ' light'
365
357
},
366
358
syncYasqePrefixes () {
367
- const prefixes = this .yasqe .getPrefixesFromQuery ()
359
+ const prefixes = this .$options . yasgui .getPrefixesFromQuery ()
368
360
this .currentQueryPrefixes = []
369
361
for (const uri of Object .values (prefixes)) {
370
362
this .currentQueryPrefixes .push (uri)
@@ -375,10 +367,10 @@ export default {
375
367
[prefix .text ]: prefix .uri
376
368
}
377
369
if (this .currentQueryPrefixes .includes (prefix .uri )) {
378
- this .yasqe .removePrefixes (newPrefix)
370
+ this .$options . yasgui .removePrefixes (newPrefix)
379
371
this .currentQueryPrefixes .splice (this .currentQueryPrefixes .indexOf (prefix .uri ), 1 )
380
372
} else {
381
- this .yasqe .addPrefixes (newPrefix)
373
+ this .$options . yasgui .addPrefixes (newPrefix)
382
374
this .currentQueryPrefixes .push (prefix .uri )
383
375
}
384
376
}
@@ -387,31 +379,5 @@ export default {
387
379
</script >
388
380
389
381
<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' ;
417
383
</style >
0 commit comments