Replace checkbox with toggle button for ipv6
This commit is contained in:
@@ -152,22 +152,17 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p>{{ 'network.ipv6.description' | tr }}</p>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="ipv6Configure.enabled" name="ipv6" ng-disabled="ipv6Configure.busy"/> {{ 'network.ipv6.enable' | tr }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<span class="text-success text-bold" ng-show="ipv6Configure.success">{{ 'network.ipv6.saved' | tr }}</span>
|
||||
<span class="text-danger" ng-show="ipv6Configure.error">{{ ipv6Configure.error }}</span>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 text-right">
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-click="ipv6Configure.submit()" ng-disabled="ipv6Configure.currentState === ipv6Configure.enabled"><i class="fa fa-circle-notch fa-spin" ng-show="ipv6Configure.busy"></i> {{ 'main.dialog.save' | tr }}</button>
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-hide="ipv6Configure.isEnabled" ng-click="ipv6Configure.setEnabled(true)" ng-disabled="ipv6Configure.busy"><i class="fa fa-circle-notch fa-spin" ng-show="ipv6Configure.busy"></i> {{ 'main.enableAction' | tr }}</button>
|
||||
<button class="btn btn-outline btn-danger pull-right" ng-show="ipv6Configure.isEnabled" ng-click="ipv6Configure.setEnabled(false)" ng-disabled="ipv6Configure.busy"><i class="fa fa-circle-notch fa-spin" ng-show="ipv6Configure.busy"></i> {{ 'main.disableAction' | tr }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+6
-11
@@ -58,35 +58,30 @@ angular.module('Application').controller('NetworkController', ['$scope', '$locat
|
||||
|
||||
$scope.ipv6Configure = {
|
||||
busy: false,
|
||||
success: false,
|
||||
error: '',
|
||||
currentState: false,
|
||||
enabled: false,
|
||||
isEnabled: false,
|
||||
|
||||
refresh: function () {
|
||||
Client.getIPv6Config(function (error, enabled) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
$scope.ipv6Configure.currentState = enabled;
|
||||
$scope.ipv6Configure.enabled = enabled;
|
||||
$scope.ipv6Configure.isEnabled = enabled;
|
||||
});
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
setEnabled: function (enabled) {
|
||||
$scope.ipv6Configure.busy = true;
|
||||
$scope.ipv6Configure.success = false;
|
||||
$scope.ipv6Configure.error = '';
|
||||
|
||||
Client.setIPv6Config($scope.ipv6Configure.enabled, function (error) {
|
||||
Client.setIPv6Config(enabled, function (error) {
|
||||
$scope.ipv6Configure.busy = false;
|
||||
|
||||
if (error) {
|
||||
$scope.ipv6Configure.error = error.message;
|
||||
$scope.ipv6Configure.enabled = !$scope.ipv6Configure.enabled; // restore old state
|
||||
return;
|
||||
}
|
||||
$scope.ipv6Configure.currentState = $scope.ipv6Configure.enabled;
|
||||
$scope.ipv6Configure.success = true;
|
||||
|
||||
$scope.ipv6Configure.isEnabled = enabled;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user