+
+
+ Map
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/admin/index.js b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/admin/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..43579fc3f89759c0389c4b435245fd0741c90404
--- /dev/null
+++ b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/admin/index.js
@@ -0,0 +1,49 @@
+'use strict';
+'require uci';
+'require view';
+
+return view.extend({
+ handleReset: null,
+ handleSave: null,
+ handleSaveApply: null,
+ load: () => {
+ return Promise.all([
+ uci.load('freifunk'),
+ uci.load('system')
+ ])
+ },
+ render: () => {
+ let nickname = uci.get('freifunk', 'contact', 'nickname');
+ let name = uci.get('freifunk', 'contact', 'name');
+ let mail = uci.get('freifunk', 'contact', 'mail');
+ let contacturl = L.url('admin/freifunk/contact');
+ let hostname = uci.get_first('system', 'system', 'hostname');
+ let latitude = uci.get_first('system', 'system', 'latitude');
+ let longitude = uci.get_first('system', 'system', 'longitude');
+ let location = uci.get_first('system', 'system', 'location');
+ let basicsurl = L.url('admin/freifunk/basics');
+ let basicSettingsWarning = (hostname == null || latitude == null || longitude == null)? E('div', {'class': 'label warning'}, [
+ _('Basic settings are incomplete. Please go to'),
+ ' ',
+ E('a', {'href': basicsurl}, _('Basic settings')),
+ ' ',
+ _('and fill out all required fields.'),
+ E('p')
+ ]): E([]);
+ let contactWarning = (nickname == null && name == null && email == null)? E('div', {'class': 'label warning'}, [
+ _('Contact information is incomplete. Please go to'),
+ ' ',
+ E('a', {'href': contacturl}, _('Contact')),
+ ' ',
+ _('and fill out all required fields.'),
+ E('p')
+ ]): E([]);
+ return E([], {}, [
+ E('h2', {}, _('Freifunk Overview')),
+ _('These pages will assist you in setting up your router for Freifunk or similar wireless community networks.'),
+ E('p'),
+ basicSettingsWarning,
+
+ ]);
+ }
+})
diff --git a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/contact.js b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/contact.js
index fefd99c1e2032df9bba1d59bdc2551d71a23a7c2..8023c87b3a05f87e5a1992753b4f00245b55ffe2 100644
--- a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/contact.js
+++ b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/contact.js
@@ -28,7 +28,7 @@ return view.extend({
let lat = uci.get_first("system", "system", "latitude");
let latlon = E([], {}, [
lat + ' ' + lon + ' (',
- E('a', {'href': L.url('freifunk/map')}, _('Show on map')),
+ E('a', {'href': L.url('freifunk/map/map')}, _('Show on map')),
')']);
let location = uci.get_first("system", "system", "location")
if (location == null) {
diff --git a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/index.js b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/index.js
index ef7639d06821961649005b08a12f73d465cf80d1..879ce6019e4ca6cf24d555ca58c655fb512dfe7a 100644
--- a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/index.js
+++ b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/index.js
@@ -1,22 +1,33 @@
'use strict';
'require fs';
+'require rpc';
'require uci';
'require view';
+var getSystemBoard = rpc.declare({
+ object: 'system',
+ method: 'board',
+ expect: {}
+});
+
return view.extend({
handleReset: null,
handleSave: null,
handleSaveApply: null,
- load: () => {
+ load: () => {
return Promise.all([
uci.load('freifunk').then(() => {
- fs.read
+ let community = uci.get('freifunk', 'community', 'name');
+ uci.load('profile_' + community);
+ }).then(() => {
+ return fs.read('/www/luci-static/index_user.html');
+ }).catch((error) => {
+ console.log(_('Error while reading file: ') + error);
}),
- fs.read('/www/luci-static/index_user.html')
+ getSystemBoard()
])
},
render: (data) => {
- console.log(data);
let redirectPage = uci.get('freifunk', 'luci', 'redirect_landingpage');
if (redirectPage != null) {
window.location.replace(L.url(redirectPage));
@@ -26,11 +37,49 @@ return view.extend({
if (redirectUrl != null) {
window.location.replace(redirectUrl);
return;
-
+
}
let defaultText = uci.get('freifunk', 'community', 'DefaultText');
let nickName = uci.get('freifunk', 'contact', 'nickname');
let community = uci.get('freifunk', 'community', 'name')
- return E('h2', 'yes');
+ community = (community === undefined) ? 'Freifunk' : community;
+ let url = uci.get_first('profile_' + community, 'community', 'homepage');
+ url = (url === undefined) ? 'https://freifunk.net' : url;
+ const hostname = data[1].hostname;
+ const userText = data[0];
+ let defaultContent;
+ if (defaultText != 'disabled' || !defaultText) {
+ defaultContent = E([], {}, [
+ E('h2', {}, _('Hello and welcome in the network of') + ' ' + community),
+ E('p', {}, [
+ _('We are an initiative to establish a free, independent and open wireless mesh network.'),
+ E('br', {}, []),
+ _('This is the access point') + ' ',
+ hostname + '.',
+ _('It is operated by') + ' ',
+ E('a', { 'href': L.url('freifunk/contact') }, (nickName === undefined) ? _('Please set your contact information') : nickName)
+ ]),
+ E('p', {}, [
+ _('You can find further information about the global Freifunk initiative at') + ' ',
+ E('a', { 'href': 'https://freifunk.net' }, 'Freifunk.net'),
+ '.',
+ E('br'),
+ _('If you are interested in our project then contact the local community') + ' ',
+ E('a', { 'href': url }, community),
+ '.'
+ ]),
+ E('p', {}, [
+ E('strong', _('Notice')),
+ ': ',
+ _('Internet access depends on technical and organisational conditions and may or may not work for you.')
+ ])
+ ]);
+ } else {
+ defaultContent = '';
+ }
+ return E([], {}, [
+ defaultContent,
+ E(userText)
+ ]);
}
})
\ No newline at end of file
diff --git a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/map/frame.js b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/map/frame.js
new file mode 100644
index 0000000000000000000000000000000000000000..55f39cd85a700e34ff33496bc43df393e132b4ef
--- /dev/null
+++ b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/map/frame.js
@@ -0,0 +1,51 @@
+'use strict';
+'require uci';
+'require view';
+
+return view.extend({
+ handleSave: null,
+ handleReset: null,
+ handleSaveApply: null,
+ load: () => {
+ return Promise.all([
+ uci.load('olsrd').then(() => {
+ return uci.sections('olsrd', 'LoadPlugin');
+ })
+ ])
+ },
+ render: (data) => {
+ let hasLatLon = false;
+ data[0].forEach(section => {
+ if (section.library === 'olsrd_nameservice') {
+ let latlonFile = uci.get('olsrd', section['.name'], 'latlon_file');
+ if (latlonFile != null) hasLatLon = true;
+ }
+ });
+ if (hasLatLon) {
+ return E([], {}, [
+ E('script', {}, ['function ffmapinit() {console.log("ach")}']),
+ E('iframe', {'id': 'mapframe', 'style': 'width:100%; height:640px; border:none', 'src': L.resource('freifunk-map/map.htm')}),
+ E('h2', _('Legend')),
+ E('ul', {}, [
+ E('li', {}, [E('strong', {}, E('span', {'style': 'color:#00cc00'}, _('Green'))), ': ' + _('Very good (ETX < 2)')]),
+ E('li', {}, [E('strong', {}, E('span', {'style': 'color:#ffcb05'}, _('Yellow'))), ': ' + _('Good (2 < ETX < 4)')]),
+ E('li', {}, [E('strong', {}, E('span', {'style': 'color:#ff6600'}, _('Orange'))), ': ' + _('Still usable (4 < ETX < 10)')]),
+ E('li', {}, [E('strong', {}, E('span', {'style': 'color:#bb3333'}, _('Red'))), ': ' + _('Bad (ETX > 10)')]),
+ ])
+ ]);
+ } else {
+ return E([], {}, [
+ E('h2', _('Map Error')),
+ E('p', _('The OLSRd service is not configured to capture position data from the network. \
+ Please make sure that the nameservice plugin is properly configured and that the latlon_file option is enabled.'))
+ ])
+ };
+ }
+})
+
+/*
+
+<% if has_latlon then %>
+
+
+ */
diff --git a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/public_status.js b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/public_status.js
index 617cc9b04d86ca9de826b2891b8986c6a3e0ed09..f56d8612ada1c08a68238127cc521b297f0c2394 100644
--- a/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/public_status.js
+++ b/modules/luci-mod-freifunk/htdocs/luci-static/resources/view/freifunk/frontend/public_status.js
@@ -131,7 +131,7 @@ return view.extend({
E('div', { 'class': 'cbi-map' }, [
E('h2', {}, _('Wireless Overview')),
E('fieldset', {'class': 'cbi-section'}, [
- E('table', { 'id': 'wirelessTable' }, [
+ E('table', { 'id': 'wirelessTable', 'width': '100%' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('td', { 'class': 'th' }, _('Signal')),
E('td', { 'class': 'th' }, _('Bitrate')),
diff --git a/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
index 3cfbba984c3db1942b4f2b15463f908918d29f5b..8f498979767c85d205427f455d4d1caf114c003e 100644
--- a/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
+++ b/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
@@ -4,32 +4,8 @@
module("luci.controller.freifunk.freifunk", package.seeall)
function index()
- local uci = require "luci.model.uci".cursor()
local page
- -- Frontend
- page = node()
- page.lock = true
- page.target = alias("freifunk")
- page.subindex = true
- page.index = false
-
- page = node("freifunk")
- page.title = _("Freifunk")
- page.target = alias("freifunk", "index")
- page.order = 5
- page.setuser = "nobody"
- page.setgroup = "nogroup"
- page.i18n = "freifunk"
- page.index = true
-
- page = node("freifunk", "index")
- page.target = template("freifunk/index")
- page.title = _("Overview")
- page.order = 10
- page.indexignore = true
-
-
if nixio.fs.access("/usr/sbin/luci-splash") then
assign({"freifunk", "status", "splash"}, {"splash", "publicstatus"}, _("Splash"), 40)
end
@@ -44,11 +20,7 @@ function index()
end
-- backend
- -- assign({"mini", "freifunk"}, {"admin", "freifunk"}, _("Freifunk"), 5)
- -- entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), _("Freifunk"), 5)
-
- entry({"freifunk", "map"}, template("freifunk-map/frame"), _("Map"), 50)
- entry({"freifunk", "map", "content"}, template("freifunk-map/map"), nil, 51)
+ assign({"mini", "freifunk"}, {"admin", "freifunk"}, _("Freifunk"), 5)
end
function zeroes()
diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm
deleted file mode 100644
index bd936ac705ae69d6bb614877a9a17b98eb6c5e2d..0000000000000000000000000000000000000000
--- a/modules/luci-mod-freifunk/luasrc/view/freifunk-map/frame.htm
+++ /dev/null
@@ -1,29 +0,0 @@
-<%+header%>
-
-<%
- local has_latlon = false
- local uci = require "luci.model.uci".cursor()
- uci:foreach("olsrd", "LoadPlugin", function(s)
- if s.library == "olsrd_nameservice" and s.latlon_file then
- has_latlon = true
- end
- end)
-%>
-
-<% if has_latlon then %>
-
-
<%:Legend%>:
-
-
<%:Green%>:<%:Very good (ETX < 2)%>
-
<%:Yellow%>:<%:Good (2 < ETX < 4)%>
-
<%:Orange%>:<%:Still usable (4 < ETX < 10)%>
-
<%:Red%>:<%:Bad (ETX > 10)%>
-
-
-<% else %>
-
<%:Map Error%>
-
<%_The OLSRd service is not configured to capture position data from the network.
- Please make sure that the nameservice plugin is properly configured and that the latlon_file option is enabled.%>
-
-<%:These pages will assist you in setting up your router for Freifunk or similar wireless community networks.%>
-
-
-<% if not (hostname and latitude and longitude and location) then%>
-
- <%:Basic settings are incomplete. Please go to%> <%:Basic settings%> <%:and fill out all required fields.%>
-
-<%end%>
-
-
-<% if not (nickname and name and mail) then%>
-
- <%:Contact information is incomplete. Please go to%> <%:Contact%> <%:and fill out all required fields.%>
-
-
-<%end%>
-
-<% uci:foreach("wireless", "wifi-device", function(section)
- local device = section[".name"]
- local url = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "network", "wireless")
- if section.diversity ~= "0" and section.disabled ~= "1" and section.type ~= "mac80211" then
- print('
'..
- translate("We are an initiative to establish a free, independent and open wireless mesh network.")..
- ' '..
- translate("This is the access point")..
- ' '..
- luci.sys.hostname()..
- '. '..
- translate("It is operated by")..
- ' '..
- (nickname or translate("Please set your contact information"))..
- '.
'..
- translate("You can find further information about the global Freifunk initiative at")..
- ' Freifunk.net. '..
- translate("If you are interested in our project then contact the local community")..
- ' '..community..'.
'..
- translate("Notice")..
- ': '..
- translate("Internet access depends on technical and organisational conditions and may or may not work for you.")..
- '
'
-end
-%>
-
-<%=defaulttext%>
-<%=usertext%>
-
-<%
--- add custom widgets from view/freifunk/widgets
-local widgets = {}
-local dir = "/usr/lib/lua/luci/view/freifunk/widgets"
-
-uci:foreach("freifunk-widgets", "widget",
- function(s)
- if s.enabled == "1" then
- table.insert(widgets, s)
- end
- end)
-
-for k, v in ipairs(widgets) do
- if v['template'] and fs.access(dir .. "/" .. v['template'] .. "/main.htm") then
- tpl.render("freifunk/widgets/" .. v['template'] .. "/main", { data = v })
- end
-end
-
-%>
-<%+footer%>
diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm
deleted file mode 100644
index a7445ef6806dbf775bf62a851742ea52d553a18f..0000000000000000000000000000000000000000
--- a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm
+++ /dev/null
@@ -1,221 +0,0 @@
-<%
-local utl = require "luci.util"
-local sys = require "luci.sys"
-local twa = require "luci.tools.webadmin"
-local ip = require "luci.ip"
-
--- System
-
-local sysinfo = utl.ubus("system", "info") or { }
-local boardinfo = utl.ubus("system", "board") or { }
-
-local loads = sysinfo.load or { 0, 0, 0 }
-local meminfo = sysinfo.memory or {
- total = 0,
- free = 0,
- buffered = 0,
- shared = 0
-}
-
-local uptime = twa.date_format(sysinfo.uptime or 0)
-local time = os.date("%a, %d %b %Y, %H:%M:%S")
-local load = string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0)
-
-local mem = string.format(
- "%.2f MB (%.2f %s, %.2f %s, %.2f %s)",
- meminfo.total / 1024 / 1024,
- (meminfo.total - meminfo.free) / 1024 / 1024,
- tostring(i18n.translate("used")),
- meminfo.free / 1024 / 1024,
- tostring(i18n.translate("free")),
- meminfo.buffered / 1024 / 1024,
- tostring(i18n.translate("buffered"))
-)
-
-local interval = 5
-
--- wireless
-local ntm = require "luci.model.network".init()
-local devices = ntm:get_wifidevs()
-local netlist = { }
-local netdevs = { }
-local dev
-for _, dev in ipairs(devices) do
- local net
- for _, net in ipairs(dev:get_wifinets()) do
- netlist[#netlist+1] = net:ifname()
- netdevs[net:ifname()] = dev:name()
- end
-end
-local has_iwinfo = pcall(require, "iwinfo")
-
-
--- Find default routes
-
-local _, r, def4, def6
-
-for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do
- def4 = {
- gateway = r.gw:string(),
- dest = r.dest:string(),
- dev = r.dev,
- metr = r.metric or 0
- }
- break
-end
-
-for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do
- def6 = {
- gateway = r.gw:string(),
- dest = r.dest:string(),
- dev = r.dev,
- metr = r.metric or 0
- }
- break
-end
-
-
-if luci.http.formvalue("status") == "1" then
- local rv = { }
- for dev in pairs(netdevs) do
- local j = { id = dev }
- local iw = luci.sys.wifi.getiwinfo(dev)
- if iw then
- local f
- for _, f in ipairs({
- "channel", "txpower", "bitrate", "signal", "noise",
- "quality", "quality_max", "mode", "ssid", "bssid", "encryption", "ifname"
- }) do
- j[f] = iw[f]
- end
- end
- rv[#rv+1] = j
- end
-
-
- rv[#rv+1] = {
- time = time,
- uptime = uptime,
- load = load,
- mem = mem,
- defroutev4 = def4,
- defroutev6 = def6
- }
-
- luci.http.prepare_content("application/json")
- luci.http.write_json(rv)
- return
-end
--%>
-
-<%+header%>
-
-
-
-
-
-
<%:System%>
-
-
<%=boardinfo.system or "?"%>
-
<%=boardinfo.model or "?"%>
-
<%=load%>
-
<%=mem%>
-
<%=time%>
-
<%=uptime%>
-
-
-
-
-
<%:Default routes%>
-
-
-
-<% if not def4 and not def6 then %>
- <%:No default routes known.%>
-<%else%>
-