import {connect} from 'react-redux';
import {add_dialog_msg, get_select_list, clear_select_list, io_cmd} from '../../actions';
import IOCmdPage from '../../components/AdminPage/IOCmd'

const mapStateToProps = (state) => ({
	i18n: state.i18n,
	permissions: (function() {
        let p = sessionStorage.getItem('permissions');
        if (!p) return {};
        let json = {};
        try {
            json = JSON.parse(p);
        } catch (e) {
            return {};
        }
        return json
    }()),
	devs: state.lists.selectdev
});

const mapDispatchToProps = (dispatch, ownProps) => ({
	showDialog: (msg) => {
		dispatch(add_dialog_msg(msg));
	},
	getSelectList: (data) => {
		dispatch(get_select_list(data));
	},
	clearSelectList: () => {
		dispatch(clear_select_list());
	},
	runCmd: (data) => {
		dispatch(io_cmd(data))
	}
})

export default connect(mapStateToProps, mapDispatchToProps)(IOCmdPage);