2 * Copyright 2010-2013 Ben Birch
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this software except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 (function( $, app, i18n ) {
18 var ui = app.ns("ui");
20 ui.Header = ui.AbstractWidget.extend({
27 this._clusterConnect = new ui.ClusterConnect({
28 cluster: this.config.cluster
31 { text: i18n.text("Nav.Info"), path: "" },
32 { text: i18n.text("Nav.Status"), path: "_stats" },
33 { text: i18n.text("Nav.NodeStats"), path: "_nodes/stats" },
34 { text: i18n.text("Nav.ClusterNodes"), path: "_nodes" },
35 { text: i18n.text("Nav.Plugins"), path: "_nodes/plugins" },
36 { text: i18n.text("Nav.ClusterState"), path: "_cluster/state" },
37 { text: i18n.text("Nav.ClusterHealth"), path: "_cluster/health" },
38 { text: i18n.text("Nav.Templates"), path: "_template" }
40 var cluster = this.config.cluster;
42 var menuItems = quicks.map( function( item ) {
43 return { text: item.text, onclick: function() {
44 cluster.get( item.path, function( data ) {
45 quickPanels[ item.path ] && quickPanels[ item.path ].el && quickPanels[ item.path ].remove();
46 quickPanels[ item.path ] = new ui.JsonPanel({
53 this._quickMenu = new ui.MenuButton({
54 label: i18n.text("NodeInfoMenu.Title"),
55 menu: new ui.MenuPanel({
59 this.el = $.joey( this._main_template() );
60 this.nameEl = this.el.find(".uiHeader-name");
61 this.statEl = this.el.find(".uiHeader-status");
62 this._clusterState = this.config.clusterState;
63 this._clusterState.on("data", function( state ) {
64 var shards = state.status._shards;
65 var colour = state.clusterHealth.status;
66 var name = state.clusterState.cluster_name;
67 this.nameEl.text( name );
69 .text( i18n.text("Header.ClusterHealth", colour, shards.successful, shards.total ) )
70 .css( "background", colour );
72 this.statEl.text( i18n.text("Header.ClusterNotConnected") ).css("background", "grey");
73 this._clusterState.refresh();
75 _main_template: function() { return (
76 { tag: "DIV", cls: this._baseCls, children: [
78 { tag: "SPAN", cls: "uiHeader-name" },
79 { tag: "SPAN", cls: "uiHeader-status" },
80 { tag: "H1", text: i18n.text("General.Elasticsearch") },
81 { tag: "SPAN", cls: "pull-right", children: [
88 })( this.jQuery, this.app, this.i18n );