Skip to content

Commit

Permalink
Add the sample apps file
Browse files Browse the repository at this point in the history
  • Loading branch information
helamanl0424 authored Mar 15, 2024
1 parent de23ef7 commit e3cea5f
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 0 deletions.
38 changes: 38 additions & 0 deletions samples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to the dApps!</title>
<link rel="stylesheet" href="index_style.css">
</head>
<body>
<div class="login-container">
<h2>Welcome to the dApps!</h2>
<form id="loginForm">
<div class="input-group">
<input type="text" id="podURL" required>
<label for="podURL">Pod URL</label>
</div>
<div class="input-group">
<input type="text" id="webID" required>
<label for="webID">WebID</label>
</div>
<div class="input-group">
<input type="text" id="clientID" required>
<label for="clientID">Client ID</label>
</div>
<div class="input-group">
<input type="password" id="clientSecret" required>
<label for="clientSecret">Client Secret</label>
</div>
<div class="input-group">
<input type="text" id="tokenURL" required>
<label for="tokenURL">Token URL</label>
</div>
<button id="attachButton" type="submit">attach</button>
</form>
</div>
<script src="index_script.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions samples/index_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
document.addEventListener('DOMContentLoaded', function() {
var button = document.getElementById('attachButton');

button.addEventListener('click', function(event) {
event.preventDefault();

const podURL = document.getElementById('podURL').value;
const webID = document.getElementById('webID').value;
const clientID = document.getElementById('clientID').value;
const clientSecret = document.getElementById('clientSecret').value;
const tokenURL = document.getElementById('tokenURL').value;

// change the ECI to make it work on your pico
const queryURL = "http://localhost:3001/sky/event/cltqlszq00012ycu4dtvt55l9/1556/test/connect_storage";
const queryParams = new URLSearchParams({
storageURL: podURL,
webID: webID,
clientID: clientID,
clientSecret: clientSecret,
tokenURL: tokenURL
}).toString();

const attachURL = `${queryURL}?${queryParams}`;

fetch(attachURL, {
method: 'POST',
})
.then(response => response.json())
.then(data => {
console.log(data);
window.location.href = 'pod.html';
})
.catch(error => console.error('Error:', error));
});
});
66 changes: 66 additions & 0 deletions samples/index_style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
body, html {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
background-color: #f0f4f8;
}

.login-container {
position: absolute;
width: 100%;
max-width: 400px;
padding: 50px 75px 50px 50px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: white;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
text-align: center;
}

h2 {
color: #333;
margin-bottom: 40px;
}

.input-group {
position: relative;
margin-bottom: 20px;
}

input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
border: 2px solid #ddd;
border-radius: 4px;
margin-top: 8px;
}

input[type="text"]:focus, input[type="password"]:focus {
border-color: #007bff;
outline: none;
}

label {
position: absolute;
top: -8px;
left: 10px;
background-color: white;
padding: 0 5px;
color: #007bff;
}

button {
width: 105%;
padding: 10px;
border: none;
border-radius: 4px;
color: white;
background-color: #007bff;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}
23 changes: 23 additions & 0 deletions samples/pod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pod</title>
</head>
<body>
<p>Welcome to your pod!</p>
<div>
<button id="detachPod">Detach pod</button>
<button id="searchPhoto">Search photo</button>
</div>
<img src="C:/Users/helam/Documents/myDoc/BYU/CS480/dApps/sample.jpg" alt="sample">
<button id="addPhoto">Add photo</button>
<button id="addFolder">Add folder</button>
<div>
<button id="listAllPhotos">All Photos</button>
<button id="listAllSharedPhotos">Shared Photos</button>
</div>
<script src="pod_script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions samples/pod_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document.addEventListener('DOMContentLoaded', function() {
var button = document.getElementById('detachPod');

button.addEventListener('click', function(event) {
event.preventDefault();

// change the ECI to make it work on your pico
const detachURL = "http://localhost:3001/sky/event/cltqlszq00012ycu4dtvt55l9/1556/test/disconnect_storage";

fetch(detachURL, {
method: 'POST',
})
.then(response => response.json())
.then(data => {
console.log(data);
window.location.href = 'index.html';
})
.catch(error => console.error('Error:', error));
});
});
Binary file added samples/sample.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e3cea5f

Please sign in to comment.