luci-app-dockerman: merge upstream source
This commit is contained in:
parent
ffd3ff2c3c
commit
82455f74c4
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-dockerman
|
||||
PKG_VERSION:=v0.1.4
|
||||
PKG_VERSION:=v0.1.5
|
||||
PKG_RELEASE:=beta
|
||||
PKG_MAINTAINER:=lisaac <https://github.com/lisaac/luci-app-dockerman>
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
@ -49,14 +49,17 @@ network_table = m:section(Table, network_list, translate("Networks"))
|
||||
network_table.nodescr=true
|
||||
|
||||
network_selecter = network_table:option(Flag, "_selected","")
|
||||
network_selecter.template = "cbi/xfvalue"
|
||||
network_id = network_table:option(DummyValue, "_id", translate("ID"))
|
||||
network_selecter.disabled = 0
|
||||
network_selecter.enabled = 1
|
||||
network_selecter.default = 0
|
||||
for k, v in pairs(network_list) do
|
||||
if v["_name"] ~= "bridge" and v["_name"] ~= "none" and v["_name"] ~= "host" then
|
||||
network_selecter:depends("_name", v["_name"])
|
||||
network_selecter.render = function(self, section, scope)
|
||||
self.disable = 0
|
||||
if network_list[section]["_name"] == "bridge" or network_list[section]["_name"] == "none" or network_list[section]["_name"] == "host" then
|
||||
self.disable = 1
|
||||
end
|
||||
Flag.render(self, section, scope)
|
||||
end
|
||||
|
||||
network_name = network_table:option(DummyValue, "_name", translate("Name"))
|
||||
|
||||
@ -32,13 +32,23 @@ if cmd_line and cmd_line:match("^docker.+") then
|
||||
-- skip '\'
|
||||
if w == '\\' then
|
||||
-- start with '-'
|
||||
elseif w:match("^%-+(.+)") and cursor <= 1 then
|
||||
local v = w:match("^%-+.-=(.+)")
|
||||
if v then
|
||||
key = w:match("^%-+(.-)=.+"):lower()
|
||||
else
|
||||
key = w:match("^%-+(.+)"):lower()
|
||||
elseif w:match("^%-+.+") and cursor <= 1 then
|
||||
--key=value
|
||||
local val
|
||||
key, val = w:match("^%-%-(.-)=(.+)")
|
||||
-- -dit
|
||||
if not key then key = w:match("^%-%-(.+)") end
|
||||
|
||||
if not key then
|
||||
key = w:match("^%-(.+)")
|
||||
if key:match("i") or key:match("t") or key:match("d") then
|
||||
if key:match("i") then default_config["interactive"] = true end
|
||||
if key:match("t") then default_config["tty"] = true end
|
||||
-- clear key
|
||||
key = nil
|
||||
end
|
||||
end
|
||||
|
||||
if key == "v" or key == "volume" then
|
||||
key = "mount"
|
||||
elseif key == "p" then
|
||||
@ -55,24 +65,28 @@ if cmd_line and cmd_line:match("^docker.+") then
|
||||
key = "blkioweight"
|
||||
elseif key == "privileged" then
|
||||
default_config["privileged"] = 1
|
||||
key = nil
|
||||
end
|
||||
if v then
|
||||
--key=value
|
||||
if val then
|
||||
if key == "mount" or key == "link" or key == "env" or key == "port" or key == "device" or key == "tmpfs" then
|
||||
if not default_config[key] then default_config[key] = {} end
|
||||
table.insert( default_config[key], v )
|
||||
table.insert( default_config[key], val )
|
||||
else
|
||||
default_config[key] = v
|
||||
default_config[key] = val
|
||||
end
|
||||
-- clear key
|
||||
key = nil
|
||||
end
|
||||
cursor = 1
|
||||
-- value
|
||||
elseif key and type(key) == "string" then
|
||||
elseif key and type(key) == "string" and cursor == 1 then
|
||||
if key == "mount" or key == "link" or key == "env" or key == "port" or key == "device" or key == "tmpfs" then
|
||||
if not default_config[key] then default_config[key] = {} end
|
||||
table.insert( default_config[key], w )
|
||||
else
|
||||
default_config[key] = w
|
||||
end
|
||||
|
||||
if key == "cpus" or key == "cpushare" or key == "memory" or key == "blkioweight" or key == "device" or key == "tmpfs" then
|
||||
default_config["advance"] = 1
|
||||
end
|
||||
@ -95,6 +109,8 @@ elseif cmd_line and cmd_line:match("^duplicate/[^/]+$") then
|
||||
if next(create_body) ~= nil then
|
||||
default_config.name = nil
|
||||
default_config.image = create_body.Image
|
||||
default_config.tty = create_body.Tty
|
||||
default_config.interactive = create_body.OpenStdin
|
||||
default_config.privileged = create_body.HostConfig.Privileged and 1 or 0
|
||||
default_config.restart = create_body.HostConfig.RestartPolicy and create_body.HostConfig.RestartPolicy.name or nil
|
||||
default_config.network = create_body.HostConfig.NetworkMode == "default" and "bridge" or create_body.HostConfig.NetworkMode
|
||||
@ -151,6 +167,19 @@ d.template = "docker/resolv_container"
|
||||
|
||||
d = s:option(Value, "name", translate("Container Name"))
|
||||
d.rmempty = true
|
||||
d.default = default_config.name or nil
|
||||
|
||||
d = s:option(Flag, "interactive", translate("Interactive (-i)"))
|
||||
d.rmempty = true
|
||||
d.disabled = 0
|
||||
d.enabled = 1
|
||||
d.default = default_config.interactive and 1 or 0
|
||||
|
||||
d = s:option(Flag, "tty", translate("TTY (-t)"))
|
||||
d.rmempty = true
|
||||
d.disabled = 0
|
||||
d.enabled = 1
|
||||
d.default = default_config.tty and 1 or 0
|
||||
|
||||
d = s:option(Flag, "_force_pull", translate("Always pull image first"))
|
||||
d.rmempty = true
|
||||
@ -158,7 +187,6 @@ d.disabled = 0
|
||||
d.enabled = 1
|
||||
d.default = 0
|
||||
|
||||
d.default = default_config.name or nil
|
||||
d = s:option(Value, "image", translate("Docker Image"))
|
||||
d.rmempty = true
|
||||
d.default = default_config.image or nil
|
||||
@ -296,6 +324,8 @@ m.handle = function(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
local tmp
|
||||
local name = data.name
|
||||
local tty = data.tty
|
||||
local interactive = data.interactive
|
||||
local image = data.image
|
||||
local user = data.user
|
||||
if not image:match(".-:.+") then
|
||||
@ -385,6 +415,8 @@ m.handle = function(self, state, data)
|
||||
end
|
||||
|
||||
create_body.Hostname = name
|
||||
create_body.Tty = tty and true or false
|
||||
create_body.OpenStdin = interactive and true or false
|
||||
create_body.User = user
|
||||
create_body.Cmd = (#command ~= 0) and command or nil
|
||||
create_body.Env = env
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<div style="display: inline-block;">
|
||||
<% if self:cfgvalue(section) ~= false then %>
|
||||
<input class="cbi-button cbi-button-<%=self.inputstyle or "button" %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
|
||||
<input class="cbi-button cbi-button-<%=self.inputstyle or "button" %>" type="submit"" <% if self.disable then %>disabled <% end %><%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
|
||||
@ -3,11 +3,15 @@
|
||||
function resolv_container(op) {
|
||||
let s = document.getElementById(op + '-status');
|
||||
if (!s) return;
|
||||
let cmd_line = prompt("Plese input <docker create> command line:", "");
|
||||
let cmd_line = prompt("Plese input <docker create/run> command line:", "");
|
||||
if (cmd_line == null || cmd_line == "") {
|
||||
s.innerHTML = "<font color='red'>Canceled</font>";
|
||||
return;
|
||||
}
|
||||
if (! cmd_line.match("^docker")) {
|
||||
s.innerHTML = "<font color='red'>Command line Error</font>";
|
||||
return;
|
||||
}
|
||||
let re = /\/admin\/docker\/newcontainer\//
|
||||
let p = window.location.href
|
||||
let path = p.split(re)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user