Skip to content

Commit

Permalink
pages added
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljainjain committed Oct 17, 2019
1 parent 5500cb9 commit c04f125
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 16 deletions.
19 changes: 11 additions & 8 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,37 @@ app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.get('/', function(req, res, next) {
res.render('index');
res.render('pro');
});

//it sends complete block chain
app.get('/blocks', (req, res)=>{
res.json(bc.chain);
res.render("block-chain", { msg: bc.chain});
});

//get latest data from the blockchain
app.get("/block-data", (req, res)=>{
res.json({data: bc.chain[bc.chain.length - 1]});
res.render("block", { msg: bc.chain[bc.chain.length - 1]});
});

//user query
app.get("/query", (req, res)=>{
console.log(req.query);
let msg = null;
let msg = null;
let sensor = null;
if (req.query.location === "x"){
msg = ( fb.data.dht.temperature > 30) ? "OK" : "NOT ADVISED";
sensor = "dht";
msg = ( fb.data.dht.temperature > 20) ? "OK" : "NOT Advisable";
}else if (req.query.location === "y"){
msg = ( fb.data.smoke.value < 700 ) ? "OK" : "NOT ADVISED";
sensor = "smoke";
msg = ( fb.data.smoke.value < 700 ) ? "OK" : "NOT Advisable";
}
res.json({ msg });
res.render("feedback", { msg, feedback: true , sensor });
});

app.post("/feedback", (req, res)=>{
const { sensor, trust } = req.body;
res.json({ msg: "Thank for your valuable feedback."});
res.render("msg", { msg: "Thank for your valuable feedback."});
if (sensor === "dht"){
if (trust === "false")
(fb.data.dht.trust > 1) ? (fb.data.dht.trust--):null;
Expand Down
51 changes: 51 additions & 0 deletions app/public/css/msg.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
body{
background-color: #29ABE2;
font-family: 'Raleway', sans-serif;
margin-top: 5px;
}

label{
font-weight: 700;
text-decoration: underline;
}

input{
margin-left: 1.5rem;
}

.message{
text-align: center;
height: 12rem;
width: 50rem;
margin: 0 auto;
padding: 2rem 5rem;
background-color: white;
border: 2px solid black;
border-radius: 10px;
font-weight: 700;
}

.message1{
height: 15rem;
width: 50rem;
margin: 2rem auto;
padding: 2rem 3rem;
background-color: white;
border: 2px solid black;
border-radius: 10px;
}

.header{
color: white;
width: 60%;
height: 100px;
margin: 0.5rem auto;
padding-top: 50px ;
text-align: center;
}

.head{
font-size: 30px;
font-weight: 600;
margin-bottom: 50px;
}
61 changes: 61 additions & 0 deletions app/public/css/pro.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
form{
padding: 20px 0px 5px 40px;
text-align: left;
}

input{
border: none;
outline: none;
background-color: inherit;
}

label{
font-weight: 700;
}

.body{
background-color: #29ABE2;
font-family: 'Raleway', sans-serif;
margin-top: 0;
}

.header{
color: white;
width: 60%;
height: 100px;
margin: 0.5rem auto;
padding-top: 50px ;
text-align: center;
}

.head{
font-size: 30px;
font-weight: 600;
margin-bottom: 50px;
}

.form{
background-color: white;
border: 2px solid black;
border-radius: 5px;
height: 20rem;
width: 20rem;
margin: 10% auto;
}

.form-group{
width: 80%;
margin: 0;
}

.input1 {
outline: none;
border: none;
height: 30px;
width: 100%;
border-bottom: 1px solid black;
}

.btn-light{
outline: none;
}
8 changes: 0 additions & 8 deletions app/public/stylesheets/style.css

This file was deleted.

16 changes: 16 additions & 0 deletions app/views/block-chain.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>VSRN</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/msg.css">
</head>
<body>
<div class="header container">
<span class="head">Result</span><br><br>
</div>
<div class="message" style="font-size: 15;">
<%= (msg) %>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions app/views/block.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>VSRN</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/msg.css">
</head>
<body>
<div class="header container">
<span class="head">Result</span><br><br>
</div>
<div class="message" style="font-size: 15;">
<%= (msg) %>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions app/views/feedback.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<html>
<head>
<title>VSRN</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/msg.css">
<link rel="stylesheet" type="text/css" href="/css/pro.css">
</head>
<body>
<div class="header container">
<span class="head">Result</span><br><br>
</div>
<div class="message">
<h1><%= (msg) %></h1>
<a href="/"><button style="margin: 5px;border: none;text-align: center;background-color: blanchedalmond;">Go to Home</button></a>
</div>
<% if (feedback){ %>
<form action="/feedback" method="post">
<div class="message1">
<input type="text" name="sensor" hidden="true" disabled="true" value="<%= (sensor) %>">
<label>Feedback</label><br><br>
Rate the accuracy of the obtained result.<br><br>
<input type="radio" name="trust" value="false">1
<input type="radio" name="trust" value="false">2
<input type="radio" name="trust" value="true">3
<input type="radio" name="trust" value="true">4
<input type="radio" name="trust" value="true">5
<br>
<button type="submit" class="bt" style="margin: 5px;border: none;text-align: center;background-color: blanchedalmond;">Submit</button>
</div>
</form>
<% } %>
</body>
</html>
16 changes: 16 additions & 0 deletions app/views/msg.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<head>
<title>VSRN</title>
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/msg.css">
</head>
<body>
<div class="header container">
<span class="head">Result</span><br><br>
</div>
<div class="message">
<h1><%= (msg) %></h1>
</div>
</body>
</html>
42 changes: 42 additions & 0 deletions app/views/pro.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<head>
<title>VSRN BLOCKCHAIN</title>
</head>
<link rel="stylesheet" type="text/css" href="/css/pro.css">
<link rel="stylesheet" type="text/css" href="/css/msg.css">
<link href="https://fonts.googleapis.com/css?family=Raleway&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<body class="body">
<div class="header container">
<span class="head">VSRN - IoT BlockChain</span><br><br>
Enter your query here.
</div>
<div class="form">
<form action="/query">
<div class="form-group">
<label for="name">NAME</label><br>
<input type="name" class="input1" id="email" placeholder="Enter your name">
</div>
<!--div-- class="form-group">
<label for="password">Password</label><br>
<input type="password" class="input1" id="password" placeholder="Enter Password">
</!--div-->
<div class="dropdown">
<label for="dropdownMenuButton">Location</label><br>
<select class="btn dropdown-toggle" name="location" id="dropdownMenuButton" data-toggle="dropdown">
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<option class="dropdown-item">Select Location</option>
<option value="x" class="dropdown-item">X</option>
<option value="y" class="dropdown-item">Y</option>
</div>
</select>
</div>
<br>
<input class="bt" type="submit">&nbsp&nbsp
<!--input class="bt" type="reset"-->
</form>
<a href="/blocks"><button class="bt" style="margin: 5px;border: none;text-align: center;background-color: blanchedalmond;">Get the VSRN - IoT BlockChain</button></a>
<a href="/block-data"><button class="bt" style="margin: 5px;border: none;text-align: center;background-color: blanchedalmond;">Last Mined Block</button></a>
</div>
</body>
</html>

0 comments on commit c04f125

Please sign in to comment.