app tweaks
This commit is contained in:
@@ -13,7 +13,7 @@ if not mon then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local changedPage = UI.Window {
|
local page = UI.Window {
|
||||||
parent = UI.Device {
|
parent = UI.Device {
|
||||||
device = mon,
|
device = mon,
|
||||||
textScale = .5,
|
textScale = .5,
|
||||||
@@ -55,7 +55,14 @@ local changedPage = UI.Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changedPage.grid:getDisplayValues(row)
|
function page.grid:getRowTextColor(row, selected)
|
||||||
|
if row.lastCount and row.lastCount ~= row.count then
|
||||||
|
return row.count > row.lastCount and colors.yellow or colors.lightGray
|
||||||
|
end
|
||||||
|
return UI.Grid:getRowTextColor(row, selected)
|
||||||
|
end
|
||||||
|
|
||||||
|
function page.grid:getDisplayValues(row)
|
||||||
row = Util.shallowCopy(row)
|
row = Util.shallowCopy(row)
|
||||||
|
|
||||||
local ind = '+'
|
local ind = '+'
|
||||||
@@ -70,7 +77,7 @@ function changedPage.grid:getDisplayValues(row)
|
|||||||
return row
|
return row
|
||||||
end
|
end
|
||||||
|
|
||||||
function changedPage:eventHandler(event)
|
function page:eventHandler(event)
|
||||||
if event.type == 'reset' then
|
if event.type == 'reset' then
|
||||||
self.lastItems = nil
|
self.lastItems = nil
|
||||||
self.grid:setValues({ })
|
self.grid:setValues({ })
|
||||||
@@ -93,7 +100,7 @@ function changedPage:eventHandler(event)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function changedPage:refresh()
|
function page:refresh()
|
||||||
local t = context.storage.cache
|
local t = context.storage.cache
|
||||||
|
|
||||||
if not self.lastItems then
|
if not self.lastItems then
|
||||||
@@ -101,7 +108,7 @@ function changedPage:refresh()
|
|||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
self.lastItems[k] = {
|
self.lastItems[k] = {
|
||||||
displayName = v.displayName,
|
displayName = v.displayName,
|
||||||
lastCount = v.count,
|
initialCount = v.count,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
self.timestamp = os.clock()
|
self.timestamp = os.clock()
|
||||||
@@ -109,6 +116,7 @@ function changedPage:refresh()
|
|||||||
|
|
||||||
else
|
else
|
||||||
for _,v in pairs(self.lastItems) do
|
for _,v in pairs(self.lastItems) do
|
||||||
|
v.lastCount = v.count
|
||||||
v.count = nil
|
v.count = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -122,7 +130,7 @@ function changedPage:refresh()
|
|||||||
self.lastItems[k] = {
|
self.lastItems[k] = {
|
||||||
displayName = v.displayName,
|
displayName = v.displayName,
|
||||||
count = v.count,
|
count = v.count,
|
||||||
lastCount = 0,
|
initialCount = 0,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -132,8 +140,8 @@ function changedPage:refresh()
|
|||||||
if not v.count then
|
if not v.count then
|
||||||
v.count = 0
|
v.count = 0
|
||||||
end
|
end
|
||||||
if v.count ~= v.lastCount then
|
if v.count ~= v.initialCount then
|
||||||
v.change = v.count - v.lastCount
|
v.change = v.count - v.initialCount
|
||||||
v.rate = Util.round(60 / self.elapsed * v.change, 1)
|
v.rate = Util.round(60 / self.elapsed * v.change, 1)
|
||||||
changedItems[k] = v
|
changedItems[k] = v
|
||||||
end
|
end
|
||||||
@@ -146,14 +154,21 @@ end
|
|||||||
|
|
||||||
Event.onInterval(5, function()
|
Event.onInterval(5, function()
|
||||||
if context.storage:isOnline() then
|
if context.storage:isOnline() then
|
||||||
changedPage:refresh()
|
page:refresh()
|
||||||
changedPage:sync()
|
page:sync()
|
||||||
else
|
else
|
||||||
changedPage.grid:clear()
|
page.grid:clear()
|
||||||
changedPage.grid:centeredWrite(math.ceil(changedPage.height / 2), 'Storage Offline')
|
page.grid:centeredWrite(math.ceil(page.height / 2), 'Storage Offline')
|
||||||
changedPage:sync()
|
page:sync()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
changedPage:draw()
|
Event.on('monitor_touch', function(_, side)
|
||||||
changedPage:sync()
|
if side == mon.side then
|
||||||
|
page:emit({ type = 'reset' })
|
||||||
|
page:sync()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
page:draw()
|
||||||
|
page:sync()
|
||||||
Reference in New Issue
Block a user