mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-10 12:18:30 +03:00
Set up structure for react
This commit is contained in:
105
scripts/html/settings-py.html
Normal file
105
scripts/html/settings-py.html
Normal file
@@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Module Settings</title>
|
||||
<style>
|
||||
.module-section { margin-bottom: 20px; }
|
||||
.module-config { display: none; }
|
||||
.help {color: #333; font-size: 0.8em; margin-left: 10px;}
|
||||
.config-option { margin-bottom: 10px; }
|
||||
</style>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js"></script>
|
||||
<script>
|
||||
function toggleModuleConfig(elem, moduleName) {
|
||||
var configSection = document.getElementById(moduleName + '-config');
|
||||
configSection.style.display = elem.checked ? 'block' : 'none';
|
||||
}
|
||||
|
||||
function loadSettings() {
|
||||
var settingsFile = document.getElementById('settings-file').value || '/Users/patrick/Developer/auto-archiver/secrets/orchestration.yaml';
|
||||
fetch(settingsFile)
|
||||
.then(response => response.text())
|
||||
.then(yamlText => {
|
||||
var config = jsyaml.load(yamlText);
|
||||
updateSettings(config);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error loading settings file:', error);
|
||||
alert('Failed to load settings file.');
|
||||
});
|
||||
}
|
||||
|
||||
function updateSettings(config) {
|
||||
for (var moduleName in config) {
|
||||
var moduleCheckbox = document.getElementById(moduleName);
|
||||
if (moduleCheckbox) {
|
||||
moduleCheckbox.checked = true;
|
||||
toggleModuleConfig(moduleName);
|
||||
var moduleConfig = config[moduleName].options;
|
||||
for (var option in moduleConfig) {
|
||||
var input = document.getElementById(moduleName + '-' + option);
|
||||
if (input) {
|
||||
if (input.type === 'checkbox') {
|
||||
input.checked = moduleConfig[option];
|
||||
} else if (input.type === 'select-one') {
|
||||
input.value = moduleConfig[option];
|
||||
} else {
|
||||
input.value = moduleConfig[option];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveSettings() {
|
||||
var formData = new FormData(document.querySelector('form'));
|
||||
var config = {};
|
||||
|
||||
formData.forEach((value, key) => {
|
||||
var [moduleName, option] = key.split('-');
|
||||
if (!config[moduleName]) {
|
||||
config[moduleName] = { enabled: false, options: {} };
|
||||
}
|
||||
if (option === undefined) {
|
||||
config[moduleName].enabled = value === 'on';
|
||||
} else {
|
||||
config[moduleName].options[option] = value;
|
||||
}
|
||||
});
|
||||
|
||||
fetch('/save_settings', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(config)
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
alert('Settings saved successfully!');
|
||||
} else {
|
||||
alert('Failed to save settings.');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Module Settings</h1>
|
||||
<form onsubmit="event.preventDefault(); saveSettings();">
|
||||
<label for="settings-file">Settings File:</label>
|
||||
<input type="text" id="settings-file" name="settings-file" value="/Users/patrick/Developer/auto-archiver/secrets/orchestration.yaml">
|
||||
<button type="button" onclick="loadSettings()">Load Settings</button>
|
||||
<h2>Steps</h2>
|
||||
|
||||
{{module_sections}}
|
||||
|
||||
<h2>Module Configuration Section</h2>
|
||||
{{module_configs}}
|
||||
|
||||
<button type="submit">Save Settings</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
0
scripts/html/settings.html
Normal file
0
scripts/html/settings.html
Normal file
Reference in New Issue
Block a user