nodes.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var $ = require('jquery');
  2. var Pubsub = require('../lib/pubsub');
  3. var AppState = require('../app_state');
  4. var BaseView = require('./base');
  5. var Nodes = require('../collections/nodes');
  6. var NodesView = BaseView.extend({
  7. className: 'nodes container-fluid',
  8. template: require('./spinner.hbs'),
  9. events: {
  10. 'click .conn-count': 'onClickConnCount'
  11. },
  12. initialize: function() {
  13. BaseView.prototype.initialize.apply(this, arguments);
  14. this.listenTo(AppState, 'change:graph_interval', this.render);
  15. this.collection = new Nodes();
  16. this.collection.fetch()
  17. .done(function(data) {
  18. this.template = require('./nodes.hbs');
  19. this.render({'message': data['message']});
  20. }.bind(this))
  21. .fail(this.handleViewError.bind(this))
  22. .always(Pubsub.trigger.bind(Pubsub, 'view:ready'));
  23. },
  24. onClickConnCount: function(e) {
  25. e.preventDefault();
  26. $(e.target).next().toggle();
  27. }
  28. });
  29. module.exports = NodesView;