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.
18 var services = app.ns("services");
19 var ux = app.ns("ux");
21 services.ClusterState = ux.Observable.extend({
27 this.cluster = this.config.cluster;
28 this.clusterState = null;
30 this.nodeStats = null;
31 this.clusterNodes = null;
34 var self = this, clusterState, status, nodeStats, clusterNodes, clusterHealth;
35 function updateModel() {
36 if( clusterState && status && nodeStats && clusterNodes && clusterHealth ) {
37 this.clusterState = clusterState;
39 this.nodeStats = nodeStats;
40 this.clusterNodes = clusterNodes;
41 this.clusterHealth = clusterHealth;
42 this.fire( "data", this );
45 this.cluster.get("_cluster/state", function( data ) {
47 updateModel.call( self );
49 this.cluster.get("_stats", function( data ) {
51 updateModel.call( self );
53 this.cluster.get("_nodes/stats", function( data ) {
55 updateModel.call( self );
57 this.cluster.get("_nodes", function( data ) {
59 updateModel.call( self );
61 this.cluster.get("_cluster/health", function( data ) {
63 updateModel.call( self );
66 _clusterState_handler: function(state) {
67 this.clusterState = state;
68 this.redraw("clusterState");
70 _status_handler: function(status) {
72 this.redraw("status");
74 _clusterNodeStats_handler: function(stats) {
75 this.nodeStats = stats;
76 this.redraw("nodeStats");
78 _clusterNodes_handler: function(nodes) {
79 this.clusterNodes = nodes;
80 this.redraw("clusterNodes");
82 _clusterHealth_handler: function(health) {
83 this.clusterHealth = health;
84 this.redraw("status");