modules/admin-full: Added list of mounted file systems to fstab configuration page
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / fstab.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 require("luci.tools.webadmin")
15 m = Map("fstab", translate("a_s_fstab"))
16
17 local mounts = luci.sys.mounts()
18
19 v = m:section(TypedSection, "_virtual", translate("a_s_fstab_active"))
20 v.anonymous = true
21 v.rowcolors = true
22 v.template = "cbi/tblsection"
23
24 function v.cfgsections(self)
25 local sections = {}
26 for i=1,#mounts do
27 table.insert(sections, i)
28 end
29 return sections
30 end
31
32 fs = v:option(DummyValue, "fs", translate("filesystem"))
33 function fs.cfgvalue(self, section)
34 return mounts[section].fs
35 end
36
37 mp = v:option(DummyValue, "mountpoint", translate("a_s_fstab_mountpoint"))
38 function mp.cfgvalue(self, section)
39 return mounts[section].mountpoint
40 end
41
42 avail = v:option(DummyValue, "avail", translate("a_s_fstab_avail"))
43 function avail.cfgvalue(self, section)
44 return luci.tools.webadmin.byte_format(
45 tonumber(mounts[section].available) * 1024
46 ) .. " / " .. luci.tools.webadmin.byte_format(
47 tonumber(mounts[section].blocks) * 1024
48 )
49 end
50
51 used = v:option(DummyValue, "used", translate("a_s_fstab_used"))
52 function used.cfgvalue(self, section)
53 return mounts[section].percent .. " (" ..
54 luci.tools.webadmin.byte_format(
55 tonumber(mounts[section].used) * 1024
56 ) .. ")"
57 end
58
59
60
61 mount = m:section(TypedSection, "mount", translate("a_s_fstab_mountpoints"), translate("a_s_fstab_mountpoints1"))
62 mount.anonymous = true
63 mount.addremove = true
64 mount.template = "cbi/tblsection"
65
66 mount:option(Flag, "enabled", translate("enable"))
67 mount:option(Value, "device", translate("device"), translate("a_s_fstab_device1"))
68 mount:option(Value, "target", translate("a_s_fstab_mountpoint"))
69 mount:option(Value, "fstype", translate("filesystem"), translate("a_s_fstab_fs1"))
70 mount:option(Value, "options", translate("options"), translatef("manpage", "siehe '%s' manpage", "mount"))
71
72
73 swap = m:section(TypedSection, "swap", "SWAP", translate("a_s_fstab_swap1"))
74 swap.anonymous = true
75 swap.addremove = true
76 swap.template = "cbi/tblsection"
77
78 swap:option(Flag, "enabled", translate("enable"))
79 swap:option(Value, "device", translate("device"), translate("a_s_fstab_device1"))
80
81 return m