🔃Chache refresh on settings page
This commit is contained in:
@@ -179,8 +179,6 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Get plugin and settings data from API endpoints
|
// Get plugin and settings data from API endpoints
|
||||||
function getData(){
|
function getData(){
|
||||||
@@ -210,7 +208,38 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
initSettingsPage(settingsData, pluginsData, generateDropdownOptions);
|
exception_occurred = false;
|
||||||
|
|
||||||
|
// check if cache needs to be refreshed
|
||||||
|
// the getSetting method returns an empty string even if a setting is not found
|
||||||
|
// however, __metadata needs to be always a JSON object
|
||||||
|
// let's use that to verify settings were initialized correctly
|
||||||
|
settingsData.forEach((set) => {
|
||||||
|
|
||||||
|
codeName = set['Code_Name']
|
||||||
|
|
||||||
|
try {
|
||||||
|
const isMetadata = codeName.includes('__metadata');
|
||||||
|
// is this isn't a metadata entry, get corresponding metadata object from the dummy setting
|
||||||
|
const setObj = isMetadata ? {} : JSON.parse(getSetting(`${codeName}__metadata`));
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error getting setting for ${codeName}:`, error);
|
||||||
|
showModalOk('WARNING', "Outdated cache - refreshing (refresh browser cache if needed)");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
clearCache()
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
exception_occurred = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// only proceed if everything was loaded correctly
|
||||||
|
if(!exception_occurred)
|
||||||
|
{
|
||||||
|
initSettingsPage(settingsData, pluginsData, generateDropdownOptions);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -228,7 +257,6 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
|||||||
const enabledPublishers = getPluginsByType(pluginsData, "publisher", true);
|
const enabledPublishers = getPluginsByType(pluginsData, "publisher", true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Loop through the settingsArray and:
|
// Loop through the settingsArray and:
|
||||||
// - collect unique settingPluginPrefixes
|
// - collect unique settingPluginPrefixes
|
||||||
// - collect enabled plugins
|
// - collect enabled plugins
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ require 'php/templates/header.php';
|
|||||||
{ "width": "15%", "targets": [0] }, // Set width of the first four columns to 10%
|
{ "width": "15%", "targets": [0] }, // Set width of the first four columns to 10%
|
||||||
{ "width": "5%", "targets": [1,3] }, // Set width of the first four columns to 10%
|
{ "width": "5%", "targets": [1,3] }, // Set width of the first four columns to 10%
|
||||||
{ "width": "50%", "targets": [2] }, // Set width of the first four columns to 10%
|
{ "width": "50%", "targets": [2] }, // Set width of the first four columns to 10%
|
||||||
{ "width": "5%", "targets": 4 }, // Set width of the "Content" column to 60%
|
{ "width": "5%", "targets": [4,5] }, // Set width of the "Content" column to 60%
|
||||||
|
|
||||||
],
|
],
|
||||||
"order": [[0, "desc"]]
|
"order": [[0, "desc"]]
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ def importConfigs (db, all_plugins):
|
|||||||
# ccd(key, default, config_dir, name, inputtype, options, group, events=[], desc = "", regex = "", setJsonMetadata = {}, overrideTemplate = {})
|
# ccd(key, default, config_dir, name, inputtype, options, group, events=[], desc = "", regex = "", setJsonMetadata = {}, overrideTemplate = {})
|
||||||
|
|
||||||
conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', [] , c_d, 'Loaded plugins', 'text.multiselect', '', 'General')
|
conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', [] , c_d, 'Loaded plugins', 'text.multiselect', '', 'General')
|
||||||
|
# conf.TEST_TEST2 = ccd('TEST_TEST2', [] , c_d, 'TEST_TEST2', 'text.multiselect', '', 'General')
|
||||||
conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', 'subnets', '', 'General')
|
conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', 'subnets', '', 'General')
|
||||||
conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', 'text.select', "['none', 'minimal', 'verbose', 'debug']", 'General')
|
conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', 'text.select', "['none', 'minimal', 'verbose', 'debug']", 'General')
|
||||||
conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', 'text', '', 'General')
|
conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', 'text', '', 'General')
|
||||||
|
|||||||
Reference in New Issue
Block a user