Files
app-autotest/site/static/js/scenario-create.js
T
naeel a96658b9b5 v1.1.55: split large files + CRUD scenario editor
Backend (5→7 files):
- api_test.py: 622→479, terraform functions → operations/terraform.py (142)
- api_scenario.py: 241→split into run (153) + defs (108) with _validate_steps()
- db/scenario_defs.py: +client_id, stand, is_seed in list_definitions

Frontend (1→10 files):
- app.js: 554→16 (loader), split into:
  utils.js (45), instances.js (89), operations.js (249),
  history.js (35), scenario-list.js (90)
- New CRUD: scenario-form.js (128), create (25), edit (12), delete (13)

Max file size: JS 249, PY 479
2026-07-30 22:02:22 +04:00

26 lines
965 B
JavaScript

// scenario-create.js — создание и клонирование сценария
async function createScenario() {
showScenarioEditor(null);
}
async function cloneScenario(defId, origName) {
const newName = prompt('Имя нового сценария (копия «' + origName + '»):', origName + '_copy');
if (!newName) return;
try {
const r = await fetch('/api/scenario/definitions/' + defId);
const def = await r.json();
if (def.error) { alert(def.error); return; }
const rr = await fetch('/api/scenario/definitions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: newName, steps: def.steps })
});
const d = await rr.json();
if (d.error) { alert(d.error); return; }
await loadScenarios();
} catch (e) {
alert('Ошибка клонирования: ' + e.message);
}
}