mirror of
https://github.com/simon987/Simple-Incremental-Search-Tool.git
synced 2025-04-16 08:46:49 +00:00
189 lines
6.8 KiB
HTML
189 lines
6.8 KiB
HTML
{% extends "layout.html" %}
|
|
|
|
{% block title %}An excellent title{% endblock title %}
|
|
|
|
{% block body %}
|
|
|
|
<script>
|
|
|
|
function swapToForm(elem, fields, formAction, inputName) {
|
|
|
|
var form = document.createElement("form");
|
|
form.setAttribute("action", formAction);
|
|
|
|
for (var i in fields) {
|
|
|
|
var hiddenInput = document.createElement("input");
|
|
hiddenInput.setAttribute("type", "hidden");
|
|
hiddenInput.setAttribute("value", fields[i].value);
|
|
hiddenInput.setAttribute("name", fields[i].name);
|
|
form.appendChild(hiddenInput);
|
|
}
|
|
|
|
var input = document.createElement("input");
|
|
input.setAttribute("class", "form-control");
|
|
input.setAttribute("type", "text");
|
|
input.setAttribute("name", inputName);
|
|
input.value = elem.innerHTML;
|
|
form.appendChild(input);
|
|
|
|
elem.parentNode.insertBefore(form, elem);
|
|
elem.remove();
|
|
|
|
input.focus();
|
|
input.addEventListener("focusout", function () {
|
|
form.submit();
|
|
});
|
|
|
|
return input;
|
|
}
|
|
|
|
function modifyKey(optId, value) {
|
|
|
|
swapToForm(document.getElementById("key-" + optId), [
|
|
{name: "id", value: optId},
|
|
{name: "value", value: value},
|
|
{name: "dir_id", value: {{ directory.id }}}
|
|
], "/directory/{{ directory.id }}/update_opt", "key");
|
|
|
|
}
|
|
|
|
function modifyVal(optId, key) {
|
|
swapToForm(document.getElementById("val-" + optId), [
|
|
{name: "id", value: optId},
|
|
{name: "key", value: key},
|
|
{name: "dir_id", value: {{ directory.id }}}
|
|
], "/directory/{{ directory.id }}/update_opt", "value");
|
|
}
|
|
|
|
function modifyDisplayName() {
|
|
swapToForm(document.getElementById("display-name"), [],
|
|
"/directory/{{ directory.id }}/update", "name");
|
|
}
|
|
|
|
function modifyPath() {
|
|
swapToForm(document.getElementById("path"), [],
|
|
"/directory/{{ directory.id }}/update", "path");
|
|
}
|
|
|
|
</script>
|
|
|
|
<div class="container">
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">Summary</div>
|
|
<div class="panel-body">
|
|
|
|
<table class="info-table">
|
|
<tr onclick="modifyDisplayName()">
|
|
<th>Display name</th>
|
|
<td>
|
|
<span id="display-name" title="Click to update">{{ directory.name }}</span>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr onclick="modifyPath()">
|
|
<th>Path</th>
|
|
<td>
|
|
<pre id="path" title="Click to update">{{ directory.path }}</pre>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th>Enabled</th>
|
|
<td>
|
|
<i class="far {{ "fa-check-square" if directory.enabled else "fa-square" }}"></i>
|
|
<form action="/directory/{{ directory.id }}/update" style="display: inline;">
|
|
<input type="hidden" name="enabled" value="{{ "0" if directory.enabled else "1" }}">
|
|
<input type="submit" class="btn {{ "btn-danger" if directory.enabled else "btn-success" }}"
|
|
value="{{ "Disable" if directory.enabled else "Enable" }}">
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">An excellent option list</div>
|
|
<div class="panel-body">
|
|
<table class="info-table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Key</th>
|
|
<th>Value</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for option in directory.options %}
|
|
|
|
<tr>
|
|
<td style="width: 40%" onclick="modifyKey({{ option.id }}, '{{ option.value }}')" title="Click to update"><span id="key-{{ option.id }}">{{ option.key }}</span></td>
|
|
<td style="width: 40%" onclick="modifyVal({{ option.id }}, '{{ option.key }}')" title="Click to update"><span id="val-{{ option.id }}">{{ option.value }}</span></td>
|
|
<td><a id="opt-{{ option.id }}-btn" class="btn btn-danger" href="/directory/{{ directory.id }}/del_opt/{{ option.id }}" >Remove</a></td>
|
|
</tr>
|
|
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<hr>
|
|
|
|
<form method="GET" action="/directory/{{ directory.id }}/add_opt">
|
|
|
|
<div class="form-group">
|
|
<div class="col-sm-4">
|
|
<input type="text" class="form-control" placeholder="Key" name="key">
|
|
</div>
|
|
|
|
|
|
<div class="col-sm-4">
|
|
<input type="text" class="form-control" placeholder="Value" name="value">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-success">Add option</button>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel panel-default">
|
|
<div class="panel-heading">An excellent control panel</div>
|
|
<div class="panel-body">
|
|
|
|
<div class="btn-group">
|
|
<a class="btn dropdown-toggle btn-primary" data-toggle="dropdown" href="#">
|
|
Create a task
|
|
<span class="caret"></span>
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="#">Indexing task</a></li>
|
|
<li><a href="#">Thumbnail generation task</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="btn-group">
|
|
<a class="btn dropdown-toggle btn-danger" data-toggle="dropdown" href="#">
|
|
Action
|
|
<span class="caret"></span>
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
<li><a href="/directory/{{ directory.id }}/del">Delete directory</a></li>
|
|
<li><a href="#">Reset to default settings</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
{% endblock body %} |