Some cleanups
[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(Table, mounts, translate("a_s_fstab_active"))
20
21 fs = v:option(DummyValue, "fs", translate("filesystem"))
22
23 mp = v:option(DummyValue, "mountpoint", translate("a_s_fstab_mountpoint"))
24
25 avail = v:option(DummyValue, "avail", translate("a_s_fstab_avail"))
26 function avail.cfgvalue(self, section)
27         return luci.tools.webadmin.byte_format(
28          tonumber(mounts[section].available) * 1024
29         ) .. " / " .. luci.tools.webadmin.byte_format(
30          tonumber(mounts[section].blocks) * 1024
31         )
32 end
33
34 used = v:option(DummyValue, "used", translate("a_s_fstab_used"))
35 function used.cfgvalue(self, section)
36         return mounts[section].percent .. " (" ..
37         luci.tools.webadmin.byte_format(
38          tonumber(mounts[section].used) * 1024
39         ) .. ")"
40 end
41
42
43
44 mount = m:section(TypedSection, "mount", translate("a_s_fstab_mountpoints"), translate("a_s_fstab_mountpoints1"))
45 mount.anonymous = true
46 mount.addremove = true
47 mount.template = "cbi/tblsection"
48
49 mount:option(Flag, "enabled", translate("enable"))
50 mount:option(Value, "device", translate("device"), translate("a_s_fstab_device1"))
51 mount:option(Value, "target", translate("a_s_fstab_mountpoint"))
52 mount:option(Value, "fstype", translate("filesystem"), translate("a_s_fstab_fs1"))
53 mount:option(Value, "options", translate("options"), translatef("manpage", "siehe '%s' manpage", "mount"))
54
55
56 swap = m:section(TypedSection, "swap", "SWAP", translate("a_s_fstab_swap1"))
57 swap.anonymous = true
58 swap.addremove = true
59 swap.template = "cbi/tblsection"
60
61 swap:option(Flag, "enabled", translate("enable"))
62 swap:option(Value, "device", translate("device"), translate("a_s_fstab_device1"))
63
64 return m