X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fadmin-full%2Fluasrc%2Fmodel%2Fcbi%2Fadmin_system%2Ffstab.lua;h=8ac3d6d5e77bc31567b6b95b4061e88c2890959a;hp=a70174d39502a2cefb8a1b834a3b4939588fb5b5;hb=2e0fbbadc546e37baf13416e66aa5173ca604f5c;hpb=21c441c5d1be85f0939484bb26f3f70e3ea453b7 diff --git a/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua b/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua index a70174d39..8ac3d6d5e 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_system/fstab.lua @@ -11,6 +11,7 @@ You may obtain a copy of the License at $Id$ ]]-- + require("luci.tools.webadmin") local fs = require "nixio.fs" @@ -62,27 +63,94 @@ mount = m:section(TypedSection, "mount", translate("Mount Points"), translate("M mount.anonymous = true mount.addremove = true mount.template = "cbi/tblsection" +mount.extedit = luci.dispatcher.build_url("admin/system/fstab/mount/%s") + +mount.create = function(...) + local sid = TypedSection.create(...) + if sid then + luci.http.redirect(mount.extedit % sid) + return + end +end + + +mount:option(Flag, "enabled", translate("Enabled")).rmempty = false + +dev = mount:option(DummyValue, "device", translate("Device")) +dev.cfgvalue = function(self, section) + local v + + v = m.uci:get("fstab", section, "uuid") + if v then return "UUID: %s" % v end + + v = m.uci:get("fstab", section, "label") + if v then return "Label: %s" % v end + + v = Value.cfgvalue(self, section) or "?" + return size[v] and "%s (%s MB)" % {v, size[v]} or v +end + +mp = mount:option(DummyValue, "target", translate("Mount Point")) +mp.cfgvalue = function(self, section) + if m.uci:get("fstab", section, "is_rootfs") == "1" then + return "/overlay" + else + return Value.cfgvalue(self, section) or "?" + end +end -mount:option(Flag, "enabled", translate("enable")).rmempty = false -dev = mount:option(Value, "device", translate("Device"), translate("The device file of the memory or partition (e.g. /dev/sda1)")) -for i, d in ipairs(devices) do - dev:value(d, size[d] and "%s (%s MB)" % {d, size[d]}) +fs = mount:option(DummyValue, "fstype", translate("Filesystem")) +fs.cfgvalue = function(self, section) + return Value.cfgvalue(self, section) or "?" end -mount:option(Value, "target", translate("Mount Point")) -mount:option(Value, "fstype", translate("Filesystem"), translate("The filesystem that was used to format the memory (e.g. ext3)")) -mount:option(Value, "options", translate("Options"), translate("See \"mount\" manpage for details")) +op = mount:option(DummyValue, "options", translate("Options")) +op.cfgvalue = function(self, section) + return Value.cfgvalue(self, section) or "defaults" +end + +rf = mount:option(DummyValue, "is_rootfs", translate("Root")) +rf.cfgvalue = function(self, section) + return Value.cfgvalue(self, section) == "1" + and translate("yes") or translate("no") +end + +ck = mount:option(DummyValue, "enabled_fsck", translate("Check")) +ck.cfgvalue = function(self, section) + return Value.cfgvalue(self, section) == "1" + and translate("yes") or translate("no") +end swap = m:section(TypedSection, "swap", "SWAP", translate("If your physical memory is insufficient unused data can be temporarily swapped to a swap-device resulting in a higher amount of usable RAM. Be aware that swapping data is a very slow process as the swap-device cannot be accessed with the high datarates of the RAM.")) swap.anonymous = true swap.addremove = true swap.template = "cbi/tblsection" +swap.extedit = luci.dispatcher.build_url("admin/system/fstab/swap/%s") + +swap.create = function(...) + local sid = TypedSection.create(...) + if sid then + luci.http.redirect(swap.extedit % sid) + return + end +end + + +swap:option(Flag, "enabled", translate("Enabled")).rmempty = false + +dev = swap:option(DummyValue, "device", translate("Device")) +dev.cfgvalue = function(self, section) + local v + + v = m.uci:get("fstab", section, "uuid") + if v then return "UUID: %s" % v end + + v = m.uci:get("fstab", section, "label") + if v then return "Label: %s" % v end -swap:option(Flag, "enabled", translate("enable")).rmempty = false -dev = swap:option(Value, "device", translate("Device"), translate("The device file of the memory or partition (e.g. /dev/sda1)")) -for i, d in ipairs(devices) do - dev:value(d, size[d] and "%s (%s MB)" % {d, size[d]}) + v = Value.cfgvalue(self, section) or "?" + return size[v] and "%s (%s MB)" % {v, size[v]} or v end return m