}
}
-async function post_to(data, target, verbose=false) {
- const fetch_kwargs = {
+function player_command(command) {
+ wrapped_fetch(PATH_PLAYER, {
method: "POST",
headers: {"Content-Type": "application/json"},
- body: JSON.stringify(data)
- };
- wrapped_fetch(target, fetch_kwargs, verbose);
-}
-
-function player_command(command) {
- post_to({command: [command]}, PATH_PLAYER);
+ body: JSON.stringify({command: [command]})
+ });
}
event_handlers.push(function(data) { // update player state
const all_tags = {{showable_tags|tojson|safe}};
var needed_tags = [];
+var filtered_files = [];
function select_tag() {
if (tags_select.selectedIndex < 1) {
let target = `${PATH_FILES_JSON}?filter_path=${filter_path}`;
if (document.getElementById("input_show_absent").checked) { target = `${target}&show_absent=1`; }
needed_tags.forEach((tag) => target = `${target}&needed_tag=${encodeURIComponent(tag)}`);
- const files_data = await wrapped_fetch(target).then((response) => response.json());
- document.getElementById("files_count").textContent = `${files_data.length}`;
+ filtered_files = await wrapped_fetch(target).then((response) => response.json());
+ document.getElementById("files_count").textContent = `${filtered_files.length}`;
const table = document.getElementById("files_table");
Array.from(document.getElementsByClassName("file_row")).forEach((row) => row.remove());
- files_data.forEach((file) => {
+ filtered_files.forEach((file) => {
const tr = new_child_to('tr', table);
tr.classList.add("file_row");
new_child_to('td', tr, file.size);
});
}
+function inject_all() {
+ filtered_files.forEach((file) => { player_command(`inject_${file.digest}`) });
+}
+
window.addEventListener('load', update_filter_inputs);
{% endblock %}
filename pattern: <input id="input_filter_path" oninput="update_files_list()" /><br />
show absent: <input id="input_show_absent" type="checkbox" onclick="update_files_list()" /><br />
needed tags: <select id="tags_select" onchange="select_tag()"></select><br />
-<span id="tags"></span><br />
+<span id="tags"></span>
<hr />
-<p>known files (shown: <span id="files_count">?</span>):</p>
+<p>
+known files (shown: <span id="files_count">?</span>):
+<button onclick="inject_all();">inject all</button>
+</p>
<table id="files_table">
<tr><th>size</th><th>actions</th><th>tags</th><th>path</th></tr>
</table>