saveButtonAction() {
        // Clear any previous validation errors
        this.clearStatusMessages();
        this.resetInputColors();

        // Only continue if validation passed
        if(!this.validate()) {
            return;
        }

        const config_json_file = new File([JSON.stringify(notebook_builder.getJSON(), null, 2)], 'config.json', {type: "text/plain"});
        const url = buildCourseUrl(['notebook_builder', 'save']);

        const form_data = new FormData();
        form_data.append('config_upload', config_json_file, 'config.json');
        form_data.append('csrf_token', csrfToken);
        form_data.append('g_id', builder_data.g_id);

        const makeRequest = async () => {
            this.appendStatusMessage('Saving...');

            // Currently only deals with uploading images, will rework later to accommodate other files/directories as needed
            // Wait for all files to be uploaded before continuing
            const file_selectors = document.querySelectorAll('input[type=file]');
            await uploadFiles(file_selectors, builder_data.g_id, 'test_input');

            const response = await fetch(url, {method: 'POST', body: form_data});
            const result = await response.json();

            this.clearStatusMessages();

            if (result.status === 'success') {
                const gradeable_submission_url = buildCourseUrl(['gradeable', builder_data.g_id]);
                const edit_gradeable_url = buildCourseUrl(['gradeable', builder_data.g_id, 'update']);

                this.appendStatusMessage(`Your gradeable is being installed.  To view it visit the <a href="${gradeable_submission_url}">submission page</a>.`);
                this.appendStatusMessage(`To make other changes to the gradeable configuration visit the <a href="${edit_gradeable_url}">edit gradeable page</a>.`);
            }
            else {
                this.appendStatusMessage(result.message);

                if (result.data && Array.isArray(result.data)) {
                    result.data.forEach(msg => this.appendStatusMessage(msg));
                }
            }
        };

        makeRequest().catch(err => console.error(err));
    }
/**
     * Pack up all the configuration data from the GUI into a nice config.json and submit it to the server.
     * Additionally perform validation on inputs and prevent saving if validation errors were found.
     */
Pack up all the configuration data from the GUI into a nice config.json and submit it to the server.
Additionally perform validation on inputs and prevent saving if validation errors were found.
Pack up all the configuration data from the GUI into a nice config . json and submit it to the server . Additionally perform validation on inputs and prevent saving if validation errors were found .
saveButtonAction() {
        this.clearStatusMessages();
        this.resetInputColors();
        if(!this.validate()) {
            return;
        }
        const config_json_file = new File([JSON.stringify(notebook_builder.getJSON(), null, 2)], 'config.json', {type: "text/plain"});
        const url = buildCourseUrl(['notebook_builder', 'save']);
        const form_data = new FormData();
        form_data.append('config_upload', config_json_file, 'config.json');
        form_data.append('csrf_token', csrfToken);
        form_data.append('g_id', builder_data.g_id);
        const makeRequest = async () => {
            this.appendStatusMessage('Saving...');
            const file_selectors = document.querySelectorAll('input[type=file]');
            await uploadFiles(file_selectors, builder_data.g_id, 'test_input');
            const response = await fetch(url, {method: 'POST', body: form_data});
            const result = await response.json();
            this.clearStatusMessages();
            if (result.status === 'success') {
                const gradeable_submission_url = buildCourseUrl(['gradeable', builder_data.g_id]);
                const edit_gradeable_url = buildCourseUrl(['gradeable', builder_data.g_id, 'update']);
                this.appendStatusMessage(`Your gradeable is being installed.  To view it visit the <a href="${gradeable_submission_url}">submission page</a>.`);
                this.appendStatusMessage(`To make other changes to the gradeable configuration visit the <a href="${edit_gradeable_url}">edit gradeable page</a>.`);
            }
            else {
                this.appendStatusMessage(result.message);
                if (result.data && Array.isArray(result.data)) {
                    result.data.forEach(msg => this.appendStatusMessage(msg));
                }
            }
        };
        makeRequest().catch(err => console.error(err));
    }
saveButtonAction ( ) { this . clearStatusMessages ( ) ; this . resetInputColors ( ) ; if ( ! this . validate ( ) ) { return ; } const config_json_file = new File ( [ JSON . stringify ( notebook_builder . getJSON ( ) , null , 2 ) ] , 'config.json' , { type : "text/plain" } ) ; const url = buildCourseUrl ( [ 'notebook_builder' , 'save' ] ) ; const form_data = new FormData ( ) ; form_data . append ( 'config_upload' , config_json_file , 'config.json' ) ; form_data . append ( 'csrf_token' , csrfToken ) ; form_data . append ( 'g_id' , builder_data . g_id ) ; const makeRequest = async ( ) => { this . appendStatusMessage ( 'Saving...' ) ; const file_selectors = document . querySelectorAll ( 'input[type=file]' ) ; await uploadFiles ( file_selectors , builder_data . g_id , 'test_input' ) ; const response = await fetch ( url , { method : 'POST' , body : form_data } ) ; const result = await response . json ( ) ; this . clearStatusMessages ( ) ; if ( result . status === 'success' ) { const gradeable_submission_url = buildCourseUrl ( [ 'gradeable' , builder_data . g_id ] ) ; const edit_gradeable_url = buildCourseUrl ( [ 'gradeable' , builder_data . g_id , 'update' ] ) ; this . appendStatusMessage ( ` ${ gradeable_submission_url } ` ) ; this . appendStatusMessage ( ` ${ edit_gradeable_url } ` ) ; } else { this . appendStatusMessage ( result . message ) ; if ( result . data && Array . isArray ( result . data ) ) { result . data . forEach ( msg => this . appendStatusMessage ( msg ) ) ; } } } ; makeRequest ( ) . catch ( err => console . error ( err ) ) ; }
Pack up all the configuration data from the GUI into a nice config.json and submit it to the server.
Pack up all the configuration data from the GUI into a nice config . json and submit it to the server .
// Clear any previous validation errors // Only continue if validation passed // Currently only deals with uploading images, will rework later to accommodate other files/directories as needed // Wait for all files to be uploaded before continuing