mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-04 23:43:56 +08:00
🛸 Sync 2026-10-27 02:27:08
This commit is contained in:
1 parent
b3798acf79
commit
8b63d5d4a9
78 files changed
+2288
-518
No files matched your search
@@ -0,0 +1,99 @@
|
||||
<%+tasks/embed%>
|
||||
<% local installed = require("luci.model.kaiplus.classic").installed() %>
|
||||
|
||||
<style type="text/css">
|
||||
.classic-kai-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin: 16px;
|
||||
}
|
||||
.classic-kai-actions #classic-kai-update {
|
||||
font-size: 0.875em;
|
||||
padding: 6px 12px;
|
||||
min-height: 32px;
|
||||
height: auto;
|
||||
line-height: 1.4;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var classicPageInstalled = <%= installed and "true" or "false" %>;
|
||||
var classicInstallUrl = '<%=url("admin/services/kaiplus/install_kai")%>';
|
||||
var classicUpdateUrl = '<%=url("admin/services/kaiplus/update_kai")%>';
|
||||
var classicOpenUrl = '<%=url("admin/services/linkease_apps/open")%>?id=kai';
|
||||
|
||||
function installClassicKai() {
|
||||
classicPackageTask(false);
|
||||
}
|
||||
|
||||
function updateClassicKai() {
|
||||
classicPackageTask(true);
|
||||
}
|
||||
|
||||
function classicPackageTask(update) {
|
||||
var prompt = update
|
||||
? '<%:Update CLASSIC KAI and its runtime engine from the iStore package feed? A running CLASSIC KAI service will restart.%>'
|
||||
: '<%:Classic KAI is not installed. Install it now?%>';
|
||||
if (!window.confirm(prompt)) return;
|
||||
if (!window.taskd || !window.taskd.show_log) {
|
||||
window.alert('<%:Task log window is not available.%>');
|
||||
return;
|
||||
}
|
||||
|
||||
var button = document.getElementById(update ? 'classic-kai-update' : 'classic-kai-install');
|
||||
button.disabled = true;
|
||||
button.value = '<%:Starting task...%>';
|
||||
(new XHR()).post(update ? classicUpdateUrl : classicInstallUrl, { token: window.taskd.csrfToken || '' }, function(x) {
|
||||
var data = {};
|
||||
button.disabled = false;
|
||||
button.value = update ? '<%:Update%>' : '<%:Install CLASSIC KAI%>';
|
||||
if (x && x.responseText) {
|
||||
try { data = JSON.parse(x.responseText || '{}'); }
|
||||
catch (e) { data = {}; }
|
||||
}
|
||||
if (!data.ok) {
|
||||
window.alert(data.error || '<%:Failed to start the CLASSIC KAI package task.%>');
|
||||
return;
|
||||
}
|
||||
if (data.installed) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
window.taskd.show_log(data.task_id || 'kaiplus-kai-install');
|
||||
});
|
||||
}
|
||||
|
||||
XHR.poll(5, '<%=url("admin/services/kaiplus/classic_status")%>', null, function(x, st) {
|
||||
if (!st) return;
|
||||
if (!classicPageInstalled && st.installed) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
var status = document.getElementById('classic-kai-status');
|
||||
var installButton = document.getElementById('classic-kai-install');
|
||||
var updateButton = document.getElementById('classic-kai-update');
|
||||
var updateHint = document.getElementById('classic-kai-update-hint');
|
||||
var openButton = document.getElementById('classic-kai-open');
|
||||
status.textContent = !st.installed
|
||||
? '<%:CLASSIC KAI is not installed. Install it to configure and start the service.%>'
|
||||
: st.running ? '<%:The CLASSIC KAI service is running.%>' : '<%:The CLASSIC KAI service is not running.%>';
|
||||
status.style.color = st.installed && st.running ? 'green' : '';
|
||||
installButton.style.display = st.installed ? 'none' : '';
|
||||
updateButton.style.display = st.installed ? '' : 'none';
|
||||
updateHint.style.display = st.installed ? '' : 'none';
|
||||
openButton.style.display = st.installed && st.running ? '' : 'none';
|
||||
});
|
||||
//]]></script>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Status%></legend>
|
||||
<p id="classic-kai-status"><em><%:Collecting data...%></em></p>
|
||||
<p id="classic-kai-update-hint" style="display:none"><%:Updates come from the iStore package feed and include CLASSIC KAI and its runtime engine.%></p>
|
||||
<div class="classic-kai-actions">
|
||||
<input id="classic-kai-install" class="btn cbi-button cbi-button-apply" type="button" value="<%:Install CLASSIC KAI%>" onclick="installClassicKai()" style="display:none"/>
|
||||
<input id="classic-kai-open" class="btn cbi-button cbi-button-apply" type="button" value="<%:Open CLASSIC KAI%>" onclick="window.open(classicOpenUrl, '_blank', 'noopener')" style="display:none"/>
|
||||
<input id="classic-kai-update" class="btn cbi-button" type="button" value="<%:Update%>" title="<%:Update CLASSIC KAI%>" aria-label="<%:Update CLASSIC KAI%>" onclick="updateClassicKai()" style="display:none"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -1,5 +1,3 @@
|
||||
<%+tasks/embed%>
|
||||
|
||||
<style type="text/css">
|
||||
.kaiplus-actions {
|
||||
display: flex;
|
||||
@@ -18,51 +16,10 @@
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var kaiInstalled = false;
|
||||
var kaiLuciUrl = '<%=url("admin/services/kai")%>';
|
||||
var kaiInstallUrl = '<%=url("admin/services/kaiplus/install_kai")%>';
|
||||
var kaiCsrfToken = (window.taskd && window.taskd.csrfToken) || '';
|
||||
|
||||
function openClassicKai() {
|
||||
var button = document.getElementById('kaiplus-open-kai');
|
||||
if (kaiInstalled) {
|
||||
window.location.href = kaiLuciUrl;
|
||||
return;
|
||||
}
|
||||
if (!window.confirm('<%:Classic KAI is not installed. Install it now?%>')) return;
|
||||
if (!window.taskd || !window.taskd.show_log) {
|
||||
window.alert('<%:Task log window is not available.%>');
|
||||
return;
|
||||
}
|
||||
|
||||
button.disabled = true;
|
||||
button.value = '<%:Starting installation...%>';
|
||||
(new XHR()).post(kaiInstallUrl, { token: kaiCsrfToken }, function(x) {
|
||||
var data = {};
|
||||
button.disabled = false;
|
||||
button.value = '<%:Classic KAI%>';
|
||||
if (x && x.responseText) {
|
||||
try { data = JSON.parse(x.responseText || '{}'); }
|
||||
catch (e) { data = {}; }
|
||||
}
|
||||
if (!data.ok) {
|
||||
window.alert(data.error || '<%:Failed to start KAI installation.%>');
|
||||
return;
|
||||
}
|
||||
if (data.installed) {
|
||||
kaiInstalled = true;
|
||||
window.location.href = kaiLuciUrl;
|
||||
return;
|
||||
}
|
||||
window.taskd.show_log(data.task_id || 'kaiplus-kai-install');
|
||||
});
|
||||
}
|
||||
|
||||
XHR.poll(5, '<%=url("admin/services/kaiplus_status")%>', null, function(x, st) {
|
||||
var el = document.getElementById('kaiplus_status');
|
||||
var openButton = document.getElementById('kaiplus-open');
|
||||
if (st && el) {
|
||||
kaiInstalled = st.kai_installed === true;
|
||||
var status = st.running
|
||||
? '<br/><em style=\"color:green\"><%:The KaiPlus service is running.%></em>'
|
||||
: '<br/><em style=\"color:red\"><%:The KaiPlus service is not running.%></em>';
|
||||
@@ -88,6 +45,6 @@ XHR.poll(5, '<%=url("admin/services/kaiplus_status")%>', null, function(x, st) {
|
||||
</p>
|
||||
<div class="kaiplus-actions">
|
||||
<input id="kaiplus-open" class="btn cbi-button cbi-button-apply" type="button" value=" <%:Click to open KaiPlus%> " onclick="window.open('<%=url("admin/services/kaiplus/open")%>')" style="display:none"/>
|
||||
<input id="kaiplus-open-kai" class="btn cbi-button" type="button" value=" <%:Classic KAI%> " onclick="openClassicKai()"/>
|
||||
<input id="kaiplus-open-kai" class="btn cbi-button" type="button" value=" <%:CLASSIC KAI%> " onclick="window.location.href='<%=url("admin/services/kaiplus/classic")%>'"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
Reference in new issue
Block a user