2019-08-16 16:46:09 +00:00
|
|
|
{% extends "coreprotect/base.html" %}
|
2019-07-26 17:36:03 +00:00
|
|
|
{% load static %}
|
2019-08-16 16:46:09 +00:00
|
|
|
{% block head %}
|
|
|
|
<link rel="shortcut icon" type="image/png" href="{% static 'coreprotect/img/intelli.png' %}"/>
|
|
|
|
{% endblock %}
|
|
|
|
{% block body %}
|
2019-08-13 22:05:34 +00:00
|
|
|
<div class="block"></div>
|
|
|
|
<div class="has-text-centered">
|
2019-08-16 16:46:09 +00:00
|
|
|
<h1 class="title">CoreProtect GUI</h1>
|
2019-08-13 22:05:34 +00:00
|
|
|
<hr/>
|
|
|
|
</div>
|
|
|
|
<div class="columns">
|
2019-08-16 16:46:09 +00:00
|
|
|
<form id="coreprotect_form" name="coreprotect_form" class="has-text-left column is-one-third">
|
2019-08-13 22:05:34 +00:00
|
|
|
<div class="columns">
|
|
|
|
<div class="column is-one-half">
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Actions
|
|
|
|
</h4>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="block_break" name="block_break" type="checkbox" {% if form.block_break %}checked{% endif %}>
|
|
|
|
<label for="block_break">Block Break</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="block_place" name="block_place" type="checkbox" {% if form.block_place %}checked{% endif %}>
|
|
|
|
<label for="block_place">Block Place</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-08-16 03:59:43 +00:00
|
|
|
<input class="is-checkradio is-block is-info" id="chat" name="chat" type="checkbox" {% if form.chat %}checked{% endif %} {% if not perms.django_coreprotect.gui_extra %}disabled{% endif %}>
|
2019-08-13 22:05:34 +00:00
|
|
|
<label for="chat">Chat</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="chest_use" name="chest_use" type="checkbox" {% if form.chest_use %}checked{% endif %}>
|
|
|
|
<label for="chest_use">Chest Use</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-08-16 03:59:43 +00:00
|
|
|
<input class="is-checkradio is-block is-info" id="command" name="command" type="checkbox" {% if form.command %}checked{% endif %} {% if not perms.django_coreprotect.gui_extra %}disabled{% endif %}>
|
2019-08-13 22:05:34 +00:00
|
|
|
<label for="command">Command</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="interact" name="interact" type="checkbox" {% if form.interact %}checked{% endif %}>
|
|
|
|
<label for="interact">Interact</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="login_logout" name="login_logout" type="checkbox" {% if form.login_logout %}checked{% endif %}>
|
|
|
|
<label for="login_logout">Login/Logout</label>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="sign_place" name="sign_place" type="checkbox" {% if form.sign_place %}checked{% endif %}>
|
|
|
|
<label for="sign_place">Sign Place</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Worlds
|
|
|
|
</h4>
|
|
|
|
{% for world in form.worlds %}
|
|
|
|
<div class="field">
|
2019-08-14 21:56:05 +00:00
|
|
|
<input class="is-checkradio is-block is-info" id="{{world.world_id}}" name="world" value="{{world.id}}" type="checkbox" {% if world.checked %}checked{% endif %}>
|
|
|
|
<label for="{{world.world_id}}">{{world.name}}</label>
|
2019-08-13 22:05:34 +00:00
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Options
|
|
|
|
</h4>
|
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="ignore_environment" name="ignore_environment" type="checkbox" {% if form.ignore_environment %}checked{% endif %}>
|
|
|
|
<label for="ignore_environment">Ignore Environment</label>
|
|
|
|
</div>
|
2019-08-16 16:46:09 +00:00
|
|
|
<div class="field">
|
|
|
|
<input class="is-checkradio is-block is-info" id="oldest_first" name="oldest_first" type="checkbox" {% if form.oldest_first %}checked{% endif %}>
|
|
|
|
<label for="oldest_first">Oldest Results First</label>
|
|
|
|
</div>
|
2019-08-13 22:05:34 +00:00
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
2019-08-15 22:00:54 +00:00
|
|
|
Page Size
|
2019-08-13 22:05:34 +00:00
|
|
|
</h4>
|
|
|
|
<div class="field">
|
|
|
|
<p class="control">
|
|
|
|
<span class="select">
|
2019-08-15 22:00:54 +00:00
|
|
|
<select id="page_size" name="page_size">
|
|
|
|
<option value="20" {% if form.page_size == "20" %}selected{% endif %}>20</option>
|
|
|
|
<option value="50" {% if form.page_size == "50" %}selected{% endif %}>50</option>
|
|
|
|
<option value="100" {% if form.page_size == "100" %}selected{% endif %}>100</option>
|
|
|
|
<option value="200" {% if form.page_size == "200" %}selected{% endif %}>200</option>
|
|
|
|
<option value="500" {% if form.page_size == "500" %}selected{% endif %}>500</option>
|
|
|
|
<option value="1000" {% if form.page_size == "1000" %}selected{% endif %}>1000</option>
|
2019-08-13 22:05:34 +00:00
|
|
|
</select>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
2019-08-15 22:00:54 +00:00
|
|
|
<input type="hidden" id="page" name="page" value="{{form.page}}"/>
|
2019-08-13 22:05:34 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="column is-one-half">
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Players
|
|
|
|
</h4>
|
|
|
|
<div class="field tooltip" data-tooltip="Accepts full or partial names. Separated by commas.">
|
|
|
|
<input class="input" id="players" name="players" type="text" placeholder="Player Names" value="{{form.players}}">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Coordinates
|
|
|
|
</h4>
|
|
|
|
<div class="field has-addons tooltip" data-tooltip="Whole numbers only.">
|
|
|
|
<p class="control">
|
|
|
|
<input class="input" id="x" name="x" type="text" placeholder="X" value="{{form.x}}">
|
|
|
|
</p>
|
|
|
|
<p class="control">
|
|
|
|
<input class="input" id="y" name="y" type="text" placeholder="Y" value="{{form.y}}">
|
|
|
|
</p>
|
|
|
|
<p class="control">
|
|
|
|
<input class="input" id="z" name="z" type="text" placeholder="Z" value="{{form.z}}">
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="field tooltip" data-tooltip="Whole numbers only.">
|
|
|
|
<p class="control">
|
|
|
|
<input class="input" id="radius" name="radius" type="text" placeholder="Radius" value="{{form.radius}}">
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Blocks
|
|
|
|
</h4>
|
2019-08-14 21:56:05 +00:00
|
|
|
<div class="field tooltip is-tooltip-multiline" data-tooltip="Accepts full or partial names. Separated by commas.">
|
|
|
|
<input class="input is-4" id="blocks" name="blocks" type="text" placeholder="Block Names" value="{{form.blocks}}">
|
2019-08-13 22:05:34 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<h4 class="title is-5 has-text-primary">
|
|
|
|
Date and Time
|
|
|
|
</h4>
|
|
|
|
<div class="field tooltip" data-tooltip="Click to open date/time picker.">
|
|
|
|
<p class="control">
|
|
|
|
<input type="date" id="date_from" name="date_from" placeholder="Date From" value="{{form.date_from}}">
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="field tooltip" data-tooltip="Click to open date/time picker.">
|
|
|
|
<p class="control">
|
|
|
|
<input type="date" id="date_to" name="date_to" placeholder="Date To" value="{{form.date_to}}">
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<p class="control">
|
2019-08-14 21:56:05 +00:00
|
|
|
<button class="button is-primary" id="search" type="button">Search</button>
|
2019-08-13 22:05:34 +00:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
|
|
|
<button class="button is-dark" id="clear" type="button">Clear</button>
|
|
|
|
</p>
|
2019-08-15 22:00:54 +00:00
|
|
|
<p class="control">
|
|
|
|
<button class="button is-info" id="export" type="button">Export</button>
|
|
|
|
</p>
|
2019-08-13 22:05:34 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2019-08-14 21:56:05 +00:00
|
|
|
<div class="column is-three-fifths" id="results">
|
2019-08-13 22:05:34 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-08-16 16:46:09 +00:00
|
|
|
{% endblock %}
|
|
|
|
{% block script %}
|
2019-08-13 22:05:34 +00:00
|
|
|
<script>
|
2019-08-15 22:00:54 +00:00
|
|
|
let text = "Copy the below command to teleport";
|
|
|
|
function attachClickRows() {
|
|
|
|
Array.from(document.querySelectorAll(".click-row")).forEach(elem => {
|
|
|
|
elem.addEventListener("click", function() {
|
|
|
|
prompt(text, elem.getAttribute("data-prompt"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
let url = new URL(window.location);
|
|
|
|
let pageParam = url.searchParams.get("page");
|
2019-08-16 03:59:43 +00:00
|
|
|
let page = 0;
|
2019-08-15 22:00:54 +00:00
|
|
|
if (pageParam !== "") {
|
|
|
|
page = parseInt(pageParam);
|
|
|
|
if (isNaN(page)) {
|
2019-08-16 03:59:43 +00:00
|
|
|
page = 0;
|
2019-08-15 22:00:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function attachPagination() {
|
2019-08-16 03:59:43 +00:00
|
|
|
let prev = document.getElementById("prev");
|
|
|
|
if (prev.getAttribute("disabled") == null) {
|
|
|
|
prev.addEventListener("click", function () {
|
|
|
|
document.getElementById("page").value = (--page).toString();
|
|
|
|
search(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
let next = document.getElementById("next");
|
|
|
|
if (next.getAttribute("disabled") == null) {
|
|
|
|
next.addEventListener("click", function () {
|
|
|
|
document.getElementById("page").value = (++page).toString();
|
|
|
|
search(false);
|
|
|
|
});
|
|
|
|
}
|
2019-08-15 22:00:54 +00:00
|
|
|
}
|
|
|
|
|
2019-08-16 03:59:43 +00:00
|
|
|
function search(resetPage) {
|
2019-08-14 21:56:05 +00:00
|
|
|
elementHTML("results", 'Querying Database...<br/><progress class="progress is-primary"></progress>');
|
|
|
|
|
2019-08-16 03:59:43 +00:00
|
|
|
if (resetPage) {
|
|
|
|
page = 0;
|
|
|
|
document.getElementById("page").value = "0";
|
|
|
|
}
|
|
|
|
|
2019-08-14 21:56:05 +00:00
|
|
|
let form = document.getElementById("coreprotect_form");
|
|
|
|
let formData = new FormData(form);
|
2019-08-16 16:46:09 +00:00
|
|
|
ajax("GET", "{% url "coreprotect_gui_query" %}?" + formURI(formData), function(status, data) {
|
2019-08-14 21:56:05 +00:00
|
|
|
elementHTML("results", data);
|
2019-08-15 22:00:54 +00:00
|
|
|
attachClickRows();
|
|
|
|
attachPagination();
|
2019-08-14 21:56:05 +00:00
|
|
|
});
|
2019-08-16 16:46:09 +00:00
|
|
|
window.history.pushState("", "", "{% url "coreprotect_gui" %}?" + formURI(formData));
|
2019-08-16 03:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("search").addEventListener("click", function() {
|
|
|
|
search(true);
|
2019-08-14 21:56:05 +00:00
|
|
|
});
|
|
|
|
|
2019-08-13 22:05:34 +00:00
|
|
|
document.getElementById("clear").addEventListener("click", function() {
|
|
|
|
// Actions
|
|
|
|
document.getElementById("block_break").checked = false;
|
|
|
|
document.getElementById("block_place").checked = false;
|
|
|
|
document.getElementById("chat").checked = false;
|
|
|
|
document.getElementById("chest_use").checked = false;
|
|
|
|
document.getElementById("command").checked = false;
|
|
|
|
document.getElementById("interact").checked = false;
|
|
|
|
document.getElementById("login_logout").checked = false;
|
|
|
|
document.getElementById("sign_place").checked = false;
|
|
|
|
|
|
|
|
// Worlds
|
|
|
|
{% for world in form.worlds %}
|
2019-08-14 21:56:05 +00:00
|
|
|
document.getElementById("{{world.world_id}}").checked = false;
|
2019-08-13 22:05:34 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
// Options
|
|
|
|
document.getElementById("ignore_environment").checked = false;
|
2019-08-16 16:46:09 +00:00
|
|
|
document.getElementById("oldest_first").checked = false;
|
2019-08-13 22:05:34 +00:00
|
|
|
|
2019-08-15 22:00:54 +00:00
|
|
|
// Page Size
|
|
|
|
document.getElementById("page_size").selectedIndex = "0";
|
|
|
|
document.getElementById("page").value = "1";
|
2019-08-13 22:05:34 +00:00
|
|
|
|
|
|
|
// Players
|
|
|
|
document.getElementById("players").value = "";
|
|
|
|
|
|
|
|
// Coordinates
|
|
|
|
document.getElementById("x").value = "";
|
|
|
|
document.getElementById("y").value = "";
|
|
|
|
document.getElementById("z").value = "";
|
|
|
|
document.getElementById("radius").value = "";
|
|
|
|
|
|
|
|
// Blocks
|
|
|
|
document.getElementById("blocks").value = "";
|
|
|
|
|
|
|
|
// Date and Time
|
|
|
|
document.getElementById("date_from")._flatpickr.setDate();
|
|
|
|
document.getElementById("date_to")._flatpickr.setDate();
|
|
|
|
});
|
2019-08-15 22:00:54 +00:00
|
|
|
|
|
|
|
document.getElementById("export").addEventListener("click", function() {
|
|
|
|
exportTableToCSV("coreprotect.csv", "results");
|
|
|
|
});
|
2019-08-13 22:05:34 +00:00
|
|
|
</script>
|
2019-08-16 16:46:09 +00:00
|
|
|
{% endblock %}
|