hostbasket/flowbroker/templates/new_flow_form.html
2025-05-20 22:08:00 +03:00

106 lines
3.4 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Flow from Rhai Script</title>
<link rel="stylesheet" href="/static/style.css">
<style>
body {
font-family: sans-serif;
margin: 20px;
background-color: #f4f4f9;
color: #333;
}
.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
h1 {
color: #333;
}
textarea {
width: 100%;
min-height: 300px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-bottom: 15px;
font-family: monospace;
font-size: 14px;
}
button {
background-color: #007bff;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
a {
color: #007bff;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
.back-link {
display: block;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<a href="/" class="back-link">&larr; Back to Flow List</a>
<h1>Create Flow from Rhai Script</h1>
<div id="rhai_script_examples_data" style="display: none;">
{% for example in example_scripts %}
<div id="rhai_example_content_{{ loop.index }}">{{ example.content }}</div>
{% endfor %}
</div>
<div>
<label for="example_script_selector">Load Example Script:</label>
<select id="example_script_selector">
<option value="">-- Select an Example --</option>
{% for example in example_scripts %}
<option value="{{ example.name }}" data-example-id="rhai_example_content_{{ loop.index }}">{{ example.name }}</option>
{% endfor %}
</select>
</div>
<form action="/flows/create_script" method="POST" style="margin-top: 15px;">
<div>
<label for="rhai_script">Rhai Script:</label>
</div>
<div>
<textarea id="rhai_script" name="rhai_script" placeholder="Enter your Rhai script here or select an example above..."></textarea>
</div>
<button type="submit">Create Flow</button>
</form>
<script>
document.getElementById('example_script_selector').addEventListener('change', function() {
var selectedOption = this.options[this.selectedIndex];
var exampleId = selectedOption.getAttribute('data-example-id');
if (exampleId) {
var scriptContent = document.getElementById(exampleId).textContent; // Use textContent
document.getElementById('rhai_script').value = scriptContent;
} else {
document.getElementById('rhai_script').value = '';
}
});
</script>
</div>
</body>
</html>