1 (function( $, app, i18n ) {
5 ui.Header = ui.AbstractWidget.extend({
12 this._clusterConnect = new ui.ClusterConnect({
13 cluster: this.config.cluster
16 { text: i18n.text("Nav.Info"), path: "" },
17 { text: i18n.text("Nav.Status"), path: "_stats" },
18 { text: i18n.text("Nav.NodeStats"), path: "_nodes/stats" },
19 { text: i18n.text("Nav.ClusterNodes"), path: "_nodes" },
20 { text: i18n.text("Nav.Plugins"), path: "_nodes/plugins" },
21 { text: i18n.text("Nav.ClusterState"), path: "_cluster/state" },
22 { text: i18n.text("Nav.ClusterHealth"), path: "_cluster/health" },
23 { text: i18n.text("Nav.Templates"), path: "_template" }
25 var cluster = this.config.cluster;
27 var menuItems = quicks.map( function( item ) {
28 return { text: item.text, onclick: function() {
29 cluster.get( item.path, function( data ) {
30 quickPanels[ item.path ] && quickPanels[ item.path ].el && quickPanels[ item.path ].remove();
31 quickPanels[ item.path ] = new ui.JsonPanel({
38 this._quickMenu = new ui.MenuButton({
39 label: i18n.text("NodeInfoMenu.Title"),
40 menu: new ui.MenuPanel({
44 this.el = $.joey( this._main_template() );
45 this.nameEl = this.el.find(".uiHeader-name");
46 this.statEl = this.el.find(".uiHeader-status");
47 this._clusterState = this.config.clusterState;
48 this._clusterState.on("data", function( state ) {
49 var shards = state.status._shards;
50 var colour = state.clusterHealth.status;
51 var name = state.clusterState.cluster_name;
52 this.nameEl.text( name );
54 .text( i18n.text("Header.ClusterHealth", colour, shards.successful, shards.total ) )
55 .css( "background", colour );
57 this.statEl.text( i18n.text("Header.ClusterNotConnected") ).css("background", "grey");
58 this._clusterState.refresh();
60 _main_template: function() { return (
61 { tag: "DIV", cls: this._baseCls, children: [
63 { tag: "SPAN", cls: "uiHeader-name" },
64 { tag: "SPAN", cls: "uiHeader-status" },
65 { tag: "H1", text: i18n.text("General.Elasticsearch") },
66 { tag: "SPAN", cls: "pull-right", children: [
73 })( this.jQuery, this.app, this.i18n );