diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 72e66d9e..3dbd48e3 100755 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -100,7 +100,6 @@ type ReadCloser interface { io.Closer } -var developerMode bool type msg struct { MessageClass uint @@ -995,6 +994,7 @@ type settings struct { PPM int OwnshipModeS string WatchList string + DeveloperMode bool } type status struct { @@ -1057,6 +1057,7 @@ func defaultSettings() { globalSettings.DisplayTrafficSource = false globalSettings.ReplayLog = false //TODO: 'true' for debug builds. globalSettings.OwnshipModeS = "F00000" + globalSettings.DeveloperMode = false } func readSettings() { @@ -1291,7 +1292,8 @@ func main() { // replayESFilename := flag.String("eslog", "none", "ES Log filename") replayUATFilename := flag.String("uatlog", "none", "UAT Log filename") - develFlag := flag.Bool("developer", false, "Developer mode") + // Removed here, but may replace later +// develFlag := flag.Bool("developer", false, "Developer mode") replayFlag := flag.Bool("replay", false, "Replay file flag") replaySpeed := flag.Int("speed", 1, "Replay speed multiplier") stdinFlag := flag.Bool("uatin", false, "Process UAT messages piped to stdin") @@ -1301,11 +1303,6 @@ func main() { timeStarted = time.Now() runtime.GOMAXPROCS(runtime.NumCPU()) // redundant with Go v1.5+ compiler - if *develFlag == true { - log.Printf("Developer mode flag true!\n") - developerMode = true - } - // Duplicate log.* output to debugLog. fp, err := os.OpenFile(debugLogf, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { @@ -1340,6 +1337,10 @@ func main() { globalSettings.ReplayLog = true } + if globalSettings.DeveloperMode == true { + log.Printf("Developer mode set\n") + } + //FIXME: Only do this if data logging is enabled. initDataLog() diff --git a/main/managementinterface.go b/main/managementinterface.go index e16d6092..d4d55273 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -290,6 +290,16 @@ func doReboot() { syscall.Reboot(syscall.LINUX_REBOOT_CMD_RESTART) } +func handleDevelModeToggle(w http.ResponseWriter, r *http.Request) { + log.Printf("handleDevelModeToggle called!!!\n") + globalSettings.DeveloperMode = true +} + +func handleRestartRequest(w http.ResponseWriter, r *http.Request) { + log.Printf("handleRestartRequest called\n") + go doRestartApp() +} + func handleRebootRequest(w http.ResponseWriter, r *http.Request) { setNoCache(w) setJSONHeaders(w) @@ -298,6 +308,17 @@ func handleRebootRequest(w http.ResponseWriter, r *http.Request) { go delayReboot() } +func doRestartApp() { + time.Sleep(1) + syscall.Sync() + out, err := exec.Command("/bin/systemctl", "restart", "stratux").Output() + if err != nil { + log.Printf("restart error: %s\n%s", err.Error(), out) + } else { + log.Printf("restart: %s\n", out) + } +} + // AJAX call - /getClients. Responds with all connected clients. func handleClientsGetRequest(w http.ResponseWriter, r *http.Request) { setNoCache(w) @@ -496,11 +517,13 @@ func managementInterface() { http.HandleFunc("/getSatellites", handleSatellitesRequest) http.HandleFunc("/getSettings", handleSettingsGetRequest) http.HandleFunc("/setSettings", handleSettingsSetRequest) + http.HandleFunc("/restart", handleRestartRequest) http.HandleFunc("/shutdown", handleShutdownRequest) http.HandleFunc("/reboot", handleRebootRequest) http.HandleFunc("/getClients", handleClientsGetRequest) http.HandleFunc("/updateUpload", handleUpdatePostRequest) http.HandleFunc("/roPartitionRebuild", handleroPartitionRebuild) + http.HandleFunc("/develmodetoggle", handleDevelModeToggle) err := http.ListenAndServe(managementAddr, nil) diff --git a/web/index.html b/web/index.html index 796d7322..48594d4e 100755 --- a/web/index.html +++ b/web/index.html @@ -64,6 +64,7 @@ + @@ -83,6 +84,9 @@ Towers Logs Settings +
+ Developer +
diff --git a/web/js/main.js b/web/js/main.js old mode 100755 new mode 100644 index a92eae92..287de8b6 --- a/web/js/main.js +++ b/web/js/main.js @@ -9,9 +9,12 @@ var URL_SATELLITES_GET = "http://" + URL_HOST_BASE + "/getSatellites" var URL_STATUS_WS = "ws://" + URL_HOST_BASE + "/status" var URL_TRAFFIC_WS = "ws://" + URL_HOST_BASE + "/traffic"; var URL_WEATHER_WS = "ws://" + URL_HOST_BASE + "/weather"; +var URL_DEVELOPER_GET = "ws://" + URL_HOST_BASE + "/developer"; var URL_UPDATE_UPLOAD = "http://" + URL_HOST_BASE + "/updateUpload"; var URL_REBOOT = "http://" + URL_HOST_BASE + "/reboot"; var URL_SHUTDOWN = "http://" + URL_HOST_BASE + "/shutdown"; +var URL_RESTARTAPP = "http://" + URL_HOST_BASE + "/restart"; +var URL_DEV_TOGGLE_GET = "http://" + URL_HOST_BASE + "/develmodetoggle"; // define the module with dependency on mobile-angular-ui //var app = angular.module('stratux', ['ngRoute', 'mobile-angular-ui', 'mobile-angular-ui.gestures', 'appControllers']); @@ -62,6 +65,12 @@ app.config(function ($stateProvider, $urlRouterProvider) { templateUrl: 'plates/settings.html', controller: 'SettingsCtrl', reloadOnSearch: false + }) + .state('developer', { + url: '/developer', + templateUrl: 'plates/developer.html', + controller: 'DeveloperCtrl', + reloadOnSearch: false }); $urlRouterProvider.otherwise('/'); }); @@ -72,6 +81,13 @@ app.run(function ($transform) { }); // For this app we have a MainController for whatever and individual controllers for each page -app.controller('MainCtrl', function ($rootScope, $scope) { +app.controller('MainCtrl', function ($scope, $http) { // any logic global logic + $http.get(URL_SETTINGS_GET) + .then(function(response) { + settings = angular.fromJson(response.data); + $scope.developerMode = settings.DeveloperMode; + }, function(response) { + //Second function handles error + }); }); \ No newline at end of file diff --git a/web/maui/css/mobile-angular-ui-hover.css b/web/maui/css/mobile-angular-ui-hover.css index 61bc5c4d..38613826 100755 --- a/web/maui/css/mobile-angular-ui-hover.css +++ b/web/maui/css/mobile-angular-ui-hover.css @@ -100,6 +100,10 @@ a.bg-danger:hover { text-decoration: none; } +.btn-hidden:hover { + color: #000000; +} + .btn-default:hover { color: #333333; background-color: #e6e6e6; diff --git a/web/plates/developer-help.html b/web/plates/developer-help.html new file mode 100644 index 00000000..333c1e30 --- /dev/null +++ b/web/plates/developer-help.html @@ -0,0 +1,4 @@ +
+

The Developer page provides basic access to developer options

+

+
\ No newline at end of file diff --git a/web/plates/developer.html b/web/plates/developer.html new file mode 100644 index 00000000..87d3396d --- /dev/null +++ b/web/plates/developer.html @@ -0,0 +1,21 @@ +
+
+
+ Developer Mode Items +
+
+
+
+
Restart Stratux application
+
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/web/plates/js/developer.js b/web/plates/js/developer.js new file mode 100644 index 00000000..ee815fa4 --- /dev/null +++ b/web/plates/js/developer.js @@ -0,0 +1,18 @@ +angular.module('appControllers').controller('DeveloperCtrl', DeveloperCtrl); // get the main module contollers set +DeveloperCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$interval']; // Inject my dependencies + +// create our controller function with all necessary logic +function DeveloperCtrl($rootScope, $scope, $state, $http, $interval) { + $scope.$parent.helppage = 'plates/developer-help.html'; + + $scope.postRestart = function () { + $http.post(URL_RESTARTAPP). + then(function (response) { + // do nothing + // $scope.$apply(); + }, function (response) { + // do nothing + }); + }; +}; + diff --git a/web/plates/js/settings.js b/web/plates/js/settings.js index 8f85df85..52b18099 100755 --- a/web/plates/js/settings.js +++ b/web/plates/js/settings.js @@ -33,6 +33,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $scope.PPM = settings.PPM; $scope.WatchList = settings.WatchList; $scope.OwnshipModeS = settings.OwnshipModeS; + $scope.DeveloperMode = settings.DeveloperMode; } function getSettings() { diff --git a/web/plates/js/status.js b/web/plates/js/status.js index d243b35e..ba4df5b5 100755 --- a/web/plates/js/status.js +++ b/web/plates/js/status.js @@ -101,6 +101,7 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) { $http.get(URL_SETTINGS_GET). then(function (response) { settings = angular.fromJson(response.data); + $scope.developerMode = settings.DeveloperMode; $scope.visible_uat = settings.UAT_Enabled; $scope.visible_es = settings.ES_Enabled; $scope.visible_ping = settings.Ping_Enabled; @@ -139,7 +140,16 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) { getTowers(); }, (5 * 1000), 0, false); - + var clicks = 0; + var clickSeconds = 0; + var developerModeClick = 0; + + var clickInterval = $interval(function () { + if ((clickSeconds >= 3)) + clicks=0; + clickSeconds++; + }, 1000); + $state.get('home').onEnter = function () { // everything gets handled correctly by the controller }; @@ -150,7 +160,26 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) { } $interval.cancel(updateTowers); }; - + + $scope.VersionClick = function() { + if (clicks==0) + { + clickSeconds = 0; + } + ++clicks; + if ((clicks > 7) && (clickSeconds < 3)) + { + clicks=0; + clickSeconds=0; + developerModeClick = 1; + $http.get(URL_DEV_TOGGLE_GET); + location.reload(); + } + } + + $scope.GetDeveloperModeClick = function() { + return developerModeClick; + } // Status Controller tasks setHardwareVisibility(); connect($scope); // connect - opens a socket and listens for messages diff --git a/web/plates/settings.html b/web/plates/settings.html index 641c0985..d3987a01 100755 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -134,6 +134,19 @@ + +
+
+
+
Developer Options
+
+
+

Coming soon

+
+
+
+
+