Skip to content

Commit

Permalink
improvement mount point display
Browse files Browse the repository at this point in the history
  • Loading branch information
lisaac committed Feb 28, 2020
1 parent 1757663 commit b2b2a7f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
11 changes: 11 additions & 0 deletions luasrc/model/cbi/diskman/disks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ v_mount_point.render = function(self, section, scope)
Value.render(self, section, scope)
else
self.template = "cbi/dvalue"
local new_mp = ""
local v_mp_d
for v_mp_d in self["section"]["data"][section]["mount_point"]:gmatch('[^/]+') do
if #v_mp_d > 12 then
new_mp = new_mp .. "/" .. v_mp_d:sub(1,7) .. ".." .. v_mp_d:sub(-4)
else
new_mp = new_mp .."/".. v_mp_d
end
end
self["section"]["data"][section]["mount_point"] = '<span title="'..self["section"]["data"][section]["mount_point"] .. '" >'..new_mp..'</span>'
self.rawhtml = true
DummyValue.render(self, section, scope)
end
end
Expand Down
23 changes: 22 additions & 1 deletion luasrc/model/cbi/diskman/partition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,28 @@ if not disk_info.p_table:match("Raid") then
s_partition_table:option(DummyValue, "used_formated", translate("Used"))
s_partition_table:option(DummyValue, "free_formated", translate("Free Space"))
s_partition_table:option(DummyValue, "usage", translate("Usage"))
s_partition_table:option(DummyValue, "mount_point", translate("Mount Point"))
local dv_mount_point = s_partition_table:option(DummyValue, "mount_point", translate("Mount Point"))
dv_mount_point.rawhtml = true
dv_mount_point.render = function(self, section, scope)
local new_mp = ""
local v_mp_d
for line in self["section"]["data"][section]["mount_point"]:gmatch("[^%s]+") do
if line == '-' then
new_mp = line
break
end
for v_mp_d in line:gmatch('[^/]+') do
if #v_mp_d > 12 then
new_mp = new_mp .. "/" .. v_mp_d:sub(1,7) .. ".." .. v_mp_d:sub(-4)
else
new_mp = new_mp .."/".. v_mp_d
end
end
new_mp = '<span title="'.. line .. '" >' ..new_mp ..'</span>' .. "<br/>"
end
self["section"]["data"][section]["mount_point"] = new_mp
DummyValue.render(self, section, scope)
end
local val_fs = s_partition_table:option(Value, "fs", translate("File System"))
val_fs.forcewrite = true
val_fs.write = function(self, section, value)
Expand Down
4 changes: 2 additions & 2 deletions luasrc/model/diskman.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ d.command.mount = nixio.fs.access("/usr/bin/mount") and "/usr/bin/mount" or "/bi
d.command.umount = nixio.fs.access("/usr/bin/umount") and "/usr/bin/umount" or "/bin/umount"

local proc_mounts = nixio.fs.readfile("/proc/mounts") or ""
local mounts = luci.util.exec(d.command.mount) or ""
local mounts = luci.util.exec(d.command.mount .. " 2>/dev/null") or ""
local swaps = nixio.fs.readfile("/proc/swaps") or ""
local df = luci.sys.exec(d.command.df) or ""
local df = luci.sys.exec(d.command.df .. " 2>/dev/null") or ""

function byte_format(byte)
local suff = {"B", "KB", "MB", "GB", "TB"}
Expand Down

0 comments on commit b2b2a7f

Please sign in to comment.