dashboard.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.MainDashboardController = Em.Controller.extend({
  20. name:'mainDashboardController',
  21. alerts: function(){
  22. return App.router.get('clusterController.alerts');
  23. }.property('App.router.clusterController.alerts'),
  24. data: {
  25. hbase : {
  26. "hbasemaster_addr": "hbasemaster:60010",
  27. "total_regionservers": "1",
  28. "hbasemaster_starttime": 1348935496,
  29. "live_regionservers": 1,
  30. "dead_regionservers": 0,
  31. "regions_in_transition_count": 0,
  32. "chart": [3,7,7,5,5,3,5,3,7],
  33. "master_server_heap_used": 2348935243,
  34. "master_server_heap_total": 5648935243,
  35. "average_load": 1.4
  36. }
  37. },
  38. services:function(){
  39. return App.router.get('mainServiceController.content');
  40. }.property('App.router.mainServiceController.content'),
  41. alertsFilteredBy: 'All',
  42. alertsFilter: function(event) {
  43. if (event.context)
  44. this.set('alertsFilteredBy', event.context.get('serviceName'));
  45. else
  46. this.set('alertsFilteredBy', 'All');
  47. },
  48. /**
  49. * We do not want to re-get all the data everytime the filter
  50. * is changed. Hence we just filtered the alerts got during page
  51. * load.
  52. */
  53. displayAlerts: function(){
  54. if(this.get('alertsFilteredBy')=='All')
  55. return this.get('alerts');
  56. else
  57. var type = this.get('alertsFilteredBy').toLowerCase();
  58. return this.get('alerts').filter(function(item){
  59. var serviceType = item.get('serviceType');
  60. return serviceType && serviceType.toLowerCase()==type.toLowerCase();
  61. });
  62. }.property('alerts', 'alertsFilteredBy'),
  63. nagiosUrl: function(){
  64. return App.router.get('clusterController.nagiosUrl');
  65. }.property('App.router.clusterController.nagiosUrl'),
  66. isNagiosInstalled: function(){
  67. return App.router.get('clusterController.isNagiosInstalled');
  68. }.property('App.router.clusterController.isNagiosInstalled'),
  69. alertsCount: function() {
  70. var alerts = this.get('alerts');
  71. return alerts ? alerts.filterProperty('status', 'corrupt').length : 0;
  72. }.property('alerts')
  73. });