Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pretranslated: do not change this file
- -- Enable localization
- gettext.textdomain('webui-core')
- local proxy = require("datamodel")
- local ui_helper = require("web.ui_helper")
- local content_helper = require("web.content_helper")
- local find, sub = string.find, string.sub
- local floor, ipairs = math.floor, ipairs
- local format = string.format
- -- Non-configurable data
- local content = {
- software_name = "uci.version.version.@version[0].marketing_name",
- software_version = "uci.version.version.@version[0].marketing_version",
- factory_id = "uci.env.rip.factory_id",
- serial_number = "uci.env.rip.serial",
- }
- content_helper.getExactContent(content)
- content["uptime"] = content_helper.readfile("/proc/uptime","number",floor)
- local name = proxy.get("uci.env.var.friendly_sw_version_activebank")
- if name then
- name = name[1].value
- name = name:gsub("_"," ")
- else
- name = ""
- end
- local board = proxy.get("uci.env.rip.board_mnemonic")
- if board then
- board = board[1].value
- else
- board = ""
- end
- -- Construct an uptime string from the number of seconds
- local function secondsToTime(uptime)
- local days = floor(uptime / 86400)
- local hours = floor(uptime / 3600) % 24
- local minutes = floor(uptime / 60) % 60
- local seconds = uptime % 60
- if (days > 0) then
- return format(T"%ddays %dhours %dmin %dsec", days, hours, minutes, seconds)
- elseif (hours > 0) then
- return format(T"%dhours %dmin %dsec", hours, minutes, seconds)
- elseif (minutes > 0) then
- return format(T"%dmin %dsec", minutes, seconds)
- else
- return format(T"%dsec", seconds)
- end
- end
- local session = ngx.ctx.session
- if session:hasAccess("/modals/gateway-modal.lp") then
- local headerAttr = {
- icon = {
- class = "icon-cogs"
- }
- }
- ngx.print('\
- <div class="span3">\
- <div class="smallcard">\
- '); ngx.print( ui_helper.createCardHeader(T"Gateway", "modals/gateway-modal.lp", nil, nil, headerAttr) ); ngx.print('\
- <div class="content">\
- <div class="light green"></div>\
- <p>'); ngx.print( T"Version: " ); ngx.print(' <strong>'); ngx.print( content.software_name .. " (" .. content.software_version .. ")" ); ngx.print('</strong></p>\
- <p class="subinfos">'); ngx.print( T"Firmware: " ); ngx.print(' '); ngx.print('<b>'); ngx.print( name ); ngx.print('</b>'); ngx.print('</p>\
- <p class="subinfos">'); ngx.print( T"Board: " ); ngx.print(' '); ngx.print('<b>'); ngx.print( board ); ngx.print('</b>'); ngx.print('</p>\
- <p class="subinfos">'); ngx.print( T"Uptime: " ); ngx.print(' <b>'); ngx.print( secondsToTime(content["uptime"]) ); ngx.print('</b></p>\
- <div data-toggle="modal" data-remote="modals/gateway-modal.lp" data-id="gateway-modal">\
- </div>\
- </div>\
- </div>\
- </div>\
- ');
- end
- ngx.print('\
- ');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement