Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Commit

Permalink
Implementé la función de teletipo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyam committed Jun 22, 2015
1 parent ed37d8c commit 4f759c8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
42 changes: 38 additions & 4 deletions src/components/teletipo/teletipo.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
import React from 'react';
import Reflux from 'reflux';
// import actions from '../../actions.js';
import _ from 'lodash';

require('./teletipo.less');

export default class Teletipo extends React.Component {
render() {
return (<div className="teletipo"> --Teletipo-- </div>);
var colores = [
'',
'warning',
'danger'
];

import teletipoStore from '../../stores/teletipo.js';

export default React.createClass({
mixins: [
Reflux.connect(teletipoStore, 'teletipo')
],
render: function () {
return (<table className="table table-striped">
<thead>
<tr>
<th>Fecha</th>
<th>Sector</th>
<th>Celda</th>
<th>Mensaje</th>
</tr>
</thead>
<tbody>
{_.map(this.state.teletipo, row => {
return (<tr className={colores[row.nivel]} key={row.fecha.getTime()}>
<td>{row.fecha.toLocaleString()}</td>
<td>{row.sector}</td>
<td>{row.coords}</td>
<td>{row.msg}</td>
</tr>);
})}
</tbody>
</table>);
}
}
});
6 changes: 4 additions & 2 deletions src/stores/sector.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class Sector {
actions.teletipo({
sector: this.descr,
coords: celdaDest.coords,
msg: 'Cambio automático propagado a celda en manual desde ' + celda.coords
msg: 'Cambio automático propagado a celda en manual desde ' + celda.coords,
nivel: 1
});
return;
}
Expand All @@ -74,7 +75,8 @@ class Sector {
actions.teletipo({
sector: this.descr,
coords: celdaDest.coords,
msg: 'Lazo infinito de enclavamiento desde ' + celda.coords
msg: 'Lazo infinito de enclavamiento desde ' + celda.coords,
nivel: 2
});
return;
}
Expand Down
18 changes: 18 additions & 0 deletions src/stores/teletipo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var Reflux = require('reflux');

import actions from '../actions.js';

var mensajes = [];

export default Reflux.createStore({
listenables: actions,
getInitialState: function () {
return mensajes;
},
onTeletipo: function (data) {
data.fecha = new Date();
data.nivel = data.nivel || 0;
mensajes.push(data);
this.trigger(mensajes);
}
});

0 comments on commit 4f759c8

Please sign in to comment.