1 (function( $, app, i18n ) {
5 ui.IndexSelector = ui.AbstractWidget.extend({
6 init: function(parent) {
8 this.el = $(this._main_template());
10 this.cluster = this.config.cluster;
14 this.cluster.get( "_stats", this._update_handler );
17 _update_handler: function(data) {
19 var index_names = Object.keys(data.indices).sort();
20 for(var i=0; i < index_names.length; i++) {
21 name = index_names[i];
22 options.push(this._option_template(name, data.indices[name]));
24 this.el.find(".uiIndexSelector-select").empty().append(this._select_template(options));
25 this._indexChanged_handler();
28 _main_template: function() {
29 return { tag: "DIV", cls: "uiIndexSelector", children: i18n.complex( "IndexSelector.SearchIndexForDocs", { tag: "SPAN", cls: "uiIndexSelector-select" } ) };
32 _indexChanged_handler: function() {
33 this.fire("indexChanged", this.el.find("SELECT").val());
36 _select_template: function(options) {
37 return { tag: "SELECT", children: options, onChange: this._indexChanged_handler };
40 _option_template: function(name, index) {
41 return { tag: "OPTION", value: name, text: i18n.text("IndexSelector.NameWithDocs", name, index.primaries.docs.count ) };
45 })( this.jQuery, this.app, this.i18n );