Added ability for admins to add others easily #3

Merged
NokomisJROTC merged 1 commits from master into master 2019-09-16 11:38:08 -09:00
2 changed files with 151 additions and 94 deletions
+34
View File
@@ -1,5 +1,39 @@
function deleteAdmin(email) {
console.log(email)
var path = firebase.database().ref("users/"+email)
path.remove();
document.getElementById("emails").innerHTML = ''
pullAllEmails();
}
function addAdmin() {
var s = document.getElementById("email-input").value
sendData("users/"+s.replace("@","|").replace(".",","),true)
document.getElementById("emails").innerHTML = ''
pullAllEmails();
}
function pullAllEmails() {
database = firebase.database().ref("users");
database.once('value', function(snapshot) {
snapshot.forEach(function(child) {
firebase.database().ref("users/" + child["key"]).on('value', function(data) {
var data1 = data.val();
var unfiltered = data.key
var email = unfiltered.replace("|","@").replace(",",".")
var a = document.createElement("tr");
a.innerHTML = "<tr> <td class='mdl-data-table__cell--non-numeric no-under' id='email-close'><i class='material-icons clickable' onclick='deleteAdmin(\""+unfiltered+"\");'>delete</i></td> <td class='mdl-data-table__cell--non-numeric' id='sign-date'>"+email+"</td></tr>"
document.getElementById("emails").appendChild(a)
componentHandler.upgradeAllRegistered();
});
});
});
}
function externalOnLoad() {
verify();
pullAllEmails();
timeChange();
updatePage();
readData("company", function(data) {
+117 -94
View File
@@ -71,121 +71,144 @@
<div id="page-content" class="page-content" style="display: none">
<table>
<tr>
<td>
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
Add Event
</div>
<div class="mdl-card__actions">
Event Type:
<select id="event" onchange="updatePage()">
<td>
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
Add Event
</div>
<div class="mdl-card__actions">
Event Type:
<select id="event" onchange="updatePage()">
<option value="FOR" selected>Formation</option>
<option value="UNI">Uniform Only</option>
<option value="CUS">Custom Message</option>
</select><br>
<div id="uniformbox">
Uniform Type:
<select id="uniformtype" onchange="updatePage()">
<div id="uniformbox">
Uniform Type:
<select id="uniformtype" onchange="updatePage()">
<option value="ACU" selected>ACU</option>
<option value="ASU (Class A)">ASU (Class A)</option>
<option value="Class B">ASU (No Tie / Class B)</option>
<option value="T-Shirt" >T-Shirt</option>
<option value="Civilian Clothes">Civilian Clothes</option>
</select><br></div>
<div id="datebox">
Date:
<input type="date" id="date"><br></div>
<div id="timebox">
Time of Formation:
<select id="time" onchange="timeChange()">
<div id="datebox">
Date:
<input type="date" id="date"><br></div>
<div id="timebox">
Time of Formation:
<select id="time" onchange="timeChange()">
<option value="RTI" selected>RTI</option>
<option value="Custom">Custom</option>
</select>
<br><span id="customtimebox">Custom Time Value:
<br><span id="customtimebox">Custom Time Value:
<input type="text" id="customtime"></span>
</div>
<div id="locationbox">
Location (i.e Gym, etc):
<input type="text" id="location"><br></div>
<div id="messagebox">
Custom Message:
<input type="text" id="custommessage"><br></div>
<input type="button" value="Update" onclick="eventSend()">
<input type="button" value="Preview" onclick="updatePage()">
</div>
</div>
</td>
<td>
<div class="calendar mdl-card mdl-shadow--2dp">
<div class="mdl-card__title mdl-card--expand">
<h3><span id="event_type">Loading...</span></h3>
<h4><span id="event_uniform">Loading...</span></h4>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">access_time</i><span id="event_time">Loading...</span>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">date_range</i><span id="event_date">Loading</span>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">room</i><span id="event_place">Loading...</span>
</div>
<div class="mdl-card__actions mdl-card--border">
<h6>(Preview)</h6>
<div class="mdl-layout-spacer"></div>
<i class="material-icons">event</i>
</div>
</div>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div class="mdl-card mdl-shadow--2dp" style="">
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Alpha Company Points:<br>
<h3>
Current:
</h3>
<h4>
<div id="alphacurrentpoints">Loading</div></h4>
New Point Total:
<input type="text" id="alpha"><br>
<input type="submit" value="Update" onclick="alphaSend()"><br>
Comments:<br>
<textarea id="alphacomments"></textarea><br>
<input type="submit" value="Send Comment" onclick="alphaComment()">
</div>
</div>
<div id="locationbox">
Location (i.e Gym, etc):
<input type="text" id="location"><br></div>
<div id="messagebox">
Custom Message:
<input type="text" id="custommessage"><br></div>
<input type="button" value="Update" onclick="eventSend()">
<input type="button" value="Preview" onclick="updatePage()">
</div>
</div>
</td>
<td>
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title" style="text-align: center;margins: auto">
Push Notification
</div>
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Login with NokomisJROTC Google Account to Push Notifications<br>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" onclick="window.open('https://app.letreach.com/5d5daebbddb25e461d8b465c');">
Open Notification Manager
</button>
</div>
</div>
</td>
<td>
<div class="mdl-card mdl-shadow--2dp" style="">
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Bravo Company Points:<br>
<h3>
Current:
</h3>
<h4>
<div id="bravocurrentpoints">Loading</div></h4>
New Point Total:
<input type="text" id="bravo"><br>
<input type="submit" value="Update" onclick="bravoSend()"><br>
Comments:<br>
<textarea id="bravocomments"></textarea><br>
<input type="submit" value="Send Comment" onclick="bravoComment()">
</div>
<div class="calendar mdl-card mdl-shadow--2dp">
<div class="mdl-card__title mdl-card--expand">
<h3><span id="event_type">Loading...</span></h3>
<h4><span id="event_uniform">Loading...</span></h4>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">access_time</i><span id="event_time">Loading...</span>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">date_range</i><span id="event_date">Loading</span>
<br><i class="material-icons" style="font-size: 18px;padding-right: 5px;">room</i><span id="event_place">Loading...</span>
</div>
<div class="mdl-card__actions mdl-card--border">
<h6>(Preview)</h6>
<div class="mdl-layout-spacer"></div>
<i class="material-icons">event</i>
</div>
</div>
</td>
</tr>
</table>
<table>
<tr>
<td>
<div class="mdl-card mdl-shadow--2dp" style="">
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Alpha Company Points:<br>
<h3>
Current:
</h3>
<h4>
<div id="alphacurrentpoints">Loading</div>
</h4>
New Point Total:
<input type="text" id="alpha"><br>
<input type="submit" value="Update" onclick="alphaSend()"><br> Comments:
<br>
<textarea id="alphacomments"></textarea><br>
<input type="submit" value="Send Comment" onclick="alphaComment()">
</div>
</div>
</td>
<td>
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title" style="text-align: center;margins: auto">
Push Notification
</div>
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Login with NokomisJROTC Google Account to Push Notifications<br>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" onclick="window.open('https://app.letreach.com/5d5daebbddb25e461d8b465c');">
Open Notification Manager
</button>
</div>
</div>
</td>
<td>
<div class="mdl-card mdl-shadow--2dp" style="">
<div class="mdl-card__actions" style="text-align: center;margins: auto">
Bravo Company Points:<br>
<h3>
Current:
</h3>
<h4>
<div id="bravocurrentpoints">Loading</div>
</h4>
New Point Total:
<input type="text" id="bravo"><br>
<input type="submit" value="Update" onclick="bravoSend()"><br> Comments:
<br>
<textarea id="bravocomments"></textarea><br>
<input type="submit" value="Send Comment" onclick="bravoComment()">
</div>
</div>
</td>
</tr>
</table>
<div class="mdl-card mdl-shadow--2dp" style="width: 75%;margin: auto">
<div class="mdl-card__title">
Add Admins
</div>
<div class="mdl-card__actions">
<table>
<tr>
<td style="text-align: center;width: 15%">
Email <br>
<input id="email-input" type="text"><br>
<input type="button" onclick="addAdmin();" value="Add Admin"></td>
<td style="width: 85%">
<div>
<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp sign-table" id="emails" style="overflow: scroll">
</table>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</main>
</div>