magneticstain / Inquisition

An advanced and versatile open-source network anomaly detection platform
MIT License
8 stars 4 forks source link

Listings Don't Reload After Edit in Tuning Module #130

Closed magneticstain closed 5 years ago

magneticstain commented 5 years ago

Only during add.

magneticstain commented 5 years ago

The solution to this should be a lot easier after Issue #144 is completed. Moving to next release.

magneticstain commented 5 years ago

It actually looks like this was already fixed. Now, all listing blobs are reloaded after a save or change.

Modal.prototype.modalCloseHandler = function () {
    /*
        Handler function used to perform post-logic for any time a modal is closed
     */

    var dataType = Global.prototype.queryGlobalAccessData('get', 'tuning', 'postActionDataType'),
        apiRequestURL = '/api/v1/tuning/?t=' + dataType;

    // check if there are any existing modals; if so, reload their data
    if(Object.keys(vex.getAll()).length >= 1)
    {
        // reload relevant content set data
        ContentSet.prototype.loadModalContentSet(dataType, '', true, true);
    }
    else
    {
        // no modals left open other than active one; close it
        // override API url when dealing with IOC field mappings since it's a "correlated" object type
        // see Issue #107 < https://github.com/magneticstain/Inquisition/issues/107 >
        if(dataType === 'ioc_field_mapping')
        {
            // use the 'all' special value here since IOC field mapping listings require field data as well
            apiRequestURL = '/api/v1/tuning/?t=all';
        }

        // query api and reload relevant config item table with returned data
        Mystic.queryAPI('GET', apiRequestURL, 20000, null, function (apiResponse) {
            var apiData = apiResponse.data,
                addlDataForCorrelation = null,
                dataType = Global.prototype.queryGlobalAccessData('get', 'tuning', 'postActionDataType');

            // ioc field mappings require special handling; see above
            if(dataType === 'ioc_field_mapping')
            {
                apiData = apiResponse.data.ioc_field_mapping;
                addlDataForCorrelation = apiResponse.data.field;
            }

            $('.' + dataType + 'Blob').replaceWith(ConfigTable.prototype.getConfigTableHTML(dataType, apiData,
                addlDataForCorrelation));

            // add events and other post-generation magic now that the html is in place
            Tuning.prototype.runPostConfigLoad();
        }, function (apiResponse) {
            var apiError = '';
            if(apiResponse.error != null)
            {
                apiError = ' :: [ ' + apiResponse.error + ' ]';
            }

            ErrorBot.generateError(4, dataType + ' data could not be reloaded' + apiError);
        });
    }
};