configs_service_menu.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. var misc = require('utils/misc');
  20. App.MainHostServiceMenuView = Em.CollectionView.extend({
  21. content:function () {
  22. var host = this.get('host');
  23. var hostComponents = host.get('hostComponents');
  24. var services = Em.A([]);
  25. if (hostComponents) {
  26. hostComponents.forEach(function (hc) {
  27. var service = hc.get('service');
  28. var serviceName = service.get('serviceName');
  29. if (serviceName) {
  30. if(!['PIG', 'SQOOP', 'HCATALOG', 'GANGLIA'].contains(serviceName)){
  31. if (!services.findProperty('serviceName', serviceName)) {
  32. services.push(service);
  33. }
  34. }
  35. } else {
  36. console.warn("serviceName not found for " + hc.get('componentName'));
  37. }
  38. });
  39. }
  40. return misc.sortByOrder(App.Service.servicesSortOrder, services);
  41. }.property('host'),
  42. host: function(){
  43. return App.router.get('mainHostDetailsController.content');
  44. }.property('App.router.mainHostDetailsController.content'),
  45. selectedService: null,
  46. showHostService: function(event){
  47. var service = event.contexts[0];
  48. if(service!=null){
  49. this.set('selectedService', service);
  50. var context = service;
  51. context.host = this.get('host');
  52. this.get('controller').connectOutlet('service_config_outlet', 'mainHostServiceConfigs', context);
  53. }else{
  54. this.get('controller').connectOutlet('service_config_outlet', Em.View.extend({
  55. template: Ember.Handlebars.compile('<i class="message">Service not available on this host</i>')
  56. }))
  57. }
  58. },
  59. didInsertElement:function () {
  60. var event = {
  61. contexts: [this.get('content').objectAt(0)]
  62. }
  63. this.showHostService(event);
  64. },
  65. activeServiceId:null,
  66. tagName:'ul',
  67. classNames:["nav", "nav-list", "nav-services"],
  68. itemViewClass:Em.View.extend({
  69. classNameBindings:["active", "clients"],
  70. active:function () {
  71. return this.get('content.serviceName') == this.get('parentView.selectedService.serviceName') ? 'active' : '';
  72. }.property('parentView.selectedService.serviceName'),
  73. template: Ember.Handlebars.compile('<a href="#" {{action showHostService view.content target="view.parentView"}} >{{view.content.displayName}}</a>')
  74. })
  75. });