163163 >Please connect your pod if you wish to look at your Query Cache...
164164 <br />(simply click the "select pod" button above.)</span
165165 >
166+ <span class =" no-pod" v-if =" currentPod !== '' && !queriesCacheExists"
167+ >No query cache found in your pod. To create a query cache, simply
168+ execute a query with the <b >"Save Query?"</b > checkbox checked.</span
169+ >
166170 <ul >
167- <div class =" cached-container" v-if =" currentPod != ''" >
171+ <div
172+ class =" cached-container"
173+ v-if =" currentPod != '' && queriesCacheExists"
174+ >
168175 <span class =" cached-title" >Cached Queries</span >
169176
170177 <!-- Iterates over list queries in Query Cache -->
544551 </div >
545552 </div >
546553
547- <!-- Display Result Count -->
548-
549- <div class =" table-container" v-show =" !loading && resultsForYasr != null" >
554+ <!-- Display results of query -->
555+ <div
556+ class =" table-container"
557+ v-show ="
558+ !loading &&
559+ resultsForYasr != null &&
560+ resultsForYasr.results.bindings.length > 0
561+ "
562+ >
550563 <div id =" yasr-container" ></div >
551564 </div >
565+ <!-- Display message if there were no results -->
566+ <div
567+ class =" null-results"
568+ v-show ="
569+ !loading &&
570+ resultsForYasr != null &&
571+ resultsForYasr.results.bindings.length === 0
572+ "
573+ >
574+ <span >This query produced no results 🙃</span >
575+ </div >
576+
577+ <!-- Display error if there was an error -->
578+ <div class =" null-results" v-show =" !loading && queryError != null" >
579+ <span
580+ >There was a(n)
581+ <b
582+ ><i >{{ queryError }}</i ></b
583+ >
584+ error when executing this query <br />(open the browser console to see
585+ more details.)</span
586+ >
587+ </div >
552588 </div >
553589 </div >
554590 <!-- Guide for file uploading -->
@@ -562,7 +598,7 @@ import Yasqe from "@triply/yasqe";
562598import " @triply/yasqe/build/yasqe.min.css" ;
563599import Yasr from " @triply/yasr" ;
564600import " @triply/yasr/build/yasr.min.css" ;
565- import { isLoggedin } from " ./login" ;
601+ import { isLoggedin , currentWebId } from " ./login" ;
566602import {
567603 ensureCacheContainer ,
568604 createQueriesTTL ,
@@ -609,9 +645,11 @@ export default {
609645 // TODO: Integrate demonstrators + example queries
610646 data() {
611647 return {
648+ webid: " " as string ,
612649 yasqe: shallowRef <Yasqe | null >(null ),
613650 yasr: shallowRef <Yasr | null >(null ),
614651 resultsForYasr: null as QueryResultJson | null ,
652+ queryError: null as Error | null ,
615653 successfulLogin: false as boolean ,
616654 currentPod: " " as string ,
617655 currentView: " newQuery" as " newQuery" | " previousQueries" ,
@@ -801,11 +839,17 @@ export default {
801839 // make sources into a ComunicaSources[]
802840 const cleanedSources = cleanSourcesUrls (this .currentQuery .sources );
803841 this .checkSolidSources (cleanedSources );
804-
842+
805843 try {
844+ // reset query error
845+ this .queryError = null ;
846+
806847 // if Save Query box is selected (pod must be connected)
807848 if (this .saveQuery ) {
808- this .cachePath = await ensureCacheContainer (this .currentPod );
849+ this .cachePath = await ensureCacheContainer (
850+ this .currentPod ,
851+ this .webid
852+ );
809853 this .currentQuery .output = await executeQueryWithPodConnected (
810854 this .currentQuery .query ,
811855 cleanedSources ,
@@ -841,17 +885,6 @@ export default {
841885 );
842886 }
843887
844- // if the result of the query was null
845- if (
846- ! this .currentQuery .output .resultsOutput ||
847- ! this .currentQuery .output .resultsOutput .results
848- ) {
849- this .currentQuery .output .resultsOutput = {
850- head: { vars: [] },
851- results: { bindings: [] },
852- };
853- }
854-
855888 // pass found results to YASR (with save query selected)
856889 this .resultsForYasr = this .currentQuery .output .resultsOutput ;
857890
@@ -878,10 +911,13 @@ export default {
878911 );
879912 }
880913 } else {
881- // If the Save Query button was not selected
914+ // If the Save Query button was not selected (pod is connected)
882915 if (this .currentPod !== " " ) {
883916 // if there is a pod connected, try to use cache
884- this .cachePath = await ensureCacheContainer (this .currentPod );
917+ this .cachePath = await ensureCacheContainer (
918+ this .currentPod ,
919+ this .webid
920+ );
885921 this .currentQuery .output = await executeQueryWithPodConnected (
886922 this .currentQuery .query ,
887923 cleanedSources ,
@@ -905,8 +941,8 @@ export default {
905941 }
906942 }
907943 } else {
908- // if there is no pod connected, use the default query execution
909- // if there are NOT solid sources use the Worker
944+ // if there is NO pod connected, use the default query execution
945+ // if there are NOT solid sources --> use the Worker
910946 if (! this .containsSolidSources ) {
911947 this .currentQuery .output = await this .executeQuery (
912948 this .currentQuery .query ,
@@ -932,7 +968,12 @@ export default {
932968 this .currentQuery .output .provenanceOutput .id .value
933969 );
934970 }
935-
971+ }
972+ // if there was an error report it here
973+ if (this .currentQuery .output instanceof Error ) {
974+ this .queryError = this .currentQuery .output .message ;
975+ } else {
976+ // if the query was empty assign it empty bindings
936977 if (
937978 ! this .currentQuery .output .resultsOutput ||
938979 ! this .currentQuery .output .resultsOutput .results
@@ -942,9 +983,10 @@ export default {
942983 results: { bindings: [] },
943984 };
944985 }
945- // pass found results to YASR (if save query was not selected)
946- this .resultsForYasr = this .currentQuery .output .resultsOutput ;
947986 }
987+ // pass found results to YASR (if save query was not selected)
988+ this .resultsForYasr = this .currentQuery .output .resultsOutput ;
989+
948990 } catch (err ) {
949991 if (this .cancelRequested ) {
950992 console .log (" Query canceled by user." );
@@ -965,14 +1007,14 @@ export default {
9651007 async executeQuery(
9661008 query : string ,
9671009 providedSources : ComunicaSources []
968- ): Promise <CacheOutput | null > {
1010+ ): Promise <CacheOutput | null | Error > {
9691011 this .cancelRequested = false ;
9701012
9711013 this .worker = new Worker (new URL (" ./queryWorker.js" , import .meta .url ), {
9721014 type: " module" ,
9731015 });
9741016
975- return new Promise <CacheOutput | null >((resolve , reject ) => {
1017+ return new Promise <CacheOutput | null | Error >((resolve , reject ) => {
9761018 this .worker ! .onmessage = (e : MessageEvent ) => {
9771019 const { data } = e as { data: any };
9781020 switch (data ?.type ) {
@@ -984,9 +1026,8 @@ export default {
9841026 });
9851027 break ;
9861028 case " error" :
987- console .log (" Worker error:" , data .error );
9881029 this .cleanupWorker ();
989- resolve (null ); // or reject(data.error) if you prefer
1030+ resolve (new Error ( data . error . message ) ); // or reject(data.error) if you prefer
9901031 break ;
9911032 case " cancelled" :
9921033 this .cleanupWorker ();
@@ -999,9 +1040,8 @@ export default {
9991040 };
10001041 // for an error or cancellation
10011042 this .worker ! .onerror = (err ) => {
1002- console .log (" Worker error:" , err );
10031043 this .cancelQuery ();
1004- reject (err );
1044+ resolve (err as any );
10051045 };
10061046 // starts a run
10071047 this .worker .postMessage ({
@@ -1253,6 +1293,7 @@ export default {
12531293
12541294 setTimeout (() => {
12551295 this .loginCheck ();
1296+ this .webid = currentWebId ();
12561297 }, 500 );
12571298 setTimeout (() => {
12581299 this .handleDelay ();
@@ -1843,6 +1884,18 @@ ul {
18431884 }
18441885}
18451886
1887+ /* No results */
1888+ .null-results {
1889+ font-family : " Oxanium" , monospace ;
1890+ color : var (--text-secondary );
1891+ font-size : 14pt ;
1892+ padding : 0.25rem ;
1893+ text-align : center ;
1894+ }
1895+ .null-results b {
1896+ color : var (--error );
1897+ }
1898+
18461899/* Results */
18471900.results-container .results-text {
18481901 font-size : 18pt ;
@@ -1968,7 +2021,7 @@ ul {
19682021 min-width : 100% ;
19692022}
19702023#yasr-container :deep(thead tr th ) {
1971- background-color : var (--primary-600 );
2024+ background-color : var (--primary );
19722025 color : var (--main-white );
19732026 font-weight : bold ;
19742027 font-size : 13pt ;
0 commit comments