0fcf76f767f15188a2c7e5626603f59a8edc69a0
[project/luci.git] / themes / luci-theme-material / luasrc / view / themes / material / header.htm
1 <%#
2         luci-theme-material is based on MUI and luci-theme-bootstrap.
3
4         luci-theme-bootstrap:
5                 Copyright 2008 Steven Barth <steven@midlink.org>
6                 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
7                 Copyright 2012 David Menting <david@nut-bolt.nl>
8
9         MUI:
10                 https://github.com/muicss/mui
11
12         luci-theme-material
13                 Copyright 2015 Lutty Yang <lutty@wcan.in>
14
15         Licensed to the public under the Apache License 2.0
16 -%>
17
18 <%
19         local sys  = require "luci.sys"
20         local util = require "luci.util"
21         local http = require "luci.http"
22         local disp = require "luci.dispatcher"
23
24         local boardinfo = util.ubus("system", "board")
25
26         local request  = disp.context.path
27         local request2 = disp.context.request
28
29         local category = request[1]
30         local cattree  = category and disp.node(category)
31
32         local leaf = request2[#request2]
33
34         local tree = disp.node()
35         local node = disp.context.dispatched
36
37         local categories = disp.node_childs(tree)
38
39         local c = tree
40         local i, r
41
42         -- tag all nodes leading to this page
43         for i, r in ipairs(request) do
44                 if c.nodes and c.nodes[r] then
45                         c = c.nodes[r]
46                         c._menu_selected = true
47                 end
48         end
49     
50     -- send as HTML5
51         http.prepare_content("text/html")
52
53         local function nodeurl(prefix, name, query)
54                 local url = controller .. prefix .. name .. "/"
55                 if query then
56                         url = url .. http.build_querystring(query)
57                 end
58                 return pcdata(url)
59         end
60
61         local function subtree(prefix, node, level)
62                 if not level then
63                         level = 1
64                 end
65
66                 local childs = disp.node_childs(node)
67                 if #childs > 0 then
68         
69             if level > 2 then
70 %>
71         <ul class="tabs">
72                 <%  
73             end
74
75                         local selected_node
76                         local selected_name
77                         local i, v
78
79                         for i, v in ipairs(childs) do
80                                 local nnode = node.nodes[v]
81                                 if nnode._menu_selected then
82                                         selected_node = nnode
83                                         selected_name = v
84                                 end
85                 if level > 2 then
86                 %>
87                         <li class="tabmenu-item-<%=v%><%- if nnode._menu_selected or (node.leaf and v == leaf) then %> active<% end %>">
88                             <a href="<%=nodeurl(prefix, v, nnode.query)%>"><%=striptags(translate(nnode.title))%></a>
89                         </li>
90                 <%      end
91                         end
92             
93             if level > 2 then
94                 %>
95         </ul>
96 <%          end
97
98                         if selected_node then
99                                 subtree(prefix .. selected_name .. "/", selected_node, level + 1)
100                         end
101                 end
102         end
103 -%>
104 <!DOCTYPE html>
105 <html lang="<%=luci.i18n.context.lang%>">
106 <head>
107     <meta charset="utf-8">
108     <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
109     <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
110     <meta name="format-detection" content="telephone=no, email=no"/>
111     <meta name="apple-mobile-web-app-capable" content="yes">
112     <meta name="mobile-web-app-capable" content="yes">
113     <meta name="x5-fullscreen" content="true">
114     <meta name="full-screen" content="yes">
115     <meta name="x5-page-mode" content="app">
116     <meta name="browsermode" content="application">
117     <meta name="theme-color" content="#0099CC">
118     <meta name="msapplication-tap-highlight" content="no">
119     <meta name="msapplication-TileColor" content="#0099CC">
120     <meta name="msapplication-TileImage" content="<%=media%>/logo.png"/>
121     <link rel="stylesheet" href="<%=media%>/css/style.css">
122     <link rel="shortcut icon" href="<%=media%>/favicon.ico">
123     <% if node and node.css then %>
124         <link rel="stylesheet" href="<%=resource%>/<%=node.css%>">
125     <% end -%>
126     <% if css then %>
127         <style title="text/css">
128             <%-= css %>
129         </style>
130     <% end -%>
131     <script src="<%=resource%>/xhr.js"></script>
132 </head>
133
134 <body class="lang_<%=luci.i18n.context.lang%> <%- if node then %><%= striptags( node.title ) %><%- end %>">
135
136 <header>
137         <div class="container">
138                 <span class="showSide"></span>
139                 <a class="brand" href="#"><%=boardinfo.hostname or "?"%></a>
140                 <div class="pull-right">
141                 <%
142                 -- calculate the number of unsaved changes
143                 if tree.nodes[category] and tree.nodes[category].ucidata then
144                         local ucichanges = 0
145                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
146                                 for k, l in pairs(j) do
147                                         for m, n in pairs(l) do
148                                                 ucichanges = ucichanges + 1;
149                                         end
150                                 end
151                         end
152                         %>
153                         <% if ucichanges > 0 then %>
154                         <a class="label notice" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucichanges%></a>
155                         <% end %>
156                         <span id="xhr_poll_status" style="display:none" onclick="XHR.running() ? XHR.halt() : XHR.run()">
157                                 <span class="label success" id="xhr_poll_status_on"><%:Auto Refresh%> <%:on%></span>
158                                 <span class="label" id="xhr_poll_status_off" style="display:none"><%:Auto Refresh%> <%:off%></span>
159                         </span>
160                 <% end %>
161                 </div>
162         </div>
163 </header>
164
165  <div class="main">
166          <div class="main-left">
167                  <ul class="nav">
168                          <%-
169                          local function submenu(prefix, node)
170                          local childs = disp.node_childs(node)
171                          if #childs > 0 then
172                          %>
173                          <ul class="slide-menu">
174                                  <%-
175                                  for i, r in ipairs(childs) do
176                                  local nnode = node.nodes[r]
177                                  local href  = controller .. prefix .. r ..
178                                  (nnode.query and http.build_querystring(nnode.query) or "")
179                                  %>
180                                  <li><a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></li>
181                                  <%-
182                                  end
183                                  %>
184                          </ul>
185                          <%-
186                          end
187                          end
188
189                          childs = disp.node_childs(cattree)
190
191                          if #childs > 0 then
192                          for i, r in ipairs(childs) do
193                          local nnode = cattree.nodes[r]
194                          local href  = controller .. "/" .. category .. "/" .. r ..
195                          (nnode.query and http.build_querystring(k.query) or "")
196                          local grandchildren = disp.node_childs(nnode)
197
198                          if #grandchildren > 0 then
199                          %>
200                          <li class="slide">
201                                  <a class="menu" data-title="<%=pcdata(striptags(nnode.title))%>" href="#"><%=pcdata(striptags(translate(nnode.title)))%></a>
202                                  <%- submenu("/" .. category .. "/" .. r .. "/", nnode) %>
203                          </li>
204                          <%          else %>
205                          <li>
206                                  <a data-title="<%=pcdata(striptags(nnode.title))%>" href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a>
207                          </li>
208                          <%
209                          end
210                          end
211                          end
212                          %>
213                  </ul>
214          </div>
215          <div class="main-right">
216                  <div class="darkMask"></div>
217                  <div id="maincontent">
218                          <div class="container">
219                                  <%- if luci.sys.process.info("uid") == 0 and luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
220                                          <div class="alert-message warning">
221                                                  <h4><%:No password set!%></h4>
222                                                  <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%><br>
223                                                  <a href="<%=pcdata(luci.dispatcher.build_url("admin/system/admin"))%>"><%:Go to password configuration...%></a>
224                                          </div>
225                                  <%- end -%>
226                                  <% if category then subtree("/" .. category .. "/", cattree) end %>
227