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

@ -40,13 +40,13 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.WatchList = settings.WatchList;
$scope.OwnshipModeS = settings.OwnshipModeS;
$scope.DeveloperMode = settings.DeveloperMode;
$scope.GLimits = settings.GLimits;
$scope.GLimits = settings.GLimits;
$scope.StaticIps = settings.StaticIps;
$scope.WiFiSSID = settings.WiFiSSID;
$scope.WiFiPassphrase = settings.WiFiPassphrase;
$scope.WiFiSecurityEnabled = settings.WiFiSecurityEnabled;
$scope.WiFiChannel = settings.WiFiChannel.toString();
$scope.WiFiSSID = settings.WiFiSSID;
$scope.WiFiPassphrase = settings.WiFiPassphrase;
$scope.WiFiSecurityEnabled = settings.WiFiSecurityEnabled;
$scope.WiFiChannel = settings.WiFiChannel.toString();
}
function getSettings() {
@ -77,10 +77,7 @@ 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();
// Reset all settings from a button on the page
@ -277,13 +274,21 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
'Errors': false
};
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 charecter but not more then 32 charecters. It cannot start with: ! , ; , # or contain: + , [ , ] , \" , or a tab";
function isValidSSID(str) { return /^[!#;].|[+\[\]/"\t\s].*$/.test(str); }
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;
}
if ($scope.WiFiSecurityEnabled) {
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;
}
if ($scope.WiFiPassphrase.length < 8 || $scope.WiFiPassphrase.length > 63 ) {
@ -291,19 +296,20 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.WiFiErrors.Errors = true;
}
}
if (!$scope.WiFiErrors.Errors) {
newsettings = {
var newsettings = {
"WiFiSSID" : $scope.WiFiSSID,
"WiFiSecurityEnabled" : $scope.WiFiSecurityEnabled,
"WiFiPassphrase" : $scope.WiFiPassphrase,
"WiFiChannel" : parseInt($scope.WiFiChannel)
};
console.log(angular.toJson(newsettings));
$scope.Ui.turnOn("modalSuccessWiFi");
// console.log(angular.toJson(newsettings));
setSettings(angular.toJson(newsettings));
$scope.Ui.turnOn("modalSuccessWiFi");
} else {
$scope.Ui.turnOn("modalErrorWiFi");
$scope.Ui.turnOn("modalErrorWiFi");
}
};
}

Wyświetl plik

@ -64,7 +64,8 @@
<div class="form-group reset-flow">
<label class="control-label col-xs-5">WiFi Passphrase</label>
<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 class="form-group reset-flow">
<label class="control-label col-xs-7">WiFi Channel</label>
@ -205,7 +206,7 @@
<label class="control-label col-xs-3">G Limits</label>
<form name="GLimitForm" ng-submit="updateGLimits()" novalidate>
<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"/>
</form>
</div>
@ -420,7 +421,7 @@
<p>WiFi Security: <b>{{WiFiSecurityEnabled}}</b></p>
<p>WiFi Passphrase: <b>{{WiFiPassphrase}}</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>
</div>
<div class="modal-footer">