Skip to content

Commit

Permalink
Merge pull request #223 from Arquisoft/bugFix-routeParsing
Browse files Browse the repository at this point in the history
First try to fix route parsing crash
  • Loading branch information
fincamd authored May 6, 2020
2 parents a45d087 + e267fa9 commit d553bf1
Show file tree
Hide file tree
Showing 30 changed files with 174 additions and 183 deletions.
64 changes: 1 addition & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
1. [Unit tests](#unit-tests)

2. [Cucumber tests](#cucumber-tests)

2. [Introduction](#introduction)

3. [To Start](#to-start)

1. [Create a POD](#create-a-pod)

2. [Login](#login)

3. [Create a route](#create-a-route)

4. [View a route](#view-a-route)

4. [Miscellaneous information](#miscellaneous-information)

Expand Down Expand Up @@ -57,59 +45,9 @@ npm test
#### Cucumber tests
For executing the [Cucumber](https://cucumber.io/) tests run:
```shell
npm run-script test:e2e
npm run test:e2e
```

## Introduction
Viade is an Application whose task is to manage routes.
<p>
<img class="fullPic" src="./public/img/sample/main.png">
</p>

It allows you to store your favourite scenic routes on your [Solid Pod](https://solid.inrupt.com/how-it-works) and to share it with your friends and family as well as comment on those of your friends'.

<p>
<img class="fullPic" src="./public/img/sample/newRouteList.png">
</p>

## To Start
### Create a POD

If you are not an owner of a POD you can create one by pressing the register button.
This will redirect you to a provider, where you can create your POD.

### Login

Once the POD is created, press the login button and a popup will ask you for credentials.
Once logged in you will have access to new options.

### Create a route

From "Route Management > Create a new Route" you can create a new route.
Just set a title, description, select the waypoints of the route and press "Save route in POD".
<p>
<img class="fullPic" src="./public/img/sample/Screenshot_1.png">
<img class="fullPic" src="./public/img/sample/Screenshot_3.png">
</p>

### View a route

We can now navigate to "Route Management > My Routes", where the routes you have created are listed.
When clicking on "Info" of the new route a new window will display all the information recorded, as well as comments posted and a elevation chart of the waypoints.

<p>
<img class="fullPic" src="./public/img/sample/routeDetails.png">
</p>

### Share with friends

When displaying all routes "Route Management > My Routes", you can click on the share option.
This will list all friends and when clicking share, a message with the route will be sent to the inbox of your friend.

<p>
<img class="fullPic" src="./public/img/sample/Screenshot_4.png">
</p>

## Miscellaneous information

This project is an assignment for the [Software Architecture course](https://arquisoft.github.io/) following [these requirements](https://labra.solid.community/public/SoftwareArchitecture/AssignmentDescription/).
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
container_name: solidserver
ports:
- "8443:8443"
sampleweb:
viadeen3a:
build: .
ports:
- "3000:3000"
Binary file added loadTests/results/simulation1-100users.zip
Binary file not shown.
Binary file added loadTests/results/simulation1-10users.zip
Binary file not shown.
Binary file added loadTests/results/simulation1-50users.zip
Binary file not shown.
Binary file added loadTests/results/simulation1-rampUp.zip
Binary file not shown.
Binary file added loadTests/results/simulation2-100users.zip
Binary file not shown.
Binary file added loadTests/results/simulation2-10users.zip
Binary file not shown.
Binary file added loadTests/results/simulation2-50users.zip
Binary file not shown.
Binary file added loadTests/results/simulation2-rampUp.zip
Binary file not shown.
Binary file added loadTests/simulations/Simulations.zip
Binary file not shown.
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" style="background-color: white !important;">

<head>
<meta charset="utf-8" />
Expand Down
24 changes: 14 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@ import { HashRouter } from "react-router-dom";

function App() {
return (
<div className="App">
<HashRouter basename='/'>
<LoggedOut>
<NavBarNotAuthenticated />
</LoggedOut>
<LoggedIn>
<MyNavBar />
</LoggedIn>
</HashRouter>
</div>
<div className="App" ref={(el) => {
if (el) {
el.style.setProperty('background-color', 'white', 'important');
}
}}>
<HashRouter basename='/'>
< LoggedOut >
<NavBarNotAuthenticated />
</ LoggedOut>
<LoggedIn>
<MyNavBar />
</LoggedIn>
</HashRouter>
</div >
);
}

Expand Down
Binary file added src/assets/howRoutesWork/Screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/howRoutesWork/Screenshot_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/howRoutesWork/newRouteList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 21 additions & 15 deletions src/components/podService/podPermissionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { AclApi } = SolidAclUtils;
// const { AclApi, AclDoc, AclParser, AclRule, Permissions, Agents } = SolidAclUtils;
// const { READ, WRITE, APPEND, CONTROL } = Permissions;

export default class PodPermissionHandler extends PodHandler{
export default class PodPermissionHandler extends PodHandler {

/**
* @param {Session} currentSession - auth.currentSession()
Expand All @@ -31,7 +31,7 @@ export default class PodPermissionHandler extends PodHandler{
// Share resources
this.podStoreHandler.getFile(url).then(
(file) => { this._processRouteFileForUnshare(file, permissions, webIds); },
(error) => { }
(error) => { }
);

// Share route
Expand All @@ -50,7 +50,7 @@ export default class PodPermissionHandler extends PodHandler{
// Share resources
this.podStoreHandler.getFile(url).then(
(file) => { this._processRouteFileForShare(file, permissions, webIds); },
(error) => { }
(error) => { }
);

// Share route
Expand All @@ -62,7 +62,7 @@ export default class PodPermissionHandler extends PodHandler{
* @param {SolidAclUtils.Permissions} permissions - Permission to give to the file
* @param {String|Array<String>|SolidAclUtils.Agents} agents - People to share with
*/
async shareFile(url, permissions, agents){
async shareFile(url, permissions, agents) {
const fetch = auth.fetch.bind(auth);
const utils = new AclApi(fetch, { autoSave: true });
const acl = await utils.loadFromFileUrl(url);
Expand All @@ -79,7 +79,7 @@ export default class PodPermissionHandler extends PodHandler{
* @param {SolidAclUtils.Permissions} permissions - Permission to remove of the file
* @param {String|Array<String>|SolidAclUtils.Agents} agents - People to unshare with
*/
async unshareFile(url, permissions, agents){
async unshareFile(url, permissions, agents) {
const fetch = auth.fetch.bind(auth);
const utils = new AclApi(fetch, { autoSave: true });
const acl = await utils.loadFromFileUrl(url);
Expand All @@ -92,20 +92,26 @@ export default class PodPermissionHandler extends PodHandler{
}

_processRouteFileForShare(routeJson, permissions, agents) {
let parsedRoute = JSON.parse(routeJson);
let mediaURIs = parsedRoute["media"].map( (j) => {return j["@id"];});

for(let i = 0; i < mediaURIs.length; i++) {
this.shareFile(mediaURIs[i], permissions, agents);
try {
let parsedRoute = JSON.parse(routeJson);
let mediaURIs = parsedRoute["media"].map((j) => { return j["@id"]; });
for (let i = 0; i < mediaURIs.length; i++) {
this.shareFile(mediaURIs[i], permissions, agents);
}
} catch (error) {
// Continue with the execution and ignore the error
}
}

_processRouteFileForUnshare(routeJson, permissions, agents) {
let parsedRoute = JSON.parse(routeJson);
let mediaURIs = parsedRoute["media"].map( (j) => {return j["@id"];});

for(let i = 0; i < mediaURIs.length; i++) {
this.unshareFile(mediaURIs[i], permissions, agents);
try {
let parsedRoute = JSON.parse(routeJson);
let mediaURIs = parsedRoute["media"].map((j) => { return j["@id"]; });
for (let i = 0; i < mediaURIs.length; i++) {
this.unshareFile(mediaURIs[i], permissions, agents);
}
} catch (error) {
// Continue with the execution and ignore the error
}
}
}
26 changes: 15 additions & 11 deletions src/components/podService/podStoreHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,21 @@ export default class PodStorageHandler extends PodHandler {
for (let i = 0; i < directory.files.length; i++) {
await this.getFile(directory.files[i].url).then(
async (sharedRoutesfile) => {
let parsedFileRoutes = JSON.parse(sharedRoutesfile).routes;
for (let j = 0; j < parsedFileRoutes.length; j++) {
await this.getFile(parsedFileRoutes[j]["@id"]).then(
(fileContents) => {
let lastFile =
(i === directory.files.length - 1) &&
(j === parsedFileRoutes.length - 1);
forEachFile(fileContents, null, lastFile);
},
(error) => { forEachFile(); }
);
try {
let parsedFileRoutes = JSON.parse(sharedRoutesfile).routes;
for (let j = 0; j < parsedFileRoutes.length; j++) {
await this.getFile(parsedFileRoutes[j]["@id"]).then(
(fileContents) => {
let lastFile =
(i === directory.files.length - 1) &&
(j === parsedFileRoutes.length - 1);
forEachFile(fileContents, null, lastFile);
},
(error) => { forEachFile(); }
);
}
} catch (error) {
// Continue with execution and ignore the route
}
},
(error) => { forEachFile(null, error); }
Expand Down
4 changes: 3 additions & 1 deletion src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const resources = {
"actions":"Actions",
"editMessage": "Click over a point to edit it",
"grupos": "Groups",
"invalidRoute": "Route with invalid format ignored",
}
},
es: {
Expand Down Expand Up @@ -169,7 +170,7 @@ const resources = {
"editProfileChangePass": "Cambiar contraseña",
"editProfileNewPass": "Nueva contraseña",
"editProfileSave": "Guardar",
"homeWelcome": "Hola",
"homeWelcome": "Hola ",
"homeWelcome2": "bienvenido a",
"profileTitle": "Tu Perfil",
"profileUsername": "Usuario:",
Expand Down Expand Up @@ -261,6 +262,7 @@ const resources = {
"actions":"Acciones",
"editMessage": "Pincha sobre un punto para editarlo",
"grupos": "Grupos",
"invalidRoute": "Ruta con formato inválido ignorada",
}
}
};
Expand Down
104 changes: 60 additions & 44 deletions src/model/MyRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,59 +152,75 @@ class MyRoute {
}

getComparableString() {
let parsedRoute = JSON.parse(this.toJsonLd());
parsedRoute["@context"] = "";
parsedRoute["id"] = "";
return JSON.stringify(parsedRoute);
try {
let parsedRoute = JSON.parse(this.toJsonLd());
parsedRoute["@context"] = "";
parsedRoute["id"] = "";
return JSON.stringify(parsedRoute);
} catch (error) {
return JSON.stringify({});
}
}

modifyFromJsonLd(parsedRoute) {
if (parsedRoute["id"] === undefined) {
this.id = uuid().toString();
} else {
this.id = parsedRoute["id"];
}

this.name = parsedRoute["name"];
this.author = parsedRoute["author"];
this.description = parsedRoute["description"];
try {
parsedRoute = JSON.parse(parsedRoute);

if (parsedRoute["id"] === undefined) {
this.id = uuid().toString();
} else {
this.id = parsedRoute["id"];
}

let rawWaypoints = parsedRoute["waypoints"];
rawWaypoints = rawWaypoints.map((jsonPoint) => {
return {
lat: jsonPoint["latitude"],
lng: jsonPoint["longitude"],
elv: jsonPoint["elevation"],
name: jsonPoint["name"],
description: jsonPoint["description"]
};
});
this.name = parsedRoute["name"];
this.author = parsedRoute["author"];
this.description = parsedRoute["description"];

this.points = processPoints(rawWaypoints);
let rawWaypoints = parsedRoute["waypoints"];
if (rawWaypoints !== undefined) {
rawWaypoints = rawWaypoints.map((jsonPoint) => {
return {
lat: jsonPoint["latitude"],
lng: jsonPoint["longitude"],
elv: jsonPoint["elevation"],
name: jsonPoint["name"],
description: jsonPoint["description"]
};
});


let rawPoints = parsedRoute["points"];
rawPoints = rawPoints.map((jsonPoint) => {
return {
lat: jsonPoint["latitude"],
lng: jsonPoint["longitude"],
elv: jsonPoint["elevation"]
};
});
this.addSimplePoints(rawPoints);

this.points = processPoints(rawWaypoints);
}

this.media = [];
let mediaURIs = parsedRoute["media"];
mediaURIs.map((j) => { return j["@id"]; }).forEach(function (url) {
let newMedia = new RouteMedia(this);
newMedia.isInPod = true;
newMedia.podURL = url;
this.media.push(newMedia);
}.bind(this));

this.routeLength = calculateRouteLength(rawPoints);
let rawPoints = parsedRoute["points"];
if (rawPoints !== undefined) {
rawPoints = rawPoints.map((jsonPoint) => {
return {
lat: jsonPoint["latitude"],
lng: jsonPoint["longitude"],
elv: jsonPoint["elevation"]
};
});
this.addSimplePoints(rawPoints);
}
if (this.points.length === 0) {
return false;
}
this.media = [];
let mediaURIs = parsedRoute["media"];
mediaURIs.map((j) => { return j["@id"]; }).forEach(function (url) {
let newMedia = new RouteMedia(this);
newMedia.isInPod = true;
newMedia.podURL = url;
this.media.push(newMedia);
}.bind(this));

this.routeLength = calculateRouteLength(rawPoints);

return true;
} catch (error) {
return false;
}
}

toJsonLd() {
Expand Down
Loading

0 comments on commit d553bf1

Please sign in to comment.