fixed destination editable issue.

This commit is contained in:
kunw 2016-07-13 13:17:31 +08:00
parent eda4b499b5
commit b9e7273ac7
2 changed files with 8 additions and 17 deletions

View File

@ -63,7 +63,7 @@
<div class="form-group col-md-12 form-group-custom"> <div class="form-group col-md-12 form-group-custom">
<div class="col-md-3"></div> <div class="col-md-3"></div>
<div class="col-md-9"> <div class="col-md-9">
<button type="button" class="btn btn-default" ng-disabled="vm.notAvailable || !vm.pingAvailable" ng-click="vm.pingDestination()" loading-progress hide-target="false" toggle-in-progress="vm.pingTIP">// 'test_connection' | tr //</button> <button type="button" class="btn btn-default" ng-disabled="//vm.notAvailable//" ng-click="vm.pingDestination()" loading-progress hide-target="false" toggle-in-progress="vm.pingTIP">// 'test_connection' | tr //</button>
</div> </div>
</div> </div>
<div class="form-group col-md-12 form-group-custom"> <div class="form-group col-md-12 form-group-custom">
@ -75,7 +75,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button ng-show="vm.editable" type="submit" class="btn btn-primary" id="btnOk" ng-click="vm.save(destination)">// 'ok' | tr //</button> <button ng-show="vm.editable" type="submit" class="btn btn-primary" id="btnOk" ng-click="form.$valid && vm.save(destination)">// 'ok' | tr //</button>
<button type="button" class="btn btn-default" data-dismiss="modal">// 'close' | tr //</button> <button type="button" class="btn btn-default" data-dismiss="modal">// 'close' | tr //</button>
</div> </div>
</div><!-- /.modal-content --> </div><!-- /.modal-content -->

View File

@ -33,25 +33,20 @@
vm.create = create; vm.create = create;
vm.update = update; vm.update = update;
vm.pingDestination = pingDestination; vm.pingDestination = pingDestination;
vm.editable = true;
vm.notAvailable = false;
vm.pingAvailable = true;
vm.pingMessage = '';
vm.closeError = closeError; vm.closeError = closeError;
vm.toggleErrorMessage = false; vm.toggleErrorMessage = false;
vm.errorMessages = []; vm.errorMessages = [];
vm.pingTIP = false; vm.pingTIP = false;
$scope.$watch('destination.endpoint', function(current) { $scope.$watch('destination.endpoint', function(current) {
if(current) { if(current) {
vm.notAvailable = false; vm.notAvailable = false;
}else{ }else{
vm.notAvailable = true; vm.notAvailable = true;
} }
}); });
function addNew() { function addNew() {
vm.modalTitle = $filter('tr')('add_new_destination', []); vm.modalTitle = $filter('tr')('add_new_destination', []);
@ -69,7 +64,7 @@
.error(getDestinationFailed); .error(getDestinationFailed);
} }
function create(destination) { function create(destination) {
CreateDestinationService(destination.name, destination.endpoint, CreateDestinationService(destination.name, destination.endpoint,
destination.username, destination.password) destination.username, destination.password)
.success(createDestinationSuccess) .success(createDestinationSuccess)
@ -143,7 +138,6 @@
function pingDestination() { function pingDestination() {
vm.pingTIP = true; vm.pingTIP = true;
vm.pingAvailable = false;
var target = { var target = {
'name': vm0.name, 'name': vm0.name,
@ -162,12 +156,10 @@
} }
function pingDestinationSuccess(data, status) { function pingDestinationSuccess(data, status) {
vm.pingAvailable = true;
vm.pingTIP = false; vm.pingTIP = false;
vm.pingMessage = $filter('tr')('successful_ping_target', []); vm.pingMessage = $filter('tr')('successful_ping_target', []);
} }
function pingDestinationFailed(data, status) { function pingDestinationFailed(data, status) {
vm.pingTIP = false; vm.pingTIP = false;
vm.pingMessage = $filter('tr')('failed_to_ping_target', []) + (data && data.length > 0 ? ':' + data : ''); vm.pingMessage = $filter('tr')('failed_to_ping_target', []) + (data && data.length > 0 ? ':' + data : '');
} }
@ -195,9 +187,9 @@
scope.$apply(function(){ scope.$apply(function(){
scope.form.$setPristine(); scope.form.$setPristine();
scope.form.$setUntouched(); scope.form.$setUntouched();
ctrl.notAvailble = false; ctrl.editable = true;
ctrl.pingAvailable = true; ctrl.notAvailble = true;
ctrl.pingMessage = ''; ctrl.pingMessage = '';
ctrl.pingTIP = false; ctrl.pingTIP = false;
@ -218,7 +210,6 @@
ctrl.toggleErrorMessage = true; ctrl.toggleErrorMessage = true;
} }
}, true); }, true);
}); });
}); });