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

Added adminAccount

parent 8c852567
Pipeline #1 skipped
<!DOCTYPE html>
<html>
<html lang="en">
<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/rolling.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 type="text/javascript" src="js/app.js"></script>
</head>
<body>
<header>
<nav>
<a href="index.html"><img src="img/logo.png" width="40px"></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>
<header class="header">
<a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<nav class="header__nav" id="navigation">
<a href=""></a>
</nav>
</header>
<div class="wrapper">
<div class="title">
<img src="img/scheduling.png" width="40px">
<h1>Create Admin Account</h1>
<main class="container">
<div class="login card">
<form class="login__form">
<h1 class="login__header">SIGN UP</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 class="card">
<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>
</main>
</body>
</html>
......@@ -21,7 +21,7 @@
</nav>
</header>
<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>
<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>
......
......@@ -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>
<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">
<form class="createTrip__form">
<h1 class="createTrip__header">Create Trip</h1>
......
<!DOCTYPE html>
<html lang="en">
<head>
<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/rolling.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script src="js/parse-1.6.7.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<header class="header">
<a href="header__logo"></a>
<nav class="header__nav" id="navigation">
<a href=""></a>
<a href=""></a>
</nav>
</header>
<main class="container">
<div class="login card">
<form class="login__form">
<h1 class="login__header">LOG-IN</h1>
<label class="fa fa-user fa-2x login__uname" >
<input type="text" id="login_uname" placeholder="Username" autofocus></label>
<label class="fa fa-unlock fa-2x login__pass">
<input type="password" id="login_pass" placeholder="Password"></label>
<label class="login__submit" >
<button id="login__btn" onclick="app.login(event)">Login</button>
</label>
</form>
</div>
</main>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<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/rolling.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script src="js/parse-1.6.7.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body>
<header class="header">
<a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<nav class="header__nav" id="navigation">
<a href=""></a>
<a href=""></a>
</nav>
</header>
<main class="container">
<h1 id="welcomeMessage"></h1>
<div class="actionbox card" id="tripManagement" style="display:none;">
<!-- This is not available when user is a Clerk user -->
<h1 class="actionbox__header">Trips Management</h1>
<h2>Trips contain information on Schedules and Bus Assignments</h2>
<ul class="actionbox__list">
<li class="actionbox__listitem"><a href="createTrip.html">Create Trips</a></li>
<li class="actionbox__listitem"><a href="viewTrip.html">View All Trips</a></li>
</ul>
</div>
<div class="actionbox card" id="scheduleManagement" style="display:none;">
<!-- This is not available when user is a Clerk user -->
<h1 class="actionbox__header">Company Management</h1>
<h2>Add Schedule templates and buses</h2>
<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 @@
<header class="header">
<a href="index.html" class="header__logo"><img src="img/logo.png" width="40px"></a>
<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>
</nav>
</header>
<main class="container">
<h1 id="welcomeMessage"></h1>
<div class="actionbox card" id="tripManagement" style="display:none;">
<!-- This is not available when user is a Clerk user -->
<h1 class="actionbox__header">Trips Management</h1>
<h2>Trips contain information on Schedules and Bus Assignments</h2>
<ul class="actionbox__list">
<li class="actionbox__listitem"><a href="createTrip.html">Create Trips</a></li>
<li class="actionbox__listitem"><a href="viewTrip.html">View All Trips</a></li>
</ul>
</div>
<div class="actionbox card" id="scheduleManagement" style="display:none;">
<!-- This is not available when user is a Clerk user -->
<h1 class="actionbox__header">Company Management</h1>
<h2>Add Schedule templates and buses</h2>
<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 class="login card">
<form class="login__form">
<h1 class="login__header">LOG-IN</h1>
<label class="fa fa-user fa-2x login__uname" >
<input type="text" id="login_uname" placeholder="Username" autofocus></label>
<label class="fa fa-unlock fa-2x login__pass">
<input type="password" id="login_pass" placeholder="Password"></label>
<label class="login__submit" >
<button id="login__btn" onclick="app.login(event)">Login</button>
</label>
</form>
<div id="loginError" style="display:none;color:red; height: 50px; width: 100%;">
<p>Wrong Credentials. Try Again</p>
</div>
</div>
<!-- <button onclick="app.searchRole()">Print in Console</button> -->
</main>
</body>
</html>
......@@ -75,7 +75,7 @@ var app = {
Parse.User.logIn(uname, pass, {
success: function(user){
console.log("success");
window.location = "index.html";
window.location = "home.html";
},
error: function(user, error){
console.log("Error " + error.code + " " + error.message);
......@@ -107,9 +107,11 @@ var app = {
Parse.User.logIn(uname, pass, {
success: function(user){
console.log("success");
window.location = "index.html";
window.location = "home.html";
},
error: function(user, error){
var errorDiv = document.getElementById("loginError");
errorDiv.style.display = "block";
console.log("Error " + error.code + " " + error.message);
}
});
......@@ -124,7 +126,7 @@ var app = {
logout : function(event) {
event.preventDefault();
Parse.User.logOut();
location.href="login.html";
location.href="index.html";
var parent = document.getElementById('navigation');
var btn = document.getElementById("logout");
parent.removeChild(btn);
......@@ -488,19 +490,16 @@ var app = {
}
}, function(err){ console.log("Error " + err.code + ": " + err.message); });
},
generateOptions : function( busCompany, parentNodeID, childClass, parseObject, objectKey ){
var objQuery = new Parse.Query(parseObject);
var busQuery = new Parse.Query("Bus_Company");
busQuery.equalTo('objectId', busCompany);
objQuery.matchesQuery("busCompany", busQuery);
objQuery.find({
generateSelectOptions : function( parseObjectType, parseQueryParameter, parseQueryValue, returnValueKey, selectNodeID, childClass ){
var objQuery = new Parse.Query(parseObjectType);
if ( parseObjectType != "Role" ){ objQuery.equalTo(parseQueryParameter, parseQueryValue); }
objectQuery.find({
success: function(res){
for (var i = res.length - 1; i >= 0; i--) {
var content = res[i].get(objectKey);
helper.appendUsingID(parentNodeID, "option", "", content);
};
for( var i = 0; i <= res.length; res++ ){
helper.appendUsingID(selectNodeID, "option", childClass, res[i].returnValueKey );
}
},
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 ){
......@@ -530,14 +529,14 @@ window.onload = function(){
var currLoc = location.href;
var currUserAffiliation;
if ( currLoc.indexOf("index.html") > -1 ||
if ( currLoc.indexOf("home.html") > -1 ||
currLoc.indexOf("createTrip.html") > -1 ||
currLoc.indexOf("viewTrip.html") > -1 ||
currLoc.indexOf("companyMgmt.html") > -1 ||
currLoc.indexOf("viewSchedules.html") > -1 ||
currLoc.indexOf("reload.html") > -1 ) {
if( currentUser == null ){
location.href = "login.html";
location.href = "index.html";
} else {
var parent = document.getElementById("navigation");
var outBtn = document.createElement("button");
......@@ -548,7 +547,7 @@ window.onload = function(){
}
}
if( currentUser.get("affiliation") != null ) {
if( currentUser != null ) {
currUserAffiliation = currentUser.get("affiliation").id;
}
console.log(currUserAffiliation);
......@@ -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
var AdminBoolean;
if ( currLoc.indexOf("index.html") > -1 ){
if ( currLoc.indexOf("home.html") > -1 ){
var queryRole = new Parse.Query(Parse.Role);
queryRole.equalTo('name', 'Administrator');
queryRole.first().then(
......@@ -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 @@
<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>
<p><a href="home.html"><span class="fa fa-arrow-left fa-2x"></span>&nbsp;Go back</a></p>
<div class="reload card">
<form class="reload__form">
<h1>Reload User</h1>
......
......@@ -21,7 +21,7 @@
</nav>
</header>
<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>
<form class="tripSearch">
<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