Skip to content

Commit

Permalink
Merge pull request #55 from noramorsi/master
Browse files Browse the repository at this point in the history
Added functionality to create a new admin
  • Loading branch information
kaimihata authored Jan 27, 2021
2 parents c53a054 + 6a5febd commit ed62d56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
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);
}
}

0 comments on commit ed62d56

Please sign in to comment.