Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend updates #41

Draft
wants to merge 2 commits into
base: praveen/json-pipeline
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added frontend/audio/Just_The_Two_Of_Us.mp3
Binary file not shown.
Binary file added frontend/audio/Sunday Vibes.mp3
Binary file not shown.
Binary file added frontend/audio/Sunny.mp3
Binary file not shown.
36 changes: 36 additions & 0 deletions frontend/audioPlayer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
session_start();
$host = 'localhost';
$user = 'dissertation';
$pass = '091164383707572306304pass';
$db = 'dreamHacker';

$link = mysqli_connect($host,$user,$pass, $db);

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Escape user inputs for security
$song = mysqli_real_escape_string($link, $_REQUEST['exampleRadios']);
//$location = mysqli_real_escape_string($link, $_REQUEST['exampleRadios']);
$location = 'audio/' . $song .'.mp3';


// Attempt insert query execution
//$sql = "INSERT INTO audio (song, location) VALUES ('$song','$location')";
$sql = "UPDATE audio SET song = '$song', location = '$location' WHERE id = 2";

if(mysqli_query($link, $sql)){
$_SESSION['message'] = "You have Succesfully changed the audio!";
header("location: sucess.php");
}
else{
$_SESSION['message'] = "ERROR: Could not able to execute: " . $sql. " . mysqli_error($link)";
header("location: sucess.php");
}

?>
8 changes: 8 additions & 0 deletions UI/code/css/main.css → frontend/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ mainPoint {
text-align: center;
border: 1px dotted grey;
}

footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
text-align: center;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
3 changes: 2 additions & 1 deletion UI/code/history.php → frontend/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
</thead>
<tbody>
<tr>
<td scope="row"> <?= $record['date'] ?></td>
<?php $date = substr($record['date'], 0, 10); ?>
<td scope="row"> <?= $date ?></td>
<td> <?= $record['remSleep'] ?></td>
<td> <?= $record['heartRate'] ?></td>
<td> <?= $record['hrsSlept'] ?></td>
Expand Down
94 changes: 94 additions & 0 deletions frontend/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
define("ROOTPATH", 'C:/Apache24/htdocs/dreamHacker');
//include ROOTPATH . '/database/db.php';
session_start();

$info = $_SESSION['started'];

if ( ($_SESSION['started'] != 1) ) {

$_SESSION['activate'] = ' <mainPoint id="action" class="w3-hover-green"> Start</mainPoint>';
$_SESSION['liveReading'] = '<a href="liveReading.php"><li> Live Reading</li></a>';

}

else if( $_SESSION['started'] = 1 ){

$_SESSION['activate'] = ' <mainPoint id="action" class="w3-hover-red"> Stop</mainPoint>';
//$_SESSION['liveReading'] = '<a href="liveReading.php"><li> Live Reading</li></a>';


}
?>

<html lang="en">
<head>
<!-- Meta Data -->

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Dream Hacker</title>

<meta name="description" content="Home page for Dream Hacker">

<meta name="author" content="Real Time Group">

<!-- Styler -->
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<style>
li {
display: inline;
margin: 2%;
padding: 2%;
font-size: 36px;
border-radius: 25px;
border: 1px grey solid;

}

ul {
list-style-type: none;
text-align: center;
}
</style>

</head>

<body>
<div class='container' align=center>
<img src="pictures/dreamHacker.png" width="400" height="150">
<hr>
</div>

<div class='row' align=center>
<div class='container'>
<?php echo $_SESSION['activate'] ?>
<br><br>
</div>
</div>


<ul class='w3-ul w3-hoverable'>
<div class='container'>
<?php echo $_SESSION['liveReading'] ?>
<a href='musicChoice.php'><li> Choose Music</li></a>
<a href='history.php'><li> View Histroy</li></a>
</div>
</ul>
<footer>
<div class="container">
<hr>
<h3>What is Dream Hacker</h3>
<p> Here we will explain </p>
<hr>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion UI/code/liveReading.php → frontend/liveReading.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function updateChart() {
</div>
<div class = "col-md-4" align=center>
<h4>Time In bed</h4>
<p id='bed'>4 hours</p>
<p id='bed'><</p>
<hr>
<h4>Song Choosen</h4>
<p id='song'>Vivaldi</p>
Expand All @@ -106,6 +106,7 @@ function updateChart() {
<p id='rem'>Yes</p>
<hr>
<p class='backButton w3-hover-red'> Stop Reading<p>
<p><?php echo $dataPoints ?></p>
</div>
</div>
</div>
Expand Down
83 changes: 66 additions & 17 deletions UI/code/musicChoice.php → frontend/musicChoice.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
<?php
define("ROOTPATH", 'C:/Apache24/htdocs/dreamHacker');
//include ROOTPATH . '/database/db.php';
include ROOTPATH . '/database/db.php';
require ROOTPATH . '/functions/paginator.php';
session_start();
$conn = mysqli_connect($host, $user, $pass, $db);
$query = "SELECT * FROM audio";

//these variables are passed via URL
$limit = ( isset( $_GET['limit'])) ? $_GET['limit'] : 1; // items per page
$page = (isset ($_GET['page'])) ? $_GET['page'] : 1; //starting page
$links = 10;

$paginator = new Paginator ( $mysqli, $query); //__constructor is called
$results = $paginator->getData( $limit, $page);

if ($_SERVER['REQUEST_METHOD'] == 'POST')

{
if (isset($_POST['save'])) { //user logging in



require 'audioPlayer.php';



}
}

?>
<html lang="en">
<head>
Expand Down Expand Up @@ -30,48 +56,71 @@
<div class='container'>
<h1>Dream Hacker <hr></h1>

</div>
</div>
<?php
$y=0;
if ($y == ($results->data)){
echo'
<div class="app-container">
<div class="row">
<h1>No results found</h1>
</div>
<hr>
</div>';
}
else {
for ($p = 0; $p < count($results->data); $p++): ?>
<?php
$record = $results->data[$p];
if ($results->num_rows = 0) {
echo "No recrods Found";
}
?>

<div class="container">
<div class = "row">
<div class = "col">
<h3>Select Music</Select></h3>
<h3>Select Audio</Select></h3>
<small class="form-text- text-muted"> Currently selected audio: <?= $record['song'] ?></small>
<hr>
</div>
<div class = "col-xs-2">
<a href='index.php'><h4 class="backButton w3-hover-red">Back<h4></a>
<hr>
</div>
</div>
</div>
<?php endfor; }?>
<div class="container">
<form>
<div class="form-group">
<form action="audioPlayer.php" method="post">
<div class="form-group">
<div class="row">
<div class="col-md-6">
<!-- Music Choice -->
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="Just The Two Of Us" checked>
<label class="form-check-label" for="exampleRadios2">
Music Name <br>
<audio controls> <source src="audio/Just_The_Two_Of_Us.mp3" type="audio/mp3"></audio>
Just The Two Of Us <br>
<audio controls> <source src="audio/Just The Two Of Us.mp3" type="audio/mp3"></audio>
</label>
<br>
<small id="passwordHelpBlock" class="form-text text-muted"> Descirbe what this song does</small>
</div>
<!-- Music Choice -->
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="Sunny" checked>
<label class="form-check-label" for="exampleRadios2">
Music Name <br>
<audio controls> <source src="audio/Just_The_Two_Of_Us.mp3" type="audio/mp3"></audio>
Sunny <br>
<audio controls> <source src="audio/Sunny.mp3" type="audio/mp3"></audio>
</label>
<br>
<small id="passwordHelpBlock" class="form-text text-muted"> Descirbe what this song does</small>
</div>
<!-- Music Choice -->
<div class="form-check">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="Sunday Vibes" checked>
<label class="form-check-label" for="exampleRadios2">
Music Name <br>
<audio controls> <source src="audio/Just_The_Two_Of_Us.mp3" type="audio/mp3"></audio>
Sunday Vibes <br>
<audio controls> <source src="audio/Sunday Vibes.mp3" type="audio/mp3"></audio>
</label>
</div>
<!-- Music Choice -->
Expand Down Expand Up @@ -121,8 +170,8 @@
</div>
</div>
<div class="container" align=right>
<button type="input" class="btn btn-secondary">Cancel</button>
<button type="submit" class="btn btn-primary">Save</button>
<button type="button" onclick="document.location='index.php'" class="btn btn-secondary">Cancel</button>
<button type="submit" class="btn btn-primary" name="save">Save</button>
</div>
</form>
</div>
Expand Down
Binary file added frontend/pictures/dreamHacker.jpg
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 frontend/pictures/dreamHacker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 23 additions & 17 deletions UI/code/index.php → frontend/sucess.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,32 @@
<h1>Dream Hacker <hr></h1>

</div>
<div class="container">
<h3>What is Dream Hacker</h3>
<p> Here we will explain </p>
<hr>
</div>

<div class='container' align=center>
<div class="card" style="width: 18rem;">
<div class="card-body">
<?php

<div class='container'>
<div class='row' align=center>
<mainPoint id="action" class="w3-hover-green"> Start</mainPoint>
<br><br>
if( isset($_SESSION['message']) AND !empty($_SESSION['message']) ):

echo $_SESSION['message'];

else:

echo 'Error, Please try again';

endif;
?>

<div align=center>
<a href='index.php'><h4 class="backButton w3-hover-green">Home<h4></a>
</div>
</div>
</div>
</div>

<div class='container'>
<ul class='w3-ul w3-hoverable'>
<a href='liveReading.php'><li> Live Reading</li></a>
<a href='musicChoice.php'><li> Choose Music</li></a>
<a href='history.php'><li> View Histroy</li></a>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>