heatmap.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. App.MainChartsHeatmapController = Em.Controller.extend({
  19. name: 'mainChartsHeatmapController',
  20. cluster: App.Cluster.find(1),
  21. allMetrics: [ Em.Object.create({
  22. label: Em.I18n.t('charts.heatmap.category.host'),
  23. category: 'host',
  24. items: [ App.MainChartHeatmapProcessRunMetric.create(), App.MainChartHeatmapDiskSpaceUsedMetric.create(), App.MainChartHeatmapMemoryFreeMetric.create() ]
  25. }) ],
  26. selectedMetric: null,
  27. showHeatMapMetric: function (event) {
  28. var metricItem = event.context;
  29. if (metricItem) {
  30. this.set('selectedMetric', metricItem);
  31. }
  32. },
  33. hostToSlotMap: function () {
  34. return this.get('selectedMetric.hostToSlotMap');
  35. }.property('selectedMetric.hostToSlotMap'),
  36. loadMetrics: function () {
  37. var selectedMetric = this.get('selectedMetric');
  38. if (selectedMetric) {
  39. selectedMetric.refreshHostSlots();
  40. }
  41. }.observes('selectedMetric'),
  42. /**
  43. * return class name for to be used for containing each rack.
  44. *
  45. * @this App.MainChartsHeatmapController
  46. */
  47. rackClass: function () {
  48. var rackCount = this.get('cluster.racks.length');
  49. if (rackCount < 2) {
  50. return "span12";
  51. } else if (rackCount == 2) {
  52. return "span6";
  53. } else {
  54. return "span4";
  55. }
  56. }.property('cluster')
  57. })