1
0
Fork 0

Cleanup code

This commit is contained in:
Gregory Eremin 2015-02-08 21:40:05 +07:00
parent 6563736fae
commit 1a1e062712
4 changed files with 27 additions and 9 deletions

View File

@ -7,6 +7,9 @@ jsx: check-react
jsx --extension jsx server/static/ server/static/ jsx --extension jsx server/static/ server/static/
rm -rf server/static/.module-cache rm -rf server/static/.module-cache
watch:
jsx --watch --extension jsx server/static/ server/static/
cleanup: cleanup:
find . -name '.DS_Store' | xargs rm -f find . -name '.DS_Store' | xargs rm -f

View File

@ -37,6 +37,7 @@ thead tr {
.title { .title {
position: relative; position: relative;
width: 350px; width: 350px;
max-width: 350px;
} }
.name { .name {
max-width: 350px; max-width: 350px;

View File

@ -1,6 +1,9 @@
var Chart = React.createClass({ var Chart = React.createClass({
getInitialState: function() { getInitialState: function() {
return {pointsIn: [], pointsOut: []}; return {
pointsIn: [],
pointsOut: []
};
}, },
componentDidMount: function() { componentDidMount: function() {
@ -26,7 +29,10 @@ var Chart = React.createClass({
pointsOut.push(pointOut); pointsOut.push(pointOut);
} }
this.setState({pointsIn: pointsIn, pointsOut: pointsOut}); this.setState({
pointsIn: pointsIn,
pointsOut: pointsOut
});
}, },
calcMaxDouble: function(a, b) { calcMaxDouble: function(a, b) {
@ -59,11 +65,14 @@ var Chart = React.createClass({
}, },
render: function() { render: function() {
var viewBox = [0, 0, this.props.width, this.props.height].join(' '); var viewBox = [0, 0, this.props.width, this.props.height].join(' '),
dIn = this.buildPathD(this.state.pointsIn),
dOut = this.buildPathD(this.state.pointsOut);
return ( return (
<svg className="chart" viewBox={viewBox}> <svg className="chart" viewBox={viewBox}>
<path className="in" d={this.buildPathD(this.state.pointsIn)} /> <path className="in" d={dIn} />
<path className="out" d={this.buildPathD(this.state.pointsOut)} /> <path className="out" d={dOut} />
</svg> </svg>
); );
} }
@ -110,6 +119,7 @@ var QueuesList = React.createClass({
if (meta.subscriptions === 0) { if (meta.subscriptions === 0) {
subscriptionsClasses.push('zero'); subscriptionsClasses.push('zero');
} }
return ( return (
<tr key={name}> <tr key={name}>
<td className="title"> <td className="title">
@ -151,7 +161,7 @@ var Dashboard = React.createClass({
clearTimeout(this.timeout); clearTimeout(this.timeout);
}, },
loop: function (timeout, func) { loop: function(timeout, func) {
var loop = this.loop; var loop = this.loop;
func(); func();
this.timeout = setTimeout(function(){ this.timeout = setTimeout(function(){
@ -159,10 +169,11 @@ var Dashboard = React.createClass({
}, timeout); }, timeout);
}, },
refresh: function () { refresh: function() {
var xhr = new XMLHttpRequest() var xhr = new XMLHttpRequest()
self = this; self = this;
xhr.open('GET', '/status?rates=please', true);
xhr.open('GET', this.props.api, true);
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
if (xhr.status === 200) { if (xhr.status === 200) {

View File

@ -13,7 +13,10 @@
<div id="dashboard"></div> <div id="dashboard"></div>
<script> <script>
React.render( React.render(
React.createElement(Dashboard, {api: "http://127.0.0.1:{{.port}}/status", interval: 1000}), React.createElement(Dashboard, {
api: "http://127.0.0.1:{{.port}}/status?rates=please",
interval: 1000
}),
document.getElementById('dashboard') document.getElementById('dashboard')
); );
</script> </script>