Skip to content

Commit fb57f4c

Browse files
committed
fixed data upload, data manager, and display query errors
1 parent 541a9cb commit fb57f4c

9 files changed

Lines changed: 235 additions & 102 deletions

File tree

src/assets/theme.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@
5353
--accent-700: hsl(195 85% 36%); /* #107eab */
5454

5555
--success: hsl(160 72% 42%); /* #1fba74 */
56-
--warning: hsl(35 92% 50%); /* #f7a611 */
56+
--warning: #ffd904; /* #f7a611 */
5757
--danger: #ff7f7fbb;
58+
--error: #ff1e00c2;
5859
--info: hsl(195 85% 48%); /* #1ba9e0 */
5960

6061
--focus-ring: 2px solid hsl(262 92% 65% / 0.7); /* #8a42f4 */
@@ -100,8 +101,9 @@
100101
--accent-700: hsl(195 85% 60%); /* #4dc0ec */
101102

102103
--success: hsl(160 72% 46%); /* #26c980 */
103-
--warning: hsl(35 92% 58%); /* #f8ad29 */
104+
--warning: #ffd700;
104105
--danger: #ff7f7fbb;
106+
--error: #ff1e00;
105107
--info: hsl(195 85% 54%); /* #34b8e6 */
106108

107109
--focus-ring: 2px solid hsl(262 92% 65% / 0.8); /* #8a42f4 */

src/components/DataQuery.vue

Lines changed: 85 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,15 @@
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 -->
@@ -544,11 +551,40 @@
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";
562598
import "@triply/yasqe/build/yasqe.min.css";
563599
import Yasr from "@triply/yasr";
564600
import "@triply/yasr/build/yasr.min.css";
565-
import { isLoggedin } from "./login";
601+
import { isLoggedin, currentWebId } from "./login";
566602
import {
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;

src/components/Guides/DataQueryGuide.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<script lang="ts">
3838
export default {
3939
data: () => ({
40-
guideDropdownOpen: true as boolean,
40+
guideDropdownOpen: false as boolean,
4141
}),
4242
methods: {
4343
toggleGuideDropdown() {

0 commit comments

Comments
 (0)