diff --git a/luci-app-airconnect/Makefile b/luci-app-airconnect/Makefile index 22da016af..b90dfbbf2 100644 --- a/luci-app-airconnect/Makefile +++ b/luci-app-airconnect/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-airconnect -PKG_VERSION:=1.0.0 +PKG_VERSION:=1.0.1 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for AirConnect diff --git a/luci-app-airconnect/htdocs/luci-static/resources/view/airconnect.js b/luci-app-airconnect/htdocs/luci-static/resources/view/airconnect.js new file mode 100644 index 000000000..9eedd963d --- /dev/null +++ b/luci-app-airconnect/htdocs/luci-static/resources/view/airconnect.js @@ -0,0 +1,80 @@ +'use strict'; +'require form'; +'require poll'; +'require rpc'; +'require uci'; +'require view'; +'require tools.widgets as widgets'; + +var callServiceList = rpc.declare({ + object: 'service', + method: 'list', + params: ['name'], + expect: { '': {} } +}); + +function getServiceStatus() { + return L.resolveDefault(callServiceList('airconnect'), {}).then(function (res) { + var isRunning = false; + try { + isRunning = res['airconnect']['instances']['airupnp']['running'] || res['airconnect']['instances']['aircast']['running']; + } catch (e) { } + return isRunning; + }); +} + +function renderStatus(isRunning) { + var spanTemp = '%s %s'; + var renderHTML; + if (isRunning) { + renderHTML = spanTemp.format('green', 'AirConnect', _('RUNNING')); + } else { + renderHTML = spanTemp.format('red', 'AirConnect', _('NOT RUNNING')); + } + + return renderHTML; +} + +return view.extend({ + render: function() { + var m, s, o; + + m = new form.Map('airconnect', _('AirConnect'), + _('Send audio to UPnP/Sonos/Chromecast players using AirPlay.')); + + s = m.section(form.TypedSection); + s.anonymous = true; + s.render = function () { + poll.add(function () { + return L.resolveDefault(getServiceStatus()).then(function (res) { + var view = document.getElementById('service_status'); + view.innerHTML = renderStatus(res); + }); + }); + + return E('div', { class: 'cbi-section', id: 'status_bar' }, [ + E('p', { id: 'service_status' }, _('Collecting data...')) + ]); + } + + s = m.section(form.NamedSection, 'config', 'airconnect'); + + o = s.option(form.Flag, 'enabled', _('Enabled')); + o.default = o.disabled; + o.rmempty = false; + + o = s.option(widgets.DeviceSelect, 'interface', + _('Bind interface')); + o.rmempty = false; + + o = s.option(form.Flag, 'airupnp', _('UPnP/Sonos'), _('Enable UPnP/Sonos Device Support')); + o.default = o.disabled; + o.rmempty = false; + + o = s.option(form.Flag, 'aircast', _('Chromecast'), _('Enable Chromecast Device Support')); + o.default = o.disabled; + o.rmempty = false; + + return m.render(); + } +}); diff --git a/luci-app-airconnect/luasrc/controller/airconnect.lua b/luci-app-airconnect/luasrc/controller/airconnect.lua deleted file mode 100644 index a9f3311bc..000000000 --- a/luci-app-airconnect/luasrc/controller/airconnect.lua +++ /dev/null @@ -1,20 +0,0 @@ -module("luci.controller.airconnect", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/airconnect") then - return - end - - local page = entry({"admin", "services", "airconnect"}, cbi("airconnect"), _("AirConnect")) - page.dependent = true - page.acl_depends = { "luci-app-airconnect" } - - entry({"admin", "services", "airconnect", "status"}, call("act_status")).leaf = true -end - -function act_status() - local e = {} - e.running = luci.sys.call("pgrep aircast >/dev/null") == 0 or luci.sys.call("pgrep airupnp >/dev/null") == 0 - luci.http.prepare_content("application/json") - luci.http.write_json(e) -end diff --git a/luci-app-airconnect/luasrc/model/cbi/airconnect.lua b/luci-app-airconnect/luasrc/model/cbi/airconnect.lua deleted file mode 100644 index cc0e0c2f3..000000000 --- a/luci-app-airconnect/luasrc/model/cbi/airconnect.lua +++ /dev/null @@ -1,30 +0,0 @@ -local i = require 'luci.sys' -local m, e - -m = Map('airconnect', translate('AirConnect')) -m.description = translate('Send audio to UPnP/Sonos/Chromecast players using AirPlay.') - -m:section(SimpleSection).template = 'airconnect/airconnect_status' - -e = m:section(TypedSection, 'airconnect') -e.addremove = false -e.anonymous = true - -o = e:option(Flag, 'enabled', translate('Enabled')) -o.rmempty = false - -o = e:option(Value, 'interface', translate('Bind interface')) -for t, e in ipairs(i.net.devices()) do - if e ~= 'lo' and not string.match(e, '^docker.*$') and not string.match(e, '^sit.*$') and not string.match(e, '^dummy.*$') and not string.match(e, '^teql.*$') and not string.match(e, '^veth.*$') and not string.match(e, '^ztly.*$') then - o:value(e) - end -end -o.rmempty = false - -o = e:option(Flag, 'airupnp', translate('UPnP/Sonos'), translate('Enable UPnP/Sonos Device Support')) -o.rmempty = false - -o = e:option(Flag, 'aircast', translate('Chromecast'), translate('Enable Chromecast Device Support')) -o.rmempty = false - -return m diff --git a/luci-app-airconnect/luasrc/view/airconnect/airconnect_status.htm b/luci-app-airconnect/luasrc/view/airconnect/airconnect_status.htm deleted file mode 100644 index bd8e34679..000000000 --- a/luci-app-airconnect/luasrc/view/airconnect/airconnect_status.htm +++ /dev/null @@ -1,23 +0,0 @@ - - -
-

- <%:Collecting data...%> -

-
diff --git a/luci-app-airconnect/po/zh_Hans/airconnect.po b/luci-app-airconnect/po/zh_Hans/airconnect.po index d71e297c4..025cffac8 100644 --- a/luci-app-airconnect/po/zh_Hans/airconnect.po +++ b/luci-app-airconnect/po/zh_Hans/airconnect.po @@ -1,3 +1,13 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: zh_Hans\n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" + msgid "AirConnect" msgstr "隔空播放" diff --git a/luci-app-airconnect/root/usr/share/luci/menu.d/luci-app-airconnect.json b/luci-app-airconnect/root/usr/share/luci/menu.d/luci-app-airconnect.json new file mode 100644 index 000000000..a387e749e --- /dev/null +++ b/luci-app-airconnect/root/usr/share/luci/menu.d/luci-app-airconnect.json @@ -0,0 +1,13 @@ +{ + "admin/services/airconnect": { + "title": "AirConnect", + "action": { + "type": "view", + "path": "airconnect" + }, + "depends": { + "acl": [ "luci-app-airconnect" ], + "uci": { "airconnect": true } + } + } +}