From 03be70c69ab9f15197b69d14d1221d0aaaa1efde Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 13 Apr 2023 01:13:44 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Eliminada=20opci=C3=B3n=20de=20borrar=20un?= =?UTF-8?q?=20lugar=20de=20tus=20amigos.=20Intento=20de=20elimar=20amigos?= =?UTF-8?q?=20de=20SOLID.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/App.js | 4 +++ .../DeleteFriendConfirmDialog.jsx | 33 +++++++++++++++++++ .../DetailsSidebar/DetailsSidebar.jsx | 12 ++++--- .../src/components/FriendCard/FriendCard.jsx | 11 ++++--- .../components/IconsSidebar/IconsSidebar.jsx | 4 +-- webapp/src/components/LoginWall/LoginWall.jsx | 1 + .../MyPlacesSidebar/MyPlacesSidebar.jsx | 4 +-- webapp/src/components/PlaceCard/PlaceCard.jsx | 11 ++++--- webapp/src/components/Sidebar/Sidebar.jsx | 5 +-- .../SocialSidebar/SocialSidebar.jsx | 5 +-- webapp/src/solidapi/solidAdapter.js | 30 +++++++++++++++++ 11 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 webapp/src/components/DeleteFriendConfirmDialog/DeleteFriendConfirmDialog.jsx 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/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 ( +
+ + + Delete friend + + + + This friend will be deleted. Are you sure you want to continue? + + + + + + + +
+ ); +}; + +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..3f526f5e 100644 --- a/webapp/src/components/PlaceCard/PlaceCard.jsx +++ b/webapp/src/components/PlaceCard/PlaceCard.jsx @@ -7,7 +7,7 @@ import {deletePlaceMarkByID} from "../../api/api"; import { removePlace } from '../../solidapi/solidAdapter'; const PlaceCard = (props) => { - const {place, setSelectedPlaceMyPlaces, deletePlace, session} = props; + const {place, setSelectedPlaceMyPlaces, deletePlace, session, showDeleteButton } = props; const [open, setOpen] = React.useState(false); const handleClickOpen = () => { @@ -41,10 +41,11 @@ const PlaceCard = (props) => { setSelectedPlaceMyPlaces({lat: place.latitude, lng: place.longitude})}> - - - - + {showDeleteButton ? ( + + + + ) : null} } title={{place.name}} 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}/> 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..00e759d8 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; @@ -112,3 +120,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); + } +} + + From 47c8ee173842b04a97a8ea91d0a3d9c833be675d Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 13 Apr 2023 02:07:54 +0200 Subject: [PATCH 2/4] Implementada la escritura en los pods dependiendo de la privacidad que elija el usuario. Corregida la forma de mostrar los lugares. --- .../AddPlaceSidebar/AddPlaceSidebar.jsx | 17 ++++++++++--- .../src/components/AddPlaceSidebar/styles.js | 1 + webapp/src/solidapi/solidAdapter.js | 25 ++++++++++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) 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) { Attractions + 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/solidapi/solidAdapter.js b/webapp/src/solidapi/solidAdapter.js index 00e759d8..b21f4b97 100644 --- a/webapp/src/solidapi/solidAdapter.js +++ b/webapp/src/solidapi/solidAdapter.js @@ -20,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)) @@ -35,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; } @@ -45,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); From ae971eafd56d9415192b7723588ea204957d9b6c Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 13 Apr 2023 02:20:11 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Borrado=20en=20los=20pods=20en=20funci?= =?UTF-8?q?=C3=B3n=20del=20nivel=20de=20privacidad.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/solidapi/solidAdapter.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webapp/src/solidapi/solidAdapter.js b/webapp/src/solidapi/solidAdapter.js index b21f4b97..43c3c5f6 100644 --- a/webapp/src/solidapi/solidAdapter.js +++ b/webapp/src/solidapi/solidAdapter.js @@ -90,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); + } } } From 4b762a1f25ca41cfc4ca55b02802b061d4db9b21 Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 13 Apr 2023 02:48:30 +0200 Subject: [PATCH 4/4] =?UTF-8?q?A=C3=B1adida=20una=20etiqueta=20al=20mostra?= =?UTF-8?q?r=20los=20places=20que=20indica=20el=20nivel=20de=20privacidad.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/components/PlaceCard/PlaceCard.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webapp/src/components/PlaceCard/PlaceCard.jsx b/webapp/src/components/PlaceCard/PlaceCard.jsx index 3f526f5e..a21def49 100644 --- a/webapp/src/components/PlaceCard/PlaceCard.jsx +++ b/webapp/src/components/PlaceCard/PlaceCard.jsx @@ -1,10 +1,12 @@ 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, showDeleteButton } = props; @@ -34,10 +36,12 @@ const PlaceCard = (props) => { return (
+ + : } label={place.privacy} /> setSelectedPlaceMyPlaces({lat: place.latitude, lng: place.longitude})}> @@ -48,13 +52,17 @@ const PlaceCard = (props) => { ) : null} } + title={{place.name}} + subheader={{place.category}} + /> {place.description} +