All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ide.configuration-dialog.jsx Maven / Gradle / Ivy

The newest version!
const { Modal, Button, Checkbox, FormGroup, ControlLabel, InputGroup, FormControl, HelpBlock } = ReactBootstrap;

class ConfigurationDialog extends React.Component {

    constructor(props) {
        super(props);
        this.getProject = ()=>this.props.root.getProject().value;
        this.state = {show: true};
        this.setStateFromConfig();
        this.handleClose = this.handleClose.bind(this);
        this.handleSave = this.handleSave.bind(this);
        this.saveConfig = this.saveConfig.bind(this);
    }

    setStateFromConfig() {
        const project = this.props.root.getProject();
        const hasStartMethod = project.type==="Batch";
        const hasServerStartMethod = project.type==="Service" || project.type==="WebSite";
        const hasHomePage = project && project.type==="WebSite";
        if(hasStartMethod)
            this.state.startMethod = project.value.startMethod;
        if(hasServerStartMethod)
            this.state.serverAboutToStartMethod = project.value.serverAboutToStartMethod;
        if(hasHomePage)
            this.state.homePage = project.value.homePage;
    }

    setConfigFromState(project) {
        const hasStartMethod = project.type==="Batch";
        const hasServerStartMethod = project.type==="Service" || project.type==="WebSite";
        const hasHomePage = project && project.type==="WebSite";
        if(hasStartMethod)
            project.value.startMethod = this.state.startMethod;
        if(hasServerStartMethod)
            project.value.serverAboutToStartMethod = this.state.serverAboutToStartMethod;
        if(hasHomePage)
            project.value.homePage = this.state.homePage;
    }

    handleClose() {
        this.setState({show: false});
        this.props.onClose();
    }

    handleSave() {
        // load latest full description before updating it
        const dbId = (this.getProject().dbId.value || this.getProject().dbId).toString();
        const params = {
            params: JSON.stringify([{name: "dbId", value: dbId}, {
                name: "register",
                type: "Boolean",
                value: false
            }])
        };
        axios.get('/ws/run/getModuleDescription', {params: params}).then(resp => {
            const response = resp.data;
            if (response.error)
                alert(response.error);
            else
                this.saveConfig(response.data);
        });
    }

    saveConfig(project) {
        this.setConfigFromState(project);
        const formData = new FormData();
        const params = [ {name: "module", type: project.type, value: project.value} ];
        formData.append("params", JSON.stringify(params));
        axios.post("/ws/run/storeModule", formData).
            then(response=>{
                this.props.root.loadDescription();
                this.handleClose()
            }).catch(error=>alert(error));
    }


    render() {
        const project = this.props.root.getProject();
        const hasStartMethod = project.type==="Batch";
        const hasServerStartMethod = project.type==="Service" || project.type==="WebSite";
        const hasHomePage = project && project.type==="WebSite";
        return 
            
                Module configuration
            
            
                
{ hasStartMethod && Select the start method for this application:
this.setState({startMethod: e.currentTarget.value})} value={this.state.startMethod || ""}/>
} { hasServerStartMethod && Select the method to run when server is launched:
this.setState({serverAboutToStartMethod: e.currentTarget.value})} value={this.state.serverAboutToStartMethod || ""}/>
} { hasHomePage && Select the home page:
this.setState({homePage: e.currentTarget.value})} value={this.state.homePage || ""}/>
}
; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy