Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Improve admin panel #9

Merged
merged 8 commits into from
Oct 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions app/client/src/services/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ angular.module('app')
return $http.get(base);
},

getPage: function (page, size, text, showUnsubmitted) {
getPage: function (page, size, text, showUnsubmitted, showAdmitted) {
if (!page || page < 0) {
page = 0;
}
Expand All @@ -34,6 +34,7 @@ angular.module('app')
{
text,
showUnsubmitted,
showAdmitted,
page,
size
})
Expand Down Expand Up @@ -95,16 +96,8 @@ angular.module('app')
return $http.post(base + 'admitall', JSON.stringify({ querytext: querytext }));
},

checkIn: function (id) {
return $http.post(base + id + '/checkin');
},

sendQrCode: function (id) {
return $http.post(base + id + '/sendqrcode');
},

checkOut: function (id) {
return $http.post(base + id + '/checkout');
}

};
Expand Down
4 changes: 0 additions & 4 deletions app/client/stylesheets/_dashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
background: $status-confirmed-color;
}

&.checked.in {
background: $status-checkedin-color;
}

&.declined {
background: $status-declined-color;
}
Expand Down
1 change: 0 additions & 1 deletion app/client/stylesheets/site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ $status-incomplete-color: #F5F5F5;
$status-submitted-color: lighten($secondary, 20%);
$status-admitted-color: $primary;
$status-confirmed-color: $secondary;
$status-checkedin-color: $secondary;
$status-waitlist-color: $tertiary;
$status-declined-color: $tertiary;
$status-rejected-color: red; // Not used
Expand Down
10 changes: 0 additions & 10 deletions app/client/views/admin/stats/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@
</div>
</div>

<div class="item">
<i class="green flag icon"></i>
<div class="content">
<strong>
Checked In
</strong> :
{{stats.checkedIn}}
</div>
</div>

<div class="ui divider"></div>

<div class="item">
Expand Down
74 changes: 17 additions & 57 deletions app/client/views/admin/users/adminUsersCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ angular.module('app')
$stateParams.queryText = queryText;
refreshPage();
});
$scope.$watch('showUnsubmitted', (showUnsubmitted) => {
$stateParams.showUnsubmitted = showUnsubmitted;
$scope.$watch('showUnsubmitted', (val) => {
$stateParams.showUnsubmitted = val;
refreshPage();
});
$scope.$watch('showAdmitted', (val) => {
$stateParams.showAdmitted = val;
refreshPage();
});
$scope.$watch('pageNum', (pageNum) => {
Expand All @@ -45,8 +49,9 @@ angular.module('app')
$scope.pages = data.totalPages;
}
const showUnsubmitted = $stateParams.showUnsubmitted || false;
const showAdmitted = $stateParams.showAdmitted || false;
UserService
.getPage($stateParams.page, $stateParams.size, $stateParams.queryText, showUnsubmitted)
.getPage($stateParams.page, $stateParams.size, $stateParams.queryText, showUnsubmitted, showAdmitted)
.success((data) => {
updatePageData(data);
});
Expand All @@ -69,38 +74,6 @@ angular.module('app')
});
};

$scope.toggleCheckIn = function ($event, user, index) {
$event.stopPropagation();

if (!user.status.checkedIn) {
swal({
title: 'Whoa, wait a minute!',
text: 'You are about to check in ' + user.profile.name + '!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes, check them in.',
closeOnConfirm: false
},
() => {
UserService
.checkIn(user._id)
.success((user) => {
$scope.users[index] = user;
swal('Accepted', user.profile.name + ' has been checked in.', 'success');
});
}
);
} else {
UserService
.checkOut(user._id)
.success((user) => {
$scope.users[index] = user;
swal('Accepted', user.profile.name + ' has been checked out.', 'success');
});
}
};

$scope.acceptUser = function ($event, user, index) {
$event.stopPropagation();

Expand All @@ -113,25 +86,15 @@ angular.module('app')
confirmButtonText: 'Yes, accept them.',
closeOnConfirm: false
}, () => {
swal({
title: 'Are you sure?',
text: 'This action cannot be undone, and will be logged.',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes, accept this user.',
closeOnConfirm: false
}, () => {
UserService
.admitUser(user._id)
.success((user) => {
$scope.users[index] = user;
swal('Accepted', user.profile.name + ' has been admitted.', 'success');
})
.error(() => {
swal('Error', 'User has not submitted an application.', 'error');
});
});
UserService
.admitUser(user._id)
.success((user) => {
$scope.users[index] = user;
swal('Accepted', user.profile.name + ' has been admitted.', 'success');
})
.error(() => {
swal('Error', 'User has not submitted an application.', 'error');
});
});
};

Expand Down Expand Up @@ -240,9 +203,6 @@ angular.module('app')
}, {
name: 'Confirm By',
value: formatTime(user.status.confirmBy) || 'N/A'
}, {
name: 'Checked In',
value: formatTime(user.status.checkInTime) || 'N/A'
}, {
name: 'Email',
value: user.email
Expand Down
30 changes: 10 additions & 20 deletions app/client/views/admin/users/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<input type="checkbox" id="showUnsubmitted" ng-model="showUnsubmitted">
<label for="showUnsubmitted">Show unsubmitted users</label>
</div>
<br>
<div class="ui checkbox">
<input type="checkbox" id="showAdmitted" ng-model="showAdmitted">
<label for="showAdmitted">Show admitted users</label>
</div>
</div>


Expand All @@ -41,7 +46,7 @@
<div class="ui header">
Users
</div>
<button type="button" ng-click="initiateAcceptAll(users)">MASS ACCEPT</button>
<button type="button" ng-click="initiateAcceptAll(users)" disabled="true">MASS ACCEPT</button>
<div class="ui long user modal">
<i class="close icon"></i>
<div class="header">
Expand Down Expand Up @@ -220,33 +225,18 @@ <h3> {{section.title}} </h3>
<td
class="right aligned collapsing">

<button
class="ui circular mini basic green icon button"
ng-disabled="!user.status.completedProfile"
ng-click="sendQrCode($event, user, $index)">
<i class="send outline icon"></i>
</button>

<button
class="accept ui circular mini basic green icon button"
ng-disabled="!user.status.completedProfile || user.status.admitted"
ng-click="acceptUser($event, user, $index)">
<i class="add user icon"></i>
</button>
</button>

<button
ng-click="toggleCheckIn($event, user, $index)"
class="ui circular mini basic green icon button"
ng-disabled="!user.status.completedProfile || !user.status.admitted"
class="ui circular mini basic green icon button">

<i
ng-if="!user.status.checkedIn"
class="flag outline icon"></i>

<i
ng-if="user.status.checkedIn"
class="green flag icon"></i>

ng-click="sendQrCode($event, user, $index)">
<i class="send outline icon"></i>
</button>

</td>
Expand Down
7 changes: 3 additions & 4 deletions app/client/views/confirmation/confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@
Our reimbursement policy is as follows:
</p>
<ul>
<li> Bus: We will be offering buses to Purdue, University of Illinois at Urbana-Champaign, Georgia Institute of
Technology and University of Florida. We may offer some sort of bussing to the Chicagoland area, pending
application numbers. If you can find your own way to any of the stops, you can board the bus. We will require
<li> Bus: We will be offering buses to Illinois Institute of Technology, Purdue, University of Illinois at Urbana-Champaign, Georgia Institute of
Technology, University of Florida, and Washington University in St. Louis. If you can find your own way to any of the stops, you can board the bus. We will require
reservation of bus seats ahead of time (this will be released prior to the event). </li>
<li> Car: We will generally reimburse all gas costs for cars containing <strong>3 or more</strong> hackers. We may
offer partial reimbursement to cars containing fewer hackers. </li>
<li> Flight: We will generally not be reimbursing flights. However, we may consider <em>on a case by case basis</em> small reimbursements (~$50) similar to the reimbursement hackers that drive would receive. Contact us for
<li> Flight & Greyhounds: Reimbursement is generally $75-$100, and However, we may consider <em>on a case by case basis</em> small reimbursements (~$50) similar to the reimbursement hackers that drive would receive. Contact us for
more information. </li>
</ul>
<p>
Expand Down
52 changes: 5 additions & 47 deletions app/server/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ UserController.getAll = function (callback) {
UserController.getPage = function (query, callback) {
const page = query.page;
const size = parseInt(query.size);
const findQuery = this.makeQuery(query.text, query.showUnsubmitted);
const findQuery = this.makeQuery(query.text, query.showUnsubmitted, query.showAdmitted);

User
.find(findQuery)
Expand Down Expand Up @@ -237,7 +237,7 @@ UserController.getPage = function (query, callback) {
};

// Makes a query with a search text
UserController.makeQuery = function (searchText, showUnsubmitted) {
UserController.makeQuery = function (searchText, showUnsubmitted, showAdmitted) {
const findQuery = { $and: [{}] };
if (searchText && searchText.length > 0) {
const queries = [];
Expand All @@ -252,6 +252,9 @@ UserController.makeQuery = function (searchText, showUnsubmitted) {
if (showUnsubmitted === 'false') {
findQuery.$and.push({ 'status.completedProfile': true });
}
if (showAdmitted === 'false') {
findQuery.$and.push({ 'status.admitted': false });
}
return findQuery;
};

Expand Down Expand Up @@ -821,51 +824,6 @@ UserController.admitUser = function (id, user, callback) {
});
};

/**
* [ADMIN ONLY]
*
* Check in a user.
* @param {String} userId User id of the user getting checked in.
* @param {String} user User checking in this person.
* @param {Function} callback args(err, user)
*/
UserController.checkInById = function (id, user, callback) {
User.findOneAndUpdate({
_id: id,
verified: true
}, {
$set: {
'status.checkedIn': true,
'status.checkInTime': Date.now()
}
}, {
new: true
},
callback);
};

/**
* [ADMIN ONLY]
*
* Check out a user.
* @param {String} userId User id of the user getting checked out.
* @param {String} user User checking in this person.
* @param {Function} callback args(err, user)
*/
UserController.checkOutById = function (id, user, callback) {
User.findOneAndUpdate({
_id: id,
verified: true
}, {
$set: {
'status.checkedIn': false
}
}, {
new: true
},
callback);
};

/**
* [ADMIN ONLY]
*/
Expand Down
4 changes: 0 additions & 4 deletions app/server/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,6 @@ schema.statics.validateProfile = function (profile, cb) {
* This provides a verbose explanation of their furthest state.
*/
schema.virtual('status.name').get(function () {
if (this.status.checkedIn) {
return 'checked in';
}

if (this.status.declined) {
return 'declined';
}
Expand Down
14 changes: 0 additions & 14 deletions app/server/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,26 +339,12 @@ module.exports = function (router) {
/**
* Check in a user. ADMIN ONLY, DUH
*/
router.post('/users/:id/checkin', isAdmin, (req, res) => {
const id = req.params.id;
const user = req.user;
UserController.checkInById(id, user, defaultResponse(req, res));
});

router.post('/users/:id/sendqrcode', isAdmin, (req, res) => {
const id = req.params.id;
UserController.sendQrCodeEmailById(id, defaultResponse(req, res));
});

/**
* Check in a user. ADMIN ONLY, DUH
*/
router.post('/users/:id/checkout', isAdmin, (req, res) => {
const id = req.params.id;
const user = req.user;
UserController.checkOutById(id, user, defaultResponse(req, res));
});

/**
* Set wristband code for User
* {
Expand Down
7 changes: 1 addition & 6 deletions app/server/services/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ function calculateStats() {
reimbursementTotal: 0,
reimbursementMissing: 0,

wantsHardware: 0,

checkedIn: 0
wantsHardware: 0
};

User
Expand Down Expand Up @@ -186,9 +184,6 @@ function calculateStats() {
});
}

// Count checked in
newStats.checkedIn += user.status.checkedIn ? 1 : 0;

callback(); // let async know we've finished
}, () => {
// Transform dietary restrictions into a series of objects
Expand Down