1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

feat(ux): replace spinners (#1383)

This commit is contained in:
Anthony Lapenna 2017-11-12 20:27:28 +01:00 committed by GitHub
parent 9bef7cd69f
commit d68708add7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
133 changed files with 701 additions and 1061 deletions

View file

@ -11,7 +11,8 @@ function ($q, $scope, $state, PluginService, Notifications, NetworkService, Labe
};
$scope.state = {
formValidationError: ''
formValidationError: '',
deploymentInProgress: false
};
$scope.availableNetworkDrivers = [];
@ -89,18 +90,16 @@ function ($q, $scope, $state, PluginService, Notifications, NetworkService, Labe
}
$scope.create = function () {
$('#createResourceSpinner').show();
var networkConfiguration = prepareConfiguration();
var accessControlData = $scope.formValues.AccessControlData;
var userDetails = Authentication.getUserDetails();
var isAdmin = userDetails.role === 1 ? true : false;
if (!validateForm(accessControlData, isAdmin)) {
$('#createResourceSpinner').hide();
return;
}
$scope.state.deploymentInProgress = true;
NetworkService.create(networkConfiguration)
.then(function success(data) {
var networkIdentifier = data.Id;
@ -115,12 +114,11 @@ function ($q, $scope, $state, PluginService, Notifications, NetworkService, Labe
Notifications.error('Failure', err, 'An error occured during network creation');
})
.finally(function final() {
$('#createResourceSpinner').hide();
$scope.state.deploymentInProgress = false;
});
};
function initView() {
$('#loadingViewSpinner').show();
var endpointProvider = $scope.applicationState.endpoint.mode.provider;
var apiVersion = $scope.applicationState.endpoint.apiVersion;
if(endpointProvider !== 'DOCKER_SWARM') {
@ -130,9 +128,6 @@ function ($q, $scope, $state, PluginService, Notifications, NetworkService, Labe
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve network drivers');
})
.finally(function final() {
$('#loadingViewSpinner').hide();
});
}
}

View file

@ -1,7 +1,5 @@
<rd-header>
<rd-header-title title="Create network">
<i id="loadingViewSpinner" class="fa fa-cog fa-spin"></i>
</rd-header-title>
<rd-header-title title="Create network"></rd-header-title>
<rd-header-content>
<a ui-sref="networks">Networks</a> &gt; Add network
</rd-header-content>
@ -130,8 +128,10 @@
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="button" class="btn btn-primary btn-sm" ng-disabled="!config.Name" ng-click="create()">Create network</button>
<a type="button" class="btn btn-default btn-sm" ui-sref="networks">Cancel</a>
<button type="button" class="btn btn-primary btn-sm" ng-disabled="state.deploymentInProgress || !config.Name" ng-click="create()" button-spinner="state.deploymentInProgress">
<span ng-hide="state.deploymentInProgress">Create the network</span>
<span ng-show="state.deploymentInProgress">Creating network...</span>
</button>
<i id="createResourceSpinner" class="fa fa-cog fa-spin" style="margin-left: 5px; display: none;"></i>
<span class="text-danger" ng-if="state.formValidationError" style="margin-left: 5px;">{{ state.formValidationError }}</span>
</div>