misc_controller.js 3.3 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. require('controllers/main/service/info/configs');
  20. App.MainAdminMiscController = App.MainServiceInfoConfigsController.extend({
  21. name:'mainAdminMiscController',
  22. users: null,
  23. content: {
  24. serviceName: 'MISC'
  25. },
  26. loadUsers: function() {
  27. this.set('selectedService', this.get('content.serviceName'));
  28. this.loadServiceConfig();
  29. },
  30. loadServiceConfig: function() {
  31. App.ajax.send({
  32. name: 'config.tags',
  33. sender: this,
  34. data: {
  35. serviceName: this.get('content.serviceName'),
  36. serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
  37. },
  38. success: 'loadServiceTagSuccess'
  39. });
  40. },
  41. loadServiceTagSuccess: function(data, opt, params) {
  42. var installedServices = App.Service.find().mapProperty("serviceName");
  43. var serviceConfigsDef = params.serviceConfigsDef;
  44. var serviceName = this.get('content.serviceName');
  45. var loadedClusterSiteToTagMap = {};
  46. for ( var site in data.Clusters.desired_configs) {
  47. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  48. loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
  49. }
  50. }
  51. this.setServiceConfigTags(loadedClusterSiteToTagMap);
  52. var configGroups = App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags'));
  53. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, [], this.get('serviceConfigTags'), serviceName);
  54. var misc_configs = configSet.globalConfigs.filterProperty('serviceName', this.get('selectedService')).filterProperty('category', 'Users and Groups').filterProperty('isVisible', true);
  55. misc_configs = App.config.miscConfigVisibleProperty(misc_configs, installedServices);
  56. var sortOrder = this.get('configs').filterProperty('serviceName', this.get('selectedService')).filterProperty('category', 'Users and Groups').filterProperty('isVisible', true).mapProperty('name');
  57. var sorted = [];
  58. if(sortOrder) {
  59. sortOrder.forEach(function(name) {
  60. sorted.push(misc_configs.findProperty('name', name));
  61. });
  62. this.set('users', sorted);
  63. }
  64. else {
  65. this.set('users', misc_configs);
  66. }
  67. if(this.get("content.hdfsUser")){
  68. this.get('content').set('hdfsUser', misc_configs.findProperty('name','hdfs_user').get("value"));
  69. }
  70. if (this.get("content.group")) {
  71. this.get('content').set('group', misc_configs.findProperty('name','user_group').get("value"));
  72. }
  73. this.set('dataIsLoaded', true);
  74. }
  75. });