kopia lustrzana https://github.com/cyoung/stratux
Added developer mode toggle by clicking on version 7 times within 3 seconds
rodzic
2a76788405
commit
bb00189e94
|
@ -1067,6 +1067,7 @@ func defaultSettings() {
|
|||
globalSettings.DisplayTrafficSource = false
|
||||
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
||||
globalSettings.OwnshipModeS = "F00000"
|
||||
globalSettings.DeveloperMode = false
|
||||
}
|
||||
|
||||
func readSettings() {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<script src="js/j3di-all.min.js"></script>
|
||||
<script src="plates/js/ahrs.js"></script>
|
||||
<script src="plates/js/gps.js"></script>
|
||||
<script src="plates/js/developer.js"></script>
|
||||
</head>
|
||||
|
||||
<body ng-app="stratux" ng-controller="MainCtrl" ui-prevent-touchmove-defaults>
|
||||
|
@ -83,7 +84,7 @@
|
|||
<a class="list-group-item" href="#/towers"><i class="fa fa-signal"></i> Towers <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<a class="list-group-item" href="#/logs"><i class="fa fa-file-text-o"></i> Logs <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<a class="list-group-item" href="#/settings"><i class="fa fa-gear"></i> Settings <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<div ng-show="developerMode">
|
||||
<div ng-show="DeveloperMode">
|
||||
<a class="list-group-item" href="#/developer"><i class="fa fa-tasks"></i> Developer <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -13,6 +13,8 @@ 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']);
|
||||
|
|
|
@ -100,6 +100,10 @@ a.bg-danger:hover {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-hidden:hover {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.btn-default:hover {
|
||||
color: #333333;
|
||||
background-color: #e6e6e6;
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
<div class="list-group text-center">
|
||||
<div class="panel-heading">
|
||||
<span class="panel_label">Developer Mode</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>Under Construction</p>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span class="panel_label">Developer Mode Items</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="panel-group col-sm-6">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Restart Stratux application</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group reset-flow">
|
||||
<div class="col-xs-12">
|
||||
<a ng-click="postRestart()" ui-turn-off="modalRestartApp" class="btn btn-primary">Restart Application</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -4,6 +4,15 @@ DeveloperCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$interval']
|
|||
// create our controller function with all necessary logic
|
||||
function DeveloperCtrl($rootScope, $scope, $state, $http, $interval) {
|
||||
$scope.$parent.helppage = 'plates/developer-help.html';
|
||||
$scope.data_list = [];
|
||||
|
||||
$scope.postRestart = function () {
|
||||
$http.post(URL_RESTARTAPP).
|
||||
then(function (response) {
|
||||
// do nothing
|
||||
// $scope.$apply();
|
||||
}, function (response) {
|
||||
// do nothing
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -140,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
|
||||
};
|
||||
|
@ -151,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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="col-sm-12">
|
||||
<div class="text-center">
|
||||
<p><strong>Version: <span>{{Version}} ({{Build}})</span></strong></p>
|
||||
</div>
|
||||
<a ng-click="VersionClick()" class="btn btn-hidden"<strong>Version: <span>{{Version}} ({{Build}})</span></strong></a>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" ng-class="{'section_invisible': !visible_errors}">
|
||||
<span class="panel_label">Errors</span>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<span class="panel_label">Status</span>
|
||||
<span ng-show="ConnectState == 'Connected'" class="label label-success">{{ConnectState}}</span>
|
||||
<span ng-hide="ConnectState == 'Connected'" class="label label-danger">{{ConnectState}}</span>
|
||||
<span ng-show="developerMode == true" class="label label-warning">Developer Mode</span>
|
||||
<span ng-show="DeveloperMode == true" class="label label-warning">Developer Mode</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-horizontal">
|
||||
|
@ -133,7 +133,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" ng-class="{'section_invisible': !developerMode}">
|
||||
<div class="row" ng-class="{'section_invisible': !DeveloperMode}">
|
||||
<div class="separator"></div>
|
||||
<div class="row"><span class="col-xs-1"> </span></div>
|
||||
<div class="separator"></div>
|
||||
|
|
Ładowanie…
Reference in New Issue