diff --git a/webapp/src/App.js b/webapp/src/App.js
index 129b4458..9521f05c 100644
--- a/webapp/src/App.js
+++ b/webapp/src/App.js
@@ -79,6 +79,10 @@ function App() {
setPlaces(places.filter(place => place.id !== placeID));//antes: place._id (por mongo)
}
+ function deleteFriend(friendID) {
+
+ }
+
const handleLogout = () => {
session.logout();
}
diff --git a/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx b/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
index b6fcc38b..f124d4ef 100644
--- a/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
+++ b/webapp/src/components/AddPlaceSidebar/AddPlaceSidebar.jsx
@@ -11,7 +11,7 @@ function AddPlaceSidebar (props) {
const [name, setName] = useState("");
const [description, setDescription] = useState("");
const [category, setCategory] = useState("");
-
+ const [privacy, setPrivacy] = useState("");
const addPlace = async(req) => {
const place = new PlaceEntity();
place.name = name;
@@ -19,6 +19,7 @@ function AddPlaceSidebar (props) {
place.latitude = selectedPoint.lat;
place.longitude = selectedPoint.lng;
place.category = category;
+ place.privacy = privacy;
//Con una webId como esta "https://aliciafp15.inrupt.net/profile/card#me";
const parts = userWebId.split('.'); // Dividimos la cadena en partes utilizando el punto como separador
@@ -43,16 +44,18 @@ function AddPlaceSidebar (props) {
}
}
+
const classes = useStyles();
function isFormComplete(){
- return name !== "" && description !== "" && category !== "";
+ return name !== "" && description !== "" && category !== "" && privacy !== "";
}
function clearForm(){
setName("");
setDescription("");
setCategory("");
+ setPrivacy("");
}
function addPlaceAndClearForm(){
@@ -61,8 +64,6 @@ function AddPlaceSidebar (props) {
clearForm();
}
}
-
-
return (
@@ -96,6 +97,14 @@ function AddPlaceSidebar (props) {
+
diff --git a/webapp/src/components/AddPlaceSidebar/styles.js b/webapp/src/components/AddPlaceSidebar/styles.js
index 21265606..b436874d 100644
--- a/webapp/src/components/AddPlaceSidebar/styles.js
+++ b/webapp/src/components/AddPlaceSidebar/styles.js
@@ -9,6 +9,7 @@ export default makeStyles((theme) => ({
margin: '25px',
marginBottom: '5px',
marginTop: '5px',
+ variant:"outlined",
},
title: {
margin: '25px',
diff --git a/webapp/src/components/DeleteFriendConfirmDialog/DeleteFriendConfirmDialog.jsx b/webapp/src/components/DeleteFriendConfirmDialog/DeleteFriendConfirmDialog.jsx
new file mode 100644
index 00000000..049a4548
--- /dev/null
+++ b/webapp/src/components/DeleteFriendConfirmDialog/DeleteFriendConfirmDialog.jsx
@@ -0,0 +1,33 @@
+import React from 'react';
+import {Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Paper} from "@mui/material";
+
+
+const DeleteFriendConfirmDialog = (props) => {
+ const {open, handleClose, handleDeleteFriend} = props;
+
+ return (
+
+
+
+ );
+};
+
+export default DeleteFriendConfirmDialog;
\ No newline at end of file
diff --git a/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx b/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
index dd25ad6b..5d291c48 100644
--- a/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
+++ b/webapp/src/components/DetailsSidebar/DetailsSidebar.jsx
@@ -13,9 +13,9 @@ const DetailsSidebar = (props) => {
const classes = useStyles();
const [content, setContent] = useState("");
const {places, setPlaces, selectedPoint, setSelectedPoint, setSelectedButton, selectedButton,setSelectedPlaceMyPlaces,
- deletePlace, setPlacesLength,userWebId, handleLogout, session, selectedFriendPlaces, setSelectedFriendPlaces} = props;
+ deletePlace, setPlacesLength,userWebId, handleLogout, session, selectedFriendPlaces, setSelectedFriendPlaces, deleteFriend} = props;
const [selectedFriend, setSelectedFriend] = useState([]);
-
+ const [showDeleteButton, setShowDeleteButton] =useState(true);
useEffect(() => {
let friendWebId = selectedFriend.friendURL;
@@ -36,7 +36,8 @@ const DetailsSidebar = (props) => {
+ setSelectedPlaceMyPlaces={setSelectedPlaceMyPlaces} session={session}
+ showDeleteButton = {showDeleteButton}/>
>
);
@@ -67,7 +68,7 @@ const DetailsSidebar = (props) => {
Explore your friends places.
-
+
>
);
@@ -82,7 +83,8 @@ const DetailsSidebar = (props) => {
+ setSelectedPlaceMyPlaces={setSelectedPlaceMyPlaces}
+ setShowDeleteButton = {false}/>
>
);
diff --git a/webapp/src/components/FriendCard/FriendCard.jsx b/webapp/src/components/FriendCard/FriendCard.jsx
index 3cea9410..1db6cc66 100644
--- a/webapp/src/components/FriendCard/FriendCard.jsx
+++ b/webapp/src/components/FriendCard/FriendCard.jsx
@@ -1,15 +1,17 @@
import React from 'react';
import {Card, CardContent, CardHeader, IconButton, Menu, MenuItem, Typography} from "@mui/material";
import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded';
-import DeletePlaceConfirmDialog from "../DeletePlaceConfirmDialog/DeletePlaceConfirmDialog";
import MapIcon from '@mui/icons-material/Map';
import Avatar from "@mui/material/Avatar";
import {Image} from "@inrupt/solid-ui-react";
import {VCARD} from "@inrupt/lit-generated-vocab-common";
import {useStyles} from "tss-react/mui";
+import DeleteFriendConfirmDialog from "../DeleteFriendConfirmDialog/DeleteFriendConfirmDialog";
+import { deleteFriendPod } from '../../solidapi/solidAdapter';
+
const FriendCard = (props) => {
const classes = useStyles();
- const {friend, setSelectedFriend, setSelectedButton} = props;
+ const {friend, setSelectedFriend, setSelectedButton, deleteFriend, userWebId} = props;
const [open, setOpen] = React.useState(false);
const handleClickOpen = () => {
@@ -22,13 +24,14 @@ const FriendCard = (props) => {
const handleDeleteFriend = () => {
console.log("DELETING FRIEND...");
+ deleteFriendPod(userWebId, "https://uo282249.inrupt.net/profile/card#me"); //deleting in the frontend
+
}
console.log(friend.profilePicture);
return (
-
{
-
+
);
};
diff --git a/webapp/src/components/IconsSidebar/IconsSidebar.jsx b/webapp/src/components/IconsSidebar/IconsSidebar.jsx
index 70f0049b..6e9ac5e4 100644
--- a/webapp/src/components/IconsSidebar/IconsSidebar.jsx
+++ b/webapp/src/components/IconsSidebar/IconsSidebar.jsx
@@ -1,4 +1,4 @@
-import React, {useState} from 'react';
+import React from 'react';
import {IconButton} from "@mui/material";
import PlaceIcon from '@mui/icons-material/Place';
import AddLocationAltIcon from '@mui/icons-material/AddLocationAlt';
@@ -7,8 +7,6 @@ import SettingsIcon from '@mui/icons-material/Settings';
import AccountCircleIcon from '@mui/icons-material/AccountCircle';
import useStyles from "./styles";
-import handleButtonAction from '../DetailsSidebar/DetailsSidebar';
-import Sidebar from "../Sidebar/Sidebar";
const IconsSidebar = (props) => {
const classes = useStyles();
diff --git a/webapp/src/components/LoginWall/LoginWall.jsx b/webapp/src/components/LoginWall/LoginWall.jsx
index e174a3db..9247939b 100644
--- a/webapp/src/components/LoginWall/LoginWall.jsx
+++ b/webapp/src/components/LoginWall/LoginWall.jsx
@@ -7,6 +7,7 @@ import { LoginButton } from "@inrupt/solid-ui-react";
import { useEffect } from 'react';
const LoginWall = (props) => {
const classes = useStyles();
+ const {setSession} = props;
const [idp, setIdp] = useState("https://inrupt.net");
const [currentUrl, setCurrentUrl] = useState("http://localhost:3000/");
diff --git a/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx b/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
index 06da2d64..1969a77f 100644
--- a/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
+++ b/webapp/src/components/MyPlacesSidebar/MyPlacesSidebar.jsx
@@ -5,7 +5,7 @@ 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} = props;
+ const {places, setPlaces,setSelectedPlaceMyPlaces, deletePlace, session, showDeleteButton} = props;
const classes = useStyles();
@@ -14,7 +14,7 @@ const MyPlacesSidebar = (props) => {
return props.places?.map((place)=> (
console.log('key ' + place._id),
+ deletePlace={deletePlace} session={session} showDeleteButton = {showDeleteButton} />
))
}
diff --git a/webapp/src/components/PlaceCard/PlaceCard.jsx b/webapp/src/components/PlaceCard/PlaceCard.jsx
index c8a5c3c6..a21def49 100644
--- a/webapp/src/components/PlaceCard/PlaceCard.jsx
+++ b/webapp/src/components/PlaceCard/PlaceCard.jsx
@@ -1,13 +1,15 @@
import React from 'react';
-import {Card, CardContent, CardHeader, IconButton, Menu, MenuItem, Typography} from "@mui/material";
+import {Card, CardContent, CardHeader, IconButton, Menu, MenuItem, Typography, Chip} from "@mui/material";
import DeleteRoundedIcon from '@mui/icons-material/DeleteRounded';
import TravelExploreRoundedIcon from '@mui/icons-material/TravelExploreRounded';
import DeletePlaceConfirmDialog from "../DeletePlaceConfirmDialog/DeletePlaceConfirmDialog";
import {deletePlaceMarkByID} from "../../api/api";
import { removePlace } from '../../solidapi/solidAdapter';
+import Diversity3Icon from '@mui/icons-material/Diversity3';
+import PermIdentityIcon from '@mui/icons-material/PermIdentity';
const PlaceCard = (props) => {
- const {place, setSelectedPlaceMyPlaces, deletePlace, session} = props;
+ const {place, setSelectedPlaceMyPlaces, deletePlace, session, showDeleteButton } = props;
const [open, setOpen] = React.useState(false);
const handleClickOpen = () => {
@@ -34,26 +36,33 @@ const PlaceCard = (props) => {
return (
+
+ : } label={place.privacy} />
setSelectedPlaceMyPlaces({lat: place.latitude, lng: place.longitude})}>
-
-
-
-
+ {showDeleteButton ? (
+
+
+
+ ) : null}
>
}
+
title={{place.name}}
+
subheader={{place.category}}
+
/>
{place.description}
+
diff --git a/webapp/src/components/Sidebar/Sidebar.jsx b/webapp/src/components/Sidebar/Sidebar.jsx
index 3a566e49..fbe0f301 100644
--- a/webapp/src/components/Sidebar/Sidebar.jsx
+++ b/webapp/src/components/Sidebar/Sidebar.jsx
@@ -9,7 +9,7 @@ const Sidebar = (props) => {
const {places, setPlaces, selectedButton, setSelectedButton, selectedPoint,
setSelectedPoint,setSelectedPlaceMyPlaces,deletePlace, setPlacesLength, userWebId, handleLogout, session,
- selectedFriendPlaces, setSelectedFriendPlaces} = props;
+ selectedFriendPlaces, setSelectedFriendPlaces, deleteFriend} = props;
const handleSelectedButtonChange = (selectedButton) => {
setSelectedButton(selectedButton);
};
@@ -28,7 +28,8 @@ const Sidebar = (props) => {
setSelectedPlaceMyPlaces={setSelectedPlaceMyPlaces} deletePlace={deletePlace}
setPlacesLength={setPlacesLength} userWebId={userWebId} handleLogout={handleLogout}
session={session} setSelectedButton={setSelectedButton}
- selectedFriendPlaces={selectedFriendPlaces} setSelectedFriendPlaces={setSelectedFriendPlaces}/>
+ selectedFriendPlaces={selectedFriendPlaces} setSelectedFriendPlaces={setSelectedFriendPlaces}
+ deleteFriend={deleteFriend}/>
div>
diff --git a/webapp/src/components/SocialSidebar/SocialSidebar.jsx b/webapp/src/components/SocialSidebar/SocialSidebar.jsx
index 2aad4db5..6d67d157 100644
--- a/webapp/src/components/SocialSidebar/SocialSidebar.jsx
+++ b/webapp/src/components/SocialSidebar/SocialSidebar.jsx
@@ -6,7 +6,7 @@ import FriendCard from "../FriendCard/FriendCard";
const SocialSidebar = (props) => {
// const classes = useStyles();
- const {userWebId, setSelectedFriend,setSelectedButton} = props;
+ const {userWebId, setSelectedFriend,setSelectedButton, deleteFriend} = props;
const [friends, setFriends] = useState([]);
useEffect(() => {
getFriends(userWebId).then((friends) => {
@@ -17,7 +17,8 @@ const SocialSidebar = (props) => {
const showFriends = () => {
console.log(friends);
return friends?.map((friend) => (
-
+
));
};
diff --git a/webapp/src/solidapi/solidAdapter.js b/webapp/src/solidapi/solidAdapter.js
index be57ca29..43c3c5f6 100644
--- a/webapp/src/solidapi/solidAdapter.js
+++ b/webapp/src/solidapi/solidAdapter.js
@@ -3,6 +3,14 @@
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
+} from '@inrupt/solid-client';
export function savePlace(session, placeEntity) {
let place = placeEntity;
@@ -12,7 +20,19 @@ export function savePlace(session, placeEntity) {
return null;
}
let basicUrl = session.info.webId?.split("/").slice(0, 3).join("/");//https://username.inrupt.net
- let PlacesUrl = basicUrl.concat("/public", "/Places", "/" + place.id + ".json");//ruta donde queremos guardar el lugar
+
+
+ let privacyOfPlace = place.privacy;
+ console.log(privacyOfPlace);
+ 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");
+ }
place = JSON.parse(JSON.stringify(place))
@@ -27,7 +47,14 @@ export function savePlace(session, placeEntity) {
//le paso el file creado con el blob
- writeData(session,PlacesUrl,file);
+ 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);
+
+ }
return place;
}
@@ -37,7 +64,7 @@ export async function getPlaces(session){
} // Check if the webId is undefined
let basicUrl = session.info.webId?.split("/").slice(0, 3).join("/");
- let pointsUrl = basicUrl.concat("/public", "/Places/");
+ let pointsUrl = basicUrl.concat("/private", "/Places/");
let places = [];
let files = await findDataInContainer(session, pointsUrl);
@@ -63,8 +90,15 @@ export async function removePlace(session,placeId){
// Si el lugar existe, eliminamos su archivo
if (placeToDelete) {
const basicUrl = session.info.webId?.split("/").slice(0, 3).join("/");
- const placeUrl = basicUrl.concat("/public", "/Places", "/" + placeToDelete.id + ".json");
- deleteData(session, placeUrl);
+ 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);
+ }
}
}
@@ -112,3 +146,25 @@ export async function getFriends(webId){
return friends;
}
+export async function deleteFriendPod(userWebId, friendwebID) {
+ //Obtenemos la lista de amigos
+ const friends = await getFriends(userWebId);
+
+ //Buscamos el amigo que queremos borrar
+ const friendToDelete = friends.find(friend => friend.friendURL === friendwebID);
+
+ // Si el amigo existe, lo eliminamos
+ if (friendToDelete) {
+ const updatedFriends = friends.filter(friend => friend.friendURL !== friendwebID);
+
+ // Actualizamos el documento de amigos
+ const myDataset = await solid.getSolidDataset(userWebId); //obtenemos el dataset de la URI
+ const theThing = await solid.getThing(myDataset, userWebId);
+ const friendsList = solid.getUrlAll(theThing, FOAF.knows);
+ let updatedList = friendsList.filter(friend => friend !== friendwebID);
+ await solid.removeUrl(myDataset, FOAF.knows, friendwebID);
+ await solid.saveSolidDatasetAt(userWebId, myDataset);
+ }
+}
+
+