- progress

This commit is contained in:
Edin Dazdarevic
2015-05-29 21:10:07 +02:00
parent bd61e4eef8
commit 797b93e81c
14 changed files with 287 additions and 23 deletions

View File

@@ -1,12 +1,51 @@
Machines = new Mongo.Collection("machines");
Meteor.startup(function() {
Meteor.methods({
updateConfiguration: function (machineId, configId, data) {
console.log('saving !!!!', machineId, configId, data);
Machines.update({
machineId: machineId,
"configurations._id": configId
}, {
$set: {
"configurations.$.content": data.content,
"configurations.$.filePath": data.filePath,
"configurations.$.description": data.description
}
});
return "ok";
}
});
var bodyParser = Meteor.npmRequire('body-parser');
Picker.middleware(bodyParser.urlencoded({ extended: false }));
Picker.middleware(bodyParser.json());
// code to run on server at startup
Picker.route('/api/machines', function(params, req, res, next) {
var allMachines = Machines.find({});
res.end(JSON.stringify(allMachines.fetch()));
});
Picker.route('/api/machine', function(params, req, res, next) {
console.log(params, req.body);
// Hostname string
// Platform string
// Architecture string
// MachineGuid string
var data = req.body;
Machines.update({
machineId: data.MachineGuid
}, {
hostname: data.Hostname,
status: 'OK',
platform: data.Platform,
architecture: data.Architecture
});
// return res.end()"ok";
res.end("ok");
});
Picker.route('/api/templates/:type', function(params, req, res, next) {
var type = params.type;
var fs = Meteor.npmRequire('fs');