/*
* STANDARD_RIFT_IO_COPYRIGHT
*/
import React from 'react';
import ReactDOM from 'react-dom';
import AppHeader from 'widgets/header/header.jsx';
import RedundancyStore from './redundancyStore.js';
import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
import SkyquakeRBAC from 'widgets/skyquake_rbac/skyquakeRBAC.jsx';
import 'style/layout.scss';
import {Panel, PanelWrapper} from 'widgets/panel/panel';
import {InputCollection, FormSection} from 'widgets/form_controls/formControls.jsx';
import TextInput from 'widgets/form_controls/textInput.jsx';
import Input from 'widgets/form_controls/input.jsx';
import Button, {ButtonGroup} from 'widgets/button/sq-button.jsx';
import SelectOption from 'widgets/form_controls/selectOption.jsx';
import 'widgets/form_controls/formControls.scss';
import imgAdd from '../../node_modules/open-iconic/svg/plus.svg'
import imgRemove from '../../node_modules/open-iconic/svg/trash.svg'
import _ from 'lodash';
import ROLES from 'utils/roleConstants.js';
import './redundancy.scss';
const PLATFORM = ROLES.PLATFORM;
class ConfigDashboard extends React.Component {
constructor(props) {
super(props);
this.Store = this.props.flux.stores.hasOwnProperty('RedundancyStore') ? this.props.flux.stores.RedundancyStore : this.props.flux.createStore(RedundancyStore, 'RedundancyStore');
this.state = this.Store.getState();
this.actions = this.state.actions;
}
componentDidUpdate() {
}
componentWillMount() {
this.state = this.Store.getState();
this.Store.getRedundancy();
this.Store.listen(this.updateState);
}
componentWillUnmount() {
this.Store.unlisten(this.updateState);
}
updateState = (state) => {
this.setState(state);
}
updateConfigInput = (containerName, key, e) => {
let configData = this.state[containerName];
if(!configData) {
configData = {};
}
configData[key] = e.target.value;
this.actions.handleUpdateConfigInput({[containerName]:configData})
}
updateDnsIpFqdnConfigInput = (e) => {
let value = e.target.value;
this.actions.handleUpdateConfigInput({'dns-ip-fqdn':value})
}
updateConfig = (e) => {
let self = this;
e.preventDefault();
e.stopPropagation();
let configData = self.state.configData;
let userCredentials = configData['user-credentials'];
if (!userCredentials || (userCredentials['username'].trim() == '' ) || (userCredentials['password'].trim() == '' )) {
self.props.flux.actions.global.showNotification("Please enter your user credentials");
return;
}
this.Store.updateConfig(configData);
}
evaluateSubmit = (e) => {
if (e.keyCode == 13) {
if (this.props.isEdit) {
this.updateConfig(e);
} else {
this.updateConfig(e);
}
e.preventDefault();
e.stopPropagation();
}
}
failOverDecisionChange = (e) => {
let value = e.target.value;
value = value.toUpperCase();
this.actions.handleFailOverDecisionChange(value);
}
render() {
let self = this;
let html;
let props = this.props;
let state = this.state;
let passwordSectionHTML = null;
let configData = state.configData;
let formButtonsHTML = (