admin.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. App.MainAdminController = Em.Controller.extend({
  20. name: 'mainAdminController',
  21. category: 'user',
  22. securityEnabled: false,
  23. /**
  24. * return true if security status is loaded and false otherwise
  25. */
  26. securityStatusLoading: function () {
  27. var dfd = $.Deferred();
  28. this.connectOutlet('loading');
  29. if (App.testMode) {
  30. window.setTimeout(function () {
  31. dfd.resolve();
  32. }, 50);
  33. } else {
  34. this.getHDFSDetailsFromServer(dfd);
  35. }
  36. return dfd.promise();
  37. },
  38. /**
  39. * return true if security status is loaded and false otherwise
  40. */
  41. getHDFSDetailsFromServer: function (dfd) { //TODO: this should be obtain from cluster level config rather than HDFS global config
  42. var self = this;
  43. var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/services/HDFS';
  44. $.ajax({
  45. type: 'GET',
  46. url: url,
  47. timeout: 10000,
  48. dataType: 'text',
  49. success: function (data) {
  50. console.log("TRACE: The url is: " + url);
  51. var jsonData = jQuery.parseJSON(data);
  52. var configs = jsonData.ServiceInfo.desired_configs;
  53. if ('global' in configs) {
  54. self.getServiceConfigsFromServer(dfd, 'global', configs['global']);
  55. } else {
  56. dfd.reject();
  57. }
  58. },
  59. error: function (request, ajaxOptions, error) {
  60. dfd.reject();
  61. },
  62. statusCode: require('data/statusCodes')
  63. });
  64. },
  65. getServiceConfigsFromServer: function (dfd, siteName, tagName) {
  66. var self = this;
  67. var url = App.apiPrefix + '/clusters/' + App.router.getClusterName() + '/configurations/?type=' + siteName + '&tag=' + tagName;
  68. $.ajax({
  69. type: 'GET',
  70. url: url,
  71. async: true,
  72. timeout: 10000,
  73. dataType: 'json',
  74. success: function (data) {
  75. console.log("TRACE: In success function for the GET getServiceConfigsFromServer call");
  76. console.log("TRACE: The url is: " + url);
  77. var configs = data.items.findProperty('tag', tagName).properties;
  78. if (configs && configs['security_enabled'] === 'true') {
  79. self.set('securityEnabled', true);
  80. } else {
  81. self.set('securityEnabled', false);
  82. }
  83. dfd.resolve();
  84. },
  85. error: function (request, ajaxOptions, error) {
  86. dfd.reject();
  87. },
  88. statusCode: require('data/statusCodes')
  89. });
  90. }
  91. });