diff --git a/bwmon/www/bwmon.js b/bwmon/www/bwmon.js index 8e92bd1..d3d8789 100644 --- a/bwmon/www/bwmon.js +++ b/bwmon/www/bwmon.js @@ -377,20 +377,49 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location', } function oldService() { - $http.get($scope.nonServiceDnsLeases, config).then(function(responseLeases) { + $scope.macNames = {}; + let dnsmasqLeasesData = ''; + let dnsmasqConfData = ''; + + function fetchDNSLeases() { + let dnsmasqLeasesFetched = false; + let dnsmasqConfFetched = false; + + $http.get($scope.nonServiceDnsLeases, config).then(function(responseLeases) { + dnsmasqLeasesData = responseLeases.data; + dnsmasqLeasesFetched = true; + notifyFetchCompleted() + }, function(error) { + dnsmasqLeasesFetched = true; + notifyFetchCompleted() + }); + $http.get($scope.nonServiceDnsConf, config).then(function(responseConf) { - $scope.macNames = {}; + dnsmasqConfData = responseConf.data; + dnsmasqConfFetched = true; + notifyFetchCompleted(); + }, function(error) { + dnsmasqConfFetched = true; + notifyFetchCompleted(); + }); - let dnsmasqLeasesData = responseLeases.data; - let dnsmasqConfData = responseConf.data; + function notifyFetchCompleted() { + if (dnsmasqLeasesFetched && dnsmasqConfFetched) { + macNameUpdate(dnsmasqLeasesData, dnsmasqConfData); + } + } + } + fetchDNSLeases(); + + function macNameUpdate(dnsmasqLeasesData, dnsmasqConfData) { + $scope.updateDnsLeases(dnsmasqLeasesData); + $scope.updateDnsConf(dnsmasqConfData); + + $scope.updateMissingEntries($scope.macNames); + $scope.macNamesOverride(); + $scope.updateDisplayUsage(); + } - $scope.updateDnsLeases(dnsmasqLeasesData); - $scope.updateDnsConf(dnsmasqConfData); - $scope.updateMissingEntries($scope.macNames); - $scope.macNamesOverride(); - $scope.updateDisplayUsage(); - }); - }); $http.get('usage_stats.js', config).then(function(response) { $scope.usageData = {}; $scope.updateUsageData(response.data);