misc_controller.js 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 stringUtils = require('utils/string_utils');
  20. require('controllers/main/service/info/configs');
  21. App.MainAdminMiscController = App.MainServiceInfoConfigsController.extend({
  22. name:'mainAdminMiscController',
  23. users: null,
  24. content: {
  25. serviceName: 'MISC'
  26. },
  27. loadUsers: function() {
  28. this.set('selectedService', this.get('content.serviceName'));
  29. this.loadServiceConfig();
  30. },
  31. loadServiceConfig: function() {
  32. App.ajax.send({
  33. name: 'config.tags',
  34. sender: this,
  35. data: {
  36. serviceName: this.get('content.serviceName'),
  37. serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
  38. },
  39. success: 'loadServiceTagSuccess'
  40. });
  41. },
  42. loadServiceTagSuccess: function(data, opt, params) {
  43. var installedServices = App.Service.find().mapProperty("serviceName");
  44. var serviceConfigsDef = params.serviceConfigsDef;
  45. var serviceName = this.get('content.serviceName');
  46. var loadedClusterSiteToTagMap = {};
  47. for ( var site in data.Clusters.desired_configs) {
  48. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  49. loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
  50. }
  51. }
  52. this.setServiceConfigTags(loadedClusterSiteToTagMap);
  53. var configGroups = App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags'));
  54. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, [], this.get('serviceConfigTags'), serviceName);
  55. var misc_configs = configSet.globalConfigs.filterProperty('serviceName', this.get('selectedService')).filterProperty('category', 'Users and Groups').filterProperty('isVisible', true);
  56. misc_configs = App.config.miscConfigVisibleProperty(misc_configs, installedServices);
  57. var sortOrder = this.get('configs').filterProperty('serviceName', this.get('selectedService')).filterProperty('category', 'Users and Groups').filterProperty('isVisible', true).mapProperty('name');
  58. var sorted = [];
  59. //stack, with version lower than 2.1, doesn't have Falcon service
  60. var proxyUserGroup = misc_configs.findProperty('name', 'proxyuser_group');
  61. if (proxyUserGroup && stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.1") !== 1) {
  62. proxyUserGroup.set('displayName', "Proxy group for Hive, WebHCat and Oozie");
  63. }
  64. if(sortOrder) {
  65. sortOrder.forEach(function(name) {
  66. var user = misc_configs.findProperty('name', name);
  67. if (user) {
  68. sorted.push({
  69. isVisible: user.get('isVisible'),
  70. displayName: user.get('displayName'),
  71. value: user.get('value')
  72. });
  73. }
  74. });
  75. this.set('users', sorted);
  76. }
  77. else {
  78. this.set('users', misc_configs);
  79. }
  80. if(this.get("content.hdfsUser")){
  81. this.get('content').set('hdfsUser', misc_configs.findProperty('name','hdfs_user').get("value"));
  82. }
  83. if (this.get("content.group")) {
  84. this.get('content').set('group', misc_configs.findProperty('name','user_group').get("value"));
  85. }
  86. this.set('dataIsLoaded', true);
  87. }
  88. });