|
| 1 | +local uci = require("simple-uci").cursor() |
| 2 | + |
| 3 | +local f = Form(translate("DSL")) |
| 4 | + |
| 5 | +local s = f:section(Section, nil, translate('ffac-web-dsl:description')) |
| 6 | + |
| 7 | +local enabled = s:option(Flag, "enabled", translate("Enabled")) |
| 8 | +enabled.default = uci:get_bool('gluon', 'dsl', 'enabled', false) |
| 9 | + |
| 10 | +local username = s:option(Value, "username", translate("Username")) |
| 11 | +username:depends(enabled, true) |
| 12 | +username.default = uci:get('gluon', 'dsl', 'username') |
| 13 | + |
| 14 | +local password = s:option(Value, "password", translate("Password")) |
| 15 | +password:depends(enabled, true) |
| 16 | +password.default = uci:get('gluon', 'dsl', 'password') |
| 17 | + |
| 18 | +local vlanid = s:option(Value, "vlanid", translate("VlanID")) |
| 19 | +vlanid:depends(enabled, true) |
| 20 | +vlanid.default = uci:get('gluon', 'dsl', 'vlanid') or '0' |
| 21 | + |
| 22 | +function f:write() |
| 23 | + local dsl_enabled = false |
| 24 | + if enabled.data then |
| 25 | + dsl_enabled = true |
| 26 | + end |
| 27 | + |
| 28 | + uci:section('gluon', 'dsl', 'dsl', { |
| 29 | + enabled = dsl_enabled, |
| 30 | + vlanid = vlanid.data, |
| 31 | + username = username.data, |
| 32 | + password = password.data, |
| 33 | + }) |
| 34 | + |
| 35 | + uci:commit('gluon') |
| 36 | +end |
| 37 | + |
| 38 | +return f |
0 commit comments