moved juci-utils to juci-diagnostics plugin and fixed some missing translations
authorReidar Cederqvist <reidar.cederqvist@gmail.com>
Thu, 24 Mar 2016 12:19:40 +0000 (13:19 +0100)
committerReidar Cederqvist <reidar.cederqvist@gmail.com>
Thu, 24 Mar 2016 12:19:40 +0000 (13:19 +0100)
22 files changed:
plugins/juci-diagnostics/Makefile [new file with mode: 0644]
plugins/juci-diagnostics/access.json
plugins/juci-diagnostics/po/en.po
plugins/juci-diagnostics/po/fi.po
plugins/juci-diagnostics/scripts/tptest-run [new file with mode: 0755]
plugins/juci-diagnostics/src/diagnostics.js [new file with mode: 0644]
plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html [new file with mode: 0644]
plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.js [new file with mode: 0644]
plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html [new file with mode: 0644]
plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.js [new file with mode: 0644]
plugins/juci-diagnostics/ubus/speedtest [new file with mode: 0755]
plugins/juci-utils/Makefile [deleted file]
plugins/juci-utils/po/en.po [deleted file]
plugins/juci-utils/po/fi.po [deleted file]
plugins/juci-utils/po/sv.po [deleted file]
plugins/juci-utils/scripts/tptest-run [deleted file]
plugins/juci-utils/service/juci-utils-speedtest [deleted file]
plugins/juci-utils/src/main.js [deleted file]
plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.html [deleted file]
plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.js [deleted file]
plugins/juci-utils/src/widgets/utils-add-testserver-picker.html [deleted file]
plugins/juci-utils/src/widgets/utils-add-testserver-picker.js [deleted file]

diff --git a/plugins/juci-diagnostics/Makefile b/plugins/juci-diagnostics/Makefile
new file mode 100644 (file)
index 0000000..0cb9a0e
--- /dev/null
@@ -0,0 +1,6 @@
+define Plugin/juci-diagnostics/install 
+       @$(INSTALL_DIR) $(1)/usr/bin/
+       @chmod +x $(PLUGIN_DIR)/scripts/*
+       @$(CP) $(PLUGIN_DIR)/scripts/* $(1)/usr/bin/
+endef
+
index 439e06c..85a3925 100644 (file)
@@ -3,7 +3,7 @@
                "description": "JUCI Diagnostics module",
                "read": {
                        "ubus": {
-                               "juci.utils.speedtest": [
+                               "/juci/speedtest": [
                                        "run"
                                ],
                                "/juci/diagnostics": [
index ad94f15..7f3db6d 100644 (file)
@@ -11,6 +11,45 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Generator: Poedit 1.5.4\n"
 
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.js
+msgid "Address and port needed"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Direction"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Package Size"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Speedtest Server"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Run test"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Test results"
+msgstr ""
+
+msgid "Error"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Server"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Port"
+msgstr ""
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Add test server"
+msgstr ""
+
 msgid "Diagnostic Utility"
 msgstr ""
 
@@ -45,9 +84,6 @@ msgstr ""
 msgid "Ping results"
 msgstr ""
 
-msgid "Error"
-msgstr ""
-
 msgid "Tracing Tool"
 msgstr ""
 
index b73959a..fc16e42 100644 (file)
@@ -11,6 +11,44 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Generator: Poedit 1.5.4\n"
 
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.js
+msgid "Address and port needed"
+msgstr "Osoite ja portti tarvitaan"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Direction"
+msgstr "Suunta"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Package Size"
+msgstr "Pakettikoko"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Speedtest Server"
+msgstr "Speedtest Server"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
+msgid "Run test"
+msgstr "Suorita testi..."
+
+msgid "Test results"
+msgstr "Jäljityksen tulokset"
+
+msgid "Error"
+msgstr "Virhe"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Server"
+msgstr "Palvelin"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Port"
+msgstr "Palvelin"
+
+# /home/reidar/juci/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
+msgid "Add test server"
+msgstr "Lisää Testipalvelin"
+
 msgid "Diagnostic Utility"
 msgstr "Diagnostiikkatyökalu"
 
@@ -42,9 +80,6 @@ msgstr "Ping"
 msgid "Ping results"
 msgstr "Ping-tulokset"
 
-msgid "Error"
-msgstr "Virhe"
-
 msgid "Tracing Tool"
 msgstr "Jäljitystyökalu"
 
diff --git a/plugins/juci-diagnostics/scripts/tptest-run b/plugins/juci-diagnostics/scripts/tptest-run
new file mode 100755 (executable)
index 0000000..143bd33
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+local SUCCESS=0
+
+local send=$1
+local receive=$2
+local sent="none"
+local received="none"
+local lable="success"
+
+if [ "$send" != "done" ]; then
+       sent=$(tptest $send | awk '/Throughput/{print($2)}')
+fi
+if [ "$receive" != "done" ]; then
+       received=$(tptest $receive | awk '/Throughput/{print($2)}')
+fi
+if [ "$receive" == "" || "$sent" == "" ]; then
+       SUCCESS=-1;
+       lable="wrong address";
+elif [ "$receive" == "0" || "$sent" == "0" ]; then
+       SUCCESS=-2;
+       lable="wrong port";
+fi
+ubus send juci.utils.speedtest "{\"status\":$SUCCESS, \"upstream\":\"$sent\",\"downstream\":\"$received\",\"lable\":\"$lable\"}"
+
+
diff --git a/plugins/juci-diagnostics/src/diagnostics.js b/plugins/juci-diagnostics/src/diagnostics.js
new file mode 100644 (file)
index 0000000..00086c7
--- /dev/null
@@ -0,0 +1,8 @@
+//! Author: Reidar Cederqvst <reidar.cederqvist@gmail.com>
+
+UCI.$registerConfig("speedtest"); 
+UCI.speedtest.$registerSectionType("testserver", {
+       "server":               { dvalue: "", type: String }, 
+       "port":                 { dvalue: "", type: String }
+});
+
diff --git a/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html b/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.html
new file mode 100644 (file)
index 0000000..256b943
--- /dev/null
@@ -0,0 +1,45 @@
+<div>
+       <juci-expandable title="TP test">
+               <juci-config-lines>
+                       <juci-config-line title="{{'Direction'|translate}}">
+                               <juci-select ng-model="data.test_type" ng-items="testType"/>
+                       </juci-config-line>
+                       <juci-config-line title="{{'Package Size'|translate}}">
+                               <div class="input-group">
+                                       <input type="number" step="5" class="form-control" ng-model="data.packagesize" />
+                                       <span class="input-group-addon">Mb</span>
+                               </div>
+                       </juci-config-line>
+                       <juci-config-line title="{{'Speedtest Server' | translate}}">
+                               <juci-select ng-model="data.server" ng-items="allTestServers"/>
+                       </juci-config-line>
+                       <juci-config-line>
+                               <button class="btn btn-default" ng-click="onRemoveAddress()">
+                                       <i class="fa fa-minus"></i>
+                               </button>
+                               <button class="btn btn-default" ng-click="onAddAddress()">
+                                       <i class="fa fa-plus"></i>
+                               </button>
+                       </juci-config-line>
+                       <juci-config-line>
+                               <button class="btn btn-default" ng-click="runTest()">
+                               {{'Run test' | translate}}</button>
+                       </juci-config-line>
+               </juci-config-lines>
+               <div class="alert alert-success" ng-show="data.state == 'result'">
+                       {{'Test results'|translate}}: <br/>
+                       <pre>{{data.result}}</pre>
+               </div>
+               <div class="alert alert-success" ng-show="data.state == 'running'">
+                       <h4>
+                               {{"Running test"|translate}}
+                               <i class="fa fa-spinner fa-pulse fa-2x"></i>
+                       </h4>
+               </div>
+           <div class="alert alert-danger" ng-show="data.state == 'error'">
+                       {{'Error'|translate}}: <br/>
+                       <pre>{{data.result|translate}}</pre>
+               </div>
+       </juci-expandable>
+</div>
+
diff --git a/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.js b/plugins/juci-diagnostics/src/widgets/diagnostics-widget-speedtest.js
new file mode 100644 (file)
index 0000000..18d27bf
--- /dev/null
@@ -0,0 +1,149 @@
+//! Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
+
+JUCI.app
+.directive("diagnosticsWidget90Speedtest", function(){
+       return {
+               scope: true,
+               replace: true,
+               templateUrl: "/widgets/diagnostics-widget-speedtest.html",
+               controller: "diagnosticsWidget90Speedtest"
+       };
+})
+.controller("diagnosticsWidget90Speedtest", function($scope, $rpc, $events, $uci, utilsAddTestserverPicker, $tr, gettext){
+       $scope.data = {
+               packagesize: 50,
+               test_type: "up_down",
+               result: "",
+               state: ""
+       }; 
+       var min = 1; 
+       var max = 100; 
+       $scope.$watch('data.packagesize', function(new_value){
+               if(new_value < min)$scope.data.packagesize = min;
+               if(new_value > max)$scope.data.packagesize = max;
+       }, false);
+
+       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; 
+       }
+
+       $scope.testType = [
+               {value:"up_down", label: $tr(gettext("Up and Down")) }, 
+               {value:"up", label: $tr(gettext("Up")) }, 
+               {value:"down", label: $tr(gettext("Down")) } 
+       ];
+
+       $uci.$sync("speedtest").done(function(){
+               $scope.testServers = $uci.speedtest["@testserver"];
+               getServers();
+               $scope.$apply();
+       });
+
+       $scope.runTest = function(){
+               if(!$scope.testServers.length){
+                       window.alert($tr(gettext("Server and port is mandatory")));
+                       return;
+               }
+               if($scope.data.state == "running"){
+                       window.alert($tr(gettext("Only one test can be run at a time")));
+                       return;
+               }
+               var server = $scope.testServers.find(function(x){ return $scope.data.server == x.server.value;});
+               var port = server.port.value;
+               var address = server.server.value;
+               $scope.data.state="running";
+               $rpc.juci.speedtest.run({
+                       "testmode": $scope.data.test_type,
+                       "port": port,
+                       "packagesize": $scope.data.packagesize * 1000,
+                       "address": address
+               }).done(function(response){
+                       if(response && response.message=="success"){
+                               $scope.data.state="running";
+                       }else{
+                               $scope.data.state="";
+                       }
+                       $scope.$apply();
+               });
+               setTimeout(function(){
+                       if($scope.data.state === "running"){
+                               $scope.data.state = "error";
+                               $scope.data.result = $tr(gettext("Unknown error"));
+                       }
+               }, 15000);
+       };
+       
+       $scope.onRemoveAddress = function(){
+               var server = $scope.testServers.find(function(x){
+                       return $scope.data.server == x.server.value
+               });
+               if(!server){
+                       alert($tr(gettext("error deleting server")));
+                       return;
+               }
+               server.$delete().done(function(){
+                       getServers();
+                       $scope.$apply();
+               });
+       };
+
+       $scope.onAddAddress = function(){
+               utilsAddTestserverPicker.show().done(function(data){
+                       if(!data)return;
+                       $uci.speedtest.$create({
+                               ".type": "testserver",
+                               "server": data.address,
+                               "port": data.port
+                       }).done(function(){
+                               getServers();
+                               $scope.$apply();
+                       });
+               });
+       }
+       $events.subscribe("juci.utils.speedtest", function(res){
+               if(res.data && res.data.status != undefined){
+                       switch(res.data.status) {
+                       case 0:
+                               var upstream = parseInt(res.data.upstream);
+                               if(upstream == "NaN") {
+                                       upstream = "none"
+                               }else{
+                                       upstream = upstream / 1000 / 1000;
+                               }
+                               var downstream = parseInt(res.data.downstream);
+                               if(downstream == "NAN"){
+                                       downstream = "none"
+                               }else{
+                                       downstream = downstream / 1000 / 1000;
+                               }
+                               if(res.data.upstream != "none" && res.data.downstream != "none"){
+                                       $scope.data.result=$tr(gettext("Upstream:"))+" " + upstream.toFixed(2) +" "+$tr(gettext("Mbit/s\nDownstream:"))+" " + downstream.toFixed(2) +" "+$tr(gettext("Mbit/s"));
+                               }else if(res.data.upstream != "none"){
+                                       $scope.data.result=$tr(gettext("Upstream:"))+" " + upstream.toFixed(2) + " "+$tr(gettext("Mbit/s"));
+                               }else if(res.data.downstream != "none"){
+                                       $scope.data.result=$tr(gettext("Downstream:"))+" " + downstream.toFixed(2) + " "+$tr(gettext("Mbit/s"));
+                               }else {
+                                       $scope.data.result="No speeds found";
+                               }
+                               $scope.data.state="result";
+                               break;
+                       case -1:
+                               $scope.data.result=$tr(gettext("Wrong TP-test address and/or port"));
+                               $scope.data.state="error";
+                               break;
+                       case -2:
+                               $scope.data.result=$tr(gettext("Wrong TP-test port but correct address"));
+                               $scope.data.state="error";
+                               break;
+                       }
+                       $scope.$apply();
+               }
+       });
+}); 
diff --git a/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html b/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.html
new file mode 100644 (file)
index 0000000..e75bfb5
--- /dev/null
@@ -0,0 +1,19 @@
+<div>
+       <div class="modal-header">
+               <h3 class="modal-title" translate>Add test server</h3>
+       </div>
+       <div class="modal-body">
+               <juci-config-lines>
+                       <juci-config-line title="{{'Server'|translate}}">
+                               <input type="text" class="form-control" ng-model="data.address"/>
+                       </juci-config-line>
+                       <juci-config-line title="{{'Port'|translate}}">
+                               <input type="number" class="form-control" min="0" max="65535" ng-model="data.port"/>
+                       </juci-config-line>
+               </juci-config-lines>
+       </div>
+       <div class="modal-footer">
+               <button class="btn btn-primary" ng-click="ok()">OK</button>
+               <button class="btn btn-default" ng-click="cancel()">Cancel</button>
+       </div>
+</div>
diff --git a/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.js b/plugins/juci-diagnostics/src/widgets/utils-add-testserver-picker.js
new file mode 100644 (file)
index 0000000..40daa0e
--- /dev/null
@@ -0,0 +1,38 @@
+//! Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
+
+JUCI.app
+.factory("utilsAddTestserverPicker", function($modal){
+       return {
+               show: function(){
+                       var def = $.Deferred(); 
+                       var modalInstance = $modal.open({
+                               animation: true,
+                               templateUrl: 'widgets/utils-add-testserver-picker.html',
+                               controller: 'utilsAddTestserverPicker'
+                       });
+
+                       modalInstance.result.then(function (data) {
+                               setTimeout(function(){ // do this because the callback is called during $apply() cycle
+                                       def.resolve(data); 
+                               }, 0); 
+                       }, function () {
+                                       
+                       });
+                       return def.promise(); 
+               }
+       }; 
+})
+.controller("utilsAddTestserverPicker", function($scope, $modalInstance, $tr, gettext){
+       $scope.data = {}; 
+       $scope.ok = function () {
+               if((!$scope.data.address) || (!$scope.data.port)) {
+                       alert($tr(gettext("Address and port needed"))); 
+                       return; 
+               }
+               $modalInstance.close($scope.data);
+       };
+
+       $scope.cancel = function () {
+               $modalInstance.dismiss('cancel');
+       };
+})
diff --git a/plugins/juci-diagnostics/ubus/speedtest b/plugins/juci-diagnostics/ubus/speedtest
new file mode 100755 (executable)
index 0000000..52e4b34
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/lua
+
+-- Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
+
+local juci = require("juci/core");
+local json = require("juci/json");
+
+function speedtest_run(msg)
+       local testmode, packagesize, address, port = msg.testmode, msg.packagesize, msg.address, msg.port;
+       local status = 0;
+       local label = "success";
+       local up, down;
+       if (not packagesize or not address or not port) then
+               print(json.encode({message = "no empty values pleace"}));
+               return; 
+       end;
+       if(type(packagesize) ~= "number")then 
+               print(json.encode({message = "packagesize must be a number"}));
+               return; 
+       end;
+       if not testmode == "up" and not testmode == "down" and not testmode == "up_down" then
+               print(json.encode({message = "allowed testmodes are: up, down and up_down"}));
+               return;
+       end
+       if address:match("\\") or port:match("\\") then 
+               print(json.encode({message = "no backspace allowed"}));
+               return;
+       end
+       print(json.encode({message = "success"}));
+       if testmode == "up" then 
+               local string = "-n 1 -m tcp-send 60 "..packagesize.." -v 2 "..address.." "..port.."";
+               os.execute("/usr/bin/tptest-run \""..string.."\" \"done\" &");
+       elseif testmode == "down" then 
+               local string = "-n 1 -m tcp-receive 60 "..packagesize.." -v 2 "..address.." "..port.."";
+               os.execute("/usr/bin/tptest-run \"done\" \""..string.."\" &");
+       elseif testmode == "up_down" then 
+               local string1 = "-n 1 -m tcp-send 60 "..packagesize.." -v 2 "..address.." "..port.."";
+               local string2 = "-n 1 -m tcp-receive 60 "..packagesize.." -v 2 "..address.." "..port.."";
+               os.execute("/usr/bin/tptest-run \""..string1.."\" \""..string2.."\" &");
+       end
+end
+
+juci.ubus({
+       ["run"] = speedtest_run
+}, arg);
diff --git a/plugins/juci-utils/Makefile b/plugins/juci-utils/Makefile
deleted file mode 100644 (file)
index b476fb5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-define Plugin/juci-utils/install 
-       @$(INSTALL_DIR) $(1)/usr/bin/
-       @$(INSTALL_DIR) $(1)/usr/lib/ubus-services/
-       @chmod +x $(PLUGIN_DIR)/service/*
-       @chmod +x $(PLUGIN_DIR)/scripts/*
-       @$(CP) $(PLUGIN_DIR)/service/juci-utils-speedtest $(1)/usr/lib/ubus-services/
-       @$(CP) $(PLUGIN_DIR)/scripts/* $(1)/usr/bin/
-endef
-
diff --git a/plugins/juci-utils/po/en.po b/plugins/juci-utils/po/en.po
deleted file mode 100644 (file)
index 985c7a3..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: \n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: Reidar Cederqvist <reidar.cederqvist@gmail.com>\n"
-"Language-Team: \n"
-"Language: en\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.5.4\n"
-
-msgid "Address and port needed"
-msgstr ""
-
-msgid "Direction"
-msgstr ""
-
-msgid "Package Size"
-msgstr ""
-
-msgid "Speedtest Server"
-msgstr ""
-
-msgid "Run test"
-msgstr ""
-
-msgid "Test results"
-msgstr ""
-
-msgid "Error"
-msgstr ""
-
-msgid "Server"
-msgstr ""
-
-msgid "Port"
-msgstr ""
-
-msgid "Add test server"
-msgstr ""
diff --git a/plugins/juci-utils/po/fi.po b/plugins/juci-utils/po/fi.po
deleted file mode 100644 (file)
index f403c4e..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: JUCI\n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: Reidar Cederqvist <reidar.cederqvist@gmail.com>\n"
-"Language-Team: Inteno\n"
-"Language: fi\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.5.4\n"
-
-msgid "Address and port needed"
-msgstr "Osoite ja portti tarvitaan"
-
-msgid "Direction"
-msgstr "Suunta"
-
-msgid "Package Size"
-msgstr "Pakettikoko"
-
-msgid "Speedtest Server"
-msgstr "Speedtest Server"
-
-msgid "Run test"
-msgstr "Suorita testi..."
-
-msgid "Test results"
-msgstr "Jäljityksen tulokset"
-
-msgid "Error"
-msgstr "Virhe"
-
-msgid "Server"
-msgstr "Palvelin"
-
-msgid "Port"
-msgstr "Portti"
-
-msgid "Add test server"
-msgstr "Lisää Testipalvelin"
diff --git a/plugins/juci-utils/po/sv.po b/plugins/juci-utils/po/sv.po
deleted file mode 100644 (file)
index b49fa3e..0000000
+++ /dev/null
@@ -1,1044 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: \n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: Reidar Cederqvist <reidar.cederqvist@gmail.com>\n"
-"Language-Team: \n"
-"Language: sv\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 1.5.4\n"
-
-msgid "Address and port needed"
-msgstr "Adress och port krävs!"
-
-msgid "Direction"
-msgstr "Riktning"
-
-msgid "Package Size"
-msgstr "Total ned-/uppladdningsstorlek"
-
-msgid "Speedtest Server"
-msgstr "Speedtest Server"
-
-msgid "Run test"
-msgstr "Kör testet"
-
-msgid "Test results"
-msgstr "Test resultat"
-
-msgid "Error"
-msgstr "Fel"
-
-msgid "Server"
-msgstr "Server"
-
-msgid "Port"
-msgstr "Port"
-
-msgid "Add test server"
-msgstr "Lägg till testserver"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/juci-utils/scripts/tptest-run b/plugins/juci-utils/scripts/tptest-run
deleted file mode 100755 (executable)
index 143bd33..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-local SUCCESS=0
-
-local send=$1
-local receive=$2
-local sent="none"
-local received="none"
-local lable="success"
-
-if [ "$send" != "done" ]; then
-       sent=$(tptest $send | awk '/Throughput/{print($2)}')
-fi
-if [ "$receive" != "done" ]; then
-       received=$(tptest $receive | awk '/Throughput/{print($2)}')
-fi
-if [ "$receive" == "" || "$sent" == "" ]; then
-       SUCCESS=-1;
-       lable="wrong address";
-elif [ "$receive" == "0" || "$sent" == "0" ]; then
-       SUCCESS=-2;
-       lable="wrong port";
-fi
-ubus send juci.utils.speedtest "{\"status\":$SUCCESS, \"upstream\":\"$sent\",\"downstream\":\"$received\",\"lable\":\"$lable\"}"
-
-
diff --git a/plugins/juci-utils/service/juci-utils-speedtest b/plugins/juci-utils/service/juci-utils-speedtest
deleted file mode 100755 (executable)
index b293e43..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/lua 
-
--- Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
-
-require "ubus"
-require "uloop"
-
-local json = require("juci/json");
-local juci = require("juci/core");
-
-uloop.init(); 
-
-local conn = ubus.connect()
-if not conn then
-       error("Failed to connect to ubus")
-end
-
-
-function test_speed(req, msg)
-       local testmode, packagesize, address, port = msg.testmode, msg.packagesize, msg.address, msg.port;
-       if(not packagesize or not address or not port)then
-               conn:reply(req, {message = "no empty values pleace"});
-               return nil; 
-       end;
-       if(type(packagesize) ~= "number")then 
-               conn:reply(req, {message = "packagesize must be a number"});
-               return nil; 
-       end;
-       if testmode == "up" then 
-               local string = "-n 1 -m tcp-send 60 "..packagesize.." -v 2 "..address.." "..port.."";
-               juci.shell("/usr/bin/tptest-run '%s' 'done' &", string);
-       elseif testmode == "down" then 
-               local string = "-n 1 -m tcp-receive 60 "..packagesize.." -v 2 "..address.." "..port.."";
-               juci.shell("/usr/bin/tptest-run 'done' '%s' &", string);
-       elseif testmode == "up_down" then 
-               local string1 = "-n 1 -m tcp-send 60 "..packagesize.." -v 2 "..address.." "..port.."";
-               local string2 = "-n 1 -m tcp-receive 60 "..packagesize.." -v 2 "..address.." "..port.."";
-               juci.shell("/usr/bin/tptest-run '%s' '%s' &", string1, string2);
-       else 
-               conn:reply(req, {message = "allowed testmodes are (up, down and up_down)"});
-               return nil;
-       end;
-       conn:reply(req, {message = "success"});
-end
-
-
-conn:add({
-       ["juci.utils.speedtest"] = {run = 
-               {test_speed, 
-                       {testmode = ubus.STRING, packagesize = ubus.INT32, address = ubus.STRING, port = ubus.STRING}
-               }
-       }; 
-}); 
-
-uloop.run();
-
diff --git a/plugins/juci-utils/src/main.js b/plugins/juci-utils/src/main.js
deleted file mode 100644 (file)
index 00086c7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-//! Author: Reidar Cederqvst <reidar.cederqvist@gmail.com>
-
-UCI.$registerConfig("speedtest"); 
-UCI.speedtest.$registerSectionType("testserver", {
-       "server":               { dvalue: "", type: String }, 
-       "port":                 { dvalue: "", type: String }
-});
-
diff --git a/plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.html b/plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.html
deleted file mode 100644 (file)
index 256b943..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<div>
-       <juci-expandable title="TP test">
-               <juci-config-lines>
-                       <juci-config-line title="{{'Direction'|translate}}">
-                               <juci-select ng-model="data.test_type" ng-items="testType"/>
-                       </juci-config-line>
-                       <juci-config-line title="{{'Package Size'|translate}}">
-                               <div class="input-group">
-                                       <input type="number" step="5" class="form-control" ng-model="data.packagesize" />
-                                       <span class="input-group-addon">Mb</span>
-                               </div>
-                       </juci-config-line>
-                       <juci-config-line title="{{'Speedtest Server' | translate}}">
-                               <juci-select ng-model="data.server" ng-items="allTestServers"/>
-                       </juci-config-line>
-                       <juci-config-line>
-                               <button class="btn btn-default" ng-click="onRemoveAddress()">
-                                       <i class="fa fa-minus"></i>
-                               </button>
-                               <button class="btn btn-default" ng-click="onAddAddress()">
-                                       <i class="fa fa-plus"></i>
-                               </button>
-                       </juci-config-line>
-                       <juci-config-line>
-                               <button class="btn btn-default" ng-click="runTest()">
-                               {{'Run test' | translate}}</button>
-                       </juci-config-line>
-               </juci-config-lines>
-               <div class="alert alert-success" ng-show="data.state == 'result'">
-                       {{'Test results'|translate}}: <br/>
-                       <pre>{{data.result}}</pre>
-               </div>
-               <div class="alert alert-success" ng-show="data.state == 'running'">
-                       <h4>
-                               {{"Running test"|translate}}
-                               <i class="fa fa-spinner fa-pulse fa-2x"></i>
-                       </h4>
-               </div>
-           <div class="alert alert-danger" ng-show="data.state == 'error'">
-                       {{'Error'|translate}}: <br/>
-                       <pre>{{data.result|translate}}</pre>
-               </div>
-       </juci-expandable>
-</div>
-
diff --git a/plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.js b/plugins/juci-utils/src/widgets/diagnostics-widget-speedtest.js
deleted file mode 100644 (file)
index f8fa5fa..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-//! Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
-
-JUCI.app
-.directive("diagnosticsWidget90Speedtest", function(){
-       return {
-               scope: true,
-               replace: true,
-               templateUrl: "/widgets/diagnostics-widget-speedtest.html",
-               controller: "diagnosticsWidget90Speedtest"
-       };
-})
-.controller("diagnosticsWidget90Speedtest", function($scope, $rpc, $events, $uci, utilsAddTestserverPicker){
-       $scope.data = {
-               packagesize: 50,
-               test_type: "up_down",
-               result: "",
-               state: ""
-       }; 
-       var min = 1; 
-       var max = 100; 
-       $scope.$watch('data.packagesize', function(new_value){
-               if(new_value < min)$scope.data.packagesize = min;
-               if(new_value > max)$scope.data.packagesize = max;
-       }, false);
-
-       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; 
-       }
-
-       $scope.testType = [
-               {value:"up_down", label: "up and down"}, 
-               {value:"up", label: "up"}, 
-               {value:"down", label:"down"} 
-       ];
-
-       $uci.$sync("speedtest").done(function(){
-               $scope.testServers = $uci.speedtest["@testserver"];
-               getServers();
-               $scope.$apply();
-       });
-
-       $scope.runTest = function(){
-               if(!$scope.testServers.length){
-                       window.alert("Server and port is mandatory");
-                       return;
-               }
-               if($scope.data.state == "running"){
-                       window.alert("Only one test can be run at a time");
-                       return;
-               }
-               var server = $scope.testServers.find(function(x){ return $scope.data.server == x.server.value;});
-               var port = server.port.value;
-               var address = server.server.value;
-               $scope.data.state="running";
-               $rpc.juci.utils.speedtest.run({
-                       "testmode": $scope.data.test_type,
-                       "port": port,
-                       "packagesize": $scope.data.packagesize * 1000,
-                       "address": address
-               }).done(function(response){
-                       if(response && response.message=="success"){
-                               $scope.data.state="running";
-                       }else{
-                               $scope.data.state="";
-                       }
-                       $scope.$apply();
-               });
-       };
-       
-       $scope.onRemoveAddress = function(){
-               var server = $scope.testServers.find(function(x){
-                       return $scope.data.server == x.server.value
-               });
-               if(!server){
-                       alert("error deleting server");
-                       return;
-               }
-               server.$delete().done(function(){
-                       getServers();
-                       $scope.$apply();
-               });
-       };
-
-       $scope.onAddAddress = function(){
-               utilsAddTestserverPicker.show().done(function(data){
-                       if(!data)return;
-                       $uci.speedtest.$create({
-                               ".type": "testserver",
-                               "server": data.address,
-                               "port": data.port
-                       }).done(function(){
-                               getServers();
-                               $scope.$apply();
-                       });
-               });
-       }
-       $events.subscribe("juci.utils.speedtest", function(res){
-               if(res.data && res.data.status != undefined){
-                       switch(res.data.status) {
-                       case 0:
-                               var upstream = parseInt(res.data.upstream);
-                               if(upstream == "NaN") {
-                                       upstream = "none"
-                               }else{
-                                       upstream = upstream / 1000 / 1000;
-                               }
-                               var downstream = parseInt(res.data.downstream);
-                               if(downstream == "NAN"){
-                                       downstream = "none"
-                               }else{
-                                       downstream = downstream / 1000 / 1000;
-                               }
-                               if(res.data.upstream != "none" && res.data.downstream != "none"){
-                                       $scope.data.result="Upstream: " + upstream.toFixed(2) + " Mbit/s\nDownstream: " + downstream.toFixed(2) + " Mbit/s";
-                               }else if(res.data.upstream != "none"){
-                                       $scope.data.result="Upstream: " + upstream.toFixed(2) + " Mbit/s";
-                               }else if(res.data.downstream != "none"){
-                                       $scope.data.result="Downstream: " + downstream.toFixed(2) + " Mbit/s";
-                               }else {
-                                       $scope.data.result="No speeds found";
-                               }
-                               $scope.data.state="result";
-                               break;
-                       case -1:
-                               $scope.data.result="Wrong TP-test address and/or port";
-                               $scope.data.state="error";
-                               break;
-                       case -2:
-                               $scope.data.result="Wrong TP-test port but correct address";
-                               $scope.data.state="error";
-                               break;
-                       }
-                       $scope.$apply();
-               }
-       });
-}); 
diff --git a/plugins/juci-utils/src/widgets/utils-add-testserver-picker.html b/plugins/juci-utils/src/widgets/utils-add-testserver-picker.html
deleted file mode 100644 (file)
index e75bfb5..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<div>
-       <div class="modal-header">
-               <h3 class="modal-title" translate>Add test server</h3>
-       </div>
-       <div class="modal-body">
-               <juci-config-lines>
-                       <juci-config-line title="{{'Server'|translate}}">
-                               <input type="text" class="form-control" ng-model="data.address"/>
-                       </juci-config-line>
-                       <juci-config-line title="{{'Port'|translate}}">
-                               <input type="number" class="form-control" min="0" max="65535" ng-model="data.port"/>
-                       </juci-config-line>
-               </juci-config-lines>
-       </div>
-       <div class="modal-footer">
-               <button class="btn btn-primary" ng-click="ok()">OK</button>
-               <button class="btn btn-default" ng-click="cancel()">Cancel</button>
-       </div>
-</div>
diff --git a/plugins/juci-utils/src/widgets/utils-add-testserver-picker.js b/plugins/juci-utils/src/widgets/utils-add-testserver-picker.js
deleted file mode 100644 (file)
index 40daa0e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//! Author: Reidar Cederqvist <reidar.cederqvist@gmail.com>
-
-JUCI.app
-.factory("utilsAddTestserverPicker", function($modal){
-       return {
-               show: function(){
-                       var def = $.Deferred(); 
-                       var modalInstance = $modal.open({
-                               animation: true,
-                               templateUrl: 'widgets/utils-add-testserver-picker.html',
-                               controller: 'utilsAddTestserverPicker'
-                       });
-
-                       modalInstance.result.then(function (data) {
-                               setTimeout(function(){ // do this because the callback is called during $apply() cycle
-                                       def.resolve(data); 
-                               }, 0); 
-                       }, function () {
-                                       
-                       });
-                       return def.promise(); 
-               }
-       }; 
-})
-.controller("utilsAddTestserverPicker", function($scope, $modalInstance, $tr, gettext){
-       $scope.data = {}; 
-       $scope.ok = function () {
-               if((!$scope.data.address) || (!$scope.data.port)) {
-                       alert($tr(gettext("Address and port needed"))); 
-                       return; 
-               }
-               $modalInstance.close($scope.data);
-       };
-
-       $scope.cancel = function () {
-               $modalInstance.dismiss('cancel');
-       };
-})