Formatting; re-do grayout of disabled text boxes.

pull/734/head^2
Eric Westphal 2017-07-22 16:03:35 -04:00
rodzic be692f7a84
commit 034e38d4e7
2 zmienionych plików z 26 dodań i 19 usunięć

Wyświetl plik

@ -78,9 +78,6 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
}); });
} }
function isValidSSID(str) { return /^[!#;].|[+\[\]/"\t\s].*$/.test(str); }
function isValidWPA(str) { return /^[\u0020-\u007e\u00a0-\u00ff]*$/.test(str); }
getSettings(); getSettings();
// Reset all settings from a button on the page // Reset all settings from a button on the page
@ -277,13 +274,21 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
'Errors': false 'Errors': false
}; };
if (($scope.WiFiSSID == undefined) || ($scope.WiFiSSID == null) || ($scope.WiFiSSID.length == 0) || ($scope.WiFiSSID.length > 32) || (isValidSSID($scope.WiFiSSID))) { function isValidSSID(str) { return /^[!#;].|[+\[\]/"\t\s].*$/.test(str); }
$scope.WiFiErrors.WiFiSSID = "Your Network Name(\"SSID\") must be at least 1 charecter but not more then 32 charecters. It cannot start with: ! , ; , # or contain: + , [ , ] , \" , or a tab"; function isValidWPA(str) { return /^[\u0020-\u007e\u00a0-\u00ff]*$/.test(str); }
if (($scope.WiFiSSID === undefined) || ($scope.WiFiSSID === null) || ($scope.WiFiSSID.length === 0) ||
($scope.WiFiSSID.length > 32) || (isValidSSID($scope.WiFiSSID))) {
$scope.WiFiErrors.WiFiSSID = "Your Network Name(\"SSID\") must be at least 1 character " +
"but not more then 32 characters." +
"It cannot start with: ! , ; , # or contain: + , [ , ] , \" , or a tab";
$scope.WiFiErrors.Errors = true; $scope.WiFiErrors.Errors = true;
} }
if ($scope.WiFiSecurityEnabled) { if ($scope.WiFiSecurityEnabled) {
if (!isValidWPA($scope.WiFiPassphrase)) { if (!isValidWPA($scope.WiFiPassphrase)) {
$scope.WiFiErrors.WiFiPassphrase = "Your WiFi Password, " + $scope.WiFiPassphrase + ", contains invalid charecters."; $scope.WiFiErrors.WiFiPassphrase = "Your WiFi Password, " + $scope.WiFiPassphrase +
", contains invalid characters.";
$scope.WiFiErrors.Errors = true; $scope.WiFiErrors.Errors = true;
} }
if ($scope.WiFiPassphrase.length < 8 || $scope.WiFiPassphrase.length > 63 ) { if ($scope.WiFiPassphrase.length < 8 || $scope.WiFiPassphrase.length > 63 ) {
@ -291,17 +296,18 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.WiFiErrors.Errors = true; $scope.WiFiErrors.Errors = true;
} }
} }
if (!$scope.WiFiErrors.Errors) { if (!$scope.WiFiErrors.Errors) {
newsettings = { var newsettings = {
"WiFiSSID" : $scope.WiFiSSID, "WiFiSSID" : $scope.WiFiSSID,
"WiFiSecurityEnabled" : $scope.WiFiSecurityEnabled, "WiFiSecurityEnabled" : $scope.WiFiSecurityEnabled,
"WiFiPassphrase" : $scope.WiFiPassphrase, "WiFiPassphrase" : $scope.WiFiPassphrase,
"WiFiChannel" : parseInt($scope.WiFiChannel) "WiFiChannel" : parseInt($scope.WiFiChannel)
}; };
console.log(angular.toJson(newsettings)); // console.log(angular.toJson(newsettings));
$scope.Ui.turnOn("modalSuccessWiFi");
setSettings(angular.toJson(newsettings)); setSettings(angular.toJson(newsettings));
$scope.Ui.turnOn("modalSuccessWiFi");
} else { } else {
$scope.Ui.turnOn("modalErrorWiFi"); $scope.Ui.turnOn("modalErrorWiFi");
} }

Wyświetl plik

@ -64,7 +64,8 @@
<div class="form-group reset-flow"> <div class="form-group reset-flow">
<label class="control-label col-xs-5">WiFi Passphrase</label> <label class="control-label col-xs-5">WiFi Passphrase</label>
<input class="col-xs-7" type="string" ng-model="WiFiPassphrase" <input class="col-xs-7" type="string" ng-model="WiFiPassphrase"
ng-disabled="!WiFiSecurityEnabled" placeholder="WiFi Passphrase" /> ng-disabled="!WiFiSecurityEnabled" ng-class="{grayout: !WiFiSecurityEnabled}"
placeholder="WiFi Passphrase" />
</div> </div>
<div class="form-group reset-flow"> <div class="form-group reset-flow">
<label class="control-label col-xs-7">WiFi Channel</label> <label class="control-label col-xs-7">WiFi Channel</label>
@ -205,7 +206,7 @@
<label class="control-label col-xs-3">G Limits</label> <label class="control-label col-xs-3">G Limits</label>
<form name="GLimitForm" ng-submit="updateGLimits()" novalidate> <form name="GLimitForm" ng-submit="updateGLimits()" novalidate>
<input class="col-xs-9" type="string" required ng-model="GLimits" ng-blur="updateGLimits()" <input class="col-xs-9" type="string" required ng-model="GLimits" ng-blur="updateGLimits()"
ng-disabled="!IMU_Sensor_Enabled" ng-disabled="!IMU_Sensor_Enabled" ng-class="{grayout: !IMU_Sensor_Enabled}"
placeholder="Space-separated negative and positive G meter limits"/> placeholder="Space-separated negative and positive G meter limits"/>
</form> </form>
</div> </div>
@ -420,7 +421,7 @@
<p>WiFi Security: <b>{{WiFiSecurityEnabled}}</b></p> <p>WiFi Security: <b>{{WiFiSecurityEnabled}}</b></p>
<p>WiFi Passphrase: <b>{{WiFiPassphrase}}</b></p> <p>WiFi Passphrase: <b>{{WiFiPassphrase}}</b></p>
<p>WiFi Channel: <b>{{WiFiChannel}}</b></p> <p>WiFi Channel: <b>{{WiFiChannel}}</b></p>
<p>Your Stratux's WiFi services are now restarting to apply the new settings. This could take up to 30 seconds<br /> <p>Your Stratux's WiFi services are now restarting to apply the new settings. This could take up to 30 seconds.<br/>
You might have to reconnect to your new WiFi SSID. </p> You might have to reconnect to your new WiFi SSID. </p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">