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

Added functionality to create a new admin #55

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions robotfrontend/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ <h1 class="display-4">Robot Setup</h1>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col">
<div class="card">
<div class="card-header" id="newAdmin">
<button class="btn btn-link btn-lg" type="button" data-toggle="collapse" data-target="#collapseNewAdmin" aria-expanded="true" aria-controls="collapseNewAdmin">Add new admin</button>
</div>
<div class="collapse collapsed" aria-labelledby="newAdmin" id="collapseNewAdmin">
<div class="card-body">
<div class="mb-2 mb-1" id="newAdmin">New administrator's email:
<input class="large-text" type="text" name="adminEmail" id="adminEmail">
<button class="btn btn-success" onclick="addNewAdmin()">Add New Admin</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col">
<div class="card">
Expand Down
23 changes: 11 additions & 12 deletions robotfrontend/scripts/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,14 @@ function deleteRobot(index) {
}
}

// No write permissions for admininstrator sub-branch so removing this functionality
// function addNewAdmin() {
// if (admins != null) {
// let nAdmins = admins.length;
// let newAdminIndex = Number(Object.keys(admins)[nAdmins-1]) + 1;
// let adminEmail = document.getElementById('adminEmail').value;
// let dbRef = firebase.database().ref("/administrators/");
// let updates = {};
// updates[newAdminIndex] = adminEmail;
// dbRef.update(updates);
// }
// }
function addNewAdmin() {
if (admins != null) {
let nAdmins = admins.length;
let newAdminIndex = Number(Object.keys(admins)[nAdmins-1]) + 1;
let adminEmail = document.getElementById('adminEmail').value;
let dbRef = firebase.database().ref("/administrators/");
let updates = {};
updates[newAdminIndex] = adminEmail;
dbRef.update(updates);
}
}