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