mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-23 19:31:03 +01:00
44 lines
803 B
JavaScript
44 lines
803 B
JavaScript
var models = require('../../models')
|
|
var mongoose = require('mongoose')
|
|
|
|
var host = require('./host')
|
|
|
|
exports.unauthorized = function (app, template) {
|
|
template([
|
|
'hosts'
|
|
], {
|
|
prefix: 'host'
|
|
});
|
|
|
|
host.unauthorized(app, template);
|
|
}
|
|
|
|
exports.httpRouter = function (app) {
|
|
host.httpRouter(app);
|
|
}
|
|
|
|
exports.router = function (app) {
|
|
app.get('/playbook/:playbook_id/hostgroups', get)
|
|
.post('/playbook/:playbook_id/hostgroups', add)
|
|
|
|
host.router(app);
|
|
}
|
|
|
|
function get (req, res) {
|
|
models.HostGroup.find({
|
|
playbook: req.playbook._id
|
|
}).sort('-created').exec(function (err, hosts) {
|
|
res.send(hosts)
|
|
})
|
|
}
|
|
|
|
function add (req, res) {
|
|
var hostgroup = new models.HostGroup({
|
|
playbook: req.playbook._id,
|
|
name: req.body.name
|
|
});
|
|
|
|
hostgroup.save(function () {
|
|
res.send(hostgroup);
|
|
});
|
|
} |