Commit e42eb8bd authored by Ian De La Cruz's avatar Ian De La Cruz

Added adminAccount

parent 8c852567
Pipeline #1 skipped
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>uBus | Bus Schedules</title> <title>uBus | Admin System</title>
<meta charset="utf-8">
<meta name="description" content="uBus Ticket Reservation System administrator tools.">
<link rel="icon" type="image/x-icon" href="img/favicon.ico">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/rolling.css">
<link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js"></script> <script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script src="js/parse-1.6.7.js"></script> <script src="js/parse-1.6.7.js"></script>
<script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/app.js"></script>
</head> </head>
<body> <body>
<header> <header class="header">
<nav> <a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<a href="index.html"><img src="img/logo.png" width="40px"></a> <nav class="header__nav" id="navigation">
<a href=""></a>
<a href="javascript:void(0);"><img src="img/add.png" width="40px"></a>
<a href="javascript:void(0);"><img src="img/search.png" width="40px"></a>
</nav> </nav>
</header> </header>
<main class="container">
<div class="wrapper"> <div class="login card">
<div class="title"> <form class="login__form">
<img src="img/scheduling.png" width="40px"> <h1 class="login__header">SIGN UP</h1>
<h1>Create Admin Account</h1> <label class="fa fa-user fa-2x login__uname" >
<input type="text" id="signup_firstname" placeholder="First Name" autofocus></label>
<label class="fa fa-user fa-2x login__uname" >
<input type="text" id="signup_lastname" placeholder="Last Name" autofocus></label>
<label class="fa fa-user fa-2x login__uname" >
<input type="text" id="signup_uname" placeholder="Username" autofocus></label>
<label class="fa fa-unlock fa-2x login__pass">
<input type="password" id="signup_pass" placeholder="Password"></label>
<label class="fa fa-unlock fa-2x login__pass">
<select id="signup_busLiner">
<option>--</option>
</select>
</label>
<label class="fa fa-unlock fa-2x login__pass">
<select id="signup_position">
<option>--</option>
</select>
</label>
<label class="login__submit" >
<button id="signup__btn">Sign Up</button>
</label>
</form>
</div> </div>
<div class="card"> </main>
<div class="row">
<form method="post" class="card_adminAccount" id="create_adminAccount" style="display:block; margin:0 auto;">
<fieldset>
<label for="addUname"><i class="fa fa-2x fa-user"></i>
<input type="text" id="addUname" placeholder="Username"></label>
</fieldset>
<fieldset>
<label for="addPassword"><i class="fa fa-2x fa-key"></i>
<input type="password" id="addPassword" placeholder="Password">
</label>
</fieldset>
<fieldset>
<label for="addEmail"><i class="fa fa-2x fa-envelope"></i>
<input type="text" id="addEmail" placeholder="admin@example.com">
</label>
</fieldset>
<fieldset>
<label for="addBusCompany"><i class="fa fa-2x fa-bus"></i>
<input type="text" id="addBusCompany" placeholder="Example Lines">
</label>
</fieldset>
<fieldset style="margin-top: 40px;">
<button onclick="adminSignIn()">Sign Up</button>
</fieldset>
</form>
</div>
</div>
<div class="schedules"></div>
</div>
<script type="text/javascript" src="js/app.js"></script>
</body> </body>
</html> </html>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</nav> </nav>
</header> </header>
<main class="container"> <main class="container">
<p><a href="index.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p> <p><a href="home.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p>
<h1>Company Management</h1> <h1>Company Management</h1>
<div id="loader" style="position: fixed; z-index: 100; width: 100%; height: 100%; display: block; background-color: gray;top: 80px;left: 0;-webkit-opacity: 0.5;"> <div id="loader" style="position: fixed; z-index: 100; width: 100%; height: 100%; display: block; background-color: gray;top: 80px;left: 0;-webkit-opacity: 0.5;">
<div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div> <div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div>
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div> <div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div>
</div> </div>
<p id="successMessage" style="display:none; color: white; font-weight: 500; background-color:darkgreen; padding: 20px;">Trip created successfully!</p> <p id="successMessage" style="display:none; color: white; font-weight: 500; background-color:darkgreen; padding: 20px;">Trip created successfully!</p>
<p><a href="index.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p> <p><a href="home.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p>
<div class="createTrip card"> <div class="createTrip card">
<form class="createTrip__form"> <form class="createTrip__form">
<h1 class="createTrip__header">Create Trip</h1> <h1 class="createTrip__header">Create Trip</h1>
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>uBus | Admin System</title> <title>uBus | Admin System</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="description" content="uBus Ticket Reservation System administrator tools."> <meta name="description" content="uBus Ticket Reservation System administrator tools.">
<link rel="icon" type="image/x-icon" href="img/favicon.ico"> <link rel="icon" type="image/x-icon" href="img/favicon.ico">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/rolling.css"> <link rel="stylesheet" type="text/css" href="css/rolling.css">
<link rel="stylesheet" type="text/css" href="css/style.css"> <link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-2.1.4.js"></script> <script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script src="js/parse-1.6.7.js"></script> <script src="js/parse-1.6.7.js"></script>
<script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/app.js"></script>
</head> </head>
<body> <body>
<header class="header"> <header class="header">
<a href="header__logo"></a> <a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<nav class="header__nav" id="navigation"> <nav class="header__nav" id="navigation">
<a href=""></a> <a href=""></a>
<a href=""></a> <a href=""></a>
</nav> </nav>
</header> </header>
<main class="container"> <main class="container">
<div class="login card"> <h1 id="welcomeMessage"></h1>
<form class="login__form"> <div class="actionbox card" id="tripManagement" style="display:none;">
<h1 class="login__header">LOG-IN</h1> <!-- This is not available when user is a Clerk user -->
<label class="fa fa-user fa-2x login__uname" > <h1 class="actionbox__header">Trips Management</h1>
<input type="text" id="login_uname" placeholder="Username" autofocus></label> <h2>Trips contain information on Schedules and Bus Assignments</h2>
<label class="fa fa-unlock fa-2x login__pass"> <ul class="actionbox__list">
<input type="password" id="login_pass" placeholder="Password"></label> <li class="actionbox__listitem"><a href="createTrip.html">Create Trips</a></li>
<label class="login__submit" > <li class="actionbox__listitem"><a href="viewTrip.html">View All Trips</a></li>
<button id="login__btn" onclick="app.login(event)">Login</button> </ul>
</label> </div>
</form> <div class="actionbox card" id="scheduleManagement" style="display:none;">
</div> <!-- This is not available when user is a Clerk user -->
</main> <h1 class="actionbox__header">Company Management</h1>
</body> <h2>Add Schedule templates and buses</h2>
</html> <ul class="actionbox__list">
<li class="actionbox__listitem"><a href="companyMgmt.html">Company Management</a></li>
</ul>
</div>
<div class="actionbox card" id="customerManagement">
<h1 class="actionbox__header">Customer Management</h1>
<ul class="actionbox__list">
<li class="actionbox__listitem"><a href="reload.html">Reload User Credits</a></li>
</ul>
</div>
<!-- <button onclick="app.searchRole()">Print in Console</button> -->
</main>
</body>
</html>
...@@ -16,37 +16,26 @@ ...@@ -16,37 +16,26 @@
<header class="header"> <header class="header">
<a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a> <a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<nav class="header__nav" id="navigation"> <nav class="header__nav" id="navigation">
<a href=""></a> <a href="adminAccount.html"><span class="fa fa-user-plus fa-2x" style="color:white;"></span></a>
<a href=""></a> <a href=""></a>
</nav> </nav>
</header> </header>
<main class="container"> <main class="container">
<h1 id="welcomeMessage"></h1> <div class="login card">
<div class="actionbox card" id="tripManagement" style="display:none;"> <form class="login__form">
<!-- This is not available when user is a Clerk user --> <h1 class="login__header">LOG-IN</h1>
<h1 class="actionbox__header">Trips Management</h1> <label class="fa fa-user fa-2x login__uname" >
<h2>Trips contain information on Schedules and Bus Assignments</h2> <input type="text" id="login_uname" placeholder="Username" autofocus></label>
<ul class="actionbox__list"> <label class="fa fa-unlock fa-2x login__pass">
<li class="actionbox__listitem"><a href="createTrip.html">Create Trips</a></li> <input type="password" id="login_pass" placeholder="Password"></label>
<li class="actionbox__listitem"><a href="viewTrip.html">View All Trips</a></li> <label class="login__submit" >
</ul> <button id="login__btn" onclick="app.login(event)">Login</button>
</div> </label>
<div class="actionbox card" id="scheduleManagement" style="display:none;"> </form>
<!-- This is not available when user is a Clerk user --> <div id="loginError" style="display:none;color:red; height: 50px; width: 100%;">
<h1 class="actionbox__header">Company Management</h1> <p>Wrong Credentials. Try Again</p>
<h2>Add Schedule templates and buses</h2> </div>
<ul class="actionbox__list">
<li class="actionbox__listitem"><a href="companyMgmt.html">Company Management</a></li>
</ul>
</div>
<div class="actionbox card" id="customerManagement">
<h1 class="actionbox__header">Customer Management</h1>
<ul class="actionbox__list">
<li class="actionbox__listitem"><a href="reload.html">Reload User Credits</a></li>
</ul>
</div> </div>
<!-- <button onclick="app.searchRole()">Print in Console</button> -->
</main> </main>
</body> </body>
</html> </html>
...@@ -75,7 +75,7 @@ var app = { ...@@ -75,7 +75,7 @@ var app = {
Parse.User.logIn(uname, pass, { Parse.User.logIn(uname, pass, {
success: function(user){ success: function(user){
console.log("success"); console.log("success");
window.location = "index.html"; window.location = "home.html";
}, },
error: function(user, error){ error: function(user, error){
console.log("Error " + error.code + " " + error.message); console.log("Error " + error.code + " " + error.message);
...@@ -107,9 +107,11 @@ var app = { ...@@ -107,9 +107,11 @@ var app = {
Parse.User.logIn(uname, pass, { Parse.User.logIn(uname, pass, {
success: function(user){ success: function(user){
console.log("success"); console.log("success");
window.location = "index.html"; window.location = "home.html";
}, },
error: function(user, error){ error: function(user, error){
var errorDiv = document.getElementById("loginError");
errorDiv.style.display = "block";
console.log("Error " + error.code + " " + error.message); console.log("Error " + error.code + " " + error.message);
} }
}); });
...@@ -124,7 +126,7 @@ var app = { ...@@ -124,7 +126,7 @@ var app = {
logout : function(event) { logout : function(event) {
event.preventDefault(); event.preventDefault();
Parse.User.logOut(); Parse.User.logOut();
location.href="login.html"; location.href="index.html";
var parent = document.getElementById('navigation'); var parent = document.getElementById('navigation');
var btn = document.getElementById("logout"); var btn = document.getElementById("logout");
parent.removeChild(btn); parent.removeChild(btn);
...@@ -488,19 +490,16 @@ var app = { ...@@ -488,19 +490,16 @@ var app = {
} }
}, function(err){ console.log("Error " + err.code + ": " + err.message); }); }, function(err){ console.log("Error " + err.code + ": " + err.message); });
}, },
generateOptions : function( busCompany, parentNodeID, childClass, parseObject, objectKey ){ generateSelectOptions : function( parseObjectType, parseQueryParameter, parseQueryValue, returnValueKey, selectNodeID, childClass ){
var objQuery = new Parse.Query(parseObject); var objQuery = new Parse.Query(parseObjectType);
var busQuery = new Parse.Query("Bus_Company"); if ( parseObjectType != "Role" ){ objQuery.equalTo(parseQueryParameter, parseQueryValue); }
busQuery.equalTo('objectId', busCompany); objectQuery.find({
objQuery.matchesQuery("busCompany", busQuery);
objQuery.find({
success: function(res){ success: function(res){
for (var i = res.length - 1; i >= 0; i--) { for( var i = 0; i <= res.length; res++ ){
var content = res[i].get(objectKey); helper.appendUsingID(selectNodeID, "option", childClass, res[i].returnValueKey );
helper.appendUsingID(parentNodeID, "option", "", content); }
};
}, },
error: function(err){ console.log("Error " + err.code + " : " + err.message ) } error: function(err){ consle.log("Error " + err.code + " : " + err.message ); }
}); });
}, },
addBus : function( currUserAffiliation, plateNumber, busType, seatNumber, seatCost ){ addBus : function( currUserAffiliation, plateNumber, busType, seatNumber, seatCost ){
...@@ -530,14 +529,14 @@ window.onload = function(){ ...@@ -530,14 +529,14 @@ window.onload = function(){
var currLoc = location.href; var currLoc = location.href;
var currUserAffiliation; var currUserAffiliation;
if ( currLoc.indexOf("index.html") > -1 || if ( currLoc.indexOf("home.html") > -1 ||
currLoc.indexOf("createTrip.html") > -1 || currLoc.indexOf("createTrip.html") > -1 ||
currLoc.indexOf("viewTrip.html") > -1 || currLoc.indexOf("viewTrip.html") > -1 ||
currLoc.indexOf("companyMgmt.html") > -1 || currLoc.indexOf("companyMgmt.html") > -1 ||
currLoc.indexOf("viewSchedules.html") > -1 || currLoc.indexOf("viewSchedules.html") > -1 ||
currLoc.indexOf("reload.html") > -1 ) { currLoc.indexOf("reload.html") > -1 ) {
if( currentUser == null ){ if( currentUser == null ){
location.href = "login.html"; location.href = "index.html";
} else { } else {
var parent = document.getElementById("navigation"); var parent = document.getElementById("navigation");
var outBtn = document.createElement("button"); var outBtn = document.createElement("button");
...@@ -548,7 +547,7 @@ window.onload = function(){ ...@@ -548,7 +547,7 @@ window.onload = function(){
} }
} }
if( currentUser.get("affiliation") != null ) { if( currentUser != null ) {
currUserAffiliation = currentUser.get("affiliation").id; currUserAffiliation = currentUser.get("affiliation").id;
} }
console.log(currUserAffiliation); console.log(currUserAffiliation);
...@@ -557,7 +556,7 @@ window.onload = function(){ ...@@ -557,7 +556,7 @@ window.onload = function(){
//set role variable → https://www.parse.com/questions/how-to-check-if-a-user-has-a-specific-role //set role variable → https://www.parse.com/questions/how-to-check-if-a-user-has-a-specific-role
var AdminBoolean; var AdminBoolean;
if ( currLoc.indexOf("index.html") > -1 ){ if ( currLoc.indexOf("home.html") > -1 ){
var queryRole = new Parse.Query(Parse.Role); var queryRole = new Parse.Query(Parse.Role);
queryRole.equalTo('name', 'Administrator'); queryRole.equalTo('name', 'Administrator');
queryRole.first().then( queryRole.first().then(
...@@ -929,4 +928,79 @@ window.onload = function(){ ...@@ -929,4 +928,79 @@ window.onload = function(){
// }) // })
} }
if (currLoc.indexOf("adminAccount.html") > -1 ) {
var roleSelect = document.getElementById("signup_position");
var companySelect = document.getElementById("signup_busLiner");
var signUp = document.getElementById("signup__btn");
var roleName, busCompany;
var roleQuery = new Parse.Query("_Role");
roleQuery.find({
success: function(res){
for(var i = 0; i < res.length; i++){
console.log(res[i].get("name"));
helper.appendUsingID("signup_position", "option", "", res[i].get("name"));
}
},
error: function(err){ console.log("Error " + err.code+ " : " + err.message) }
});
var companyQuery = new Parse.Query("Bus_Company");
companyQuery.find({
success: function(res){
for( var i = 0; i < res.length; i++ ){
console.log(res[i]);
helper.appendUsingID("signup_busLiner", "option", "", res[i].get("companyName"))
}
},
error: function(err){ console.log("Error " + err.code + " : " + err.message ); }
});
roleSelect.onchange = function(){
roleName = helper.getSelectedOption("signup_position");
}
companySelect.onchange = function(){
busCompany = helper.getSelectedOption("signup_busLiner");
}
signUp.addEventListener("click", function(event){
event.preventDefault();
var roleEdit = new Parse.Query("_Role");
var busEdit = new Parse.Query("Bus_Company");
var busID;
var username = document.getElementById("signup_uname").value,
password = document.getElementById("signup_pass").value,
firstname = document.getElementById("signup_firstname").value,
lastname = document.getElementById("signup_lastname").value,
affiliationPointer;
busEdit.equalTo("companyName", busCompany);
busEdit.first()
.then(function(res){
busID = res.id;
affiliationPointer = helper.pointerTo(busID, "Bus_Company");
console.log(res);
roleEdit.equalTo("name", roleName);
return roleEdit.first();
})
.then(function(res){
var newRole = res;
var newUser = new Parse.User;
newUser.set("username", username);
newUser.set("password", password);
newUser.set("firstName", firstname);
newUser.set("lastName", lastname);
newUser.set("affiliation", affiliationPointer);
newUser.signUp(null, {
success: function(user) {
console.log(newRole);
newRole.getUsers().add(user);
newRole.save();
location.href="home.html";
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
console.log("Error: " + error.code + " : " + error.message);
}
});
})
})
};
} }
\ No newline at end of file
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<div id="loader" style="position: fixed; z-index: 100; width: 100%; height: 100%; display: none; background-color: gray;top: 80px;left: 0;-webkit-opacity: 0.5;"> <div id="loader" style="position: fixed; z-index: 100; width: 100%; height: 100%; display: none; background-color: gray;top: 80px;left: 0;-webkit-opacity: 0.5;">
<div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div> <div class='uil-rolling-css' style='margin:20vh auto; -webkit-transform:scale(0.6);'><div><div></div><div></div></div></div>
</div> </div>
<p><a href="home.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p>
<div class="reload card"> <div class="reload card">
<form class="reload__form"> <form class="reload__form">
<h1>Reload User</h1> <h1>Reload User</h1>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</nav> </nav>
</header> </header>
<main class="container"> <main class="container">
<p><a href="index.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p> <p><a href="home.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p>
<h2>Search for Trips</h2> <h2>Search for Trips</h2>
<form class="tripSearch"> <form class="tripSearch">
<label> <label>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment