Skip to content

Commit

Permalink
web: move model to separate lua for easy implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel committed May 15, 2019
1 parent ae7066c commit 490cc9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
38 changes: 9 additions & 29 deletions decompressed/gui_file/www/cards/001_gateway.lp
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,20 @@ gettext.textdomain('webui-core')
local proxy = require("datamodel")
local content_helper = require("web.content_helper")
local ui_helper = require("web.ui_helper")
local model_helper = require("model_helper")

local find, sub = string.find, string.sub
local version = proxy.get("uci.version.version.@version[0].marketing_version")[1].value or ""
local content = {
version = "uci.version.version.@version[0].marketing_version",
name = "uci.version.version.@version[0].marketing_name",
model = "uci.env.var.prod_friendly_name",
}

local name = proxy.get("uci.version.version.@version[0].marketing_name")[1].value or ""

local content = {}

content["loadavg"] = content_helper.readfile("/proc/loadavg","string")
local cpuload = content["loadavg"]
cpuload = string.sub(cpuload,1,14)
content_helper.getExactContent(content)

local modalPath = nil
local switchName = nil
local session = ngx.ctx.session

local model = proxy.get("uci.env.var.prod_friendly_name")[1].value or ""

if ( model == "DGA4130" ) then
model = "AGTEF"
elseif ( model == "DGA4132" ) then
model = "AGTHP"
elseif ( model == "MediaAccess DGA4131FWB" ) then
model = "DGA4131FWB"
elseif ( model:match("TG788") ) then
model = "TG788vn"
elseif ( model:match("TG789") ) then
model = "TG789vac"
elseif ( model == "Technicolor TG799vac" ) then
model = "TG799vac"
elseif ( model == "Technicolor TG800vac" ) then
model = "TG800vac"
end

if session:hasAccess("/modals/gateway-modal.lp") then
modalPath = "/modals/gateway-modal.lp"
switchName = nil
Expand All @@ -55,15 +35,15 @@ ngx.print('\
<div class="divtable">\
<p>\
<i class="fa fa-info" id="Gateway_=LED_Id"></i>\
<strong id = "Version_Id">'); ngx.print(string.format(T"Version %s (%s)", name, version)); ngx.print('</strong></br>');
<strong id = "Version_Id">'); ngx.print(string.format(T"Version %s (%s)", content.name, content.version)); ngx.print('</strong></br>');
ngx.print('<span class="subinfos">' .. T"CPU Load"..":" ); ngx.print('\
<strong data-bind="text: cpuload">\
</strong></span>\
<div data-remote="/modals/gateway-modal.lp" data-id="gateway-modal" style="text-align: center;">\
<picture>\
<source srcset="/img/gateway_'); ngx.print(model); ngx.print('.webp" type="image/webp">\
<source srcset="/img/gateway_'); ngx.print(model); ngx.print('.png" type="image/png">\
<img class="someInfos" href="#" rel="tooltip" data-placement="top" data-original-title="'); ngx.print( T"Your Gateway" ); ngx.print('" src="/img/gateway_'); ngx.print(model); ngx.print('.png" alt="gateway">\
<img class="someInfos" href="#" rel="tooltip" data-placement="top" data-original-title="'); ngx.print( T"Your Gateway" ); ngx.print('" src="/img/gateway_'); ngx.print(model_helper.model); ngx.print('.png" alt="gateway">\
</picture>\
</div>\
</div>\
Expand Down
10 changes: 10 additions & 0 deletions decompressed/gui_file/www/lua/model_helper.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
"DGA4130" = "AGTEF",
"DGA4132" = "AGTHP",
"MediaAccess DGA4131FWB" = "DGA4131FWB",
"Technicolor TG799vac" = "TG799vac",
"Technicolor TG800vac" = "TG800vac",
"Technicolor TG789vac V2" = "TG789vac",
"Technicolor TG788vn" = "TG788vn",
"MediaAccess TG788vn v2" = "TG788vn"
}

0 comments on commit 490cc9d

Please sign in to comment.