Skip to content

Commit

Permalink
start adding UI
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Mar 21, 2015
1 parent 0eb25c0 commit c172bed
Show file tree
Hide file tree
Showing 16 changed files with 2,767 additions and 46 deletions.
12 changes: 12 additions & 0 deletions configure.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<link rel="stylesheet" href="css/ratchet.css">
<style type="text/css">

</style>
</head>
<body>
<div class="app"></div>
<script src="configure.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions configure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var ipc = require('ipc')
var mustache = require('mustache')
var fs = require('fs')

var template = fs.readFileSync('./configure.mustache').toString()
var container = document.querySelector('.app')

ipc.on('status', function(data) {
data = data.map(function(d) {
if (d.uptime) {
d.classes = "btn-positive"
d.message = "Running"
return d
}
if (d.state === 'dead') {
d.classes = "btn-negative"
d.message = "Dead"
return d
}

d.message = "Not Running"
return d
})
var output = mustache.render(template, {items: data})
container.innerHTML = output

addEvents()
})

ipc.send('update-me')

function addEvents() {
var startAll = document.querySelector('.start-all')
var stopAll = document.querySelector('.stop-all')
var restartAll = document.querySelector('.restart-all')
var buttons = [startAll, stopAll, restartAll]

buttons.forEach(function (button) {
button.addEventListener('mousedown', function(e) {
var action = e.target.attributes['data-action'].value
ipc.send('task', {task: action})
})
})
}
10 changes: 10 additions & 0 deletions configure.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="table-view">
{{#items}}
<li class="table-view-cell">{{name}} <button class="btn {{classes}}">{{message}}</button></li>
{{/items}}
</ul>
<div class="content-padded">
<button data-action="startAll" class="start-all btn btn-positive btn-block">Start All</button>
<button data-action="restartAll" class="restart-all btn btn-primary btn-block">Restart All</button>
<button data-action="stopAll" class="stop-all btn btn-negative btn-block">Stop All</button>
</div>
Loading

0 comments on commit c172bed

Please sign in to comment.