moved files around
This commit is contained in:
Родитель
117cfa3f42
Коммит
2a83603e07
До Ширина: | Высота: | Размер: 68 KiB После Ширина: | Высота: | Размер: 68 KiB |
Двоичные данные
frontend/notifier_firefox.opus
Двоичные данные
frontend/notifier_firefox.opus
Двоичный файл не отображается.
|
@ -1 +0,0 @@
|
|||
{"led1":"factory-name-for-led1-C00FF33"}
|
|
@ -1 +0,0 @@
|
|||
{"led2":"gigagator-ultra-leds-inqqpa2","led4":"gigagator-ultra-leds-inqqpa2"}
|
|
@ -0,0 +1,36 @@
|
|||
var http = require("http");
|
||||
var url = require("url");
|
||||
var express = require('express');
|
||||
var getRawBody = require('raw-body');
|
||||
var cors = require('cors');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
|
||||
var argv = process.argv;
|
||||
var port = argv[2];
|
||||
console.log("arguments are port", port);
|
||||
var app = express();
|
||||
|
||||
//handle post/put
|
||||
app.use(function (req, res, next) {
|
||||
getRawBody(req, {
|
||||
length: req.headers['content-length'],
|
||||
limit: '1mb',
|
||||
encoding: 'utf8'
|
||||
}, function (err, string) {
|
||||
if (err)
|
||||
return next(err);
|
||||
req.text = string;
|
||||
next();
|
||||
})
|
||||
});
|
||||
|
||||
app.use(cors());
|
||||
app.get("/", function(req, res) {
|
||||
console.log("---------------GET /, send email: -------");
|
||||
var ssh = spawn('ssh', ["ubuntu@ec2-54-185-133-18.us-west-2.compute.amazonaws.com", "node", "mailSender.js"]);
|
||||
res.send("------mail sent-----");
|
||||
})
|
||||
|
||||
|
||||
app.listen(port);
|
|
@ -1,87 +0,0 @@
|
|||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
||||
|
||||
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
|
||||
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
|
||||
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.0/select2.min.css" rel="stylesheet"/>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/3.5.0/select2.min.js"></script>
|
||||
|
||||
<body>
|
||||
<table id='tagstable' border=1px>
|
||||
<tr>
|
||||
<td>Feature</td>
|
||||
<td>Tags</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
* tags dict received from slave/server
|
||||
* {led1: "factory-name-for-led1-C00FF33"}
|
||||
*
|
||||
* feature: name of a feature: factory-name-for-led1-C00FF33
|
||||
* Return: list of tags for this feature [led1]
|
||||
*/
|
||||
function findTags(feature, tags) {
|
||||
var l = [];
|
||||
$.each(tags, function(tag, fname) { if (fname === feature) l.push(tag); });
|
||||
console.log("findTags:", l);
|
||||
return l;
|
||||
}
|
||||
|
||||
function writeTagTable(features, tags) {
|
||||
console.log('features:', features);
|
||||
$.each(features, function(fname, finfo) {
|
||||
var row = $('<tr>');
|
||||
$('<td>').text(fname).appendTo(row);
|
||||
|
||||
var tagsSelector = $('<input type="hidden" style="width:300px"/>');
|
||||
tagsSelector.appendTo(row);
|
||||
|
||||
// See http://ivaynberg.github.io/select2/
|
||||
// Accept user defined strings (nothing predefined => tags:[])
|
||||
tagsSelector.select2({tags:[],
|
||||
tokenSeparators: [",", " "]});
|
||||
|
||||
// Populate with already defined tags. Only calling 'val' is
|
||||
// not enough. To make the value change visible in UI have to
|
||||
// trigger the 'change' event.
|
||||
tagsSelector.val(findTags(fname, tags)).trigger("change");
|
||||
|
||||
tagsSelector.on("change", function(e) {
|
||||
console.log(e.added, e.removed);
|
||||
if (e.added !== undefined) {
|
||||
var newTag = e.added.text;
|
||||
var tagUrl = 'tags/' + newTag;
|
||||
console.log('Adding tag', tagUrl);
|
||||
$.ajax({url: tagUrl, type:'PUT', data: fname})
|
||||
.done(function(data) { console.log('Tag: ', newTag, 'defined!'); });
|
||||
}
|
||||
|
||||
if (e.removed !== undefined) {
|
||||
var oldTag = e.removed.text;
|
||||
var tagUrl = 'tags/' + oldTag;
|
||||
console.log('Deleting tag', tagUrl);
|
||||
$.ajax({url: tagUrl, type:'DELETE'})
|
||||
.done(function(data) { console.log('Tag: ', oldTag, 'DELETED!'); });
|
||||
}
|
||||
});
|
||||
|
||||
$('#tagstable').append(row);
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$.ajax({url:'/features'})
|
||||
.done(function(features) {
|
||||
$.ajax({url:'/tags'})
|
||||
.done(function(tags) {
|
||||
console.log("DATA FEATURES: ", features, "TAGS:", tags);
|
||||
writeTagTable(features, tags);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче