incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1397948 [2/3] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-web/ ambari-web/app/ ambari-web/app/assets/data/ ambari-web/app/assets/data/services/ ambari-web/app/assets/data/services/summary/ ambari-web/app/assets/img/ ambari-web/ap...
Date Sat, 13 Oct 2012 21:03:20 GMT
Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/chart.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/chart.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/chart.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/chart.js Sat Oct 13 21:03:18
2012
@@ -0,0 +1,290 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.ChartView = Em.View.extend({
+  dateFormat:'dd/mm/yy',
+  timeFormat:'h:m',
+  w:900,
+  p:30, // axis padding
+  shift:30,
+  ticksCount:10,
+  pointsLimit:300,
+  areaHeight:30, // px
+  axis:false,
+  x:false,
+  y:false,
+
+  init:function () {
+    this._super();
+    var renderer = this;
+
+    this.x = d3.time.scale().domain([renderer.getMinDate({}), renderer.getMaxDate({})]).range([0,
this.get('w')]);
+    this.y = d3.scale.linear().domain([0, 50]).range([this.get('h'), 0]);
+    this.axis = d3.svg.axis().orient("top").scale(this.x).ticks(this.get('ticksCount'));
+  },
+
+  h: function(){
+    return this.get('p') + this.get('nodeAttributes').length * this.get('areaHeight'); //default:
160
+  }.property('nodeAttributes', 'p'),
+
+  activeH: function(){
+    return this.get('nodeAttributes').length * this.get('areaHeight'); // default 160;
+  }.property('h'),
+
+  ruleHeight: function(){
+    return this.get('nodeAttributes').length * this.get('areaHeight');
+  }.property('nodeAttributes'),
+
+  updateY: function(){
+    this.y = d3.scale.linear().domain([0, 50]).range([this.get('h'), 0]);
+  }.observes('h'),
+
+  getMinDate:function (data) {
+    if (data.length)
+      return new Date(Date.parse(data[0]['date']));
+
+    return new Date();
+  },
+
+  getMaxDate:function (data) {
+    if (data.length)
+      return new Date(Date.parse(data[data.length - 1]['date']));
+
+    return new Date();
+  },
+
+  area:function () {
+    var renderer = this;
+    var area = d3.svg.area().x(function (d) {
+      return renderer.x(renderer.getDate(d));
+    });
+
+    area.y1(function (d) {
+      return renderer.get('h') - (renderer.get('h') - renderer.y(d[$(this).attr("getter")]))
/ renderer.get('koef');
+    });
+
+    area.y0(function (d) {
+      return renderer.get('h');
+    });
+
+    return area;
+  },
+
+  line:function () {
+    var renderer = this;
+    var area = d3.svg.line().x(function (d) {
+      return renderer.x(renderer.getDate(d));
+    })
+      .interpolate("basis");
+
+    area.y(function (d) {
+      return renderer.get('h');
+    });
+
+    return area;
+  },
+
+  /**
+   * @todo: calculate this
+   * coefficient of compression
+   * @param shift
+   * @return {Number}
+   */
+
+  koef:function () {
+    // max value divide on area height;
+    return 2 * (this.get('nodeAttributes').length + 1);
+  }.property('h'),
+
+  getDate:function (d) {
+    return new Date(Date.parse(d.date));
+  },
+
+  dateTimeToDateObject:function (string) {
+    var ren = this;
+    return new Date($.datepicker.parseDateTime(ren.dateFormat, ren.timeFormat, string));
+  },
+
+  getDefaultShift:function () {
+    return  -1 * this.get('areaHeight') * (this.get('nodeAttributes').length - 1);
+  },
+
+  percentScaleXDefaultTranslate:function () {
+    return this.w + 3
+  },
+
+  clearPlot: function(){
+    d3.select(this.get('chartContainerSelector')).selectAll("*").remove();
+  },
+
+  drawPlot:function () {
+    this.clearPlot();
+
+    var renderer = this;
+    this.x.domain([renderer.getMinDate({}), renderer.getMaxDate({})]);
+
+    var rule = $('<div></div>').addClass("rule").css('height', renderer.get('ruleHeight')).mouseenter(function
() { $(this).hide(); });
+    $(this.get('chartContainerSelector')).prepend(rule);
+
+    var vis = d3.select(this.get('chartContainerSelector'))
+      .append("svg:svg")
+      .attr("width", renderer.get('w') + 5)
+      .attr("height", renderer.get('h'))
+      .attr("rendererId", this.$().attr('id'))
+      .on("mousemove", function () {
+
+        var area = d3.select(this).select("path.line");
+        var d = area.data()[0];
+        var x = d3.mouse(this)[0];
+
+        var renderer = Em.View.views[d3.select(this).attr('rendererId')];
+        var container = $(this).parent();
+        var scale = renderer.x;
+
+        // first move rule
+        var rule = $(container).children("div.rule");
+        rule.css("left", (168 + x) + "px"); // 168 - left container margin
+        rule.show();
+
+        x = x + 5; // some correction
+        var selectedDate = scale.invert(x);
+
+        // search date between this coordinates
+        var prevVal = false;
+        var nextVal = d[0];
+
+        $.each(d, function (i, point) {
+          if (renderer.getDate(point).getTime() <= selectedDate.getTime()) {
+            prevVal = nextVal;
+            nextVal = point;
+          } else {
+            return;
+          }
+        });
+
+        var len1 = Math.abs(x - scale(renderer.getDate(prevVal)));
+        var len2 = Math.abs(x - scale(renderer.getDate(nextVal)));
+
+        var clearing = 5;
+        var pointToShow = false;
+        // if the first point if closer
+        if ((len1 < len2) && (len1 <= clearing)) {
+          pointToShow = prevVal;
+        } else if (len2 <= clearing) { // the second point is closer
+          pointToShow = nextVal;
+        }
+
+        $.each(renderer.get('nodeAttributes'), function (i, v) {
+          var value = !pointToShow ? "" : pointToShow[v] + "%";
+          $(rule).children("div." + v).html(value);
+        });
+      });
+
+    vis.append("svg:g")
+      .attr("class", "axis")
+      .attr("transform", "translate(0," + this.get('p') + ")")
+      .call(renderer.axis)
+
+    $.each(this.get('nodeAttributes'), function (i, v) {
+      var element = $('<div></div>').addClass(v).addClass("stateValue").html("");
+      rule.append(element);
+    });
+
+    var shift = this.getDefaultShift();
+    vis.append("svg:path")
+      .attr("class", "horizontal-line")
+      .data([
+      {}
+    ])
+      .attr("transform", "translate(0," + (shift - this.get('areaHeight')) + ")")
+      .attr("d", renderer.line())
+      .style("stroke", "#000");
+
+    $.each(this.get('nodeAttributes'), function (i, v) {
+      vis.append("svg:path").data([
+        {}
+      ])
+        .attr("class", "line")
+        .attr("getter", v)
+        .attr("transform", "translate(0, " + shift + ")")
+        .attr("d", renderer.area())
+        .style("fill", function () {
+          return "#31a354";
+        });
+
+      vis.append("svg:path")
+        .attr("class", "horizontal-line")
+        .data([
+        {}
+      ])
+        .attr("transform", "translate(0," + shift + ")")
+        .attr("d", renderer.line())
+        .style("stroke", "#000");
+
+      shift += renderer.get('areaHeight');
+    });
+  },
+
+  getData:function (containerId) {
+    return (d3.select(containerId + " path.line").data())[0];
+  },
+
+  drawChart:function () {
+    var containerSel = this.get('chartContainerSelector');
+    var data = this.get('data');
+
+    while (data.length > this.get('pointsLimit')) {
+      data.shift();
+    }
+
+    var renderer = this;
+    var minDate = this.getMinDate(data);
+    var maxDate = this.getMaxDate(data);
+
+    this.x.domain([minDate, maxDate]);
+
+    var ticks = data.length > 10 ? 10 : data.length;
+    this.axis.scale(renderer.x).ticks(ticks);
+
+//        remove dots axis
+    $(containerSel + " svg g.axis g").remove();
+    d3.select(containerSel + " svg g.axis")
+      .call(this.axis);
+
+    $.each(this.get('nodeAttributes'), function (i, v) {
+      d3.select(containerSel + " path.line[getter='" + v + "']")
+        .data([data])
+        .transition()
+        .attr("d", renderer.area());
+    });
+
+    // lines between charts
+    $(containerSel + " path.horizontal-line").each(
+      function (i, path) {
+        d3.select(path).data([
+          [
+            {date:minDate},
+            {date:maxDate}
+          ]
+        ]).attr("d", renderer.line());
+      }
+    );
+  }
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/metric.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/metric.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/metric.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/common/metric.js Sat Oct 13
21:03:18 2012
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+/**
+ * use: {{view App.MetricFilteringWidget controllerBinding="App.router.mainChartsController"}}
+ * set controller.metric field with metric value
+ * widget assign itself to controller like metricWidget (controller.get('metricWidget'))
+ * @type {*}
+ */
+App.MetricFilteringWidget = Em.View.extend({
+  metrics:[],
+  itemView:Em.View.extend({
+    tagName:'li',
+    classNameBindings:['disabled'],
+    disabled:function () {
+      return this.get('isActive') ? "disabled" : false;
+    }.property('isActive'),
+    isActive:function () {
+      return this.get('metric.value') == this.get('widget.controller.metric');
+    }.property('widget.controller.metric'),
+    template:Em.Handlebars.compile('<a {{action activate view.metric.value target="view.widget"
}}>{{view.metric.label}}</a>')
+  }),
+
+  metricsConfig:[
+    { label:Em.I18n.t('metric.default'), value:null},
+    { label:Em.I18n.t('metric.cpu'), value:'cpu'},
+    { label:Em.I18n.t('metric.memory'), value:'memory'},
+    { label:Em.I18n.t('metric.network'), value:'network'},
+    { label:Em.I18n.t('metric.io'), value:'io'}
+  ],
+
+  allMetrics:function () {
+    var values = [];
+    $.each(this.get('metricsConfig'), function () {
+      if (this.value) {
+        values.push(this.value);
+      }
+    });
+    return values;
+  }.property(),
+
+  init:function () {
+    this._super();
+    var thisW = this;
+    var controller = this.get('controller');
+    controller.set('metricWidget', thisW);
+
+    this.get('itemView').reopen({
+      widget:thisW
+    });
+
+    // preparing metric objects
+    this.get('metricsConfig').forEach(function (config) {
+      config['widget'] = thisW;
+      thisW.get('metrics').push(Em.Object.create(config))
+    });
+
+  },
+
+  /**
+   * write active metric to binded controller
+   * @param event
+   */
+  activate:function (event) {
+    var selected = event.context;
+    var controller = this.get('controller');
+    controller.set('metric', selected);
+  },
+
+  templateName:require('templates/common/metric')
+})
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js?rev=1397948&r1=1397947&r2=1397948&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/admin/user/edit.js Sat
Oct 13 21:03:18 2012
@@ -28,16 +28,11 @@ App.MainAdminUserEditView = Em.View.exte
     }
   },
 
-  willInsertElement: function() {
-    this.setFormObject();
-    this._super();
-  },
+  userForm: App.UserForm.create({}),
+
 
-  setFormObject: function(){
-    console.log("submit new user");
-    var user = App.router.get('mainAdminUserEditController.content');
-    this.userForm.set('object', user);
-  }.observes('App.router.mainAdminUserEditController.content'),
+  didInsertElement: function(){
+    this.get('userForm').propertyDidChange('object');
+  }
 
-  userForm: App.UserForm.create({})
 });
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap.js Sat Oct
13 21:03:18 2012
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHeatmapView = Em.View.extend({
+    templateName: require('templates/main/charts/heatmap')
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host.js
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host.js
Sat Oct 13 21:03:18 2012
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHeatmapHostView = Em.View.extend({
+  templateName: require('templates/main/charts/heatmap/heatmap_host'),
+  /** @private */ hostClass: 'hostBlock',
+
+  /**
+   * show Host details block and move it near the cursor
+   * @param {Object} e
+   * @this App.MainChartsHeatmapHostView
+   */
+  mouseEnter:function (e) {
+    var host = this.get('content');
+    var view = App.MainChartsHeatmapHostDetailView.create();
+    $.each(view.get('details'), function (i) {
+      view.set('details.' + i, host.get(i));
+    });
+    $("#heatmapDetailsBlock").css('top', e.pageY + 10);
+    $("#heatmapDetailsBlock").css('left', e.pageX + 10);
+
+    $("#heatmapDetailsBlock").show();
+  },
+
+  /**
+   * hide Host details block
+   * @param {Object} e
+   * @this App.MainChartsHeatmapHostView
+   */
+  mouseLeave:function (e) {
+    $("#heatmapDetailsBlock").hide();
+  }
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
Sat Oct 13 21:03:18 2012
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHeatmapHostDetailView = Em.View.extend({
+  templateName: require('templates/main/charts/heatmap/heatmap_host_detail'),
+  /** @private */ classNames:['heatmap_host_details', 'hide'],
+  /** @private */ elementId:'heatmapDetailsBlock',
+  /** @private */ details:{
+    hostName:'test node',
+    cpuUsage: '10',
+    memoryUsage: '10',
+    networkUsage: '30',
+    ioUsage: '40'
+  }
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_rack.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_rack.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_rack.js
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/heatmap/heatmap_rack.js
Sat Oct 13 21:03:18 2012
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHeatmapRackView = Em.View.extend({
+  templateName: require('templates/main/charts/heatmap/heatmap_rack'),
+  classNames: ['rack'],
+  classNameBindings: ['visualSchema'],
+  /**
+   * this is the class for binding attribute to hosts block
+   * @private
+   */
+  hostsBlockClass:"hosts clearfix",
+  heatmapIsOpened: 1,
+
+  /** rack status block class */
+  statusIndicator:'statusIndicator',
+
+  toggleRack: function(){
+    var newHeatmapStatus = 1 - this.get('heatmapIsOpened');
+    this.set('heatmapIsOpened', newHeatmapStatus);
+  },
+
+  /**
+   * change toggler class, depends on heatmapIsOpened property
+   * @this App.MainChartsHeatmapRackView
+   */
+  heatmapTogglerClass:function () {
+    if (this.heatmapIsOpened) {
+      return "isActive"
+    }
+    return "";
+  }.property("heatmapIsOpened")
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon.js Sat Oct
13 21:03:18 2012
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHorizonView = Em.View.extend({
+  templateName:require('templates/main/charts/horizon'),
+  classNames: ['horizon', 'charts'],
+  hosts: App.Host.find()
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon/chart.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon/chart.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon/chart.js
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/horizon/chart.js
Sat Oct 13 21:03:18 2012
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsHorizonChartView = App.ChartView.extend({
+  containerIdPrefix:'chartHistoricalMetrick',
+  classNames:['chart'],
+  chartOpened:0,
+  chartDrawn:false,
+  data:[],
+  healthStatusClass:function () {
+    return this.get('host.healthStatus') + ' ' + 'health';
+  }.property('host.healthStatus'),
+
+  templateName:require('templates/main/charts/horizon/chart'),
+
+  chartClass:function () {
+    return this.get('chartOpened') ? "display" : "noDisplay";
+  }.property('chartOpened'),
+
+  showChartText:function () {
+    return this.t("charts.horizon.chart." + (this.get('chartOpened') ? "hideText" : "showText"));
+  }.property('chartOpened'),
+
+  chartContainerSelector:function () {
+    return "#" + this.get('chartContainerId');
+  }.property('chartContainerId'),
+
+  chartContainerId:function () {
+    return this.get('containerIdPrefix') + this.get('host.id');
+  }.property('host.id'),
+
+  getNodeChartBlock:function () {
+    return $('#' + this.get('elementId') + ' div.chartBlock');
+  },
+
+  drawChart:function () {
+    this._super();
+  }.observes('dataLoaded'),
+
+  loadHorizonInfo:function () {
+    var hostInfo = App.HostInfo.create({});
+    var data = hostInfo.get('horizonData');
+    this.set('data', data);
+    this.set('dataLoaded', Math.random()*10);
+  },
+
+  usedMetrics: function(){
+    var thisW = this;
+    var attributes = [];
+    $.each(this.get('nodeAttributes'), function(){
+      attributes.push(thisW.t('metric.'+this));
+    });
+
+    return attributes;
+
+  }.property('nodeAttributes'),
+
+  nodeAttributes: function(){
+    var controller = App.get('router.mainChartsController');
+    var metric = controller.get('metric');
+    if(!metric) {
+      return controller.get('metricWidget.allMetrics');
+    }
+    return [metric];
+  }.property('App.router.mainChartsController.metric'),
+
+  toggleChart:function () {
+    var thisChart = this;
+    var host = this.get('host');
+    var controller = App.router.get('mainChartsController');
+    if (!this.get('chartOpened')) { // if chart will be opened
+      if (!this.get('chartDrawn')) {
+        this.drawPlot(); // parent method
+        this.set('chartDrawn', 1);
+      }
+
+      this.loadHorizonInfo();
+      controller.addObserver('metric', thisChart, 'drawPlot');
+      controller.addObserver('metric', thisChart, 'loadHorizonInfo');
+    } else { // if chart will be closed
+      controller.removeObserver('metric', thisChart, 'drawPlot');
+      controller.removeObserver('metric', thisChart, 'loadHorizonInfo');
+    }
+
+    this.set('chartOpened', 1 - this.get('chartOpened'));
+  }
+});
\ No newline at end of file

Added: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/menu.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/menu.js?rev=1397948&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/menu.js (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/charts/menu.js Sat Oct
13 21:03:18 2012
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainChartsMenuView = Em.CollectionView.extend({
+  tagName: 'ul',
+  classNames: ["nav", "nav-tabs"],
+  content:[
+    { label:'Heatmap', routing:'heatmap', active:"active"},
+    { label:'Horizon Chart', routing:'horizon_chart'}
+  ],
+
+  init: function(){ this._super(); this.activateView(); },
+
+  activateView:function () {
+    $.each(this._childViews, function () {
+      this.set('active', (this.get('content.routing') == 'heatmap' ? "active" : ""));
+    });
+  },
+
+  deactivateChildViews: function() {
+    $.each(this._childViews, function(){
+      this.set('active', "");
+    });
+  },
+
+  itemViewClass: Em.View.extend({
+    classNameBindings: ["active"],
+    active: "",
+    template: Ember.Handlebars.compile('<a {{action showChart view.content.routing }}
href="#"> {{unbound view.content.label}}</a>')
+  })
+});
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/service/info/summary.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/service/info/summary.js?rev=1397948&r1=1397947&r2=1397948&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/service/info/summary.js
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/service/info/summary.js
Sat Oct 13 21:03:18 2012
@@ -19,5 +19,51 @@
 var App = require('app');
 
 App.MainServiceInfoSummaryView = Em.View.extend({
-  templateName: require('templates/main/service/info/summary')
+  templateName: require('templates/main/service/info/summary'),
+  attributes: null,
+  serviceStatus: {
+    hdfs: false
+  },
+  serviceName: function() {
+    return App.router.mainServiceInfoSummaryController.get('content.serviceName');
+  }.property('App.router.mainServiceInfoSummaryController.content'),
+  init: function() {
+    this._super();
+    if (this.get('serviceName'))
+      this.loadServiceSummary(this.get('serviceName'));
+  },
+  loadServiceSummary: function(serviceName) {
+    var summaryView = this;
+    jQuery.getJSON('data/services/summary/' + serviceName + '.json',
+      function (data) {
+        if (data[serviceName]) {
+          var summary = data[serviceName];
+          if(serviceName == 'hdfs') {
+            summaryView.set('serviceStatus.hdfs', true);
+            summary['memory_heap_used'] = summaryView.convertByteToMbyte(summary['memory_heap_used']);
+            summary['memory_heap_max'] = summaryView.convertByteToMbyte(summary['memory_heap_max']);
+            summary['memory_heap_percent_used'] = summaryView.countPercentageRatio(summary['memory_heap_used'],
summary['memory_heap_max']);
+            summary['used_bytes'] = summaryView.convertByteToGbyte(summary['dfs_used_bytes']
+ summary['nondfs_used_bytes']);
+            summary['dfs_total_bytes'] = summaryView.convertByteToGbyte(summary['dfs_total_bytes']);
+          } else {
+            summaryView.set('serviceStatus.hdfs', false);
+          }
+          summaryView.set('attributes', summary);
+        }
+      }
+    )
+  },
+  convertByteToMbyte: function(value) {
+    var bytesInMbyte = 1048576;
+    var newValue = value/bytesInMbyte;
+    return parseFloat(newValue.toFixed(1));
+  },
+  convertByteToGbyte: function(value) {
+    var bytesInGbyte = 1073741824;
+    var newValue = value/bytesInGbyte;
+    return parseFloat(newValue.toFixed(2));
+  },
+  countPercentageRatio: function(usedValue, maxValue) {
+    return Math.round((usedValue/maxValue) * 100);
+  }
 });
\ No newline at end of file

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee?rev=1397948&r1=1397947&r2=1397948&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/config.coffee Sat Oct 13 21:03:18 2012
@@ -40,6 +40,7 @@ exports.config =
           'vendor/scripts/ember-data-latest.js',
           'vendor/scripts/ember-i18n-1.2.0.js',
           'vendor/scripts/bootstrap.js',
+          'vendor/scripts/d3.v2.js',
           'vendor/scripts/sinon-1.4.2.js'
           ]
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/package.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/package.json?rev=1397948&r1=1397947&r2=1397948&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/package.json (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/package.json Sat Oct 13 21:03:18 2012
@@ -1,4 +1,3 @@
-
 {
   "name": "Ambari",
   "description": "Front-end package for the Apache Ambari Project",



Mime
View raw message