123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var stringUtils = require('utils/string_utils');
- App.KerberosWizardStep5Controller = App.KerberosProgressPageController.extend({
- name: 'kerberosWizardStep5Controller',
- csvData: [],
- submit: function() {
- App.router.send('next');
- },
- /**
- * get CSV data from the server
- */
- getCSVData: function () {
- App.ajax.send({
- name: 'admin.kerberos.cluster.csv',
- sender: this,
- data: {},
- success: 'getCSVDataSuccessCallback',
- error: 'getCSVDataSuccessCallback'
- })
- },
- /**
- * get CSV data from server success callback
- */
- getCSVDataSuccessCallback: function (data, opt, params) {
- this.set('csvData', this.prepareCSVData(data.split('\n')));
- this.downloadCSV();
- },
- prepareCSVData: function (array) {
- for (var i = 0; i < array.length; i += 1) {
- array[i] = array[i].split(',');
- }
- return array;
- },
- /**
- * download CSV file
- */
- downloadCSV: function () {
- if ($.browser.msie && $.browser.version < 10) {
- this.openInfoInNewTab();
- } else {
- try {
- var blob = new Blob([stringUtils.arrayToCSV(this.get('csvData'))], {type: "text/csv;charset=utf-8;"});
- saveAs(blob, "kerberos.csv");
- } catch (e) {
- this.openInfoInNewTab();
- }
- }
- },
- /**
- * open content of CSV file in new window
- */
- openInfoInNewTab: function () {
- var newWindow = window.open('');
- var newDocument = newWindow.document;
- newDocument.write(stringUtils.arrayToCSV(this.get('hostComponents')));
- newWindow.focus();
- },
- /**
- * Send request to post kerberos descriptor
- * @param kerberosDescriptor
- * @returns {$.ajax|*}
- */
- postKerberosDescriptor: function (kerberosDescriptor) {
- return App.ajax.send({
- name: 'admin.kerberos.cluster.artifact.create',
- sender: this,
- data: {
- artifactName: 'kerberos_descriptor',
- data: {
- artifact_data: kerberosDescriptor
- }
- }
- });
- },
- /**
- * Send request to update kerberos descriptor
- * @param kerberosDescriptor
- * @returns {$.ajax|*}
- */
- putKerberosDescriptor: function (kerberosDescriptor) {
- return App.ajax.send({
- name: 'admin.kerberos.cluster.artifact.update',
- sender: this,
- data: {
- artifactName: 'kerberos_descriptor',
- data: {
- artifact_data: kerberosDescriptor
- }
- },
- success: 'unkerberizeCluster',
- error: 'unkerberizeCluster'
- });
- },
- /**
- * Send request to unkerberisze cluster
- * @returns {$.ajax}
- */
- unkerberizeCluster: function () {
- return App.ajax.send({
- name: 'admin.unkerberize.cluster',
- sender: this,
- success: 'goToNextStep',
- error: 'goToNextStep'
- });
- },
- goToNextStep: function() {
- this.clearStage();
- App.router.transitionTo('step5');
- },
- isSubmitDisabled: function () {
- return !["COMPLETED", "FAILED"].contains(this.get('status'));
- }.property('status')
- });
|