bunch of stuff
This commit is contained in:
@@ -8,10 +8,11 @@ meteor-platform
|
||||
autopublish
|
||||
insecure
|
||||
twbs:bootstrap
|
||||
nimble:restivus
|
||||
iron:router
|
||||
perak:codemirror
|
||||
meteorhacks:npm
|
||||
|
||||
|
||||
npm-container
|
||||
npm-container
|
||||
meteorhacks:picker
|
||||
http
|
||||
|
||||
@@ -7,7 +7,6 @@ blaze-tools@1.0.3
|
||||
boilerplate-generator@1.0.3
|
||||
callback-hook@1.0.3
|
||||
check@1.0.5
|
||||
coffeescript@1.0.6
|
||||
ddp@1.1.0
|
||||
deps@1.0.7
|
||||
ejson@1.0.6
|
||||
@@ -35,11 +34,11 @@ meteor@1.1.6
|
||||
meteor-platform@1.2.2
|
||||
meteorhacks:async@1.0.0
|
||||
meteorhacks:npm@1.3.0
|
||||
meteorhacks:picker@1.0.2
|
||||
minifiers@1.1.5
|
||||
minimongo@1.0.8
|
||||
mobile-status-bar@1.0.3
|
||||
mongo@1.1.0
|
||||
nimble:restivus@0.6.6
|
||||
npm-container@1.0.0
|
||||
observe-sequence@1.0.6
|
||||
ordered-dict@1.0.3
|
||||
|
||||
@@ -22,18 +22,31 @@ 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 config = Machines.findOne({
|
||||
// // "machineId": this.params.machineId,
|
||||
// "configurations._id": this.params.configId
|
||||
// }, {
|
||||
// 'configurations.$': 1
|
||||
// });
|
||||
|
||||
var machine = Machines.findOne({machineId: this.params.machineId});
|
||||
return {
|
||||
machine: machine,
|
||||
config: config
|
||||
};
|
||||
var machine = Machines.findOne({
|
||||
machineId: this.params.machineId
|
||||
});
|
||||
if (machine) {
|
||||
|
||||
var config;
|
||||
|
||||
for (var i = 0; i < machine.configurations.length; i++) {
|
||||
if (machine.configurations[i]._id === this.params.configId) {
|
||||
config = machine.configurations[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
machine: machine,
|
||||
config: config
|
||||
};
|
||||
}
|
||||
// return config;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,15 +4,26 @@
|
||||
<h1>confighub.io</h1>
|
||||
<div class='col-lg-12'>
|
||||
<h2>
|
||||
Configuration page for {{ machine.machineId}} {{ config.type }} {{ config.description }}
|
||||
Configuration for {{ config.type }}
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-12">
|
||||
{{> CodeMirror id="config-content" name="config-content" options=editorOptions code=editorCode reactiveVar="varName"}}
|
||||
|
||||
Description <input type="text" value={{config.description}}>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
|
||||
File path <input type="text" value={{config.filePath}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-12">
|
||||
<!-- {{config.content}} -->
|
||||
{{> CodeMirror id="config-content" name="config-content" options=editorOptions code=editorCode }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
Template.configPage.events({
|
||||
"click .save-config-details-btn": function(event, template) {
|
||||
console.log('should save config!!!');
|
||||
var content = template.find('#config-content').value;
|
||||
// Machines.update({});
|
||||
var config = Template.instance().data.config;
|
||||
// var machine = Machines.findOne({ machineId: Template.instance().data.machine.machineId });
|
||||
// if (machine) {
|
||||
// for(var i = 0; i < machine.configurations.length; i++) {
|
||||
// if(machine.configurations[i]._id === config._id) {
|
||||
// machine.configurations[i].content = content;
|
||||
// // Machines.save(machine);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Machines.update({
|
||||
// "configurations._id": Template.instance().data.config._id,
|
||||
// "machineId": Template.instance().data.machine.machineId
|
||||
// }, {
|
||||
// content: content
|
||||
// });
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Session.set('config.content', Template.configPage.);
|
||||
|
||||
Template.configPage.helpers({
|
||||
"editorOptions": function() {
|
||||
return {
|
||||
lineNumbers: true,
|
||||
mode: "javascript"
|
||||
}
|
||||
},
|
||||
"editorCode": function(a,template) {
|
||||
return Template.instance().data.config.content;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,25 +9,31 @@ Template.newConfigurationDialog.events({
|
||||
var configDescription = template.find('.configuration-description').value;
|
||||
var configType = template.find('.config-type').value;
|
||||
|
||||
if (machine) {
|
||||
Machines.update({
|
||||
_id: machine._id
|
||||
}, {
|
||||
$push: {
|
||||
configurations: {
|
||||
machineId: machine.machineId,
|
||||
_id: (new Mongo.ObjectID()).toHexString(),
|
||||
description: configDescription,
|
||||
type: configType
|
||||
HTTP.call("GET", "/configs/" + configType + '.conf', function(error, result) {
|
||||
console.log(result);
|
||||
if (machine) {
|
||||
Machines.update({
|
||||
_id: machine._id
|
||||
}, {
|
||||
$push: {
|
||||
configurations: {
|
||||
machineId: machine.machineId,
|
||||
_id: (new Mongo.ObjectID()).toHexString(),
|
||||
description: configDescription,
|
||||
type: configType,
|
||||
content: result.content,
|
||||
filePath: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// db.students.update(
|
||||
// { _id: 1 },
|
||||
// { $push: { scores: 89 } }
|
||||
// )
|
||||
|
||||
// db.students.update(
|
||||
// { _id: 1 },
|
||||
// { $push: { scores: 89 } }
|
||||
// )
|
||||
}
|
||||
Session.set('newConfigurationRequested', false);
|
||||
},
|
||||
"click .cancel-save-config-btn": function(event, template) {
|
||||
|
||||
@@ -2,42 +2,70 @@ Machines = new Mongo.Collection("machines");
|
||||
|
||||
Meteor.startup(function() {
|
||||
// code to run on server at startup
|
||||
|
||||
// Global API configuration
|
||||
Restivus.configure({
|
||||
prettyJson: true,
|
||||
useAuth: false
|
||||
Picker.route('/api/machines', function(params, req, res, next) {
|
||||
var allMachines = Machines.find({});
|
||||
res.end(JSON.stringify(allMachines.fetch()));
|
||||
});
|
||||
|
||||
Restivus.addCollection(Machines);
|
||||
Restivus.addRoute('post/:_id', {
|
||||
get: function () {
|
||||
var id = this.urlParams._id; // "5"
|
||||
return {hamo:1}
|
||||
}
|
||||
});
|
||||
Restivus.addRoute('/api/templates/:type', {
|
||||
Picker.route('/api/templates/:type', function(params, req, res, next) {
|
||||
var type = params.type;
|
||||
var fs = Meteor.npmRequire('fs');
|
||||
var path = Meteor.npmRequire('path');
|
||||
|
||||
},{
|
||||
get: {
|
||||
action: function() {
|
||||
var type = this.urlParams.type;
|
||||
var fs = Meteor.npmRequire('fs');
|
||||
var template = Async.runSync(function(done) {
|
||||
// github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
|
||||
// done(null, data);
|
||||
// });
|
||||
fs.readFile(path.resolve('../public/configs/' + type + '.conf'), function(err, data) {
|
||||
console.log('done!', err, data);
|
||||
done(null, data);
|
||||
});
|
||||
|
||||
var template = Async.runSync(function(done) {
|
||||
// github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
|
||||
// done(null, data);
|
||||
// });
|
||||
fs.readFile('../public/configs/'+type+'.conf', function(err, data) {
|
||||
done(null, data);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
console.log('done received!', template);
|
||||
res.end(template.result);
|
||||
});
|
||||
|
||||
return template.result;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Global API configuration
|
||||
// Restivus.configure({
|
||||
// prettyJson: true,
|
||||
// useAuth: false
|
||||
// });
|
||||
//
|
||||
// Restivus.addCollection(Machines);
|
||||
// Restivus.addRoute('post/:_id', {
|
||||
// get: function() {
|
||||
// var id = this.urlParams._id; // "5"
|
||||
// return {
|
||||
// hamo: 1
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// Restivus.addRoute('/api/templates/:type', {
|
||||
//
|
||||
// }, {
|
||||
// get: {
|
||||
// action: function() {
|
||||
// var type = this.urlParams.type;
|
||||
// var fs = Meteor.npmRequire('fs');
|
||||
//
|
||||
// var template = Async.runSync(function(done) {
|
||||
// // github.gists.getFromUser({user: 'arunoda'}, function(err, data) {
|
||||
// // done(null, data);
|
||||
// // });
|
||||
// fs.readFile('../public/configs/' + type + '.conf', function(err, data) {
|
||||
// done(null, data);
|
||||
// });
|
||||
//
|
||||
// });
|
||||
//
|
||||
// return template.result;
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// Restivus.addRoute('/api/machines', {
|
||||
// // authRequired: false
|
||||
// }, {
|
||||
|
||||
Reference in New Issue
Block a user