Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
multi user support
Browse files Browse the repository at this point in the history
  • Loading branch information
graboskyc committed Sep 13, 2019
1 parent 07acf75 commit 5733914
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Stitch-Hosting/admin/entries.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<button class='btn btn-outline-light btn-md ' style="margin-right: 10px;" onclick="window.location = 'courses.html';"><i class='fa fa-arrow-left' aria-hidden='true'></i></button>
<button class='btn btn-outline-success btn-md ' style="margin-right: 10px;" onclick="$('#newModal').modal('show');"><i class='fa fa-plus-circle' aria-hidden='true'></i></button>
<button class='btn btn-outline-warning btn-md ' style="margin-right: 10px;" onclick="$('#userModal').modal('show');"><i class='fa fa-user-plus' aria-hidden='true'></i></button>
<button class='btn btn-outline-info btn-md ' onclick="toggleNextVis()"><i class='fa fa-eye' aria-hidden='true'></i></button>

</nav>
Expand Down Expand Up @@ -82,6 +83,27 @@ <h5 class="modal-title">New Course</h5>
</div>
</div>

<div class="modal" tabindex="-1" role="dialog" id="userModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add User To Course</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<label for="txt_uid">User ID</label>
<input type="text" class="form-control" id="txt_uid" >
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="document.location.reload()">Close</button>
<button type="button" class="btn btn-success" onclick="addUser()">Add User</button>
</div>
</div>
</div>
</div>

<div class="modal " tabindex="-1" role="dialog" id="imgModal">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
Expand Down Expand Up @@ -293,6 +315,25 @@ <h5 class="modal-title">Image</h5>
});
}

function addUser() {
db.collection("classes").find({classid:getHashbang()},{owner:1}).asArray().then(
function(docs) {
var owners = [];
if(Array.isArray(docs[0].owner)) {
owners = docs[0].owner;
} else {
owners.push(docs[0].owner);
}
owners.push({id:$('#txt_uid').val()});

db.collection("classes").updateOne(
{"classid":getHashbang()},
{$set: {"owner":owners}}
).then(result => { location.reload(true); }).catch(err => console.log(err));
}
).catch(err => {console.error(err)});
}

function saveNew() {
var entry = {};
entry.entryid = parseInt($('#txt_order').val());
Expand Down

0 comments on commit 5733914

Please sign in to comment.