heatmap.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.MainChartHeatmapDiskSpaceUsedMetric.create(), App.MainChartHeatmapMemoryUsedMetric.create() /*, App.MainChartHeatmapProcessRunMetric.create()*/ ]
  25. }) ],
  26. selectedMetric: null,
  27. /**
  28. * route on host detail page
  29. * @param event
  30. */
  31. routeHostDetail: function(event){
  32. App.router.transitionTo('main.hostDetails.summary', event.context)
  33. },
  34. showHeatMapMetric: function (event) {
  35. var metricItem = event.context;
  36. if (metricItem) {
  37. this.set('selectedMetric', metricItem);
  38. }
  39. },
  40. hostToSlotMap: function () {
  41. return this.get('selectedMetric.hostToSlotMap');
  42. }.property('selectedMetric.hostToSlotMap'),
  43. loadMetrics: function () {
  44. var selectedMetric = this.get('selectedMetric');
  45. if (selectedMetric) {
  46. selectedMetric.refreshHostSlots();
  47. }
  48. }.observes('selectedMetric'),
  49. /**
  50. * return class name for to be used for containing each rack.
  51. *
  52. * @this App.MainChartsHeatmapController
  53. */
  54. rackClass: function () {
  55. var rackCount = this.get('cluster.racks.length');
  56. if (rackCount < 2) {
  57. return "span12";
  58. } else if (rackCount == 2) {
  59. return "span6";
  60. } else {
  61. return "span4";
  62. }
  63. }.property('cluster')
  64. });