Merge pull request #526 from wknet123/master

Update for destination interaction refinements.
This commit is contained in:
kun wang 2016-07-13 13:36:14 +08:00 committed by GitHub
commit a86a82dba3
2 changed files with 16 additions and 23 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,26 +33,23 @@
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) { $timeout(function(){
if(current) { $scope.$watch('destination.endpoint', function(current) {
vm.notAvailable = false; if(current) {
}else{ vm.notAvailable = false;
vm.notAvailable = true; }else{
} vm.notAvailable = true;
}
});
}); });
function addNew() { function addNew() {
vm.modalTitle = $filter('tr')('add_new_destination', []); vm.modalTitle = $filter('tr')('add_new_destination', []);
vm0.name = ''; vm0.name = '';
@ -69,7 +66,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 +140,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 +158,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 +189,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 +212,6 @@
ctrl.toggleErrorMessage = true; ctrl.toggleErrorMessage = true;
} }
}, true); }, true);
}); });
}); });