добавление кнопки "Панель"
This commit is contained in:
parent
49896af672
commit
2c699235f7
|
|
@ -316,6 +316,7 @@ button:hover{filter:brightness(1.1)}
|
||||||
<div class="prof-row">
|
<div class="prof-row">
|
||||||
<select id="prof-sel">__PROFILES__</select>
|
<select id="prof-sel">__PROFILES__</select>
|
||||||
<button onclick="switchProf()" class="btn-s" style="padding:0; width:36px; justify-content:center;" title="Выбрать">✔</button>
|
<button onclick="switchProf()" class="btn-s" style="padding:0; width:36px; justify-content:center;" title="Выбрать">✔</button>
|
||||||
|
<button onclick="downloadProf()" class="btn-g" style="padding:0; width:36px; justify-content:center;" title="Скачать">💾</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="prof-btns">
|
<div class="prof-btns">
|
||||||
<button onclick="openAddProf()" class="btn-u">➕ Создать</button>
|
<button onclick="openAddProf()" class="btn-u">➕ Создать</button>
|
||||||
|
|
@ -431,6 +432,30 @@ function delProf() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadProf() {
|
||||||
|
var sel = document.getElementById('prof-sel');
|
||||||
|
if (!sel.value) return;
|
||||||
|
var name = sel.value;
|
||||||
|
var params = new URLSearchParams();
|
||||||
|
params.append('act', 'get_prof_content');
|
||||||
|
params.append('name', name);
|
||||||
|
fetch('/', { method: 'POST', body: params })
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(d => {
|
||||||
|
if (d.error) {
|
||||||
|
alert(d.error);
|
||||||
|
} else {
|
||||||
|
var a = document.createElement('a');
|
||||||
|
a.href = 'data:text/yaml;charset=utf-8,' + encodeURIComponent(d.content);
|
||||||
|
a.download = name + '.yaml';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
showToast('📄 Загрузка началась');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function fmtLog(raw) {
|
function fmtLog(raw) {
|
||||||
if(!raw) return "Log empty";
|
if(!raw) return "Log empty";
|
||||||
return raw.split('\\n').map(l => {
|
return raw.split('\\n').map(l => {
|
||||||
|
|
@ -753,6 +778,17 @@ class H(http.server.SimpleHTTPRequestHandler):
|
||||||
s.wfile.write(json.dumps({'error': 'File not found'}).encode('utf-8'))
|
s.wfile.write(json.dumps({'error': 'File not found'}).encode('utf-8'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if a == 'get_prof_content':
|
||||||
|
n = p.get('name')
|
||||||
|
target = os.path.join(PROFILES_DIR, n + ".yaml")
|
||||||
|
if os.path.exists(target):
|
||||||
|
with open(target, 'r', encoding='utf-8') as f:
|
||||||
|
content = f.read()
|
||||||
|
s.wfile.write(json.dumps({'status': 'ok', 'content': content}).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
s.wfile.write(json.dumps({'error': 'Profile not found'}).encode('utf-8'))
|
||||||
|
return
|
||||||
|
|
||||||
# --- EXISTING ACTIONS ---
|
# --- EXISTING ACTIONS ---
|
||||||
|
|
||||||
if a == 'parse':
|
if a == 'parse':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue