diff --git a/controller/src/index-file.ts b/controller/src/index-file.ts index cebc508..78bc395 100644 --- a/controller/src/index-file.ts +++ b/controller/src/index-file.ts @@ -6,7 +6,14 @@ import { saveFileInContainer, } from "@inrupt/solid-client"; import { Session } from "@inrupt/solid-client-authn-browser"; -import { Index, IndexItem, Permission, url, UserTypeObject } from "./types"; +import { + Index, + IndexItem, + Permission, + Type, + url, + UserTypeObject, +} from "./types"; import { setAgentAccess, setPublicAccess, @@ -102,7 +109,7 @@ export async function editPermissions( const itemIndex = index.items.findIndex(({ id }) => id === itemId); if (itemIndex === -1) { - throw new Error("Element not found"); + throw new Error("Item is not found, is it present in the index file?"); } const item = index.items[itemIndex]; @@ -130,6 +137,16 @@ export async function editPermissions( return index; } +export function getItemId(index: Index, resource: url, user: url) { + return index.items.find( + (indexItem) => + indexItem.resources.includes(resource) && + indexItem.userType && + indexItem.userType.type === Type.WebID && + indexItem.userType.url === user + )?.id; +} + async function updateACL( session: Session, resources: url[], diff --git a/controller/src/pod.ts b/controller/src/pod.ts index d301ffa..86e39e0 100644 --- a/controller/src/pod.ts +++ b/controller/src/pod.ts @@ -46,11 +46,14 @@ async function listThings( ): Promise { const dataset = await getSolidDataset(url, { fetch: session.fetch }); return Promise.all( - getThingAll(dataset).map(async (t) => ({ - url: t.url, - properties: getPropertyAll(t), - accessModes: await getAccessModes(session, t.url), - })) + getThingAll(dataset) + // For some reason the appointments container is utterly borked permissions-wise + .filter((t) => !t.url.includes("appointments")) + .map(async (t) => ({ + url: t.url, + properties: getPropertyAll(t), + accessModes: await getAccessModes(session, t.url), + })) ); } @@ -80,8 +83,8 @@ async function getAccessModes( function accessModesToPermissions( record: Record ): Record { - const result: { - [agent: string]: Permission[] + const result: { + [agent: string]: Permission[]; } = {}; // List -> Set -> List is done to filter out possible duplicate Permission.Control's const mapToPermission = (accessModes: [string, boolean][]) => [ @@ -210,5 +213,6 @@ export async function getAppointments( }; }; - return fetchResources(session, `${url}/appointments/`, mapAppointment); + // As the appointments folder is borked, cooltoinments is used as a back-up. + return fetchResources(session, `${url}/cooltoinments/`, mapAppointment); } diff --git a/loama/src/components/explorer/ResourceExplorer.vue b/loama/src/components/explorer/ResourceExplorer.vue index 7bf80ca..4965b9e 100644 --- a/loama/src/components/explorer/ResourceExplorer.vue +++ b/loama/src/components/explorer/ResourceExplorer.vue @@ -17,7 +17,7 @@ + :url="selectedEntry.url" :agents="selectedEntry.accessModes" @close="selectedEntry = null" /> diff --git a/loama/src/components/explorer/SelectedEntry.vue b/loama/src/components/explorer/SelectedEntry.vue index df86405..e86ceee 100644 --- a/loama/src/components/explorer/SelectedEntry.vue +++ b/loama/src/components/explorer/SelectedEntry.vue @@ -19,6 +19,9 @@ @update:checked="updatePermissions(option.name, $event)"> {{ option.label }} + + {{ updateStatus }} + @@ -27,24 +30,28 @@ diff --git a/loama/src/utils/types.ts b/loama/src/utils/types.ts index 10af962..d34258c 100644 --- a/loama/src/utils/types.ts +++ b/loama/src/utils/types.ts @@ -1,3 +1,5 @@ import type { FormattedThing } from 'loama-controller/dist/types' export type Entry = FormattedThing & { name: string; isContainer: boolean } + +export type Result = { ok: true; value: string } | { ok: false; error: unknown }