if you get to speedtest page and a test is running you will now see it
authorReidar Cederqvist <reidar.cederqvist@gmail.com>
Mon, 31 Oct 2016 15:09:22 +0000 (16:09 +0100)
committerReidar Cederqvist <reidar.cederqvist@gmail.com>
Mon, 31 Oct 2016 15:09:22 +0000 (16:09 +0100)
plugins/juci-diagnostics/access.json
plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.js
plugins/juci-diagnostics/ubus/juci.speedtest

index ea73645..3cc3edb 100644 (file)
@@ -5,7 +5,8 @@
                        "ubus": {
                                "juci.speedtest": [
                                        "run",
-                                       "get_packet_size"
+                                       "get_packet_size",
+                                       "is_running"
                                ],
                                "juci.diagnostics": [
                                        "ping",
index a1ee019..028afe1 100644 (file)
@@ -16,7 +16,14 @@ JUCI.app
                state: "",
                auto: true
        }; 
-       
+
+       $rpc.$call("juci.speedtest", "is_running").done(function(res){
+               if(res.running){
+                       $scope.data.state = "running";
+                       $scope.$apply();
+               }
+       });
+
        function getDefaultPacketSize(){
                $rpc.$call("juci.speedtest", "get_packet_size").done(function(data){
                        $scope.data.downsize = parseInt(data.packetsize_down);
@@ -25,7 +32,7 @@ JUCI.app
                }).fail(function(e){ console.log(e); });
        }
        getDefaultPacketSize();
-       
+
        $scope.$watch('data.auto', function(new_value){
                if(new_value === false){ getDefaultPacketSize(); }
        }, false);
@@ -97,7 +104,7 @@ JUCI.app
                        }
                }, 15000);
        };
-       
+
        $scope.onRemoveAddress = function(){
                var server = $scope.testServers.find(function(x){
                        return $scope.data.server == x.server.value
index dcf392e..0d1fcd3 100755 (executable)
@@ -62,7 +62,7 @@ get_iface () {
 
 case "$1" in
        list)
-               echo '{ "run" : {"testmode":"str","packetsize_up":32,"packetsize_down":32,"address":"str","port":32}, "get_packet_size" : {} }'
+               echo '{ "run" : {"testmode":"str","packetsize_up":32,"packetsize_down":32,"address":"str","port":32}, "get_packet_size" : {}, "is_running": {} }'
        ;;
        call)
                case "$2" in
@@ -81,6 +81,17 @@ case "$1" in
                                        json_dump
                                fi
                        ;;
+                       is_running)
+                               json_init
+                               if pidof tptest-run >/dev/null; then
+                                       json_add_string "message" "running"
+                                       json_add_boolean "running" 1
+                               else
+                                       json_add_string "message" "not running"
+                                       json_add_boolean "running" 0
+                               fi
+                               json_dump
+                       ;;
                        get_packet_size)
                                get_iface