1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 07:15:23 +02:00

feat(storidge): introduce endpoint extensions and proxy Storidge API (#1661)

This commit is contained in:
Anthony Lapenna 2018-02-23 03:10:26 +01:00 committed by GitHub
parent b5e256c967
commit eb43579378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 571 additions and 372 deletions

View file

@ -7,7 +7,7 @@ angular.module('portainer.docker')
},
{
info: { method: 'GET', params: { action: 'info' }, ignoreLoadingBar: true },
version: { method: 'GET', params: { action: 'version' }, ignoreLoadingBar: true },
version: { method: 'GET', params: { action: 'version' }, ignoreLoadingBar: true, timeout: 4500 },
events: {
method: 'GET', params: { action: 'events', since: '@since', until: '@until' },
isArray: true, transformResponse: jsonObjectsToArrayHandler

View file

@ -1,6 +1,6 @@
angular.module('portainer.docker')
.controller('CreateVolumeController', ['$q', '$scope', '$state', 'VolumeService', 'PluginService', 'ResourceControlService', 'Authentication', 'Notifications', 'FormValidator', 'ExtensionManager',
function ($q, $scope, $state, VolumeService, PluginService, ResourceControlService, Authentication, Notifications, FormValidator, ExtensionManager) {
.controller('CreateVolumeController', ['$q', '$scope', '$state', 'VolumeService', 'PluginService', 'ResourceControlService', 'Authentication', 'Notifications', 'FormValidator',
function ($q, $scope, $state, VolumeService, PluginService, ResourceControlService, Authentication, Notifications, FormValidator) {
$scope.formValues = {
Driver: 'local',
@ -88,11 +88,5 @@ function ($q, $scope, $state, VolumeService, PluginService, ResourceControlServi
}
}
ExtensionManager.init()
.then(function success(data) {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to initialize extensions');
});
initView();
}]);

View file

@ -1,52 +0,0 @@
angular.module('extension.storidge')
.factory('StoridgeCluster', ['$http', 'StoridgeManager', function StoridgeClusterFactory($http, StoridgeManager) {
'use strict';
var service = {};
service.queryEvents = function() {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/events',
skipAuthorization: true,
timeout: 4500,
ignoreLoadingBar: true
});
};
service.queryVersion = function() {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/version',
skipAuthorization: true
});
};
service.queryInfo = function() {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/info',
skipAuthorization: true,
timeout: 4500,
ignoreLoadingBar: true
});
};
service.reboot = function() {
return $http({
method: 'POST',
url: StoridgeManager.StoridgeAPIURL() + '/cluster/reboot',
skipAuthorization: true
});
};
service.shutdown = function() {
return $http({
method: 'POST',
url: StoridgeManager.StoridgeAPIURL() + '/cluster/shutdown',
skipAuthorization: true
});
};
return service;
}]);

View file

@ -1,24 +0,0 @@
angular.module('extension.storidge')
.factory('StoridgeNodes', ['$http', 'StoridgeManager', function StoridgeNodesFactory($http, StoridgeManager) {
'use strict';
var service = {};
service.query = function() {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/nodes',
skipAuthorization: true
});
};
service.inspect = function(id) {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/nodes/' + id,
skipAuthorization: true
});
};
return service;
}]);

View file

@ -1,52 +0,0 @@
angular.module('extension.storidge')
.factory('StoridgeProfiles', ['$http', 'StoridgeManager', function StoridgeProfilesFactory($http, StoridgeManager) {
'use strict';
var service = {};
service.create = function(payload) {
return $http({
method: 'POST',
url: StoridgeManager.StoridgeAPIURL() + '/profiles',
data: payload,
headers: { 'Content-type': 'application/json' },
skipAuthorization: true
});
};
service.update = function(id, payload) {
return $http({
method: 'PUT',
url: StoridgeManager.StoridgeAPIURL() + '/profiles/' + id,
data: payload,
headers: { 'Content-type': 'application/json' },
skipAuthorization: true
});
};
service.query = function() {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/profiles',
skipAuthorization: true
});
};
service.inspect = function(id) {
return $http({
method: 'GET',
url: StoridgeManager.StoridgeAPIURL() + '/profiles/' + id,
skipAuthorization: true
});
};
service.delete = function(id) {
return $http({
method: 'DELETE',
url: StoridgeManager.StoridgeAPIURL() + '/profiles/' + id,
skipAuthorization: true
});
};
return service;
}]);

View file

@ -0,0 +1,20 @@
angular.module('extension.storidge')
.factory('Storidge', ['$resource', 'API_ENDPOINT_ENDPOINTS', 'EndpointProvider', function StoridgeFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
'use strict';
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/extensions/storidge/:resource/:id/:action', {
endpointId: EndpointProvider.endpointID
},
{
rebootCluster: { method: 'POST', params: { resource: 'cluster', action: 'reboot' } },
shutdownCluster: { method: 'POST', params: { resource: 'cluster', action: 'shutdown' } },
queryEvents: { method: 'GET', params: { resource: 'events' }, timeout: 4500, ignoreLoadingBar: true, isArray: true },
getVersion: { method: 'GET', params: { resource: 'version' } },
getInfo: { method: 'GET', params: { resource: 'info' }, timeout: 4500, ignoreLoadingBar: true },
queryNodes: { method: 'GET', params: { resource: 'nodes' } },
queryProfiles: { method: 'GET', params: { resource: 'profiles' } },
getProfile: { method: 'GET', params: { resource: 'profiles' } },
createProfile: { method: 'POST', params: { resource: 'profiles' } },
updateProfile: { method: 'PUT', params: { resource: 'profiles', id: '@name' } },
deleteProfile: { method: 'DELETE', params: { resource: 'profiles' } }
});
}]);

View file

@ -1,22 +1,22 @@
angular.module('extension.storidge')
.factory('StoridgeClusterService', ['$q', 'StoridgeCluster', function StoridgeClusterServiceFactory($q, StoridgeCluster) {
.factory('StoridgeClusterService', ['$q', 'Storidge', function StoridgeClusterServiceFactory($q, Storidge) {
'use strict';
var service = {};
service.reboot = function() {
return StoridgeCluster.reboot();
return Storidge.rebootCluster().$promise;
};
service.shutdown = function() {
return StoridgeCluster.shutdown();
return Storidge.shutdownCluster().$promise;
};
service.info = function() {
var deferred = $q.defer();
StoridgeCluster.queryInfo()
.then(function success(response) {
var info = new StoridgeInfoModel(response.data);
Storidge.getInfo().$promise
.then(function success(data) {
var info = new StoridgeInfoModel(data);
deferred.resolve(info);
})
.catch(function error(err) {
@ -29,9 +29,9 @@ angular.module('extension.storidge')
service.version = function() {
var deferred = $q.defer();
StoridgeCluster.queryVersion()
.then(function success(response) {
var version = response.data.version;
Storidge.getVersion().$promise
.then(function success(data) {
var version = data.version;
deferred.resolve(version);
})
.catch(function error(err) {
@ -44,9 +44,9 @@ angular.module('extension.storidge')
service.events = function() {
var deferred = $q.defer();
StoridgeCluster.queryEvents()
.then(function success(response) {
var events = response.data.map(function(item) {
Storidge.queryEvents().$promise
.then(function success(data) {
var events = data.map(function(item) {
return new StoridgeEventModel(item);
});
deferred.resolve(events);

View file

@ -1,48 +0,0 @@
angular.module('extension.storidge')
.factory('StoridgeManager', ['$q', 'LocalStorage', 'SystemService', function StoridgeManagerFactory($q, LocalStorage, SystemService) {
'use strict';
var service = {
API: ''
};
service.init = function() {
var deferred = $q.defer();
var storedAPIURL = LocalStorage.getStoridgeAPIURL();
if (storedAPIURL) {
service.API = storedAPIURL;
deferred.resolve();
} else {
SystemService.info()
.then(function success(data) {
var endpointAddress = LocalStorage.getEndpointPublicURL();
var storidgeAPIURL = '';
if (endpointAddress) {
storidgeAPIURL = 'http://' + endpointAddress + ':8282';
} else {
var managerIP = data.Swarm.NodeAddr;
storidgeAPIURL = 'http://' + managerIP + ':8282';
}
service.API = storidgeAPIURL;
LocalStorage.storeStoridgeAPIURL(storidgeAPIURL);
deferred.resolve();
})
.catch(function error(err) {
deferred.reject({ msg: 'Unable to retrieve Storidge API URL', err: err });
});
}
return deferred.promise;
};
service.reset = function() {
LocalStorage.clearStoridgeAPIURL();
};
service.StoridgeAPIURL = function() {
return service.API;
};
return service;
}]);

View file

@ -1,14 +1,14 @@
angular.module('extension.storidge')
.factory('StoridgeNodeService', ['$q', 'StoridgeNodes', function StoridgeNodeServiceFactory($q, StoridgeNodes) {
.factory('StoridgeNodeService', ['$q', 'Storidge', function StoridgeNodeServiceFactory($q, Storidge) {
'use strict';
var service = {};
service.nodes = function() {
var deferred = $q.defer();
StoridgeNodes.query()
.then(function success(response) {
var nodeData = response.data.nodes;
Storidge.queryNodes().$promise
.then(function success(data) {
var nodeData = data.nodes;
var nodes = [];
for (var key in nodeData) {

View file

@ -1,28 +1,28 @@
angular.module('extension.storidge')
.factory('StoridgeProfileService', ['$q', 'StoridgeProfiles', function StoridgeProfileServiceFactory($q, StoridgeProfiles) {
.factory('StoridgeProfileService', ['$q', 'Storidge', function StoridgeProfileServiceFactory($q, Storidge) {
'use strict';
var service = {};
service.create = function(model) {
var payload = new StoridgeCreateProfileRequest(model);
return StoridgeProfiles.create(payload);
return Storidge.createProfile(payload).$promise;
};
service.update = function(model) {
var payload = new StoridgeCreateProfileRequest(model);
return StoridgeProfiles.update(model.Name, payload);
return Storidge.updateProfile(payload).$promise;
};
service.delete = function(profileName) {
return StoridgeProfiles.delete(profileName);
return Storidge.deleteProfile({ id: profileName }).$promise;
};
service.profile = function(profileName) {
var deferred = $q.defer();
StoridgeProfiles.inspect(profileName)
.then(function success(response) {
var profile = new StoridgeProfileModel(profileName, response.data);
Storidge.getProfile({ id: profileName }).$promise
.then(function success(data) {
var profile = new StoridgeProfileModel(profileName, data);
deferred.resolve(profile);
})
.catch(function error(err) {
@ -35,9 +35,9 @@ angular.module('extension.storidge')
service.profiles = function() {
var deferred = $q.defer();
StoridgeProfiles.query()
.then(function success(response) {
var profiles = response.data.profiles.map(function (item) {
Storidge.queryProfiles().$promise
.then(function success(data) {
var profiles = data.profiles.map(function (item) {
return new StoridgeProfileListModel(item);
});
deferred.resolve(profiles);

View file

@ -1,6 +1,6 @@
angular.module('extension.storidge')
.controller('StoridgeClusterController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeClusterService', 'StoridgeNodeService', 'StoridgeManager', 'ModalService',
function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNodeService, StoridgeManager, ModalService) {
.controller('StoridgeClusterController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeClusterService', 'StoridgeNodeService', 'ModalService',
function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNodeService, ModalService) {
$scope.state = {
shutdownInProgress: false,
@ -44,30 +44,20 @@ function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNod
function shutdownCluster() {
$scope.state.shutdownInProgress = true;
StoridgeClusterService.shutdown()
.then(function success(data) {
Notifications.success('Cluster successfully shutdown');
$state.go('docker.dashboard');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to shutdown cluster');
})
.finally(function final() {
$scope.state.shutdownInProgress = false;
Notifications.success('Cluster successfully shutdown');
$state.go('docker.dashboard');
});
}
function rebootCluster() {
$scope.state.rebootInProgress = true;
StoridgeClusterService.reboot()
.then(function success(data) {
Notifications.success('Cluster successfully rebooted');
$state.reload();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to reboot cluster');
})
.finally(function final() {
$scope.state.rebootInProgress = false;
Notifications.success('Cluster successfully rebooted');
$state.reload();
});
}
@ -87,11 +77,5 @@ function ($q, $scope, $state, Notifications, StoridgeClusterService, StoridgeNod
});
}
StoridgeManager.init()
.then(function success() {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
});
initView();
}]);

View file

@ -1,6 +1,6 @@
angular.module('extension.storidge')
.controller('StoridgeMonitorController', ['$q', '$scope', '$interval', '$document', 'Notifications', 'StoridgeClusterService', 'StoridgeChartService', 'StoridgeManager', 'ModalService',
function ($q, $scope, $interval, $document, Notifications, StoridgeClusterService, StoridgeChartService, StoridgeManager, ModalService) {
.controller('StoridgeMonitorController', ['$q', '$scope', '$interval', '$document', 'Notifications', 'StoridgeClusterService', 'StoridgeChartService', 'ModalService',
function ($q, $scope, $interval, $document, Notifications, StoridgeClusterService, StoridgeChartService, ModalService) {
$scope.$on('$destroy', function() {
stopRepeater();
@ -98,11 +98,5 @@ function ($q, $scope, $interval, $document, Notifications, StoridgeClusterServic
});
}
StoridgeManager.init()
.then(function success() {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
});
initView();
}]);

View file

@ -1,6 +1,6 @@
angular.module('extension.storidge')
.controller('StoridgeCreateProfileController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeProfileService', 'StoridgeManager',
function ($scope, $state, $transition$, Notifications, StoridgeProfileService, StoridgeManager) {
.controller('StoridgeCreateProfileController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeProfileService',
function ($scope, $state, $transition$, Notifications, StoridgeProfileService) {
$scope.state = {
NoLimit: true,
@ -62,11 +62,5 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService, S
$scope.model = profile;
}
StoridgeManager.init()
.then(function success() {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
});
initView();
}]);

View file

@ -1,6 +1,6 @@
angular.module('extension.storidge')
.controller('StoridgeProfileController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeProfileService', 'StoridgeManager', 'ModalService',
function ($scope, $state, $transition$, Notifications, StoridgeProfileService, StoridgeManager, ModalService) {
.controller('StoridgeProfileController', ['$scope', '$state', '$transition$', 'Notifications', 'StoridgeProfileService', 'ModalService',
function ($scope, $state, $transition$, Notifications, StoridgeProfileService, ModalService) {
$scope.state = {
NoLimit: false,
@ -88,11 +88,6 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService, S
});
}
StoridgeManager.init()
.then(function success() {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
});
initView();
}]);

View file

@ -1,6 +1,6 @@
angular.module('extension.storidge')
.controller('StoridgeProfilesController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeProfileService', 'StoridgeManager',
function ($q, $scope, $state, Notifications, StoridgeProfileService, StoridgeManager) {
.controller('StoridgeProfilesController', ['$q', '$scope', '$state', 'Notifications', 'StoridgeProfileService',
function ($q, $scope, $state, Notifications, StoridgeProfileService) {
$scope.state = {
actionInProgress: false
@ -60,11 +60,5 @@ function ($q, $scope, $state, Notifications, StoridgeProfileService, StoridgeMan
});
}
StoridgeManager.init()
.then(function success() {
initView();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to communicate with Storidge API');
});
initView();
}]);

View file

@ -0,0 +1,10 @@
angular.module('portainer.app')
.factory('Extensions', ['$resource', 'EndpointProvider', 'API_ENDPOINT_ENDPOINTS', function Extensions($resource, EndpointProvider, API_ENDPOINT_ENDPOINTS) {
'use strict';
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/extensions', {
endpointId: EndpointProvider.endpointID
},
{
register: { method: 'POST', params: { endpointId: '@endpointId' } }
});
}]);

View file

@ -66,6 +66,7 @@ angular.module('portainer.app')
TLSSkipVerify: TLSSkipVerify,
TLSSkipClientVerify: TLSSkipClientVerify
};
var deferred = $q.defer();
Endpoints.create({}, endpoint).$promise
.then(function success(data) {
@ -85,6 +86,7 @@ angular.module('portainer.app')
deferred.notify({upload: false});
deferred.reject({msg: 'Unable to upload TLS certs', err: err});
});
return deferred.promise;
};

View file

@ -0,0 +1,17 @@
angular.module('portainer.app')
.factory('ExtensionService', ['Extensions', function ExtensionServiceFactory(Extensions) {
'use strict';
var service = {};
service.registerStoridgeExtension = function(endpointId, url) {
var payload = {
endpointId: endpointId,
Type: 1,
URL: url
};
return Extensions.register(payload).$promise;
};
return service;
}]);

View file

@ -1,35 +1,71 @@
angular.module('portainer.app')
.factory('ExtensionManager', ['$q', 'PluginService', 'StoridgeManager', function ExtensionManagerFactory($q, PluginService, StoridgeManager) {
.factory('ExtensionManager', ['$q', 'PluginService', 'SystemService', 'ExtensionService',
function ExtensionManagerFactory($q, PluginService, SystemService, ExtensionService) {
'use strict';
var service = {};
service.init = function() {
return $q.all(
StoridgeManager.init()
);
};
service.reset = function() {
StoridgeManager.reset();
};
service.extensions = function() {
service.initEndpointExtensions = function(endpointId) {
var deferred = $q.defer();
var extensions = [];
PluginService.volumePlugins()
SystemService.version()
.then(function success(data) {
var volumePlugins = data;
if (_.includes(volumePlugins, 'cio:latest')) {
extensions.push('storidge');
}
var endpointAPIVersion = parseFloat(data.ApiVersion);
return $q.all([
endpointAPIVersion >= 1.25 ? initStoridgeExtension(endpointId): null
]);
})
.finally(function final() {
.then(function success(data) {
var extensions = data.filter(function filterNull(x) {
return x;
});
deferred.resolve(extensions);
})
.catch(function error(err) {
deferred.reject({ msg: 'Unable to connect to the Docker environment', err: err });
});
return deferred.promise;
};
function initStoridgeExtension(endpointId) {
var deferred = $q.defer();
PluginService.volumePlugins()
.then(function success(data) {
var volumePlugins = data;
if (_.includes(volumePlugins, 'cio:latest')) {
return registerStoridgeUsingSwarmManagerIP(endpointId);
}
})
.then(function success(data) {
deferred.resolve(data);
})
.catch(function error(err) {
deferred.reject({ msg: 'An error occured during Storidge extension check', err: err });
});
return deferred.promise;
}
function registerStoridgeUsingSwarmManagerIP(endpointId) {
var deferred = $q.defer();
SystemService.info()
.then(function success(data) {
var managerIP = data.Swarm.NodeAddr;
var storidgeAPIURL = 'tcp://' + managerIP + ':8282';
return ExtensionService.registerStoridgeExtension(endpointId, storidgeAPIURL);
})
.then(function success(data) {
deferred.resolve(data);
})
.catch(function error(err) {
deferred.reject({ msg: 'An error occured during Storidge extension initialization', err: err });
});
return deferred.promise;
}
return service;
}]);

View file

@ -41,15 +41,6 @@ angular.module('portainer.app')
getPaginationLimit: function(key) {
return localStorageService.cookie.get('pagination_' + key);
},
storeStoridgeAPIURL: function(url) {
localStorageService.set('STORIDGE_API_URL', url);
},
getStoridgeAPIURL: function() {
return localStorageService.get('STORIDGE_API_URL');
},
clearStoridgeAPIURL: function() {
return localStorageService.remove('STORIDGE_API_URL');
},
getDataTableOrder: function(key) {
return localStorageService.get('datatable_order_' + key);
},

View file

@ -1,5 +1,6 @@
angular.module('portainer.app')
.factory('StateManager', ['$q', 'SystemService', 'InfoHelper', 'LocalStorage', 'SettingsService', 'StatusService', 'ExtensionManager', 'APPLICATION_CACHE_VALIDITY', function StateManagerFactory($q, SystemService, InfoHelper, LocalStorage, SettingsService, StatusService, ExtensionManager, APPLICATION_CACHE_VALIDITY) {
.factory('StateManager', ['$q', 'SystemService', 'InfoHelper', 'LocalStorage', 'SettingsService', 'StatusService', 'APPLICATION_CACHE_VALIDITY',
function StateManagerFactory($q, SystemService, InfoHelper, LocalStorage, SettingsService, StatusService, APPLICATION_CACHE_VALIDITY) {
'use strict';
var manager = {};
@ -107,8 +108,24 @@ angular.module('portainer.app')
return deferred.promise;
};
manager.updateEndpointState = function(loading) {
function assignExtensions(endpointExtensions) {
console.log(JSON.stringify(endpointExtensions, null, 4));
var extensions = [];
for (var i = 0; i < endpointExtensions.length; i++) {
var extension = endpointExtensions[i];
if (extension.Type === 1) {
extensions.push('storidge');
}
}
return extensions;
}
manager.updateEndpointState = function(loading, extensions) {
var deferred = $q.defer();
if (loading) {
state.loading = true;
}
@ -121,10 +138,7 @@ angular.module('portainer.app')
var endpointAPIVersion = parseFloat(data.version.ApiVersion);
state.endpoint.mode = endpointMode;
state.endpoint.apiVersion = endpointAPIVersion;
return $q.when(endpointAPIVersion < 1.25 || ExtensionManager.extensions());
})
.then(function success(data) {
state.endpoint.extensions = data instanceof Array ? data : [];
state.endpoint.extensions = assignExtensions(extensions);
LocalStorage.storeEndpointState(state.endpoint);
deferred.resolve();
})

View file

@ -18,7 +18,7 @@ function ($scope, $state, $transition$, $window, $timeout, $sanitize, Authentica
if (!endpointID) {
EndpointProvider.setEndpointID(endpoint.Id);
}
StateManager.updateEndpointState(true)
StateManager.updateEndpointState(true, endpoint.Extensions)
.then(function success(data) {
$state.go('docker.dashboard');
})

View file

@ -1,6 +1,6 @@
angular.module('portainer.app')
.controller('EndpointsController', ['$scope', '$state', '$filter', 'EndpointService', 'Notifications',
function ($scope, $state, $filter, EndpointService, Notifications) {
.controller('EndpointsController', ['$scope', '$state', '$filter', 'EndpointService', 'Notifications', 'ExtensionManager', 'EndpointProvider',
function ($scope, $state, $filter, EndpointService, Notifications, ExtensionManager, EndpointProvider) {
$scope.state = {
uploadInProgress: false,
actionInProgress: false
@ -31,9 +31,22 @@ function ($scope, $state, $filter, EndpointService, Notifications) {
var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey;
$scope.state.actionInProgress = true;
EndpointService.createRemoteEndpoint(name, URL, PublicURL, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile).then(function success(data) {
Notifications.success('Endpoint created', name);
$state.reload();
EndpointService.createRemoteEndpoint(name, URL, PublicURL, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
.then(function success(data) {
var currentEndpointId = EndpointProvider.endpointID();
EndpointProvider.setEndpointID(data.Id);
ExtensionManager.initEndpointExtensions(data.Id)
.then(function success(data) {
Notifications.success('Endpoint created', name);
$state.reload();
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to create endpoint');
})
.finally(function final() {
$scope.state.actionInProgress = false;
EndpointProvider.setEndpointID(currentEndpointId);
});
}, function error(err) {
$scope.state.uploadInProgress = false;
$scope.state.actionInProgress = false;

View file

@ -30,9 +30,9 @@ function ($scope, $state, $sanitize, Notifications, Authentication, StateManager
if (data.length === 0) {
$state.go('portainer.init.endpoint');
} else {
var endpointID = data[0].Id;
EndpointProvider.setEndpointID(endpointID);
StateManager.updateEndpointState(false)
var endpoint = data[0];
EndpointProvider.setEndpointID(endpoint.Id);
StateManager.updateEndpointState(false, endpoint.Extensions)
.then(function success() {
$state.go('docker.dashboard');
})

View file

@ -1,6 +1,6 @@
angular.module('portainer.app')
.controller('InitEndpointController', ['$scope', '$state', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications',
function ($scope, $state, EndpointService, StateManager, EndpointProvider, Notifications) {
.controller('InitEndpointController', ['$scope', '$state', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications', 'ExtensionManager',
function ($scope, $state, EndpointService, StateManager, EndpointProvider, Notifications, ExtensionManager) {
if (!_.isEmpty($scope.applicationState.endpoint)) {
$state.go('docker.dashboard');
@ -35,7 +35,11 @@ function ($scope, $state, EndpointService, StateManager, EndpointProvider, Notif
.then(function success(data) {
endpointID = data.Id;
EndpointProvider.setEndpointID(endpointID);
return StateManager.updateEndpointState(false);
return ExtensionManager.initEndpointExtensions(endpointID);
})
.then(function success(data) {
var extensions = data;
return StateManager.updateEndpointState(false, extensions);
})
.then(function success(data) {
$state.go('docker.dashboard');
@ -66,7 +70,11 @@ function ($scope, $state, EndpointService, StateManager, EndpointProvider, Notif
.then(function success(data) {
endpointID = data.Id;
EndpointProvider.setEndpointID(endpointID);
return StateManager.updateEndpointState(false);
return ExtensionManager.initEndpointExtensions(endpointID);
})
.then(function success(data) {
var extensions = data;
return StateManager.updateEndpointState(false, extensions);
})
.then(function success(data) {
$state.go('docker.dashboard');

View file

@ -24,7 +24,7 @@
sidebar-toggled-on="toggle"
current-state="$state.current.name"
></docker-sidebar-content>
<li class="sidebar-title" ng-if="applicationState.endpoint.extensions.length > 0 && isAdmin && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">
<li class="sidebar-title" ng-if="applicationState.endpoint.extensions.length > 0">
<span>Extensions</span>
</li>
<li class="sidebar-list" ng-if="applicationState.endpoint.extensions.indexOf('storidge') !== -1 && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER'">

View file

@ -1,6 +1,6 @@
angular.module('portainer.app')
.controller('SidebarController', ['$q', '$scope', '$state', 'Settings', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications', 'Authentication', 'UserService', 'ExtensionManager',
function ($q, $scope, $state, Settings, EndpointService, StateManager, EndpointProvider, Notifications, Authentication, UserService, ExtensionManager) {
.controller('SidebarController', ['$q', '$scope', '$state', 'Settings', 'EndpointService', 'StateManager', 'EndpointProvider', 'Notifications', 'Authentication', 'UserService',
function ($q, $scope, $state, Settings, EndpointService, StateManager, EndpointProvider, Notifications, Authentication, UserService) {
$scope.switchEndpoint = function(endpoint) {
var activeEndpointID = EndpointProvider.endpointID();
@ -8,9 +8,8 @@ function ($q, $scope, $state, Settings, EndpointService, StateManager, EndpointP
EndpointProvider.setEndpointID(endpoint.Id);
EndpointProvider.setEndpointPublicURL(endpoint.PublicURL);
StateManager.updateEndpointState(true)
StateManager.updateEndpointState(true, endpoint.Extensions)
.then(function success() {
ExtensionManager.reset();
$state.go('docker.dashboard');
})
.catch(function error(err) {
@ -47,7 +46,7 @@ function ($q, $scope, $state, Settings, EndpointService, StateManager, EndpointP
$scope.displayExternalContributors = StateManager.getState().application.displayExternalContributors;
$scope.logo = StateManager.getState().application.logo;
$scope.endpoints = [];
EndpointService.endpoints()
.then(function success(data) {
var endpoints = data;