diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2015-01-16 13:24:07 -0500 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2015-01-16 13:24:07 -0500 |
commit | 3e5ff4516e5b373f49d40b4dec5b916c62eeaade (patch) | |
tree | b11b7e8eb2e25910c5abaf635fa81d6d4ef12889 /tools/template/views/sidebar.js | |
parent | 0818cac80d76f5255abcfe0fb547cbc9da92edf9 (diff) | |
parent | 0df01e94eb8688b50f11786995f5832e249dc365 (diff) | |
download | mongo-3e5ff4516e5b373f49d40b4dec5b916c62eeaade.tar.gz |
Merge pull request #1532 from rueckstiess/1365-wtstats-rewrite
Overhaul of wtstats tool, see #1365.
Diffstat (limited to 'tools/template/views/sidebar.js')
-rw-r--r-- | tools/template/views/sidebar.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/template/views/sidebar.js b/tools/template/views/sidebar.js new file mode 100644 index 00000000000..645358a1df6 --- /dev/null +++ b/tools/template/views/sidebar.js @@ -0,0 +1,60 @@ +var AmpersandView = require('ampersand-view'), + PanelView = require('./panel'), + _ = require('lodash'), + debug = require('debug')('view:sidebar'); + +var SidebarView = module.exports = AmpersandView.extend({ + props: { + panelViews: 'object' + }, + template: require('./templates/sidebar.jade'), + events: { + 'click [data-hook=button]': 'clearClicked', + 'input [data-hook=input]': 'inputChanged' + }, + bindings: { + 'model.search.content': { + type: 'value', + hook: 'input' + } + }, + render: function () { + this.renderWithTemplate(this.model); + this.panelViews = this.renderCollection(this.model.panels, PanelView, this.queryByHook('panels')); + }, + closeAndReset: function () { + _.each(this.panelViews.views, function (view) { + view.collapsibleClose(); + view.resetStats(); + }); + }, + clearClicked: function () { + this.model.search.content = ''; + this.closeAndReset(); + this.queryByHook('button').blur(); + }, + filterPanels: function (search) { + _.each(this.panelViews.views, function (view) { + view.filterStats(search); + }); + }, + statChanged: function(stat, options) { + this.parent.statChanged(stat, options); + if (options.all) { + // inform all other panels that they need to update their indicators + _.each(this.panelViews.views, function (pv) { + pv.statChanged(stat, {all: false, propagate: false}); + }); + } + }, + inputChanged: _.debounce(function () { + var content = this.queryByHook('input').value; + this.model.search.content = content; + + if (content.trim() === '') { + this.closeAndReset(); + } else { + this.filterPanels(content); + } + }, 200, {leading: false, trailing: true}) +}); |