configs_service.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.MainHostServiceConfigsController = App.MainServiceInfoConfigsController.extend({
  19. name: 'mainHostServiceConfigsController',
  20. host: null,
  21. isHostsConfigsPage: true,
  22. typeTagToHostMap: null,
  23. configKeyToConfigMap: null,
  24. /**
  25. * On load function
  26. */
  27. loadStep: function () {
  28. var content = this.get('content');
  29. this.set('host', content.host);
  30. this._super();
  31. },
  32. /**
  33. * Removes categories which are not valid for this host. Ex: Remove JOBTRACKER
  34. * category on host which does not have it installed.
  35. */
  36. renderServiceConfigs: function (serviceConfigs) {
  37. var newServiceConfigs = jQuery.extend({}, serviceConfigs);
  38. newServiceConfigs.configCategories = this.filterServiceConfigs(serviceConfigs.configCategories);
  39. this._super(newServiceConfigs);
  40. },
  41. /**
  42. * filter config categories by host-component of host
  43. * @param configCategories
  44. * @return {Array}
  45. */
  46. filterServiceConfigs: function (configCategories) {
  47. var hostComponents = this.get('host.hostComponents');
  48. var hostHostComponentNames = (hostComponents) ? hostComponents.mapProperty('componentName') : [];
  49. return configCategories.filter(function (category) {
  50. var hcNames = category.get('hostComponentNames');
  51. if (hcNames && hcNames.length > 0) {
  52. for (var i = 0, l = hcNames.length; i < l; i++) {
  53. if (hostHostComponentNames.contains(hcNames[i])) {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. return true;
  60. });
  61. },
  62. /**
  63. * invoke dialog for switching group of host
  64. */
  65. switchHostGroup: function () {
  66. var self = this;
  67. App.config.launchSwitchConfigGroupOfHostDialog(this.get('selectedConfigGroup'), this.get('configGroups'), this.get('host.hostName'), function (newGroup) {
  68. self.set('selectedConfigGroup', newGroup);
  69. });
  70. }
  71. });