dashboard.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. alertsFilteredByName: 'All',
  25. alertsFilteredByType: 'All',
  26. alertsFilter: function(event) {
  27. if (event.context && event.context.model && event.context.model.get('serviceName')){
  28. this.set('alertsFilteredByName', event.context.model.get('displayName'));
  29. this.set('alertsFilteredByType', event.context.model.get('serviceName'));
  30. } else {
  31. this.set('alertsFilteredByName', 'All');
  32. this.set('alertsFilteredByType', 'All');
  33. }
  34. },
  35. /**
  36. * We do not want to re-get all the data everytime the filter
  37. * is changed. Hence we just filtered the alerts got during page
  38. * load.
  39. */
  40. displayAlerts: function(){
  41. if(this.get('alertsFilteredByType')=='All')
  42. return this.get('alerts');
  43. else
  44. var type = this.get('alertsFilteredByType').toLowerCase();
  45. return this.get('alerts').filter(function(item){
  46. var serviceType = item.get('serviceType');
  47. return serviceType && serviceType.toLowerCase()==type.toLowerCase();
  48. });
  49. }.property('alerts', 'alertsFilteredByType'),
  50. nagiosUrl: function(){
  51. return App.router.get('clusterController.nagiosUrl');
  52. }.property('App.router.clusterController.nagiosUrl'),
  53. isNagiosInstalled: function(){
  54. return App.router.get('clusterController.isNagiosInstalled');
  55. }.property('App.router.clusterController.isNagiosInstalled'),
  56. alertsCount: function() {
  57. var alerts = this.get('alerts');
  58. return alerts ? alerts.filterProperty('status', 'corrupt').length : 0;
  59. }.property('alerts')
  60. });