Added admin buttons for status, and user info
This commit is contained in:
parent
7f0d29ae16
commit
650e13881b
56
hourglass/client/admin/admin.css
Normal file
56
hourglass/client/admin/admin.css
Normal file
@ -0,0 +1,56 @@
|
||||
.adminUserIcon {
|
||||
width: 2.7vw;
|
||||
margin: 1%;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
-moz-border-radius: 50%;
|
||||
-webkit-border-radius: 50%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.adminUserInfo {
|
||||
margin-top: 1vh;
|
||||
padding: 0.5% 1.5% 0.5% 1.5%;
|
||||
|
||||
background-color: #fff;
|
||||
-webkit-filter: drop-shadow(0px -1px 2px #666);
|
||||
filter: drop-shadow(0px -1px 2px #666);
|
||||
|
||||
position: fixed;
|
||||
display: none;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.adminUserInfo p {
|
||||
margin: 5% 0 5% 0;
|
||||
}
|
||||
|
||||
.infoTitle {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.infoTab {
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
border-bottom: 2vh solid #fff;
|
||||
border-left: 1.5vh solid transparent;
|
||||
border-right: 1.5vh solid transparent;
|
||||
|
||||
position: absolute;
|
||||
right: 1vh;
|
||||
top: -1.9vh;
|
||||
}
|
||||
|
||||
.approveStatus {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.approveStatus .fa {
|
||||
font-size: 5vh
|
||||
}
|
||||
|
||||
.approveStatus .fa-toggle-on {
|
||||
color: #288cd3;
|
||||
}
|
||||
17
hourglass/client/admin/admin.html
Normal file
17
hourglass/client/admin/admin.html
Normal file
@ -0,0 +1,17 @@
|
||||
<template name="adminUserDisplay">
|
||||
{{#each info}}
|
||||
<img class="adminUserIcon" src="{{icon}}">
|
||||
<div class="adminUserInfo">
|
||||
<div class="infoTab"></div>
|
||||
<p><span class="infoTitle">ID: </span><span>{{id}}</span></p>
|
||||
<p><span class="infoTitle">Email: </span><span>{{email}}</span></p>
|
||||
<p><span class="infoTitle">Name: </span><span>{{name}}</span></p>
|
||||
</div>
|
||||
{{/each}}
|
||||
</template>
|
||||
|
||||
<template name="statusButton">
|
||||
<div class="approveStatus">
|
||||
<i class="fa fa-toggle-{{status}}" aria-hidden="true"></i>
|
||||
</div>
|
||||
</template>
|
||||
66
hourglass/client/admin/admin.js
Normal file
66
hourglass/client/admin/admin.js
Normal file
@ -0,0 +1,66 @@
|
||||
var inInfo = false;
|
||||
var openUserDisplay = null;
|
||||
|
||||
Template.adminUserDisplay.helpers({
|
||||
info() {
|
||||
var ids = (this.value instanceof Array) ? this.value : [this.value];
|
||||
var userInfo = [];
|
||||
for(var i = 0; i < ids.length; i++) {
|
||||
var user = Meteor.users.findOne({_id: ids[i]});
|
||||
userInfo.push({
|
||||
name: user.profile.name,
|
||||
email: user.services.google.email,
|
||||
id: user._id,
|
||||
icon: user.services.google.picture
|
||||
})
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
});
|
||||
|
||||
Template.statusButton.helpers({
|
||||
status() {
|
||||
console.log(this.value);
|
||||
return (this.value) ? "on" : "off";
|
||||
}
|
||||
});
|
||||
|
||||
Template.adminUserDisplay.events({
|
||||
'click .adminUserIcon' (event) {
|
||||
var icoCoords = $(event.target)[0].getBoundingClientRect();
|
||||
var x = window.innerWidth - icoCoords.right;
|
||||
var y = icoCoords.bottom;
|
||||
openUserDisplay = $(event.target).next();
|
||||
$(".adminUserInfo").fadeOut(200);
|
||||
openUserDisplay
|
||||
.css({'right': x, 'top': y})
|
||||
.fadeIn(200);
|
||||
},
|
||||
'mouseenter .adminUserInfo' () {
|
||||
inInfo = true;
|
||||
},
|
||||
'mouseleave .adminUserInfo' (event) {
|
||||
if(inInfo) openUserDisplay.fadeOut(200);
|
||||
inInfo = false;
|
||||
openUserDisplay = null;
|
||||
}
|
||||
});
|
||||
|
||||
Template.AdminLTE.events({
|
||||
'click' (event) {
|
||||
if(!event.target.className.includes("adminUserInfo") &&
|
||||
!event.target.className.includes("adminUserIcon") &&
|
||||
openUserDisplay !== null) {
|
||||
openUserDisplay.fadeOut(200);
|
||||
openUserDisplay = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.statusButton.events({
|
||||
'click .approveStatus' () {
|
||||
console.log(this.doc._id);
|
||||
Meteor.call("approveClass", this.doc._id);
|
||||
}
|
||||
})
|
||||
|
||||
@ -48,11 +48,3 @@ schools.attachSchema(schools.schema);
|
||||
classes.attachSchema(classes.schema);
|
||||
work.attachSchema(work.schema);
|
||||
requests.attachSchema(requests.schema);
|
||||
|
||||
classes.helpers({
|
||||
fullUserInfo() {
|
||||
var user = Meteor.users.findOne({_id: this.admin});
|
||||
console.log(user);
|
||||
return this.admin + " | " + user.services.google.email + " | " + user.profile.name;
|
||||
}
|
||||
})
|
||||
|
||||
@ -131,16 +131,16 @@ AdminConfig = {
|
||||
{ label: 'Name', name: 'name' },
|
||||
{ label: 'Hour', name: 'hour' },
|
||||
{ label: 'Teacher', name: 'teacher' },
|
||||
{ label: 'Admin', name: 'admin' },
|
||||
{ label: 'Status', name: 'status' },
|
||||
{ label: 'Admin', name: 'admin', template: 'adminUserDisplay' },
|
||||
{ label: 'Status', name: 'status', template: 'statusButton'},
|
||||
{ label: 'Code', name: 'code' },
|
||||
{ label: 'Privacy', name: 'privacy' },
|
||||
{ label: 'Category', name: 'category' },
|
||||
{ label: 'Moderators', name: 'moderators' },
|
||||
{ label: 'Banned', name: 'banned' },
|
||||
{ label: 'Subscribers', name: 'subscribers' }
|
||||
{ label: 'Moderators', name: 'moderators', template: 'adminUserDisplay' },
|
||||
{ label: 'Banned', name: 'banned', template: 'adminUserDisplay' },
|
||||
{ label: 'Subscribers', name: 'subscribers', template: 'adminUserDisplay'}
|
||||
],
|
||||
color: 'blue'
|
||||
color: 'purple'
|
||||
},
|
||||
work: {
|
||||
tableColumns: [
|
||||
@ -149,11 +149,11 @@ AdminConfig = {
|
||||
{ label: 'Name', name: 'name' },
|
||||
{ label: 'Due Date', name: 'dueDate' },
|
||||
{ label: 'Description', name: 'description' },
|
||||
{ label: 'Creator', name: 'creator' },
|
||||
{ label: 'Creator', name: 'creator', template: 'adminUserDisplay' },
|
||||
{ label: 'Comments', name: 'comments' },
|
||||
{ label: 'Confirmations', name: 'confirmations' },
|
||||
{ label: 'Reports', name: 'reports' },
|
||||
{ label: 'Done', name: 'done' },
|
||||
{ label: 'Confirmations', name: 'confirmations', template: 'adminUserDisplay' },
|
||||
{ label: 'Reports', name: 'reports', template: 'adminUserDisplay' },
|
||||
{ label: 'Done', name: 'done', template: 'adminUserDisplay' },
|
||||
{ label: 'Type', name: 'type' }
|
||||
],
|
||||
color: 'yellow'
|
||||
@ -161,7 +161,7 @@ AdminConfig = {
|
||||
requests: {
|
||||
tableColumns: [
|
||||
{ label: 'ID', name: '_id' },
|
||||
{ label: 'User', name: 'requestor' },
|
||||
{ label: 'User', name: 'requestor', template: 'adminUserDisplay' },
|
||||
{ label: 'Request', name: 'request' },
|
||||
{ label: 'Time', name: 'timeRequested' }
|
||||
],
|
||||
|
||||
@ -208,15 +208,15 @@ Meteor.methods({
|
||||
},
|
||||
'approveClass': function(classId) {
|
||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||
var currentclass = classes.find({
|
||||
var currentclass = classes.findOne({
|
||||
_id: classId
|
||||
});
|
||||
currentclass.status = !currentclass.status;
|
||||
Meteor.update({
|
||||
|
||||
classes.update({
|
||||
_id: classId
|
||||
}, {
|
||||
$set: {
|
||||
currentclass
|
||||
status: !currentclass.status
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user