constructor()

in source/console/src/Components/Create/Create.js [49:137]


    constructor(props) {
        super(props);
        if (this.props.location.state && this.props.location.state.data.testId) {
            let fileType = '';
            if (this.props.location.state.data.testType && this.props.location.state.data.testType !== 'simple') {
                if (this.props.location.state.data.fileType) {
                    fileType = this.props.location.state.data.fileType;
                } else {
                    fileType = 'script';
                }
            }

            this.state = {
                isLoading: false,
                runningTasks: false,
                availableTasks: 1000,
                testId: this.props.location.state.data.testId,
                file: null,
                validFile: false,
                chooseNewFile: false,
                activeTab: this.props.location.state.data.recurrence ? '2' : '1',
                submitLabel: this.props.location.state.data.scheduleDate ? "Schedule" : "Run Now",
                formValues: {
                    testName: this.props.location.state.data.testName,
                    testDescription: this.props.location.state.data.testDescription,
                    taskCount: this.props.location.state.data.taskCount,
                    concurrency: this.props.location.state.data.concurrency,
                    holdFor: this.props.location.state.data.holdFor.slice(0, -1),
                    holdForUnits: this.props.location.state.data.holdFor.slice(-1),
                    rampUp: this.props.location.state.data.rampUp.slice(0, -1),
                    rampUpUnits: this.props.location.state.data.rampUp.slice(-1),
                    endpoint: this.props.location.state.data.endpoint,
                    method: this.props.location.state.data.method,
                    body: JSON.stringify(this.props.location.state.data.body, null, 2),
                    headers: JSON.stringify(this.props.location.state.data.headers, null, 2),
                    testType: this.props.location.state.data.testType ? this.props.location.state.data.testType : 'simple',
                    fileType: fileType,
                    onSchedule: this.props.location.state.data.scheduleDate ? '1' : '0',
                    scheduleDate: this.props.location.state.data.scheduleDate || null,
                    scheduleTime: this.props.location.state.data.scheduleTime || null,
                    recurrence: this.props.location.state.data.recurrence || null
                }
            }
        } else {
            this.state = {
                isLoading: false,
                runningTasks: false,
                availableTasks: 1000,
                testId: null,
                file: null,
                validFile: false,
                chooseNewFile: false,
                activeTab: '1',
                submitLabel: 'Run Now',
                formValues: {
                    testName: '',
                    testDescription: '',
                    taskCount: 0,
                    concurrency: 0,
                    holdFor: 0,
                    holdForUnits: 'm',
                    rampUp: 0,
                    rampUpUnits: 'm',
                    endpoint: '',
                    method: 'GET',
                    body: '',
                    headers: '',
                    testType: 'simple',
                    fileType: '',
                    onSchedule: '0',
                    scheduleDate: null,
                    scheduleTime: null,
                    recurrence: null
                }
            };
        }

        this.form = React.createRef();
        this.handleSubmit = this.handleSubmit.bind(this);
        this.handleInputChange = this.handleInputChange.bind(this);
        this.setFormValue = this.setFormValue.bind(this);
        this.handleBodyPayloadChange = this.handleBodyPayloadChange.bind(this);
        this.handleHeadersChange = this.handleHeadersChange.bind(this);
        this.handleFileChange = this.handleFileChange.bind(this);
        this.handleCheckBox = this.handleCheckBox.bind(this);
        this.parseJson = this.parseJson.bind(this);
        this.listTasks = this.listTasks.bind(this);
        this.toggleTab = this.toggleTab.bind(this);
    }