mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 22:05:23 +02:00
feat(templates): remove template management features (#3719)
* feat(api): remove template management features * feat(templates): remove template management features
This commit is contained in:
parent
45f93882d0
commit
5563ff60fc
36 changed files with 26 additions and 965 deletions
|
@ -533,28 +533,6 @@ angular.module('portainer.app', []).config([
|
|||
},
|
||||
};
|
||||
|
||||
var template = {
|
||||
name: 'portainer.templates.template',
|
||||
url: '/:id',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: './views/templates/edit/template.html',
|
||||
controller: 'TemplateController',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
var templateCreation = {
|
||||
name: 'portainer.templates.new',
|
||||
url: '/new',
|
||||
views: {
|
||||
'content@': {
|
||||
templateUrl: './views/templates/create/createtemplate.html',
|
||||
controller: 'CreateTemplateController',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
$stateRegistryProvider.register(root);
|
||||
$stateRegistryProvider.register(portainer);
|
||||
$stateRegistryProvider.register(about);
|
||||
|
@ -595,7 +573,5 @@ angular.module('portainer.app', []).config([
|
|||
$stateRegistryProvider.register(teams);
|
||||
$stateRegistryProvider.register(team);
|
||||
$stateRegistryProvider.register(templates);
|
||||
$stateRegistryProvider.register(template);
|
||||
$stateRegistryProvider.register(templateCreation);
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -3,8 +3,5 @@ angular.module('portainer.app').component('templateItem', {
|
|||
bindings: {
|
||||
model: '=',
|
||||
onSelect: '<',
|
||||
onDelete: '<',
|
||||
showUpdateAction: '<',
|
||||
showDeleteAction: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -28,15 +28,6 @@
|
|||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="text-small">
|
||||
<a ui-sref="portainer.templates.template({ id: $ctrl.model.Id })" class="btn btn-xs btn-primary" ng-click="$event.stopPropagation();" ng-if="$ctrl.showUpdateAction">
|
||||
<i class="fa fa-edit" aria-hidden="true"></i>
|
||||
Update
|
||||
</a>
|
||||
<btn class="btn btn-xs btn-danger" ng-click="$event.stopPropagation(); $ctrl.onDelete($ctrl.model)" ng-if="$ctrl.showDeleteAction">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Delete
|
||||
</btn>
|
||||
</span>
|
||||
</div>
|
||||
<!-- !blocklist-item-line1 -->
|
||||
<!-- blocklist-item-line2 -->
|
||||
|
|
|
@ -7,10 +7,6 @@ angular.module('portainer.app').component('templateList', {
|
|||
templates: '<',
|
||||
tableKey: '@',
|
||||
selectAction: '<',
|
||||
deleteAction: '<',
|
||||
showSwarmStacks: '<',
|
||||
showAddAction: '<',
|
||||
showUpdateAction: '<',
|
||||
showDeleteAction: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -49,10 +49,7 @@
|
|||
<template-item
|
||||
ng-repeat="template in $ctrl.templates | filter: $ctrl.filterByType | filter:$ctrl.filterByCategory | filter:$ctrl.state.textFilter"
|
||||
model="template"
|
||||
show-update-action="$ctrl.showUpdateAction"
|
||||
show-delete-action="$ctrl.showDeleteAction"
|
||||
on-select="($ctrl.selectAction)"
|
||||
on-delete="($ctrl.deleteAction)"
|
||||
></template-item>
|
||||
<div ng-if="!$ctrl.templates" class="text-center text-muted">
|
||||
Loading...
|
||||
|
|
|
@ -9,7 +9,6 @@ export function SettingsViewModel(data) {
|
|||
this.AllowVolumeBrowserForRegularUsers = data.AllowVolumeBrowserForRegularUsers;
|
||||
this.SnapshotInterval = data.SnapshotInterval;
|
||||
this.TemplatesURL = data.TemplatesURL;
|
||||
this.ExternalTemplates = data.ExternalTemplates;
|
||||
this.EnableHostManagementFeatures = data.EnableHostManagementFeatures;
|
||||
this.EdgeAgentCheckinInterval = data.EdgeAgentCheckinInterval;
|
||||
this.EnableEdgeComputeFeatures = data.EnableEdgeComputeFeatures;
|
||||
|
@ -21,7 +20,6 @@ export function PublicSettingsViewModel(settings) {
|
|||
this.AllowVolumeBrowserForRegularUsers = settings.AllowVolumeBrowserForRegularUsers;
|
||||
this.AuthenticationMethod = settings.AuthenticationMethod;
|
||||
this.EnableHostManagementFeatures = settings.EnableHostManagementFeatures;
|
||||
this.ExternalTemplates = settings.ExternalTemplates;
|
||||
this.EnableEdgeComputeFeatures = settings.EnableEdgeComputeFeatures;
|
||||
this.LogoURL = settings.LogoURL;
|
||||
this.OAuthLoginURI = settings.OAuthLoginURI;
|
||||
|
|
|
@ -1,58 +1,6 @@
|
|||
import _ from 'lodash-es';
|
||||
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
|
||||
|
||||
export function TemplateDefaultModel() {
|
||||
this.Type = 1;
|
||||
this.AdministratorOnly = false;
|
||||
this.Title = '';
|
||||
this.Description = '';
|
||||
this.Volumes = [];
|
||||
this.Ports = [];
|
||||
this.Env = [];
|
||||
this.Labels = [];
|
||||
this.RestartPolicy = 'always';
|
||||
this.RegistryModel = new PorImageRegistryModel();
|
||||
}
|
||||
|
||||
export function TemplateCreateRequest(model) {
|
||||
this.Type = model.Type;
|
||||
this.Name = model.Name;
|
||||
this.Hostname = model.Hostname;
|
||||
this.Title = model.Title;
|
||||
this.Description = model.Description;
|
||||
this.Note = model.Note;
|
||||
this.Categories = model.Categories;
|
||||
this.Platform = model.Platform;
|
||||
this.Logo = model.Logo;
|
||||
this.Image = model.RegistryModel.Image;
|
||||
this.Registry = model.RegistryModel.Registry.URL;
|
||||
this.Command = model.Command;
|
||||
this.Network = model.Network && model.Network.Name;
|
||||
this.Privileged = model.Privileged;
|
||||
this.Interactive = model.Interactive;
|
||||
this.RestartPolicy = model.RestartPolicy;
|
||||
this.Labels = model.Labels;
|
||||
this.Repository = model.Repository;
|
||||
this.Env = model.Env;
|
||||
this.AdministratorOnly = model.AdministratorOnly;
|
||||
|
||||
this.Ports = [];
|
||||
for (var i = 0; i < model.Ports.length; i++) {
|
||||
var binding = model.Ports[i];
|
||||
if (binding.containerPort && binding.protocol) {
|
||||
var port = binding.hostPort ? binding.hostPort + ':' + binding.containerPort + '/' + binding.protocol : binding.containerPort + '/' + binding.protocol;
|
||||
this.Ports.push(port);
|
||||
}
|
||||
}
|
||||
|
||||
this.Volumes = model.Volumes;
|
||||
}
|
||||
|
||||
export function TemplateUpdateRequest(model) {
|
||||
TemplateCreateRequest.call(this, model);
|
||||
this.id = model.Id;
|
||||
}
|
||||
|
||||
export function TemplateViewModel(data) {
|
||||
this.Id = data.Id;
|
||||
this.Title = data.title;
|
||||
|
|
|
@ -6,11 +6,7 @@ angular.module('portainer.app').factory('Templates', [
|
|||
API_ENDPOINT_TEMPLATES + '/:id',
|
||||
{},
|
||||
{
|
||||
create: { method: 'POST' },
|
||||
query: { method: 'GET', isArray: true },
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
remove: { method: 'DELETE', params: { id: '@id' } },
|
||||
query: { method: 'GET' },
|
||||
}
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { TemplateViewModel, TemplateCreateRequest, TemplateUpdateRequest } from '../../models/template';
|
||||
import { TemplateViewModel } from '../../models/template';
|
||||
|
||||
angular.module('portainer.app').factory('TemplateService', [
|
||||
'$q',
|
||||
|
@ -21,7 +21,7 @@ angular.module('portainer.app').factory('TemplateService', [
|
|||
dockerhub: DockerHubService.dockerhub(),
|
||||
})
|
||||
.then(function success(data) {
|
||||
const templates = data.templates.map(function (item) {
|
||||
const templates = data.templates.templates.map(function (item) {
|
||||
const res = new TemplateViewModel(item);
|
||||
const registry = RegistryService.retrievePorRegistryModelFromRepositoryWithRegistries(res.RegistryModel.Registry.URL, data.registries, data.dockerhub);
|
||||
registry.Image = res.RegistryModel.Image;
|
||||
|
@ -37,40 +37,6 @@ angular.module('portainer.app').factory('TemplateService', [
|
|||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.template = function (id) {
|
||||
var deferred = $q.defer();
|
||||
let template;
|
||||
Templates.get({ id: id })
|
||||
.$promise.then(function success(data) {
|
||||
template = new TemplateViewModel(data);
|
||||
return RegistryService.retrievePorRegistryModelFromRepository(template.RegistryModel.Registry.URL);
|
||||
})
|
||||
.then((registry) => {
|
||||
registry.Image = template.RegistryModel.Image;
|
||||
template.RegistryModel = registry;
|
||||
deferred.resolve(template);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve template details', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.delete = function (id) {
|
||||
return Templates.remove({ id: id }).$promise;
|
||||
};
|
||||
|
||||
service.create = function (model) {
|
||||
var payload = new TemplateCreateRequest(model);
|
||||
return Templates.create(payload).$promise;
|
||||
};
|
||||
|
||||
service.update = function (model) {
|
||||
var payload = new TemplateUpdateRequest(model);
|
||||
return Templates.update(payload).$promise;
|
||||
};
|
||||
|
||||
service.createTemplateConfiguration = function (template, containerName, network) {
|
||||
var imageConfiguration = ImageHelper.createImageConfigForContainer(template.RegistryModel);
|
||||
var containerConfiguration = createContainerConfiguration(template, containerName, network);
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
import { TemplateDefaultModel } from '../../../models/template';
|
||||
|
||||
angular.module('portainer.app').controller('CreateTemplateController', [
|
||||
'$q',
|
||||
'$scope',
|
||||
'$state',
|
||||
'TemplateService',
|
||||
'TemplateHelper',
|
||||
'NetworkService',
|
||||
'Notifications',
|
||||
function ($q, $scope, $state, TemplateService, TemplateHelper, NetworkService, Notifications) {
|
||||
$scope.state = {
|
||||
actionInProgress: false,
|
||||
};
|
||||
|
||||
$scope.create = function () {
|
||||
var model = $scope.model;
|
||||
|
||||
$scope.state.actionInProgress = true;
|
||||
TemplateService.create(model)
|
||||
.then(function success() {
|
||||
Notifications.success('Template successfully created', model.Title);
|
||||
$state.go('portainer.templates');
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to create template');
|
||||
})
|
||||
.finally(function final() {
|
||||
$scope.state.actionInProgress = false;
|
||||
});
|
||||
};
|
||||
|
||||
function initView() {
|
||||
$scope.model = new TemplateDefaultModel();
|
||||
var provider = $scope.applicationState.endpoint.mode.provider;
|
||||
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||
|
||||
$q.all({
|
||||
templates: TemplateService.templates(),
|
||||
networks: NetworkService.networks(provider === 'DOCKER_STANDALONE' || provider === 'DOCKER_SWARM_MODE', false, provider === 'DOCKER_SWARM_MODE' && apiVersion >= 1.25),
|
||||
})
|
||||
.then(function success(data) {
|
||||
$scope.categories = TemplateHelper.getUniqueCategories(data.templates);
|
||||
$scope.networks = data.networks;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve template details');
|
||||
});
|
||||
}
|
||||
|
||||
initView();
|
||||
},
|
||||
]);
|
|
@ -1,22 +0,0 @@
|
|||
<rd-header>
|
||||
<rd-header-title title-text="Create template"></rd-header-title>
|
||||
<rd-header-content> <a ui-sref="portainer.templates">Templates</a> > Add template </rd-header-content>
|
||||
</rd-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<template-form
|
||||
model="model"
|
||||
categories="categories"
|
||||
networks="networks"
|
||||
form-action="create"
|
||||
show-type-selector="true"
|
||||
form-action-label="Create the template"
|
||||
action-in-progress="state.actionInProgress"
|
||||
></template-form>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
|
@ -1,26 +0,0 @@
|
|||
<rd-header>
|
||||
<rd-header-title title-text="Template details">
|
||||
<a data-toggle="tooltip" title-text="Refresh" ui-sref="portainer.templates.template({id: template.Id})" ui-sref-opts="{reload: true}">
|
||||
<i class="fa fa-sync" aria-hidden="true"></i>
|
||||
</a>
|
||||
</rd-header-title>
|
||||
<rd-header-content> <a ui-sref="portainer.templates">Templates</a> > {{ ::template.Title }} </rd-header-content>
|
||||
</rd-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<template-form
|
||||
model="template"
|
||||
categories="categories"
|
||||
networks="networks"
|
||||
form-action="update"
|
||||
show-type-selector="false"
|
||||
form-action-label="Update the template"
|
||||
action-in-progress="state.actionInProgress"
|
||||
></template-form>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
|
@ -1,66 +0,0 @@
|
|||
import _ from 'lodash-es';
|
||||
|
||||
angular.module('portainer.app').controller('TemplateController', [
|
||||
'$q',
|
||||
'$scope',
|
||||
'$state',
|
||||
'$transition$',
|
||||
'TemplateService',
|
||||
'TemplateHelper',
|
||||
'NetworkService',
|
||||
'Notifications',
|
||||
function ($q, $scope, $state, $transition$, TemplateService, TemplateHelper, NetworkService, Notifications) {
|
||||
$scope.state = {
|
||||
actionInProgress: false,
|
||||
};
|
||||
|
||||
$scope.update = function () {
|
||||
var model = $scope.template;
|
||||
|
||||
$scope.state.actionInProgress = true;
|
||||
TemplateService.update(model)
|
||||
.then(function success() {
|
||||
Notifications.success('Template successfully updated', model.Title);
|
||||
$state.go('portainer.templates');
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to update template');
|
||||
})
|
||||
.finally(function final() {
|
||||
$scope.state.actionInProgress = false;
|
||||
});
|
||||
};
|
||||
|
||||
function initView() {
|
||||
var provider = $scope.applicationState.endpoint.mode.provider;
|
||||
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||
|
||||
var templateId = $transition$.params().id;
|
||||
$q.all({
|
||||
templates: TemplateService.templates(),
|
||||
template: TemplateService.template(templateId),
|
||||
networks: NetworkService.networks(provider === 'DOCKER_STANDALONE' || provider === 'DOCKER_SWARM_MODE', false, provider === 'DOCKER_SWARM_MODE' && apiVersion >= 1.25),
|
||||
})
|
||||
.then(function success(data) {
|
||||
var template = data.template;
|
||||
if (template.Network) {
|
||||
template.Network = _.find(data.networks, function (o) {
|
||||
return o.Name === template.Network;
|
||||
});
|
||||
} else {
|
||||
template.Network = _.find(data.networks, function (o) {
|
||||
return o.Name === 'bridge';
|
||||
});
|
||||
}
|
||||
$scope.categories = TemplateHelper.getUniqueCategories(data.templates);
|
||||
$scope.template = data.template;
|
||||
$scope.networks = data.networks;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve template details');
|
||||
});
|
||||
}
|
||||
|
||||
initView();
|
||||
},
|
||||
]);
|
|
@ -366,10 +366,6 @@
|
|||
templates="templates"
|
||||
table-key="templates"
|
||||
select-action="selectTemplate"
|
||||
delete-action="deleteTemplate"
|
||||
show-add-action="state.templateManagement && isAdmin"
|
||||
show-update-action="state.templateManagement && isAdmin"
|
||||
show-delete-action="state.templateManagement && isAdmin"
|
||||
show-swarm-stacks="applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && applicationState.endpoint.mode.role === 'MANAGER' && applicationState.endpoint.apiVersion >= 1.25"
|
||||
></template-list>
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,6 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
'SettingsService',
|
||||
'StackService',
|
||||
'EndpointProvider',
|
||||
'ModalService',
|
||||
function (
|
||||
$scope,
|
||||
$q,
|
||||
|
@ -39,15 +38,13 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
FormValidator,
|
||||
SettingsService,
|
||||
StackService,
|
||||
EndpointProvider,
|
||||
ModalService
|
||||
EndpointProvider
|
||||
) {
|
||||
$scope.state = {
|
||||
selectedTemplate: null,
|
||||
showAdvancedOptions: false,
|
||||
formValidationError: '',
|
||||
actionInProgress: false,
|
||||
templateManagement: true,
|
||||
};
|
||||
|
||||
$scope.formValues = {
|
||||
|
@ -255,27 +252,6 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
return TemplateService.createTemplateConfiguration(template, name, network);
|
||||
}
|
||||
|
||||
$scope.deleteTemplate = function (template) {
|
||||
ModalService.confirmDeletion('Do you want to delete this template?', function onConfirm(confirmed) {
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
deleteTemplate(template);
|
||||
});
|
||||
};
|
||||
|
||||
function deleteTemplate(template) {
|
||||
TemplateService.delete(template.Id)
|
||||
.then(function success() {
|
||||
Notifications.success('Template successfully deleted');
|
||||
var idx = $scope.templates.indexOf(template);
|
||||
$scope.templates.splice(idx, 1);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to remove template');
|
||||
});
|
||||
}
|
||||
|
||||
function initView() {
|
||||
$scope.isAdmin = Authentication.isAdmin();
|
||||
|
||||
|
@ -300,7 +276,6 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
$scope.availableNetworks = networks;
|
||||
var settings = data.settings;
|
||||
$scope.allowBindMounts = settings.AllowBindMountsForRegularUsers;
|
||||
$scope.state.templateManagement = !settings.ExternalTemplates;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
$scope.templates = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue