|
|
@ -29,55 +29,126 @@ |
|
|
|
<div class="container"> |
|
|
|
<div class="container"> |
|
|
|
<h1>Dashboard</h1> |
|
|
|
<h1>Dashboard</h1> |
|
|
|
|
|
|
|
|
|
|
|
<h2>Statistics</h2> |
|
|
|
<div style="height: 3rem;"></div> |
|
|
|
<div id="statistics"> |
|
|
|
|
|
|
|
<ol class="list-group list-group-numbered"> |
|
|
|
|
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
<div class="container"> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
<h2>Statistics</h2> |
|
|
|
<div class="fw-bold">Pages visited</div> |
|
|
|
<div id="statistics"> |
|
|
|
</div> |
|
|
|
<ol class="list-group list-group-numbered"> |
|
|
|
<span class="badge bg-primary rounded-pill" id="pages_visited">0</span> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
</li> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
<div class="fw-bold">Pages visited</div> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
</div> |
|
|
|
<div class="fw-bold">Matches found</div> |
|
|
|
<span class="badge bg-primary rounded-pill" id="pages_visited">0</span> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
<span class="badge bg-primary rounded-pill" id="matches_found">0</span> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
</li> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
<div class="fw-bold">Matches found</div> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
</div> |
|
|
|
<div class="fw-bold">Pages saved</div> |
|
|
|
<span class="badge bg-primary rounded-pill" id="matches_found">0</span> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
<span class="badge bg-primary rounded-pill" id="pages_saved">0</span> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
</li> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
<div class="fw-bold">Pages saved</div> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
</div> |
|
|
|
<div class="fw-bold">Start time</div> |
|
|
|
<span class="badge bg-primary rounded-pill" id="pages_saved">0</span> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
<span class="badge bg-primary rounded-pill" id="start_time_unix">0</span> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
</li> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
<div class="fw-bold">Start time</div> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
</div> |
|
|
|
<div class="fw-bold">Stopped</div> |
|
|
|
<span class="badge bg-primary rounded-pill" id="start_time_unix">0</span> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
<span class="badge bg-primary rounded-pill" id="stopped">false</span> |
|
|
|
<li class="list-group-item d-flex justify-content-between align-items-start"> |
|
|
|
</li> |
|
|
|
<div class="ms-2 me-auto"> |
|
|
|
</ol> |
|
|
|
<div class="fw-bold">Stopped</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<span class="badge bg-primary rounded-pill" id="stopped">false</span> |
|
|
|
|
|
|
|
</li> |
|
|
|
|
|
|
|
</ol> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<!-- <h2>Configuration</h2> |
|
|
|
<div style="height: 3rem;"></div> |
|
|
|
<pre id="configuration"></pre> --> |
|
|
|
|
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
|
|
|
|
<h2>Configuration</h2> |
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
|
|
<b>Make runtime changes to configuration</b> |
|
|
|
|
|
|
|
<table class="table table-borderless"> |
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
|
|
<th>Key</th> |
|
|
|
|
|
|
|
<th>Value</th> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
|
|
<th>Query</th> |
|
|
|
|
|
|
|
<th> |
|
|
|
|
|
|
|
<input type="text" id="conf_query"> |
|
|
|
|
|
|
|
</th> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
<tr> |
|
|
|
|
|
|
|
<th>Is regexp</th> |
|
|
|
|
|
|
|
<th> |
|
|
|
|
|
|
|
<input type="text" id="conf_is_regexp"> |
|
|
|
|
|
|
|
</th> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
</table> |
|
|
|
|
|
|
|
<button class="btn btn-primary" id="config_apply_button"> |
|
|
|
|
|
|
|
Apply |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div style="height: 3rem;"></div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<pre id="conf_output"></pre> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</body> |
|
|
|
</body> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
window.onload = function () { |
|
|
|
window.onload = function () { |
|
|
|
let confOutput = document.getElementById("configuration"); |
|
|
|
let confOutput = document.getElementById("conf_output"); |
|
|
|
let pagesVisitedOut = document.getElementById("pages_visited"); |
|
|
|
let pagesVisitedOut = document.getElementById("pages_visited"); |
|
|
|
let matchesFoundOut = document.getElementById("matches_found"); |
|
|
|
let matchesFoundOut = document.getElementById("matches_found"); |
|
|
|
let pagesSavedOut = document.getElementById("pages_saved"); |
|
|
|
let pagesSavedOut = document.getElementById("pages_saved"); |
|
|
|
let startTimeOut = document.getElementById("start_time_unix"); |
|
|
|
let startTimeOut = document.getElementById("start_time_unix"); |
|
|
|
let stoppedOut = document.getElementById("stopped"); |
|
|
|
let stoppedOut = document.getElementById("stopped"); |
|
|
|
|
|
|
|
let applyConfButton = document.getElementById("config_apply_button"); |
|
|
|
|
|
|
|
let confQuery = document.getElementById("conf_query"); |
|
|
|
|
|
|
|
let confIsRegexp = document.getElementById("conf_is_regexp"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applyConfButton.addEventListener("click", (event) => { |
|
|
|
|
|
|
|
let query = String(confQuery.value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (confIsRegexp.value === "0") { |
|
|
|
|
|
|
|
isRegexp = false; |
|
|
|
|
|
|
|
} else if (confIsRegexp.value === "1") { |
|
|
|
|
|
|
|
isRegexp = true; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (confIsRegexp.value === "false") { |
|
|
|
|
|
|
|
isRegexp = false; |
|
|
|
|
|
|
|
} else if (confIsRegexp.value === "true") { |
|
|
|
|
|
|
|
isRegexp = true; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let newConf = { |
|
|
|
|
|
|
|
"search": { |
|
|
|
|
|
|
|
"is_regexp": isRegexp, |
|
|
|
|
|
|
|
"query": query, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(newConf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetch("/conf", { |
|
|
|
|
|
|
|
method: "POST", |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
"Content-type": "application/json", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
body: JSON.stringify(newConf), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const interval = setInterval(function () { |
|
|
|
const interval = setInterval(function () { |
|
|
|
// update statistics |
|
|
|
// update statistics |
|
|
@ -90,13 +161,22 @@ |
|
|
|
startTimeOut.innerText = new Date(1000 * statistics.start_time_unix); |
|
|
|
startTimeOut.innerText = new Date(1000 * statistics.start_time_unix); |
|
|
|
stoppedOut.innerText = statistics.stopped; |
|
|
|
stoppedOut.innerText = statistics.stopped; |
|
|
|
}); |
|
|
|
}); |
|
|
|
// // update config just in case |
|
|
|
// update config |
|
|
|
// fetch("/conf") |
|
|
|
fetch("/conf") |
|
|
|
// .then((response) => response.text()) |
|
|
|
.then((response) => response.text()) |
|
|
|
// .then((response_text) => JSON.parse(response_text)) |
|
|
|
.then((config) => { |
|
|
|
// .then((config) => { |
|
|
|
// "print" whole configuration |
|
|
|
// confOutput.innerText = "Configuration: \n" + JSON.stringify(config); |
|
|
|
confOutput.innerText = config; |
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
// update values in the change table if they're empty |
|
|
|
|
|
|
|
let confJSON = JSON.parse(config); |
|
|
|
|
|
|
|
if (confQuery.value == "") { |
|
|
|
|
|
|
|
confQuery.value = confJSON.search.query; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (confIsRegexp.value == "") { |
|
|
|
|
|
|
|
confIsRegexp.value = confJSON.search.is_regexp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}, 650); |
|
|
|
}, 650); |
|
|
|
}(); |
|
|
|
}(); |
|
|
|
</script> |
|
|
|
</script> |
|
|
|