This commit is contained in:
Senad Uka
2015-05-29 21:10:56 +02:00
14 changed files with 287 additions and 23 deletions

View File

@@ -1 +1,9 @@
/* CSS declarations go here */
.thumbnail {
border: 0 none;
box-shadow: none;
}
.main-header {
background-color: rebeccapurple;
}

View File

@@ -1,7 +1,11 @@
<template name='configPage'>
<div class='container'>
<div class='row'>
<div class="page-header">
<a href="/">
<h1>confighub.io</h1>
</a>
</div>
<div class='col-lg-12'>
<h2>
Configuration for {{ config.type }}
@@ -12,11 +16,11 @@
<div class="col-lg-12">
Description <input type="text" value={{config.description}}>
Description <input type="text" class='description' value={{config.description}}>
</div>
<div class="col-lg-12">
File path <input type="text" value={{config.filePath}}>
File path <input type="text" class='file-path' value={{config.filePath}}>
</div>
</div>
<div class="row">

View File

@@ -2,6 +2,8 @@ Template.configPage.events({
"click .save-config-details-btn": function(event, template) {
console.log('should save config!!!');
var content = template.find('#config-content').value;
var filePath = template.find('.file-path').value;
var description = template.find('.description').value;
// Machines.update({});
var config = Template.instance().data.config;
// var machine = Machines.findOne({ machineId: Template.instance().data.machine.machineId });
@@ -15,11 +17,25 @@ Template.configPage.events({
// }
// }
// Machines.update({
// "configurations._id": Template.instance().data.config._id,
// "machineId": Template.instance().data.machine.machineId
// "configurations._id": Template.instance().data.config._id
// }, {
// content: content
// });
Meteor.call('updateConfiguration',
Template.instance().data.machine.machineId, config._id, {
content: content,
filePath: filePath,
description: description
}, function(error, result) {
if (error) {
// handle error
console.log('error!!!!', error);
} else {
console.log(result);
// examine result
}
});
}
});
@@ -32,7 +48,7 @@ Template.configPage.helpers({
mode: "javascript"
}
},
"editorCode": function(a,template) {
"editorCode": function(a, template) {
return Template.instance().data.config.content;
}
});

View File

@@ -1,7 +1,18 @@
<template name='home'>
<div class="navbar main-header">
<div class="container">
<div class="navbar-header">
<a href="/">
<h1>confighub.io</h1>
</a>
</div>
</div>
</div>
<div class='container'>
<div class='row'>
<h1>confighub.io</h1>
<div class='col-lg-12'>
<h2>
Your machines
@@ -13,7 +24,7 @@
{{#unless newMachineRequested}}
<div class="row">
<div class='col-lg-12'>
<button type='button' class='add-new-machine-btn'>Add new machine</button>
<button type='button' class='btn add-new-machine-btn'>Add new machine</button>
</div>
</div>
{{/unless}} {{#if newMachineRequested}} {{> newMachine }} {{/if}}

View File

@@ -50,6 +50,10 @@ Template.newMachine.helpers({
});
Template.newMachine.events({
"click .new-machine-cancel-btn": function() {
Session.set('newMachineJustAdded', false);
Session.set('newMachineRequested', false);
},
"click .close-new-machine-btn": function() {
Session.set('newMachineJustAdded', false);
Session.set('newMachineRequested', false);

View File

@@ -1,7 +1,11 @@
<template name='machinePage'>
<div class='container'>
<div class='row'>
<div class="page-header">
<a href="/">
<h1>confighub.io</h1>
</a>
</div>
<div class='col-lg-12'>
<h2>
Machine details: {{ name }}

View File

@@ -1,5 +1,5 @@
<template name="machineDetails">
<div class="col-lg-4" style="text-align: center;">
<div class="col-lg-4 thumbnail" style="text-align: center;">
<a href=machine/{{ machineId }}>
<img src='https://d13yacurqjgara.cloudfront.net/users/595800/screenshots/1702094/linux_1x.png' style="width: 200px; 130px;" />
<br />
@@ -8,8 +8,9 @@
</div>
</a>
<div style="text-align: center;" class="machine-status">
status: {{status}}
</div>
<span class="text-center label label-warning">
{{status}}
</span>
</div>
</template>

View File

@@ -1,16 +1,22 @@
<template name="newMachine">
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-body">
<h3>Add new machine</h3>
<form class="new-machine">
<input type="text" name="machineName" class='machine-name' placeholder="Machine Name" />
<button type='button' name='btnAddNewMachine' class='new-machine-save-btn'>Add new machine</button>
<input type="text" name="machineName" class='form-control machine-name' placeholder="Machine Name" />
<button type='button' name='btnAddNewMachine' class='btn btn-default new-machine-save-btn'>Save</button>
<button type='button' class='btn btn-default new-machine-cancel-btn'>Cancel</button>
{{#if newMachineAdded}}
<div>You have successfully added a new machine. Please run <b>'chub init {{newMachineAdded}}'</b> on your computer. </div>
<button type='button' class='close-new-machine-btn'>Ok! Got It.</button>
<div>You have successfully added a new machine. Please run <pre>'chub init {{newMachineAdded}}'</pre> on your computer. </div>
<button type='button' class='btn btn-default close-new-machine-btn'>Ok, Got It!</button>
{{/if}}
</form>
</div>
</div>
</div>
</div>
</template>

View File

@@ -1,3 +1,3 @@
{
"body-parser": "1.12.4"
}

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,7 @@
This directory and the files immediately inside it are automatically generated
when you change this package's NPM dependencies. Commit the files in this
directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
so that others run the same versions of sub-dependencies.
You should NOT check in the node_modules directory that Meteor automatically
creates; if you are using git, the .gitignore file tells git to ignore it.

View File

@@ -0,0 +1,64 @@
{
"dependencies": {
"body-parser": {
"version": "1.12.4",
"dependencies": {
"bytes": {
"version": "1.0.0"
},
"content-type": {
"version": "1.0.1"
},
"debug": {
"version": "2.2.0",
"dependencies": {
"ms": {
"version": "0.7.1"
}
}
},
"depd": {
"version": "1.0.1"
},
"iconv-lite": {
"version": "0.4.8"
},
"on-finished": {
"version": "2.2.1",
"dependencies": {
"ee-first": {
"version": "1.1.0"
}
}
},
"qs": {
"version": "2.4.2"
},
"raw-body": {
"version": "2.0.2",
"dependencies": {
"bytes": {
"version": "2.1.0"
}
}
},
"type-is": {
"version": "1.6.2",
"dependencies": {
"media-typer": {
"version": "0.3.0"
},
"mime-types": {
"version": "2.0.12",
"dependencies": {
"mime-db": {
"version": "1.10.0"
}
}
}
}
}
}
}
}
}

View File

@@ -0,0 +1,99 @@
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
# cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# node.name: node-1
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /path/to/data
#
# Path to log files:
#
# path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.mlockall: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind adress to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Elasticsearch nodes will find each other via multicast, by default.
#
# To use the unicast discovery, disable the multicast discovery:
#
# discovery.zen.ping.multicast.enabled: false
#
# Pass an initial list of hosts to perform discovery when new node is started:
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true

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');