misc_controller.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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', 'MISC');
  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 serviceConfigsDef = params.serviceConfigsDef;
  43. var serviceName = this.get('content.serviceName');
  44. var loadedClusterSiteToTagMap = {};
  45. for ( var site in data.Clusters.desired_configs) {
  46. if (serviceConfigsDef.sites.indexOf(site) > -1) {
  47. loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
  48. }
  49. }
  50. this.setServiceConfigTags(loadedClusterSiteToTagMap);
  51. var configGroups = App.config.loadConfigsByTags(this.get('serviceConfigTags'));
  52. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, [], this.get('serviceConfigTags'), serviceName);
  53. var misc_configs = configSet.globalConfigs.filterProperty('serviceName', 'MISC').filterProperty('category', 'Users and Groups').filterProperty('isVisible', true);
  54. this.set('users', misc_configs);
  55. this.set('dataIsLoaded', true);
  56. }
  57. });