step5_controller.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 stringUtils = require('utils/string_utils');
  19. var fileUtils = require('utils/file_utils');
  20. App.KerberosWizardStep5Controller = App.KerberosProgressPageController.extend({
  21. name: 'kerberosWizardStep5Controller',
  22. csvData: [],
  23. submit: function() {
  24. App.router.send('next');
  25. },
  26. /**
  27. * get CSV data from the server
  28. */
  29. getCSVData: function (skipDownload) {
  30. App.ajax.send({
  31. name: 'admin.kerberos.cluster.csv',
  32. sender: this,
  33. data: {
  34. 'skipDownload': skipDownload
  35. },
  36. success: 'getCSVDataSuccessCallback',
  37. error: 'getCSVDataSuccessCallback'
  38. })
  39. },
  40. /**
  41. * get CSV data from server success callback
  42. */
  43. getCSVDataSuccessCallback: function (data, opt, params) {
  44. this.set('csvData', this.prepareCSVData(data.split('\n')));
  45. if(!Em.get(params, 'skipDownload')){
  46. fileUtils.downloadTextFile(stringUtils.arrayToCSV(this.get('csvData')), 'csv', 'kerberos.csv');
  47. }
  48. },
  49. prepareCSVData: function (array) {
  50. for (var i = 0; i < array.length; i += 1) {
  51. array[i] = array[i].split(',');
  52. }
  53. return array;
  54. },
  55. /**
  56. * Send request to post kerberos descriptor
  57. * @param kerberosDescriptor
  58. * @returns {$.ajax|*}
  59. */
  60. postKerberosDescriptor: function (kerberosDescriptor) {
  61. return App.ajax.send({
  62. name: 'admin.kerberos.cluster.artifact.create',
  63. sender: this,
  64. data: {
  65. artifactName: 'kerberos_descriptor',
  66. data: {
  67. artifact_data: kerberosDescriptor
  68. }
  69. }
  70. });
  71. },
  72. /**
  73. * Send request to update kerberos descriptor
  74. * @param kerberosDescriptor
  75. * @returns {$.ajax|*}
  76. */
  77. putKerberosDescriptor: function (kerberosDescriptor) {
  78. return App.ajax.send({
  79. name: 'admin.kerberos.cluster.artifact.update',
  80. sender: this,
  81. data: {
  82. artifactName: 'kerberos_descriptor',
  83. data: {
  84. artifact_data: kerberosDescriptor
  85. }
  86. },
  87. success: 'unkerberizeCluster',
  88. error: 'unkerberizeCluster'
  89. });
  90. },
  91. /**
  92. * Send request to unkerberisze cluster
  93. * @returns {$.ajax}
  94. */
  95. unkerberizeCluster: function () {
  96. return App.ajax.send({
  97. name: 'admin.unkerberize.cluster',
  98. sender: this,
  99. success: 'goToNextStep',
  100. error: 'goToNextStep'
  101. });
  102. },
  103. goToNextStep: function() {
  104. this.clearStage();
  105. App.router.transitionTo('step5');
  106. },
  107. isSubmitDisabled: function () {
  108. return !["COMPLETED", "FAILED"].contains(this.get('status'));
  109. }.property('status'),
  110. confirmProperties: function () {
  111. var kdc_type = App.router.get('kerberosWizardController.content.kerberosOption'),
  112. filterObject = [
  113. {
  114. key: Em.I18n.t('admin.kerberos.wizard.step1.option.kdc'),
  115. properties: ['kdc_type', 'kdc_host', 'realm', 'executable_search_paths']
  116. },
  117. {
  118. key: Em.I18n.t('admin.kerberos.wizard.step1.option.ad'),
  119. properties: ['kdc_type', 'kdc_host', 'realm', 'ldap_url', 'container_dn', 'executable_search_paths']
  120. },
  121. {
  122. key: Em.I18n.t('admin.kerberos.wizard.step1.option.manual'),
  123. properties: ['kdc_type', 'realm', 'executable_search_paths']
  124. }
  125. ],
  126. kdcTypeProperties = filterObject.filter(function (item) {
  127. return item.key === kdc_type;
  128. }),
  129. filterBy = kdcTypeProperties.length ? kdcTypeProperties[0].properties : [];
  130. return App.router.kerberosWizardController.content.serviceConfigProperties.filter(function (item) {
  131. return filterBy.contains(item.name);
  132. }).map(function (item) {
  133. item['label'] = Em.I18n.t('admin.kerberos.wizard.step5.' + item['name'] + '.label');
  134. return item;
  135. });
  136. }.property('App.router.kerberosWizardController.content.@each.serviceConfigProperties')
  137. });