mirror of https://github.com/portainer/portainer
fix(services): use secrets with services only if endpoint API version >= 1.25
parent
02203e7ce5
commit
7c40d2caa9
|
@ -302,10 +302,11 @@ function ($q, $scope, $state, Service, ServiceHelper, SecretHelper, SecretServic
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
$('#loadingViewSpinner').show();
|
$('#loadingViewSpinner').show();
|
||||||
|
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||||
$q.all({
|
$q.all({
|
||||||
volumes: VolumeService.volumes(),
|
volumes: VolumeService.volumes(),
|
||||||
networks: NetworkService.retrieveSwarmNetworks(),
|
networks: NetworkService.retrieveSwarmNetworks(),
|
||||||
secrets: SecretService.secrets()
|
secrets: apiVersion >= 1.25 ? SecretService.secrets() : []
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
$scope.availableVolumes = data.volumes;
|
$scope.availableVolumes = data.volumes;
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
<li class="interactive"><a data-target="#network" data-toggle="tab">Network</a></li>
|
<li class="interactive"><a data-target="#network" data-toggle="tab">Network</a></li>
|
||||||
<li class="interactive"><a data-target="#labels" data-toggle="tab">Labels</a></li>
|
<li class="interactive"><a data-target="#labels" data-toggle="tab">Labels</a></li>
|
||||||
<li class="interactive"><a data-target="#update-config" data-toggle="tab">Update config</a></li>
|
<li class="interactive"><a data-target="#update-config" data-toggle="tab">Update config</a></li>
|
||||||
<li class="interactive"><a data-target="#secrets" data-toggle="tab" ng-if="applicationState.endpoint.apiVersion >= 1.25">Secrets</a></li>
|
<li class="interactive" ng-if="applicationState.endpoint.apiVersion >= 1.25"><a data-target="#secrets" data-toggle="tab">Secrets</a></li>
|
||||||
<li class="interactive"><a data-target="#placement" data-toggle="tab">Placement</a></li>
|
<li class="interactive"><a data-target="#placement" data-toggle="tab">Placement</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- tab-content -->
|
<!-- tab-content -->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div ng-if="service.ServicePreferences && applicationState.endpoint.apiVersion >= 1.30" id="service-placement-preferences">
|
<div ng-if="service.ServicePreferences" id="service-placement-preferences">
|
||||||
<rd-widget>
|
<rd-widget>
|
||||||
<rd-widget-header icon="fa-tasks" title="Placement preferences">
|
<rd-widget-header icon="fa-tasks" title="Placement preferences">
|
||||||
<div class="nopadding">
|
<div class="nopadding">
|
||||||
|
|
|
@ -113,11 +113,11 @@
|
||||||
<li><a href ng-click="goToItem('service-network-specs')">Network & published ports</a></li>
|
<li><a href ng-click="goToItem('service-network-specs')">Network & published ports</a></li>
|
||||||
<li><a href ng-click="goToItem('service-resources')">Resource limits & reservations</a></li>
|
<li><a href ng-click="goToItem('service-resources')">Resource limits & reservations</a></li>
|
||||||
<li><a href ng-click="goToItem('service-placement-constraints')">Placement constraints</a></li>
|
<li><a href ng-click="goToItem('service-placement-constraints')">Placement constraints</a></li>
|
||||||
<li><a href ng-click="goToItem('service-placement-preferences')" ng-if="applicationState.endpoint.apiVersion >= 1.30">Placement preferences</a></li>
|
<li ng-if="applicationState.endpoint.apiVersion >= 1.30"><a href ng-click="goToItem('service-placement-preferences')">Placement preferences</a></li>
|
||||||
<li><a href ng-click="goToItem('service-restart-policy')">Restart policy</a></li>
|
<li><a href ng-click="goToItem('service-restart-policy')">Restart policy</a></li>
|
||||||
<li><a href ng-click="goToItem('service-update-config')">Update configuration</a></li>
|
<li><a href ng-click="goToItem('service-update-config')">Update configuration</a></li>
|
||||||
<li><a href ng-click="goToItem('service-labels')">Service labels</a></li>
|
<li><a href ng-click="goToItem('service-labels')">Service labels</a></li>
|
||||||
<li><a href ng-click="goToItem('service-secrets')">Secrets</a></li>
|
<li ng-if="applicationState.endpoint.apiVersion >= 1.25"><a href ng-click="goToItem('service-secrets')">Secrets</a></li>
|
||||||
<li><a href ng-click="goToItem('service-tasks')">Tasks</a></li>
|
<li><a href ng-click="goToItem('service-tasks')">Tasks</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</rd-widget-body>
|
</rd-widget-body>
|
||||||
|
@ -160,11 +160,11 @@
|
||||||
<h3 id="service-specs">Service specification</h3>
|
<h3 id="service-specs">Service specification</h3>
|
||||||
<div id="service-resources" class="padding-top" ng-include="'app/components/service/includes/resources.html'"></div>
|
<div id="service-resources" class="padding-top" ng-include="'app/components/service/includes/resources.html'"></div>
|
||||||
<div id="service-placement-constraints" class="padding-top" ng-include="'app/components/service/includes/constraints.html'"></div>
|
<div id="service-placement-constraints" class="padding-top" ng-include="'app/components/service/includes/constraints.html'"></div>
|
||||||
<div id="service-placement-preferences" class="padding-top" ng-include="'app/components/service/includes/placementPreferences.html'"></div>
|
<div id="service-placement-preferences" ng-if="applicationState.endpoint.apiVersion >= 1.30" class="padding-top" ng-include="'app/components/service/includes/placementPreferences.html'"></div>
|
||||||
<div id="service-restart-policy" class="padding-top" ng-include="'app/components/service/includes/restart.html'"></div>
|
<div id="service-restart-policy" class="padding-top" ng-include="'app/components/service/includes/restart.html'"></div>
|
||||||
<div id="service-update-config" class="padding-top" ng-include="'app/components/service/includes/updateconfig.html'"></div>
|
<div id="service-update-config" class="padding-top" ng-include="'app/components/service/includes/updateconfig.html'"></div>
|
||||||
<div id="service-labels" class="padding-top" ng-include="'app/components/service/includes/servicelabels.html'"></div>
|
<div id="service-labels" class="padding-top" ng-include="'app/components/service/includes/servicelabels.html'"></div>
|
||||||
<div id="service-secrets" class="padding-top" ng-include="'app/components/service/includes/secrets.html'"></div>
|
<div id="service-secrets" ng-if="applicationState.endpoint.apiVersion >= 1.25" class="padding-top" ng-include="'app/components/service/includes/secrets.html'"></div>
|
||||||
<div id="service-tasks" class="padding-top" ng-include="'app/components/service/includes/tasks.html'"></div>
|
<div id="service-tasks" class="padding-top" ng-include="'app/components/service/includes/tasks.html'"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
angular.module('service', [])
|
angular.module('service', [])
|
||||||
.controller('ServiceController', ['$q', '$scope', '$stateParams', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'Secret', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService',
|
.controller('ServiceController', ['$q', '$scope', '$stateParams', '$state', '$location', '$timeout', '$anchorScroll', 'ServiceService', 'SecretService', 'SecretHelper', 'Service', 'ServiceHelper', 'LabelHelper', 'TaskService', 'NodeService', 'Notifications', 'Pagination', 'ModalService',
|
||||||
function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll, ServiceService, Secret, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) {
|
function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll, ServiceService, SecretService, SecretHelper, Service, ServiceHelper, LabelHelper, TaskService, NodeService, Notifications, Pagination, ModalService) {
|
||||||
|
|
||||||
$scope.state = {};
|
$scope.state = {};
|
||||||
$scope.state.pagination_count = Pagination.getPaginationCount('service_tasks');
|
$scope.state.pagination_count = Pagination.getPaginationCount('service_tasks');
|
||||||
|
@ -288,7 +288,7 @@ function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll,
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
$('#loadingViewSpinner').show();
|
$('#loadingViewSpinner').show();
|
||||||
|
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||||
ServiceService.service($stateParams.id)
|
ServiceService.service($stateParams.id)
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
var service = data;
|
var service = data;
|
||||||
|
@ -304,21 +304,17 @@ function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll,
|
||||||
return $q.all({
|
return $q.all({
|
||||||
tasks: TaskService.serviceTasks(service.Name),
|
tasks: TaskService.serviceTasks(service.Name),
|
||||||
nodes: NodeService.nodes(),
|
nodes: NodeService.nodes(),
|
||||||
secrets: Secret.query({}).$promise
|
secrets: apiVersion >= 1.25 ? SecretService.secrets() : []
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(function success(data) {
|
.then(function success(data) {
|
||||||
$scope.tasks = data.tasks;
|
$scope.tasks = data.tasks;
|
||||||
$scope.nodes = data.nodes;
|
$scope.nodes = data.nodes;
|
||||||
|
$scope.secrets = data.secrets;
|
||||||
$scope.secrets = data.secrets.map(function (secret) {
|
|
||||||
return new SecretViewModel(secret);
|
|
||||||
});
|
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$anchorScroll();
|
$anchorScroll();
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(function error(err) {
|
.catch(function error(err) {
|
||||||
$scope.secrets = [];
|
$scope.secrets = [];
|
||||||
|
@ -329,20 +325,6 @@ function ($q, $scope, $stateParams, $state, $location, $timeout, $anchorScroll,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchSecrets() {
|
|
||||||
$('#loadSecretsSpinner').show();
|
|
||||||
Secret.query({}, function (d) {
|
|
||||||
$scope.secrets = d.map(function (secret) {
|
|
||||||
return new SecretViewModel(secret);
|
|
||||||
});
|
|
||||||
$('#loadSecretsSpinner').hide();
|
|
||||||
}, function(e) {
|
|
||||||
$('#loadSecretsSpinner').hide();
|
|
||||||
Notifications.error('Failure', e, 'Unable to retrieve secrets');
|
|
||||||
$scope.secrets = [];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.updateServiceAttribute = function updateServiceAttribute(service, name) {
|
$scope.updateServiceAttribute = function updateServiceAttribute(service, name) {
|
||||||
if (service[name] !== originalService[name] || !(name in originalService)) {
|
if (service[name] !== originalService[name] || !(name in originalService)) {
|
||||||
service.hasChanges = true;
|
service.hasChanges = true;
|
||||||
|
|
Loading…
Reference in New Issue