composer/projects/gk7205v200_lite_meldana/general/overlay/www/cgi-bin/webui.cgi

81 lines
2.7 KiB
Perl
Executable File
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/haserl
<%in p/common.cgi %>
<%
if [ "POST" = "$REQUEST_METHOD" ]; then
case "$POST_action" in
init)
update_caminfo
redirect_back
;;
*)
redirect_to $SCRIPT_NAME "danger" "UNKNOWN ACTION: $POST_action"
;;
esac
fi
page_title="Веб интерфейс"
web_branch="master"
[ -n "$ui_version" ] && web_branch="$(echo "$ui_version" | cut -d+ -f1)"
%>
<%in p/header.cgi %>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4 mb-4">
<div class="col">
<h3>Версия прошивки</h3>
<dl class="list small">
<dt>Установленная</dt><dd><%= $ui_version %></dd>
<dt>Стабильная</dt><dd id="microbe-web-master-ver"></dd>
<dt>Нестабильная</dt><dd id="microbe-web-dev-ver"></dd>
</dl>
</div>
<div class="col">
<h3>Обновление</h3>
<% if [ -n "$network_gateway" ]; then %>
<form action="webui-update.cgi" method="post">
<% field_hidden "action" "update" %>
<% field_select "web_branch" "Тип прошивки" "master:Стабильная,dev:Тестовая" %>
<% if [ "$debug" -gt 0 ]; then %>
<% field_text "web_commit" "Commit" "" %>
<% fi %>
<% field_checkbox "web_verbose" "Подробный вывод." %>
<% field_checkbox "web_enforce" "Установить, даже если та же версия." %>
<% field_checkbox "web_noreboot" "Не перезагружать после обновления." %>
<% button_submit "Установить обновление с GitHub" "warning" %>
</form>
<% else %>
<p class="alert alert-danger">Для обновления требуется доступ к GitHub.</p>
<% fi %>
</div>
</div>
<script>
const GH_URL="https://github.com/OpenIPC/";
const GH_API="https://api.github.com/repos/OpenIPC/";
function checkUpdates() {
queryBranch('microbe-web', 'master');
queryBranch('microbe-web', 'dev');
}
function queryBranch(repo, branch) {
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", function(){
const d = JSON.parse(this.response);
const sha_short = d.commit.sha.slice(0,7);
const date = d.commit.commit.author.date.slice(0,10);
const link = document.createElement('a');
link.href = GH_URL + repo + '/commits/' + branch;
link.target = '_blank';
link.textContent = branch + '+' + sha_short + ', ' + date;
const el = $('#' + repo + '-' + branch + '-ver').appendChild(link);
});
oReq.open("GET", GH_API + repo + '/branches/' + branch);
oReq.setRequestHeader("Authorization", "Basic " + btoa("<%= "${GITHUB_USERNAME}:${GITHUB_TOKEN}" %>"));
oReq.send();
}
window.addEventListener('load', checkUpdates);
</script>
<%in p/footer.cgi %>