@@ -245,11 +245,13 @@ import Graph from "graphology";
245245import forceAtlas2 from " graphology-layout-forceatlas2" ;
246246import FA2Layout from " graphology-layout-forceatlas2/worker" ;
247247import Sigma from " sigma" ;
248- import { NodeImageProgram } from " @sigma/node-image" ;
248+ // import { NodeImageProgram } from "@sigma/node-image";
249249import {watch } from " vue" ;
250250
251251import relationColors from " @/data/RelationsColors.json"
252252import networkGraph from " @/data/networkGraph.json"
253+ import axios from " axios" ;
254+ import {mapStores , storeToRefs } from " pinia" ;
253255/*
254256import Loaders from "@/components/Navigation/Loaders";
255257import GraphClient from '@/lib/GraphClient/GraphClient.js'
@@ -310,15 +312,19 @@ export default {
310312 networkGraph: networkGraph
311313 }
312314 },
313- setup () {
315+ async setup () {
314316 const store = useAdvancedSearchStore ();
315- watch (() => store .getAdvancedSearchResponse , () => {
316- // TODO: Get graph data and (re-)plot graph.
317- console .log (" Got response..." )
317+ // This watch is here because I can't find any way to get it to work in `watch:` below.
318+ watch (() => store .getAdvancedSearchResponse , async () => {
319+ console .log (" We need to be able to call a method here but can't." );
320+ // await this.getData(store.getAdvancedSearchResponse.map((x) => x.id).join(','));
318321 })
322+ // apparently one is supposed to use storeToRefs on the store, export the ref, and
323+ // watch that below. But, whatever formulation I try, it is never reactive.
319324 return { store };
320325 },
321326 computed: {
327+ // ...mapStores(useAdvancedSearchStore),
322328 noData () {
323329 if (this .store .getNoData ) {
324330 return " No data available" ;
@@ -331,6 +337,23 @@ export default {
331337 return this .fa2Layout .isRunning ();
332338 },
333339 },
340+ /*
341+ watch: {
342+ useAdvancedSearchStore: {
343+ immediate: true,
344+ deep: true,
345+ handler(newValue, oldValue) {
346+ console.log("Javascript sucks!");
347+ this.$nextTick(() => {
348+ console.log("Watched!");
349+ console.log("OLD: " + JSON.stringify(oldValue));
350+ console.log("NEW: " + JSON.stringify(newValue));
351+ })
352+ }
353+ }
354+ },
355+ */
356+ /*
334357 watch: {
335358 active: {
336359 async handler() {
@@ -363,57 +386,50 @@ export default {
363386 deep: true,
364387 }
365388 },
366- /*
367- // This stuff will have to be triggered when data changes instead.
389+ */
368390 async mounted () {
391+ // window.vm = this;
392+ /*
369393 let _module = this;
370394 this.$nextTick(async function () {
371- await this.getData();
372- if (_module.error) {
373- return;
374- }
375395 container = document.getElementById("sigma-container");
376396 if (_module.fa2Layout && _module.fa2Layout.isRunning()) {
377397 _module.fa2Layout.kill();
378398 }
379399 _module.plotGraph();
380400 })
401+ */
381402 },
382- */
383403 methods: {
384- async getData (){
404+ async getData (ids ){
385405 this .loading = true ;
386406 this .legend .types = {
387407 circle: false ,
388408 square: false ,
389409 triangle: false ,
390410 diamond: false
391411 }
412+ try {
413+ const url =
414+ import .meta.env.VITE_API_ENDPOINT +
415+ " /search_utils/link_fairassist/" + ids;
416+ const data = await axios .get (url);
417+ this .graphData = data .data ;
418+ } catch (error) {
419+ if (error) {
420+ this .noData = true ;
421+ }
422+ }
423+ this .loading = false ;
392424 /* A maxPathLength of 1-3 may be specified (API's default is 2).
393425 Higher values may make the resulting graph rather large... */
394- graphQuery .queryParam = {id: parseInt (this .$route .params .id )};
395- const response = await graphClient .executeQuery (graphQuery);
426+ // Instead, get /search_utils/link_fairassist/ids
396427 // Check if response is array format
428+ /*
397429 if (Array.isArray(response) && response[0].message === 'record not found') {
398430 this.error = true;
399431 }
400- // response is in object format
401- else if (response .fairsharingGraph === undefined ||
402- response .fairsharingGraph .data === undefined ||
403- response .fairsharingGraph .data .length === 0 ||
404- Object .keys (response .fairsharingGraph .data ).length === 0 ) {
405- this .loading = false ;
406- this .noData = true ;
407- this .registry = " N/A" ;
408- this .type = " N/A" ;
409- this .initialized = true ;
410- }
411- else {
412- this .graphData = response .fairsharingGraph .data ;
413- this .loading = false ;
414- this .registry = this .graphData .registry ;
415- this .type = this .graphData .type ;
416- }
432+ */
417433 },
418434 async plotGraph (){
419435 let _module = this ;
@@ -441,9 +457,11 @@ export default {
441457 container,
442458 {
443459 allowInvalidContainer: true ,
460+ /*
444461 nodeProgramClasses: {
445- image: NodeImageProgram
462+ image: NodeImageProgram // Breaks the page now...
446463 }
464+ */
447465 });
448466 _module .fa2Layout .start ();
449467
0 commit comments