callDawnGetNetwork = rpc.declare({
object: 'dawn',
method: 'get_network',
- expect: { }
+ expect: { }
});
callDawnGetHearingMap = rpc.declare({
object: 'dawn',
method: 'get_hearing_map',
- expect: { }
+ expect: { }
});
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') );
}
}
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
});
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()
]);
},
});
}
+ if (!dawnHearingMapData || !dawnNetworkData) {
+ return dawn.getDawnServiceNotRunningErrorMessage();
+ }
+
const body = E([
E('h2', _('Hearing Map'))
]);
load: function() {
return Promise.all([
- dawn.callDawnGetNetwork(),
+ dawn.isDawnRPCAvailable().then(function(isAvailable) {
+ return ( isAvailable ? dawn.callDawnGetNetwork() : null );
+ }),
dawn.callHostHints()
]);
},
const dawnNetworkData = data[0];
const hostHintsData = data[1];
+ if (!dawnNetworkData) {
+ return dawn.getDawnServiceNotRunningErrorMessage();
+ }
+
const body = E([
E('h2', _('Network Overview'))
]);