diff options
3 files changed, 37 insertions, 7 deletions
diff --git a/applications/luci-app-dawn/htdocs/luci-static/resources/dawn/dawn-common.js b/applications/luci-app-dawn/htdocs/luci-static/resources/dawn/dawn-common.js index 79f37a7d63..9dec2c6ec1 100644 --- a/applications/luci-app-dawn/htdocs/luci-static/resources/dawn/dawn-common.js +++ b/applications/luci-app-dawn/htdocs/luci-static/resources/dawn/dawn-common.js @@ -7,13 +7,13 @@ let callDawnGetNetwork, callDawnGetHearingMap, callHostHints; callDawnGetNetwork = rpc.declare({ object: 'dawn', method: 'get_network', - expect: { } + expect: { } }); callDawnGetHearingMap = rpc.declare({ object: 'dawn', method: 'get_hearing_map', - expect: { } + expect: { } }); callHostHints = rpc.declare({ @@ -22,6 +22,12 @@ callHostHints = rpc.declare({ expect: { } }); +function isDawnRPCAvailable() { + return rpc.list("dawn").then(function(signatures) { + return 'dawn' in signatures && 'get_network' in signatures.dawn && 'get_hearing_map' in signatures.dawn; + }); +} + function getAvailableText(available) { return ( available ? _('Available') : _('Not available') ); } @@ -59,16 +65,26 @@ function getFormattedNumber(num, decimals, divider = 1) { } function getHostnameFromMAC(hosthints, mac) { - return ( hosthints[mac] && hosthints[mac].name ? hosthints[mac].name + ' (' + mac + ')' : mac); + return ( hosthints[mac] && hosthints[mac].name ? hosthints[mac].name + ' (' + mac + ')' : mac ); +} + +function getDawnServiceNotRunningErrorMessage() { + return E('div', { 'class': 'alert-message fade-in warning' }, [ + E('h4', _('DAWN service unavailable')), + E('p', _('Unable to query the DAWN service via ubus, the service appears to be stopped.')), + E('a', { 'href': L.url('admin/system/startup') }, _('Check Startup services')) + ]); } return L.Class.extend({ callDawnGetNetwork: callDawnGetNetwork, callDawnGetHearingMap: callDawnGetHearingMap, callHostHints: callHostHints, + isDawnRPCAvailable: isDawnRPCAvailable, getAvailableText: getAvailableText, getYesText: getYesText, getChannelFromFrequency: getChannelFromFrequency, getFormattedNumber: getFormattedNumber, - getHostnameFromMAC: getHostnameFromMAC + getHostnameFromMAC: getHostnameFromMAC, + getDawnServiceNotRunningErrorMessage: getDawnServiceNotRunningErrorMessage }); diff --git a/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/hearing_map.js b/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/hearing_map.js index a5b59519ce..8b93fbfd6d 100644 --- a/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/hearing_map.js +++ b/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/hearing_map.js @@ -10,8 +10,12 @@ return view.extend({ load: function() { return Promise.all([ - dawn.callDawnGetHearingMap(), - dawn.callDawnGetNetwork(), + dawn.isDawnRPCAvailable().then(function(isAvailable) { + return ( isAvailable ? dawn.callDawnGetHearingMap() : null ) + }), + dawn.isDawnRPCAvailable().then(function(isAvailable) { + return ( isAvailable ? dawn.callDawnGetNetwork() : null ) + }), dawn.callHostHints() ]); }, @@ -37,6 +41,10 @@ return view.extend({ }); } + if (!dawnHearingMapData || !dawnNetworkData) { + return dawn.getDawnServiceNotRunningErrorMessage(); + } + const body = E([ E('h2', _('Hearing Map')) ]); diff --git a/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/network_overview.js b/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/network_overview.js index 71133991ab..a605858eca 100644 --- a/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/network_overview.js +++ b/applications/luci-app-dawn/htdocs/luci-static/resources/view/dawn/network_overview.js @@ -10,7 +10,9 @@ return view.extend({ load: function() { return Promise.all([ - dawn.callDawnGetNetwork(), + dawn.isDawnRPCAvailable().then(function(isAvailable) { + return ( isAvailable ? dawn.callDawnGetNetwork() : null ); + }), dawn.callHostHints() ]); }, @@ -20,6 +22,10 @@ return view.extend({ const dawnNetworkData = data[0]; const hostHintsData = data[1]; + if (!dawnNetworkData) { + return dawn.getDawnServiceNotRunningErrorMessage(); + } + const body = E([ E('h2', _('Network Overview')) ]); |