Merge pull request 'Fixed start/stop buttons | Added confirm to remove popup' (#1) from riley/luci-lib-taskd:main into main
Reviewed-on: #1main
commit
760ae61700
@ -1,56 +1,91 @@
|
|||||||
|
<%
|
||||||
|
local taskd = require "luci.model.tasks"
|
||||||
|
local status = taskd.status(self.task_id)
|
||||||
|
|
||||||
|
-- Check if a task is running
|
||||||
|
local task_running = status.running
|
||||||
|
|
||||||
<% if self.task_start_failed then %>
|
-- Check for a task start failure
|
||||||
<div class="alert-message warning"><%:Another task running, try again later.%> <a href="javascript:void(taskd.show_log('<%=self.task_id%>'))"><%:Click here to check running task%></a></div>
|
if self.task_start_failed then
|
||||||
|
%>
|
||||||
|
<div class="alert-message warning">
|
||||||
|
<%:Another task running, try again later.%>
|
||||||
|
<a href="javascript:void(taskd.show_log('<%=self.task_id%>'))">
|
||||||
|
<%:Click here to check running task%>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%+cbi/map%>
|
<%+cbi/map%>
|
||||||
<%
|
|
||||||
local task_running = false
|
<div id="customModal" class="alert-message danger" style="display:none; text-align: center;">
|
||||||
local taskd = require "luci.model.tasks"
|
<strong style="text-transform: uppercase;">This will permanently delete your installation, are you sure?</strong>
|
||||||
local status = taskd.status(self.task_id)
|
<br>
|
||||||
task_running = status.running
|
<input class="btn cbi-button cbi-button-remove" type="button" value="YES" onclick="proceedRemoval()" style="margin-right: 10px;">
|
||||||
-%>
|
<input class="btn cbi-button" type="button" value="NO" onclick="closeRemoveConfirmation()">
|
||||||
|
</div>
|
||||||
<div class="cbi-page-actions control-group">
|
<div class="cbi-page-actions control-group">
|
||||||
<%
|
<%
|
||||||
if not task_running then
|
if not task_running then
|
||||||
%>
|
local util = require "luci.util"
|
||||||
<%
|
|
||||||
local util = require "luci.util"
|
local container_status = util.trim(util.exec(self.script_path.." status"))
|
||||||
local container_status = util.trim(util.exec(self.script_path.." status"))
|
local container_status_lower = string.lower(container_status)
|
||||||
local container_install = (string.len(container_status) > 0)
|
|
||||||
local container_running = container_status == "running"
|
local container_install = not string.match(container_status_lower, " is not installed$")
|
||||||
if container_install then
|
local container_running = string.match(container_status_lower, "^up%W")
|
||||||
-%>
|
|
||||||
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Upgrade%>/<%:Apply%>" onclick="cbi_submit(this, 'cbi.apply', 'upgrade')" />
|
if container_install then
|
||||||
<%
|
%>
|
||||||
if container_running then
|
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Upgrade%>/<%:Apply%>" onclick="cbi_submit(this, 'cbi.apply', 'upgrade')" />
|
||||||
-%>
|
|
||||||
<input class="btn cbi-button cbi-button-remove" type="button" value="<%:Stop%>" onclick="cbi_submit(this, 'cbi.apply', 'stop')" />
|
|
||||||
|
|
||||||
<input class="btn cbi-button cbi-button-reload" type="button" value="<%:Restart%>" onclick="cbi_submit(this, 'cbi.apply', 'restart')" />
|
|
||||||
<% else %>
|
|
||||||
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Start%>" onclick="cbi_submit(this, 'cbi.apply', 'start')" />
|
|
||||||
|
|
||||||
<input class="btn cbi-button cbi-button-remove" type="button" value="<%:Remove%>" onclick="cbi_submit(this, 'cbi.apply', 'rm')" />
|
|
||||||
<% end
|
|
||||||
else %>
|
|
||||||
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Install%>" onclick="cbi_submit(this, 'cbi.apply', 'install')" />
|
|
||||||
<% end
|
|
||||||
else
|
|
||||||
%>
|
|
||||||
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Task Running%>…" onclick="taskd.show_log('<%=self.task_id%>')" />
|
|
||||||
<%
|
<%
|
||||||
end
|
if container_running then
|
||||||
|
%>
|
||||||
|
<input class="btn cbi-button cbi-button-remove" type="button" value="<%:Stop%>" onclick="cbi_submit(this, 'cbi.apply', 'stop')" />
|
||||||
|
<input class="btn cbi-button cbi-button-reload" type="button" value="<%:Restart%>" onclick="cbi_submit(this, 'cbi.apply', 'restart')" />
|
||||||
|
<%
|
||||||
|
else
|
||||||
|
%>
|
||||||
|
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Start%>" onclick="cbi_submit(this, 'cbi.apply', 'start')" />
|
||||||
|
<input class="btn cbi-button cbi-button-remove" type="button" value="<%:Remove%>" onclick="showRemoveConfirmation()" />
|
||||||
|
<%
|
||||||
|
end
|
||||||
|
else
|
||||||
|
%>
|
||||||
|
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Install%>" onclick="cbi_submit(this, 'cbi.apply', 'install')" />
|
||||||
|
<%
|
||||||
|
end
|
||||||
|
else
|
||||||
|
%>
|
||||||
|
<input class="btn cbi-button cbi-button-apply" type="button" value="<%:Task Running%>…" onclick="taskd.show_log('<%=self.task_id%>')" />
|
||||||
|
<%
|
||||||
|
end
|
||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function showRemoveConfirmation() {
|
||||||
|
document.getElementById("customModal").style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeRemoveConfirmation() {
|
||||||
|
document.getElementById("customModal").style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
function proceedRemoval() {
|
||||||
|
closeRemoveConfirmation();
|
||||||
|
cbi_submit(document.querySelector('.cbi-button-remove'), 'cbi.apply', 'rm');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<%+tasks/embed%>
|
<%+tasks/embed%>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
if self.auto_show_task and task_running then
|
if self.auto_show_task and task_running then
|
||||||
-%>
|
%>
|
||||||
<script>
|
<script>
|
||||||
taskd.show_log("<%=self.task_id%>");
|
taskd.show_log("<%=self.task_id%>");
|
||||||
</script>
|
</script>
|
||||||
<%
|
<%
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
Loading…
Reference in New Issue