Skip to content

Commit 0e358fe

Browse files
committed
added global login variables (1/2 done implementing)
1 parent fb57f4c commit 0e358fe

11 files changed

Lines changed: 382 additions & 302 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"actor-query-process-remote-cache": "^0.1.0",
3030
"core-js": "^3.8.3",
3131
"fs": "^0.0.1-security",
32-
"pinia": "^2.2.6",
32+
"pinia": "^2.3.1",
3333
"query-sparql-remote-cache": "^0.0.8",
3434
"sparqljs": "^3.7.3",
3535
"vite": "^6.2.3",

src/components/DataQuery.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</div>
1616

1717
<div v-if="successfulLogin" class="pod-chooseContainer">
18-
<PodRegistration @pod-selected="handlePodSelected" />
18+
<PodRegistration />
1919
</div>
2020
</div>
2121
<div class="general-container">
@@ -623,13 +623,7 @@ import {
623623
fetchPublicAccess,
624624
} from "./getData";
625625
import {
626-
changeAclAgent,
627-
changeAclPublic,
628-
checkUrl,
629-
generateAcl,
630-
createInboxWithACL,
631-
updateSharedWithMe,
632-
updateSharedWithOthers,
626+
generateAcl
633627
} from "./privacyEdit";
634628
import PodLogin from "./PodLogin.vue";
635629
import PodRegistration from "./PodRegistration.vue";

src/components/EditPrivacy.vue

Lines changed: 87 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030
<!-- Choose Pod -->
3131
<div class="pod-chooseContainer">
32-
<PodRegistration @pod-selected="handlePodSelected" />
32+
<PodRegistration @pod-selected="handlePodSelected"/>
3333
</div>
3434

3535
<!-- the side nav -->
36-
<div class="body-container" v-if="currentPod !== ''">
36+
<div class="body-container" v-if="selectedPodUrl !== ''">
3737
<div>
3838
<ul class="side-nav fixed floating #28353e z-depth-0">
3939
<li>
@@ -86,7 +86,7 @@
8686
<!-- Browse existing path -->
8787
<li class="container-choose">
8888
<container-nav
89-
:currentPod="currentPod"
89+
:currentPod="selectedPodUrl"
9090
@path-selected="handleSelectedContainer"
9191
/>
9292
</li>
@@ -457,7 +457,7 @@
457457
<div class="shared-with" v-if="navValue === 1">
458458
<SharedWith
459459
:currentOperation="currentDisplay"
460-
:currentPod="currentPod"
460+
:currentPod="selectedPodUrl"
461461
:currentWebId="webId"
462462
/>
463463
</div>
@@ -466,7 +466,7 @@
466466
<div class="shared-with" v-if="navValue === 2">
467467
<SharedWith
468468
:currentOperation="currentDisplay"
469-
:currentPod="currentPod"
469+
:currentPod="selectedPodUrl"
470470
:currentWebId="webId"
471471
/>
472472
</div>
@@ -491,7 +491,6 @@ import {
491491
updateSharedWithMe,
492492
updateSharedWithOthers,
493493
} from "./privacyEdit";
494-
import { currentWebId } from "./login";
495494
import {
496495
fetchPermissionsData,
497496
fetchData,
@@ -503,6 +502,9 @@ import PodRegistration from "./PodRegistration.vue";
503502
import ContainerNav from "./ContainerNav.vue";
504503
import SharedWith from "./Styling/SharedWith.vue";
505504
import { ref } from "vue";
505+
import { useAuthStore } from "../stores/auth";
506+
507+
506508
interface Permissions {
507509
read: boolean;
508510
append: boolean;
@@ -522,82 +524,60 @@ export default {
522524
PrivacyEditingGuide,
523525
},
524526
name: "PrivacyComponent",
525-
data(): {
526-
currentPod: string;
527-
filters: string[];
528-
filterValues: boolean[];
529-
filterMenuOpen: boolean;
530-
showSharedIndex: number | null;
531-
showFormIndex: number | null;
532-
userUrl: string;
533-
userUrlInvalid: boolean;
534-
submissionDone: boolean;
535-
recordedOthers: boolean;
536-
permissions: Permissions;
537-
navValue: number;
538-
permissionsString: string;
539-
webId: string;
540-
dirContents: WorkingData | null;
541-
containerContents: WorkingData | null;
542-
hasAcl: any; // Replace with a more specific type if available
543-
cannotMakeAcl: boolean;
544-
accessType: string;
545-
currentLocation: string;
546-
currentUrl: string | null;
547-
urls: string[];
548-
containerUrls: string[];
549-
resourceUrls: string[];
550-
inContainer: WorkingData | null;
551-
newUrls: string[];
552-
aclUrl: string;
553-
postedMe: boolean;
554-
hasAccess: AccessData;
555-
publicAccess: { [permission: string]: boolean };
556-
uploadedSharingDoc: string;
557-
container: string[];
558-
currentDisplay: string;
559-
} {
527+
data() {
560528
return {
561-
currentPod: "",
562-
filters: ["containers", "resources"],
563-
filterValues: [true, true],
564-
filterMenuOpen: false,
565-
showSharedIndex: null,
566-
showFormIndex: null,
567-
userUrl: "",
568-
userUrlInvalid: false,
569-
submissionDone: false,
570-
recordedOthers: false,
529+
filters: ["containers", "resources"] as string[],
530+
filterValues: [true, true] as boolean[],
531+
filterMenuOpen: false as boolean,
532+
showSharedIndex: null as number | null,
533+
showFormIndex: null as number | null,
534+
userUrl: "" as string,
535+
userUrlInvalid: false as boolean,
536+
submissionDone: false as boolean,
537+
recordedOthers: false as boolean,
571538
permissions: {
572539
read: false,
573540
append: false,
574541
write: false,
575542
control: false,
576-
},
577-
navValue: 0,
578-
permissionsString: "",
579-
webId: "",
580-
dirContents: null,
581-
containerContents: null,
582-
hasAcl: null,
583-
cannotMakeAcl: false,
584-
accessType: "Agent",
585-
currentLocation: "",
586-
currentUrl: null,
587-
urls: [],
588-
containerUrls: [],
589-
resourceUrls: [],
590-
inContainer: null,
591-
newUrls: [],
592-
aclUrl: "",
593-
postedMe: false,
594-
hasAccess: {},
595-
publicAccess: {},
596-
uploadedSharingDoc: "",
597-
container: [],
598-
currentDisplay: "default",
543+
} as Permissions,
544+
navValue: 0 as number,
545+
permissionsString: "" as string,
546+
dirContents: null as WorkingData | null,
547+
containerContents: null as WorkingData | null,
548+
hasAcl: null as any, // Replace with a more specific type if available
549+
cannotMakeAcl: false as boolean,
550+
accessType: "Agent" as string,
551+
currentLocation: "" as string,
552+
currentUrl: null as string | null,
553+
urls: [] as string[],
554+
containerUrls: [] as string[],
555+
resourceUrls: [] as string[],
556+
inContainer: null as WorkingData | null,
557+
newUrls: [] as string[],
558+
aclUrl: "" as string,
559+
postedMe: false as boolean,
560+
hasAccess: {} as AccessData,
561+
publicAccess: {} as { [permission: string]: boolean },
562+
uploadedSharingDoc: "" as string,
563+
container: [] as string[],
564+
currentDisplay: "default" as string,
599565
};
600566
},
567+
computed: {
568+
authStore() {
569+
return useAuthStore(); // Access the store
570+
},
571+
loggedIn() {
572+
return this.authStore.loggedIn; // Access loggedIn state
573+
},
574+
webId() {
575+
return this.authStore.webId; // Access webId state
576+
},
577+
selectedPodUrl() {
578+
return this.authStore.selectedPodUrl; // Access selected Pod URL
579+
},
580+
},
601581
methods: {
602582
/*
603583
Checks if the input item url is a container
@@ -626,7 +606,7 @@ export default {
626606
return segments[segments.length - 1] + "/";
627607
});
628608
// for navigating up a directory path (not possible when in root directory)
629-
if (currentDir !== this.currentPod) {
609+
if (currentDir !== this.selectedPodUrl()) {
630610
newUrlLst.push("/..");
631611
}
632612
return newUrlLst.sort((a, b) => a.length - b.length);
@@ -723,7 +703,7 @@ export default {
723703
* Method for creating an inbox/ container in a Pod if it does not already exist
724704
*/
725705
createInbox() {
726-
createInboxWithACL(this.currentPod, this.webId);
706+
createInboxWithACL(this.selectedPodUrl(), this.webId());
727707
},
728708
729709
/**
@@ -753,22 +733,22 @@ export default {
753733
754734
// for Agent ACL changes
755735
if (this.accessType === "Agent") {
756-
this.userUrlInvalid = checkUrl(this.userUrl, this.webId);
736+
this.userUrlInvalid = checkUrl(this.userUrl, this.webId());
757737
if (!this.userUrlInvalid) {
758738
// add condition for different agents here ...
759739
// actual .acl changing
760740
await changeAclAgent(url, this.userUrl, this.permissions);
761741
// write changes to specified user's sharedWithMe.ttl file
762742
this.postedMe = await updateSharedWithMe(
763743
this.userUrl,
764-
this.webId,
744+
this.webId(),
765745
url,
766746
this.permissions
767747
);
768748
769749
// write changes to current user's sharedWithOthers.ttl file
770750
this.recordedOthers = await updateSharedWithOthers(
771-
this.currentPod,
751+
this.selectedPodUrl(),
772752
url,
773753
this.userUrl,
774754
this.permissions
@@ -782,7 +762,7 @@ export default {
782762
783763
// write changes to current user's sharedWithOthers.ttl file
784764
this.recordedOthers = await updateSharedWithOthers(
785-
this.currentPod,
765+
this.selectedPodUrl(),
786766
url,
787767
"http://xmlns.com/foaf/0.1/Agent",
788768
this.permissions
@@ -830,32 +810,24 @@ export default {
830810
this.containerUrls = this.urls.filter((url) => url.endsWith("/"));
831811
this.resourceUrls = this.urls.filter((url) => !url.endsWith("/"));
832812
if (
833-
this.currentLocation === this.currentPod &&
834-
!this.urls.includes(this.currentPod)
813+
this.currentLocation === this.selectedPodUrl() &&
814+
!this.urls.includes(this.selectedPodUrl())
835815
) {
836-
this.urls.push(this.currentPod);
837-
this.containerUrls.push(this.currentPod);
816+
this.urls.push(this.selectedPodUrl());
817+
this.containerUrls.push(this.selectedPodUrl());
838818
}
839819
this.urls = this.urls.sort((a, b) => a.length - b.length);
840820
this.container = this.urls.sort((a, b) => a.length - b.length);
841821
this.resourceUrls = this.urls.sort((a, b) => a.length - b.length);
842822
},
843823
844-
/**
845-
* Calls getPodURLs() from fileUpload.ts to obtain a list of pods from the logged-in user's webID.
846-
* Obtains 'pod' variable (URL path to user's Pod).
847-
*/
848-
async podURL() {
849-
this.webId = currentWebId();
850-
},
851-
852824
/**
853825
* Obtains the containers within the root directory of a user's pod,
854826
* puts the URLs for these containers into an array,
855827
* then sorts the array to reflect heirarchy
856828
*/
857829
async getGeneralData() {
858-
this.dirContents = await fetchData(this.currentPod);
830+
this.dirContents = await fetchData(this.selectedPodUrl());
859831
this.urls = getContainedResourceUrlAll(this.dirContents);
860832
this.separateUrls();
861833
},
@@ -900,23 +872,24 @@ export default {
900872
*/
901873
async makeNewAcl(path: string) {
902874
try {
903-
await generateAcl(path, this.webId);
875+
await generateAcl(path, this.webId());
904876
await this.getSpecificAclData(path);
905877
} catch (err) {
906878
console.error(err);
907879
this.cannotMakeAcl = true;
908880
}
909881
},
910-
/* Takes in the emitted value from PodRegistration.vue */
911-
handlePodSelected(selectedPod: string) {
912-
this.currentPod = selectedPod;
913-
this.currentLocation = this.currentPod;
914-
this.getGeneralData();
915-
this.createStuff();
882+
async initialLoad() {
883+
if (this.selectedPodUrl() != "") {
884+
this.currentLocation = this.selectedPodUrl();
885+
await this.getGeneralData();
886+
await this.createStuff();
887+
}
916888
},
889+
917890
/* creates files and directories if not already present */
918891
async createStuff() {
919-
await createInboxWithACL(this.currentPod, this.webId);
892+
await createInboxWithACL(this.selectedPodUrl(), this.webId());
920893
this.$forceUpdate(); // Forces a re-render of the component
921894
},
922895
/* Takes in the emitted value from ContainerNav.vue */
@@ -926,8 +899,15 @@ export default {
926899
},
927900
},
928901
mounted() {
929-
// Delays the execution of these functions on page reload (to avoid async-related errors)
930-
this.podURL();
902+
try {
903+
if (this.selectedPodUrl() != "") {
904+
this.currentLocation = this.selectedPodUrl();
905+
this.getGeneralData();
906+
this.createStuff();
907+
}
908+
} catch (error) {
909+
console.error("Error during component mount:", error);
910+
}
931911
},
932912
};
933913
</script>
@@ -1336,7 +1316,7 @@ form input[type="text"] {
13361316
padding: 3px;
13371317
margin-bottom: 5px;
13381318
border: 1px solid var(--text-secondary) !important;
1339-
border-radius: 4px;;
1319+
border-radius: 4px;
13401320
font-family: "Courier New", Courier, monospace;
13411321
font-size: large;
13421322
max-width: 100%;
@@ -1347,7 +1327,8 @@ form input::placeholder {
13471327
padding-left: 0.5rem;
13481328
color: var(--text-muted); /* Slight transparency */
13491329
}
1350-
.agent-button, .public-button {
1330+
.agent-button,
1331+
.public-button {
13511332
padding: 10px;
13521333
margin-top: 5px;
13531334
background-color: var(--border);
@@ -1360,7 +1341,7 @@ form input::placeholder {
13601341
font-family: "Oxanium", monospace;
13611342
font-weight: 600;
13621343
border-radius: 6px;
1363-
margin-top: 0.25rem;;
1344+
margin-top: 0.25rem;
13641345
padding: 0.75rem;
13651346
background-color: var(--primary);
13661347
color: var(--main-white);
@@ -1423,6 +1404,4 @@ label span {
14231404
#resetButton button:hover {
14241405
background-color: var(--hover);
14251406
}
1426-
1427-
14281407
</style>

0 commit comments

Comments
 (0)