Changeset 6718

Show
Ignore:
Timestamp:
01/13/11 23:13:35 (2 years ago)
Author:
jow
Message:

modules/admin-full: merge Overview -> User Interface into System -> System page

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/modules/admin-full/luasrc/model/cbi/admin_system/system.lua

    r6702 r6718  
    33 
    44Copyright 2008 Steven Barth <steven@midlink.org> 
     5Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> 
    56 
    67Licensed under the Apache License, Version 2.0 (the "License"); 
     
    1718require("luci.tools.webadmin") 
    1819require("luci.fs") 
     20require("luci.config") 
    1921 
    2022m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone.")) 
     23m:chain("luci") 
    2124 
    2225local has_rdate = false 
     
    2932 
    3033 
    31 s = m:section(TypedSection, "system", "") 
     34s = m:section(TypedSection, "system", translate("System Properties")) 
    3235s.anonymous = true 
    3336s.addremove = false 
    3437 
     38s:tab("general",  translate("General Settings")) 
     39s:tab("logging",  translate("Logging")) 
     40s:tab("language", translate("Language and Style")) 
     41 
     42 
     43-- 
     44-- System Properties 
     45-- 
     46 
    3547local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo() 
    3648local uptime = luci.sys.uptime() 
    3749 
    38 s:option(DummyValue, "_system", translate("System")).value = system 
    39 s:option(DummyValue, "_cpu", translate("Processor")).value = model 
    40  
    41 s:option(DummyValue, "_kernel", translate("Kernel")).value = 
     50s:taboption("general", DummyValue, "_system", translate("System")).value = system 
     51s:taboption("general", DummyValue, "_cpu", translate("Processor")).value = model 
     52 
     53s:taboption("general", DummyValue, "_kernel", translate("Kernel")).value = 
    4254 luci.util.exec("uname -r") or "?" 
    4355 
    4456local load1, load5, load15 = luci.sys.loadavg() 
    45 s:option(DummyValue, "_la", translate("Load")).value = 
     57s:taboption("general", DummyValue, "_la", translate("Load")).value = 
    4658 string.format("%.2f, %.2f, %.2f", load1, load5, load15) 
    4759 
    48 s:option(DummyValue, "_memtotal", translate("Memory")).value = 
     60s:taboption("general", DummyValue, "_memtotal", translate("Memory")).value = 
    4961 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)", 
    5062  tonumber(memtotal) / 1024, 
     
    5769) 
    5870 
    59 s:option(DummyValue, "_systime", translate("Local Time")).value = 
     71s:taboption("general", DummyValue, "_systime", translate("Local Time")).value = 
    6072 os.date("%c") 
    6173 
    62 s:option(DummyValue, "_uptime", translate("Uptime")).value = 
     74s:taboption("general", DummyValue, "_uptime", translate("Uptime")).value = 
    6375 luci.tools.webadmin.date_format(tonumber(uptime)) 
    6476 
    65 hn = s:option(Value, "hostname", translate("Hostname")) 
     77hn = s:taboption("general", Value, "hostname", translate("Hostname")) 
    6678 
    6779function hn.write(self, section, value) 
     
    7183 
    7284 
    73 tz = s:option(ListValue, "zonename", translate("Timezone")) 
     85tz = s:taboption("general", ListValue, "zonename", translate("Timezone")) 
    7486tz:value("UTC") 
    7587 
     
    91103end 
    92104 
    93 s:option(Value, "log_size", translate("System log buffer size"), "kiB").optional = true 
    94 s:option(Value, "log_ip", translate("External system log server")).optional = true 
    95 s:option(Value, "log_port", translate("External system log server port")).optional = true 
    96 s:option(Value, "conloglevel", translate("Log output level")).optional = true 
    97 s:option(Value, "cronloglevel", translate("Cron Log Level")).optional = true 
     105 
     106-- 
     107-- Logging 
     108-- 
     109 
     110o = s:taboption("logging", Value, "log_size", translate("System log buffer size"), "kiB") 
     111o.optional    = true 
     112o.placeholder = 16 
     113o.datatype    = "uinteger" 
     114 
     115o = s:taboption("logging", Value, "log_ip", translate("External system log server")) 
     116o.optional    = true 
     117o.placeholder = "0.0.0.0" 
     118o.datatype    = "ip4addr" 
     119 
     120o = s:taboption("logging", Value, "log_port", translate("External system log server port")) 
     121o.optional    = true 
     122o.placeholder = 514 
     123o.datatype    = "port" 
     124 
     125o = s:taboption("logging", ListValue, "conloglevel", translate("Log output level")) 
     126o:value(7, translate("Debug")) 
     127o:value(6, translate("Info")) 
     128o:value(5, translate("Notice")) 
     129o:value(4, translate("Warning")) 
     130o:value(3, translate("Error")) 
     131o:value(2, translate("Critical")) 
     132o:value(1, translate("Alert")) 
     133o:value(0, translate("Emergency")) 
     134 
     135o = s:taboption("logging", ListValue, "cronloglevel", translate("Cron Log Level")) 
     136o.default = 8 
     137o:value(5, translate("Debug")) 
     138o:value(8, translate("Normal")) 
     139o:value(9, translate("Warning")) 
     140 
     141 
     142-- 
     143-- Langauge & Style 
     144-- 
     145 
     146o = s:taboption("language", ListValue, "_lang", translate("Language")) 
     147o:value("auto") 
     148 
     149local i18ndir = luci.i18n.i18ndir .. "base." 
     150for k, v in luci.util.kspairs(luci.config.languages) do 
     151    local file = i18ndir .. k:gsub("_", "-") 
     152    if k:sub(1, 1) ~= "." and luci.fs.access(file .. ".lmo") then 
     153        o:value(k, v) 
     154    end 
     155end 
     156 
     157function o.cfgvalue(...) 
     158    return m.uci:get("luci", "main", "lang") 
     159end 
     160 
     161function o.write(self, section, value) 
     162    m.uci:set("luci", "main", "lang", value) 
     163end 
     164 
     165 
     166o = s:taboption("language", ListValue, "_mediaurlbase", translate("Design")) 
     167for k, v in pairs(luci.config.themes) do 
     168    if k:sub(1, 1) ~= "." then 
     169        o:value(v, k) 
     170    end 
     171end 
     172 
     173function o.cfgvalue(...) 
     174    return m.uci:get("luci", "main", "mediaurlbase") 
     175end 
     176 
     177function o.write(self, section, value) 
     178    m.uci:set("luci", "main", "mediaurlbase", value) 
     179end 
     180 
     181 
     182-- 
     183-- Rdate 
     184-- 
    98185 
    99186if has_rdate then 
     
    105192end 
    106193 
    107 return m 
     194 
     195m2 = Map("luci") 
     196 
     197f = m2:section(NamedSection, "main", "core", translate("Files to be kept when flashing a new firmware")) 
     198 
     199f:tab("detected", translate("Detected Files"), 
     200    translate("The following files are detected by the system and will be kept automatically during sysupgrade")) 
     201 
     202f:tab("custom", translate("Custom Files"), 
     203    translate("This is a list of shell glob patterns for matching files and directories to include during sysupgrade")) 
     204 
     205d = f:taboption("detected", DummyValue, "_detected", translate("Detected files")) 
     206d.rawhtml = true 
     207d.cfgvalue = function(s) 
     208    local list = io.popen( 
     209        "( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' /etc/sysupgrade.conf " .. 
     210        "/lib/upgrade/keep.d/* 2>/dev/null) -type f 2>/dev/null; " .. 
     211        "opkg list-changed-conffiles ) | sort -u" 
     212    ) 
     213 
     214    if list then 
     215        local files = { "<ul>" } 
     216 
     217        while true do 
     218            local ln = list:read("*l") 
     219            if not ln then 
     220                break 
     221            else 
     222                files[#files+1] = "<li>" 
     223                files[#files+1] = luci.util.pcdata(ln) 
     224                files[#files+1] = "</li>" 
     225            end 
     226        end 
     227 
     228        list:close() 
     229        files[#files+1] = "</ul>" 
     230 
     231        return table.concat(files, "") 
     232    end 
     233 
     234    return "<em>" .. translate("No files found") .. "</em>" 
     235end 
     236 
     237c = f:taboption("custom", TextValue, "_custom", translate("Custom files")) 
     238c.rmempty = false 
     239c.cols = 70 
     240c.rows = 30 
     241 
     242c.cfgvalue = function(self, section) 
     243    return nixio.fs.readfile("/etc/sysupgrade.conf") 
     244end 
     245 
     246c.write = function(self, section, value) 
     247    value = value:gsub("\r\n?", "\n") 
     248    return nixio.fs.writefile("/etc/sysupgrade.conf", value) 
     249end 
     250 
     251 
     252return m, m2