diff --git a/web/.meteor/packages b/web/.meteor/packages
index d3dac77..3081d6c 100644
--- a/web/.meteor/packages
+++ b/web/.meteor/packages
@@ -8,10 +8,11 @@ meteor-platform
autopublish
insecure
twbs:bootstrap
-nimble:restivus
iron:router
perak:codemirror
meteorhacks:npm
-npm-container
\ No newline at end of file
+npm-container
+meteorhacks:picker
+http
diff --git a/web/.meteor/versions b/web/.meteor/versions
index 52a8eb9..a03026a 100644
--- a/web/.meteor/versions
+++ b/web/.meteor/versions
@@ -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
diff --git a/web/client/confighub.js b/web/client/confighub.js
index fdf387c..b386ea4 100644
--- a/web/client/confighub.js
+++ b/web/client/confighub.js
@@ -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;
}
});
diff --git a/web/client/views/configPage/configPage.html b/web/client/views/configPage/configPage.html
index 3ff8174..5d7873d 100644
--- a/web/client/views/configPage/configPage.html
+++ b/web/client/views/configPage/configPage.html
@@ -4,15 +4,26 @@
confighub.io
- Configuration page for {{ machine.machineId}} {{ config.type }} {{ config.description }}
+ Configuration for {{ config.type }}
-
+
+
+
+
+ {{> CodeMirror id="config-content" name="config-content" options=editorOptions code=editorCode }}
diff --git a/web/client/views/configPage/configPage.js b/web/client/views/configPage/configPage.js
index b448415..629b54b 100644
--- a/web/client/views/configPage/configPage.js
+++ b/web/client/views/configPage/configPage.js
@@ -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;
+ }
+});
diff --git a/web/client/views/shared/newConfigurationDialog/newConfigurationDialog.js b/web/client/views/shared/newConfigurationDialog/newConfigurationDialog.js
index 6b5c141..880a409 100644
--- a/web/client/views/shared/newConfigurationDialog/newConfigurationDialog.js
+++ b/web/client/views/shared/newConfigurationDialog/newConfigurationDialog.js
@@ -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) {
diff --git a/web/server/confighub.js b/web/server/confighub.js
index c33fe15..49da7e0 100644
--- a/web/server/confighub.js
+++ b/web/server/confighub.js
@@ -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
// }, {