summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshymad <czilukim@o2.pl>2018-05-05 22:38:39 +0200
committerAshymad <czilukim@o2.pl>2018-05-05 22:38:39 +0200
commit12e829acc00b8cae85c343f97c88673cc631aa73 (patch)
tree13777f0c703982db0946c940b820c6bdf7ee7fff
parentf11ae9de0882edf2a43b800a877c364b72168a87 (diff)
Setup LAN access.
-rwxr-xr-xmain.py6
-rw-r--r--static/src/index.css2
-rw-r--r--static/src/index.html2
-rw-r--r--static/src/index.js32
-rw-r--r--static/webpack.config.js5
5 files changed, 22 insertions, 25 deletions
diff --git a/main.py b/main.py
index a1eebb5..0d080a7 100755
--- a/main.py
+++ b/main.py
@@ -6,9 +6,11 @@ import uuid
app = Flask(__name__)
-rmq_adr = '127.0.0.1'
+rmq_adr = '10.0.0.118'
+rmq_credentials = pika.PlainCredentials('pi', 'raspberry')
rmq_exchange = 'raspi.live'
-rmq_par = pika.ConnectionParameters(host=rmq_adr)
+rmq_par = pika.ConnectionParameters(host=rmq_adr,
+ credentials=rmq_credentials)
@app.route('/api/binding/<int:binding_id>', methods=['PUT'])
def put_binding(binding_id):
diff --git a/static/src/index.css b/static/src/index.css
index 0bb944a..c6d37ae 100644
--- a/static/src/index.css
+++ b/static/src/index.css
@@ -7,10 +7,12 @@ body {
}
.graph .axis .tick line {
+ visibility: hidden;
stroke: black;
}
.graph .axis .tick text {
+ visibility: hidden;
fill: black;
font-size: 0.7em;
}
diff --git a/static/src/index.html b/static/src/index.html
index 68716c8..4a48be3 100644
--- a/static/src/index.html
+++ b/static/src/index.html
@@ -5,7 +5,7 @@
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
- <h1>Plot</h1>
+ <div id="title">Connecting...</div>
<div class="graph"></div>
</body>
</html>
diff --git a/static/src/index.js b/static/src/index.js
index 4d0bbbf..13bbe47 100644
--- a/static/src/index.js
+++ b/static/src/index.js
@@ -4,7 +4,7 @@ import * as request from 'superagent';
import style from './index.css';
-var beAPI = 'http://127.0.0.1:8888/api/';
+var beAPI = window.location.protocol + "//" + window.location.host + "/api/"
var client;
var subscription;
@@ -12,6 +12,7 @@ request
.get(beAPI + 'stomp')
.then((res) => {
client = Stomp.client(res.body.url)
+ client.debug = null
client.connect(res.body.login, res.body.passcode,
on_connect,
(error) => {
@@ -30,6 +31,8 @@ var on_connect = function() {
subscription = client
.subscribe("/amq/queue/" + res.body.queue_name,
on_message)
+ document.getElementById("title")
+ .textContent = "Reading from: " + res.body.queue_name;
})
.catch((err) => {
@@ -46,12 +49,12 @@ var on_message = function(message) {
}
-var limit = 60 * 1,
+var limit = 60 * 5,
duration = 50,
now = new Date(Date.now() - duration)
-var width = 800,
- height = 300
+var width = window.innerWidth - 10,
+ height = window.innerHeight/2
var groups = {
x: {
@@ -83,7 +86,7 @@ var x = d3.scaleTime()
var y = d3.scaleLinear()
.domain([-2, 2])
- .range([height, 0])
+ .range([0, height])
var line = d3.line()
.x(function(d, i) {
@@ -96,11 +99,11 @@ var line = d3.line()
var svg = d3.select('.graph').append('svg')
.attr('class', 'chart')
.attr('width', width)
- .attr('height', height + 50)
+ .attr('height', height)
var axis = svg.append('g')
.attr('class', 'x axis')
- .attr('transform', 'translate(0,' + height + ')')
+ .attr('transform', 'translate(0,' + height/2 + ')')
.call(x.axis = d3.axisBottom(x))
var paths = svg.append('g')
@@ -125,20 +128,7 @@ function tick(data) {
// Shift domain
x.domain([now - (limit - 2) * duration, now - duration])
- axis.call(x.axis)
-
- var t = d3.transition()
- .duration(duration)
- .ease(d3.easeLinear)
-
- // Slide x-axis left
- // axis.transition(t).call(x.axis);
-
- // Slide paths left
- // paths.attr('transform', null)
- // .transition(t)
- // .attr('transform', 'translate(' + x(now - (limit - 1) * duration) + ')')
- // .on('end', tick)
+ //axis.call(x.axis)
// Remove oldest data point from each group
for (var name in groups) {
diff --git a/static/webpack.config.js b/static/webpack.config.js
index 607683c..a610e86 100644
--- a/static/webpack.config.js
+++ b/static/webpack.config.js
@@ -23,5 +23,8 @@ module.exports = {
title: 'D3 and RabbitMQ',
template: './src/index.html'
})
- ]
+ ],
+ devServer: {
+ host: '0.0.0.0'
+ }
}