Skip to content

Commit

Permalink
Commenting on all pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinTonev committed Jul 4, 2019
1 parent afafe34 commit 799e297
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 33 deletions.
1 change: 1 addition & 0 deletions public/bower_components/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In this folder are plugins that come with adminLTE
3 changes: 3 additions & 0 deletions public/dist/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This folder contains the css folde which is provided by AmdinLTE
In the img folder are stored any images that are used in the admin panel
And in the js folder is where the javascript files that will be called in multiple places
8 changes: 8 additions & 0 deletions public/pages/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This is the pages folder it contains all the HTML files in sections which are pretty self explanatory

-admin : all the admin CRUD pages
-dashboard : the statistics and feed pages
-locations : the attractions and stories CRUD pages
-user_requests : the comments and ratings pages
-users : managing users (un/blocking)
The login page is where the index.html in the public folder redirects to.
6 changes: 3 additions & 3 deletions public/pages/admin/Radmins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Get all admins
getAll();

//Create table
var table = $('#adminTable').DataTable({
"columnDefs": [{
"targets": -1,
Expand All @@ -11,7 +11,7 @@ var table = $('#adminTable').DataTable({
"targets": [2],
"visible": false
}]});

//Wait for remove button to be pressed and ask user to confirm
$('#adminTable tbody').on('click', 'button', function () {
var data = table.row($(this).parents('tr')).data();

Expand All @@ -26,7 +26,7 @@ $('#adminTable tbody').on('click', 'button', function () {
}

});

//Call all users from the database and on any activity reload the table
function getAll() {
db.collection("administrator").where('active', '==', true).onSnapshot(function(querySnapshot){
var adminTable = $('#adminTable').DataTable();
Expand Down
4 changes: 3 additions & 1 deletion public/pages/dashboard/Rtimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ function draw(){
},250);
}

//Create a feed item and when data is updated reload the feed item

function createFeedItem(attractionId,attractionName,reviewDoc){


Expand Down Expand Up @@ -155,7 +157,7 @@ function createFeedItem(attractionId,attractionName,reviewDoc){
divTimelineBody.appendChild(text);
}


//Apped all items to the div and append the div to the page

span.appendChild(iClock);

Expand Down
20 changes: 8 additions & 12 deletions public/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,24 @@

<script src="../dist/js/connectivity.js"></script>
<script>
//var email = window.location.pathname.split('/');


//Check if the login page was redirected from a registration link and login the new admin
if(firebase.auth().isSignInWithEmailLink(window.location.href)){

var email = window.location.href.split('?')[1].split('&')[0];
//document.getElementById('signin')
// var email = window.prompt('Please provide the email you\'d like to sign-in with for confirmation.');
firebase.auth().signInWithEmailLink(email, window.location.href).then(function(result) {

// Clear email from storage.
//window.localStorage.removeItem('emailForSignIn');
firebase.auth().signInWithEmailLink(email, window.location.href).then(function(result) {
// Signed-in user's information.
var user = result.user;
var isNewUser = result.additionalUserInfo.isNewUser;
// console.log(db.collection("administrator").doc(user.uid).get());

db.collection("administrator").doc(user.uid).get().then(function(doc) {
if (doc.exists) {
//console.log("Document data:", doc.data());

location.assign('../../pages/dashboard/statistics.html');
//console.log(user.displayName);

} else {
// doc.data() will be undefined in this case

db.collection("administrator").doc(user.uid).set({
created_at: firebase.firestore.FieldValue.serverTimestamp(),
updated_at: firebase.firestore.FieldValue.serverTimestamp(),
Expand All @@ -101,7 +97,7 @@
email: email
})
.then(function() {
//console.log("Document successfully written!");

location.assign('../../pages/dashboard/statistics.html');
})
.catch(function(error) {
Expand Down
3 changes: 2 additions & 1 deletion public/pages/user_requests/Rcomments.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Draw items and check if new items have been added and draw them
function draw(){
var lenght = ratings.length;
setInterval(function(){
Expand All @@ -13,7 +14,7 @@ function draw(){
}
},250);
}

//Create a comment item and when data is updated reload the comment item
function createCommentItem(attractionId,attractionName,reviewDoc){

db.collection('attraction').doc(attractionId).collection('review').doc(reviewDoc).onSnapshot(function(doc){
Expand Down
2 changes: 2 additions & 0 deletions public/pages/user_requests/Rratings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Draw items and check if new items have been added and draw them
function draw(){
var lenght = ratings.length;
setInterval(function(){
Expand All @@ -13,6 +14,7 @@ function draw(){
}
},250);
}
//Create a rating item and when data is updated reload the rating item
function createRatingItem(attractionId,attractionName,reviewDoc){
db.collection('attraction').doc(attractionId).collection('review').doc(reviewDoc).onSnapshot(function(doc){
reviewDoc = doc;
Expand Down
20 changes: 4 additions & 16 deletions public/pages/users/manageusers.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@

// var table = null;
//Retrieves all users from the database and on any update diplays it in the table
function getAll(status){
//table = $('#monumentsTable').DataTable();

db.collection("user").where("blocked", "==", status).where('active', '==', true).onSnapshot(function(querySnapshot) {


var table = $('#usersTable').DataTable();
table.rows().remove();
querySnapshot.forEach(function(doc) {
// doc.data() is never undefined for query doc snapshots
//var table = document.getElementById("monumentsTable");
//console.log(doc.id);


var user = doc.data().username;
var email = doc.data().email;
Expand All @@ -35,14 +30,9 @@
});

}
//Block a user which set their status to blocked = true or false
function blockUser(name,blocked){
/* var newusersRef = usersRef.push();
newusersRef.set({
name:name,
longitude:longitude,
latitude:latitude,
direction:direction
});*/

db.collection("user").where('username', '==', name)
.get()
.then(function(querySnapshot) {
Expand All @@ -51,8 +41,6 @@
updated_at: firebase.firestore.FieldValue.serverTimestamp(),
blocked: blocked
}).then(function() {
// console.log("Document successfully written!");
// location.reload();

})
.catch(function(error) {
Expand Down
1 change: 1 addition & 0 deletions public/plugins/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In this folder are plugins that come with adminLTE

0 comments on commit 799e297

Please sign in to comment.