diff --git a/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx b/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
index 1d972264..39f5b5c8 100644
--- a/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
+++ b/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
@@ -1,5 +1,5 @@
import React, {useState} from 'react';
-import {Button, FormControl, MenuItem, Select, Alert, SnackBar, Snackbar} from "@mui/material";
+import {Button, FormControl, MenuItem, Select, Alert, Snackbar} from "@mui/material";
import TextField from "@mui/material/TextField";
import useStyles from "./styles";
import PlaceEntity from "../../entities/PlaceEntity";
diff --git a/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx b/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
index 49e5aeee..288686ed 100644
--- a/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
+++ b/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
@@ -6,18 +6,17 @@ import {Typography} from "@mui/material";
import SettingsSideBar from "../SettingsSideBar/SettingsSideBar";
import ProfileSideBar from "../ProfileSideBar/ProfileSideBar";
import SocialSidebar from "../SocialSidebar/SocialSidebar";
-import { FOAF } from '@inrupt/lit-generated-vocab-common';
import {getFriends, getPlacesByWebId} from "../../solidapi/solidAdapter";
import CommentsSidebar from "../CommentsSidebar/CommentsSidebar";
const DetailsSidebar = (props) => {
const classes = useStyles();
- const [content, setContent] = useState("");
+ const [setContent] = useState("");
const {places, setPlaces, selectedPoint, setSelectedPoint, setSelectedButton, selectedButton,setSelectedPlaceMyPlaces,
deletePlace, setPlacesLength,userWebId, session, selectedFriendPlaces, setSelectedFriendPlaces, deleteFriend} = props;
const [selectedFriend, setSelectedFriend] = useState([]);
const [selectedPlaceComment, setSelectedPlaceComment] = useState([]);
- const [showDeleteButton, setShowDeleteButton] =useState(true);
+ const [showDeleteButton] =useState(true);
const selectedFriendUsername = selectedFriend.friendURL?.split("/")[2].split(".")[0]
useEffect(() => {
@@ -72,7 +71,11 @@ const DetailsSidebar = (props) => {
Explore your friends places.
@@ -60,12 +58,6 @@ const FriendCard = (props) => {
title={{friend.friendName}}
subheader={{part}}
/>
- {/**/}
- {/* */}
- {/* /!*{place.description}*!/*/}
- {/* */}
- {/* */}
- {/**/}
diff --git a/webapp/src/components/Map/Map.jsx b/webapp/src/components/Map/Map.jsx
index 13cf3267..e23862ca 100644
--- a/webapp/src/components/Map/Map.jsx
+++ b/webapp/src/components/Map/Map.jsx
@@ -121,15 +121,6 @@ const Map = (props) => {
{showAddPlaceMarker()}
- //{/*{places?.map((place) => (
-
-
- {place.name} | {place.category}
- {place.description}
-
-
- // ))}*/}
-
{showPlaces()}
diff --git a/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx b/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
index 8c30672a..65f1b6d3 100644
--- a/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
+++ b/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
@@ -1,11 +1,9 @@
import React from 'react';
-import {Typography} from "@mui/material";
import useStyles from "./styles";
import PlaceCard from "../PlaceCard/PlaceCard";
-import {Marker, Popup} from "react-leaflet";
-import List from '@mui/material/List';
+
const MyPlacesSidebar = (props) => {
- const {places, setPlaces,setSelectedPlaceMyPlaces, deletePlace, session, showDeleteButton, setSelectedPlaceComment,
+ const {setSelectedPlaceMyPlaces, deletePlace, session, showDeleteButton, setSelectedPlaceComment,
setSelectedButton} = props;
const classes = useStyles();
diff --git a/webapp/src/components/PlaceCard/PlaceCard.jsx b/webapp/src/components/PlaceCard/PlaceCard.jsx
index ad6cdcdd..e0400f10 100644
--- a/webapp/src/components/PlaceCard/PlaceCard.jsx
+++ b/webapp/src/components/PlaceCard/PlaceCard.jsx
@@ -4,8 +4,6 @@ import {
CardContent,
CardHeader,
IconButton,
- Menu,
- MenuItem,
Typography,
Chip,
Alert,
@@ -48,7 +46,7 @@ const PlaceCard = (props) => {
console.log("El id que buscará en el pod es: " + place.id) //correcto, asi lo tenemos guardado en los pods por ahora
//no se si los guiones que separan en el log, y en la web de los pods no aparecen, afectan
- removePlace(session,place.id)//TODO delete from the pods
+ removePlace(session,place.id)// delete from the pods
deletePlaceMarkByID(place._id); //deleting in the database
deletePlace(place.id); //deleting in the frontend
diff --git a/webapp/src/components/ProfileSideBar/ProfileSideBar.jsx b/webapp/src/components/ProfileSideBar/ProfileSideBar.jsx
index cce5f2c9..8fcbf2b3 100644
--- a/webapp/src/components/ProfileSideBar/ProfileSideBar.jsx
+++ b/webapp/src/components/ProfileSideBar/ProfileSideBar.jsx
@@ -7,12 +7,11 @@ import ListItem from '@mui/material/ListItem';
import Card from '@mui/material/Card';
import {Alert, Button, CardContent, Snackbar, Typography} from "@mui/material";
import {
- useSession,
CombinedDataProvider,
Image,
Text,
} from "@inrupt/solid-ui-react";
-import { FOAF, VCARD } from "@inrupt/lit-generated-vocab-common";
+import { VCARD } from "@inrupt/lit-generated-vocab-common";
const ProfileSideBar = (props) => {
const classes = useStyles();
diff --git a/webapp/src/components/SocialSidebar/SocialSidebar.jsx b/webapp/src/components/SocialSidebar/SocialSidebar.jsx
index 6d67d157..bdc41c88 100644
--- a/webapp/src/components/SocialSidebar/SocialSidebar.jsx
+++ b/webapp/src/components/SocialSidebar/SocialSidebar.jsx
@@ -1,11 +1,8 @@
import React, {useEffect, useState} from 'react';
-import useStyles from "./styles";
-import PlaceCard from "../PlaceCard/PlaceCard";
-import {getFriends} from "../../solidapi/solidAdapter";
+import {getFriends, giveFriendsPermissions} from "../../solidapi/solidAdapter";
import FriendCard from "../FriendCard/FriendCard";
const SocialSidebar = (props) => {
- // const classes = useStyles();
const {userWebId, setSelectedFriend,setSelectedButton, deleteFriend} = props;
const [friends, setFriends] = useState([]);
useEffect(() => {
diff --git a/webapp/src/solidapi/solidAdapter.js b/webapp/src/solidapi/solidAdapter.js
index 59a3ea98..a30211a8 100644
--- a/webapp/src/solidapi/solidAdapter.js
+++ b/webapp/src/solidapi/solidAdapter.js
@@ -1,16 +1,6 @@
-import PlaceEntity from "../entities/PlaceEntity";
-
-import { writeData, findDataInContainer, deleteData} from "./solidapi";
+import { writeData, findDataInContainer, deleteData} from "./solidapi";
import * as solid from "@inrupt/solid-client";
import {FOAF, VCARD} from "@inrupt/lit-generated-vocab-common";
-import {
- getSolidDataset,
- saveSolidDatasetAt,
- removeUrlFromThing,
- getThing,
- getUrlAll,
- setThing, getNamedNode
-} from '@inrupt/solid-client';
export function savePlace(session, placeEntity) {
let place = placeEntity;
@@ -26,12 +16,12 @@ export function savePlace(session, placeEntity) {
let PlacesUrl ="";
let PlacesUrlPublic ="";
- if(privacyOfPlace === "Public"){
- PlacesUrlPublic = basicUrl.concat("/public", "/Places", "/" + place.id + ".json");
- PlacesUrl = basicUrl.concat("/private", "/Places", "/" + place.id + ".json");
- }else if(privacyOfPlace === "Private") {
- PlacesUrl = basicUrl.concat("/private", "/Places", "/" + place.id + ".json");
- }
+ // if(privacyOfPlace === "Public"){
+ // PlacesUrlPublic = basicUrl.concat("/public", "/Places", "/" + place.id + ".json");
+ // PlacesUrl = basicUrl.concat("/private", "/Places", "/" + place.id + ".json");
+ // }else if(privacyOfPlace === "Private") {
+ // PlacesUrl = basicUrl.concat("/private", "/Places", "/" + place.id + ".json");
+ // }
place = JSON.parse(JSON.stringify(place))
@@ -46,14 +36,14 @@ export function savePlace(session, placeEntity) {
//le paso el file creado con el blob
- if(privacyOfPlace === "Public") { //si es publico se guarda en la carpeta de contenido privado y en la de público
+ // if(privacyOfPlace === "Public") { //si es publico se guarda en la carpeta de contenido privado y en la de público
+ // writeData(session,PlacesUrl,file);
+ // writeData(session,PlacesUrlPublic,file);
+ //
+ // }else {
writeData(session,PlacesUrl,file);
- writeData(session,PlacesUrlPublic,file);
- }else {
- writeData(session,PlacesUrl,file);
-
- }
+ //}
return place;
}
@@ -91,13 +81,14 @@ export async function removePlace(session,placeId){
const basicUrl = session.info.webId?.split("/").slice(0, 3).join("/");
const placeUrl = basicUrl.concat("/private", "/Places", "/" + placeToDelete.id + ".json");
- if (placeToDelete.privacy === "Public") {
- deleteData(session, placeUrl);
- const placeUrlPublic = basicUrl.concat("/public", "/Places", "/" + placeToDelete.id + ".json");
- deleteData(session, placeUrlPublic);
- }else {
- deleteData(session, placeUrl);
- }
+ // if (placeToDelete.privacy === "Public") {
+ // deleteData(session, placeUrl);
+ // const placeUrlPublic = basicUrl.concat("/public", "/Places", "/" + placeToDelete.id + ".json");
+ // deleteData(session, placeUrlPublic);
+ // }else {
+ // deleteData(session, placeUrl);
+ // }
+ deleteData(session, placeUrl);
}
}
@@ -157,19 +148,14 @@ export async function getFriends(webId){
myDataset = await solid.getSolidDataset(friendsURL[i]); // obtain the dataset from the URI
theThing = await solid.getThing(myDataset, friendsURL[i]);
- //
let name = solid.getStringNoLocale(theThing, FOAF.name);
- // let hasPhoto = theThing.get(getNamedNode(VCARD.hasPhoto));
- // let profilePicture = hasPhoto ? solid.getUrl(hasPhoto) : null;
let friend = {
friendURL:friendsURL[i],
friendName:name,
profilePicture:VCARD.hasPhoto.iri.value,
- //profilePicture: profilePicture,
- //profilePicture: getFriendsImage(friendsURL[i]),
- }
- //console.log(friend.profilePicture);
+ }
+
friends.push(friend);
}
return friends;
@@ -194,6 +180,88 @@ export async function deleteFriendPod(userWebId, friendwebID) {
await solid.removeUrl(myDataset, FOAF.knows, friendwebID);
await solid.saveSolidDatasetAt(userWebId, myDataset);
}
+
+}
+//Función que da permiso a un amigo sobre un sitio
+export async function giveFriendPermissionPoint(webId,session, placeId, friendUrl) {
+
+ let friendsURL = solid.getUrlAll(await getProfile(webId), FOAF.knows); //array de amigos del usuario
+
+ let url = urlPlaceUser(webId,placeId); //url del archivo a dar permisos
+
+
+ try { //obtener el archivo de control de acceso para la cuenta de usuario
+ let file = await solid.getFile(
+ url,
+ { fetch: session.fetch }
+ );
+
+ //recorremos el array de amigos para encontrar el amigo con el que queremos compartir el sitio
+ for(let friend in friendsURL) {
+ if(friend === friendUrl) {
+ let resourceAcl = solid.createAcl(file); //recurso de permisos
+
+ const updatedAcl = solid.setAgentResourceAccess( //se establecen los permisos
+ resourceAcl,
+ friendsURL[friend],
+ { read: true, append: false, write: true, control: false }
+ );
+ await solid.saveAclFor(file, updatedAcl, { fetch: session.fetch }); //se guardan en el amigo los cambios
+ console.log("Permisos al amigo :"+ friendsURL);
+ }
+
+ }
+
+ } catch (error) {
+ console.log(error);
+ }
+}
+
+//Funcion que da permiso sobre un punto a todos los amigos
+export async function giveAllFriendPermissionPoint(webId,session, placeId) {
+
+ let friendsURL = solid.getUrlAll(await getProfile(webId), FOAF.knows);
+
+ let url = urlPlaceUser(webId,placeId); //url del archivo a dar permisos
+
+ try { //obtener el archivo de control de acceso para la cuenta de usuario
+ let file = await solid.getFile(
+ url,
+ { fetch: session.fetch }
+ );
+
+ //recorremos el array de amigos para compartir el sitio con todos los amigos
+ for(let friend in friendsURL){ //para cada amigo
+ let resourceAcl = solid.createAcl(file); //se crea un objeto de control de acceso
+
+ const updatedAcl = solid.setAgentResourceAccess( //se establecen los permisos
+ resourceAcl,
+ friendsURL[friend],
+ { read: true, append: false, write: true, control: false }
+ );
+
+ await solid.saveAclFor(file, updatedAcl, { fetch: session.fetch }); //se guardan en cada amigo los cambios
+ console.log("Permisos al amigo :"+ friendsURL);
+ }
+
+ } catch (error) {
+ console.log(error);
+ }
+}
+
+
+
+export async function getProfile(webId){
+ let profileDocumentURI = webId.split("#")[0]; // we remove the right hand side of the # for consistency
+ let myDataset = await solid.getSolidDataset(profileDocumentURI); // obtain the dataset from the URI
+ return solid.getThing(myDataset, webId); // we obtain the thing we are looking for from the dataset
+}
+
+//Devuelve la url para poder acceder al json.ld
+export function urlPlaceUser(webId, placeId){
+ let url = webId.replace("profile/card#me","");
+ url = url+"private/" + placeId +".json";
+ return url;
}