2015-04-10 19:23:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-09 19:53:19 +00:00
|
|
|
var Steppy = require('twostep').Steppy,
|
2015-07-05 20:35:57 +00:00
|
|
|
createBuildDataResource = require('../distributor').createBuildDataResource,
|
2015-07-05 18:03:58 +00:00
|
|
|
logger = require('../lib/logger')('projects resource');
|
2015-04-12 22:19:42 +00:00
|
|
|
|
2015-05-12 20:12:28 +00:00
|
|
|
module.exports = function(app) {
|
2015-04-12 22:41:09 +00:00
|
|
|
|
2015-07-05 20:35:57 +00:00
|
|
|
var resource = app.dataio.resource('projects'),
|
|
|
|
distributor = app.distributor;
|
2015-05-10 10:04:54 +00:00
|
|
|
|
2015-05-14 20:37:44 +00:00
|
|
|
resource.use('createBuildDataResource', function(req, res) {
|
|
|
|
createBuildDataResource({id: req.data.id});
|
|
|
|
res.send();
|
|
|
|
});
|
|
|
|
|
2015-05-17 13:48:16 +00:00
|
|
|
resource.use('readAll', function(req, res) {
|
2015-06-13 19:25:18 +00:00
|
|
|
res.send(app.projects);
|
2015-04-12 22:41:09 +00:00
|
|
|
});
|
2015-05-01 11:11:29 +00:00
|
|
|
|
|
|
|
resource.use('run', function(req, res) {
|
2015-06-13 18:59:32 +00:00
|
|
|
var projectName = req.data.projectName;
|
2015-07-05 18:03:58 +00:00
|
|
|
logger.log('Run the project: "%s"', projectName);
|
2015-06-14 14:21:04 +00:00
|
|
|
distributor.run({
|
|
|
|
projectName: projectName,
|
|
|
|
initiator: {type: 'user'}
|
2015-07-05 18:03:58 +00:00
|
|
|
});
|
2015-05-03 15:23:01 +00:00
|
|
|
res.send();
|
2015-05-01 11:11:29 +00:00
|
|
|
});
|
2015-05-03 15:23:01 +00:00
|
|
|
|
|
|
|
return resource;
|
2015-04-10 19:23:52 +00:00
|
|
|
};
|