Skip to content

Commit 9295463

Browse files
nwalters512james9909
authored andcommitted
Admin management (#265)
* Initial work * Add more necessary columns; create migration * Add skeleton of admin pages * Add endpoint for admin users * Skeleton of admin user management * Work on autocomplete api * Add autocompletion for admin netids * Batch dom updates * Refactor to share user item component * Wire up frontent to API * Add tests for admin creation/deletion * Remove course requests skeleton page * Fix linter errors * Add test for user autocompletion * Improve rendering of user typeahead * Add index on isAdmin for users table * Remove course reqeust models * Improve spacing of loading indicator * Remove course request page from routes * Better filtering of current admins * Add admin by pressing Enter key * Add changelog entry
1 parent 910209f commit 9295463

18 files changed

+719
-44
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ with the current semantic version and the next changes should go under a **[Next
77

88
## [Next]
99

10+
* Add page for admin management. ([@nwalters512](https://github.com/nwalters512) in [#265](https://github.com/illinois/queue/pull/265))
11+
1012
## v1.0.5
1113

1214
* Fix logic for filtering confidential questions. ([@james9909](https://github.com/james9909) in [#257](https://github.com/illinois/queue/pull/257))

package-lock.json

+205
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"pg": "^7.8.0",
5252
"prop-types": "^15.7.1",
5353
"react": "^16.8.1",
54+
"react-bootstrap-typeahead": "^4.0.0-alpha.6",
5455
"react-dom": "^16.8.1",
5556
"react-flip-move": "^3.0.3",
5657
"react-fontawesome": "^1.6.1",
@@ -70,6 +71,7 @@
7071
"styled-jsx": "^3.2.1",
7172
"supertest-session": "^3.3.0",
7273
"umzug": "^2.2.0",
74+
"use-debounce": "^1.1.1",
7375
"validator": "^10.11.0",
7476
"winston": "^3.2.1"
7577
},

src/api/autocomplete.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const router = require('express').Router()
2+
3+
const { User, Sequelize } = require('../models')
4+
5+
const { failIfErrors, ApiError } = require('./util')
6+
const requireAdmin = require('../middleware/requireAdmin')
7+
const safeAsync = require('../middleware/safeAsync')
8+
9+
router.get(
10+
'/users',
11+
[requireAdmin, failIfErrors],
12+
safeAsync(async (req, res, next) => {
13+
const { q } = req.query
14+
if (q === null || q === undefined) {
15+
next(new ApiError(422, 'No query specified'))
16+
return
17+
}
18+
const users = await User.findAll({
19+
where: {
20+
[Sequelize.Op.or]: {
21+
netid: {
22+
[Sequelize.Op.like]: `${q}%`,
23+
},
24+
},
25+
},
26+
limit: 10,
27+
})
28+
res.send(users)
29+
})
30+
)
31+
32+
module.exports = router

0 commit comments

Comments
 (0)