Ticket refs #15090: JUCI: SpeedTest add/delete servers
authorFeten Besbes <feten.besbes@pivasoftware.com>
Thu, 7 Jun 2018 10:58:26 +0000 (11:58 +0100)
committerReidar Cederqvist <reidar.cederqvist@gmail.com>
Thu, 7 Jun 2018 12:03:55 +0000 (14:03 +0200)
plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.js

index 76ccc9d..0b9cf83 100644 (file)
@@ -35,6 +35,18 @@ JUCI.app
                return def.promise();
        }
 
+       function getServers(){
+               $scope.allTestServers = $scope.testServers.map(function(x){
+                       return {
+                               label: x.server.value + ":" + x.port.value,
+                               value: x.server.value
+                       }
+               });
+               if($scope.allTestServers.length)
+                       $scope.data.server = $scope.allTestServers[0].value;
+               else
+                       $scope.data.server = null;
+       }
 
        JUCI.interval.repeat("diagnostics-tptest-running", 10000, function(next){
                refresh().done(function(){
@@ -65,14 +77,7 @@ JUCI.app
 
        $uci.$sync("speedtest").done(function(){
                $scope.testServers = $uci.speedtest["@testserver"];
-               $scope.allTestServers = $scope.testServers.map(function(x){
-                       return {
-                               label: x.server.value + ":" + x.port.value,
-                               value: x.server.value
-                       }
-               });
-               if($scope.allTestServers.length)
-                       $scope.data.server = $scope.allTestServers[0].value;
+               getServers();
                $scope.$apply();
        });