diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-11-08 15:51:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-08 15:51:22 +0100 |
commit | 2ddfd5d395d5105f86a342d68b36ad42ba1ff5fe (patch) | |
tree | 40ee635f81c4a20898c6da42067844531b90a759 /applications | |
parent | ac7b37ef0133ab8349c8516d5a63a57a44dddafd (diff) | |
parent | 69eeebe23d60736c1d4436162444f7b9c53de3ed (diff) |
Merge pull request #6679 from danielvijge/luci-app-dawn-error-message-when-dawn-service-not-running
luci-app-dawn: error message when service not running
Diffstat (limited to 'applications')
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')) ]); |