Files
old-confighub/web/client/confighub.js
2015-05-28 13:44:14 +02:00

80 lines
1.8 KiB
JavaScript

// pages
// / => home
// /:machineName => machineDetails
// .
Machines = new Mongo.Collection("machines");
Router.route('/', function() {
this.render('Home')
});
Router.route('machine/:machineId', function() {
this.render('machinePage', {
data: function() {
return Machines.findOne({
machineId: this.params.machineId
});
}
});
});
Router.route('/machine/:machineId/config/:configId', function() {
this.render('configPage', {
data: function() {
var config = Machines.find({
"machineId": this.params.machineId,
"configurations._id": this.params.configId
}, {
'configurations.$': 1
});
var machine = Machines.findOne({machineId: this.params.machineId});
return {
machine: machine,
config: config
};
// return config;
}
});
});
// this.render('Post', {
// // we don't really need this since we set the data context for the
// // the entire layout above. But this demonstrates how you can set
// // a new data context for each specific region.
// data: function () { return Posts.findOne({_id: this.params._id})
// });
if (Meteor.isServer) {
Meteor.startup(function() {
// code to run on server at startup
// Global API configuration
Restivus.configure({
prettyJson: true
});
Restivus.addRoute('machines', {
authRequired: false
}, {
get: function() {
var allMaMachines = Machines.find({});
return {
data: allMaMachines
};
// var post = Posts.findOne(this.urlParams.id);
// if (post) {
// return {status: 'success', data: post};
// }
// return {
// statusCode: 404,
// body: {status: 'fail', message: 'Post not found'}
// };
}
});
});
}