luci-app-shadowsocks-libev: rewrite for shadowsocks-libev 3.0.6-2
[project/luci.git] / applications / luci-app-shadowsocks-libev / luasrc / model / cbi / shadowsocks-libev / servers.lua
1 -- Copyright 2017 Yousong Zhou <yszhou4tech@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local ds = require "luci.dispatcher"
5 local ss = require("luci.model.shadowsocks-libev")
6
7 local m, s
8
9 m = Map("shadowsocks-libev",
10 translate("Remote Servers"),
11 translate("Definition of remote shadowsocks servers. \
12 Disable any of them will also disable instances refering to it."))
13
14 local sname = arg[1]
15 if sname then
16 if not m:get(sname) then
17 luci.http.redirect(ds.build_url("admin/services/shadowsocks-libev/servers"))
18 return
19 end
20 s = m:section(NamedSection, sname, "server")
21 m.title = m.title .. ' - ' .. sname
22 else
23 s = m:section(TypedSection, "server")
24 s.template = 'cbi/tblsection'
25 s.addremove = true
26 end
27
28 s:option(Flag, "disabled", translate("Disable"))
29 ss.options_server(s)
30
31 return m