mirror of https://github.com/portainer/portainer
feat(config-details): add the ability to clone a config (#2189)
parent
6ab6cfafb7
commit
e8ab89ae79
|
@ -32,7 +32,7 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
|
|
||||||
var configCreation = {
|
var configCreation = {
|
||||||
name: 'docker.configs.new',
|
name: 'docker.configs.new',
|
||||||
url: '/new',
|
url: '/new?id',
|
||||||
views: {
|
views: {
|
||||||
'content@': {
|
'content@': {
|
||||||
templateUrl: 'app/docker/views/configs/create/createconfig.html',
|
templateUrl: 'app/docker/views/configs/create/createconfig.html',
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
ng-disabled="$ctrl.state.selectedItemCount === 0" ng-click="$ctrl.removeAction($ctrl.state.selectedItems)">
|
ng-disabled="$ctrl.state.selectedItemCount === 0" ng-click="$ctrl.removeAction($ctrl.state.selectedItems)">
|
||||||
<i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Remove
|
<i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Remove
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-sm btn-primary" ui-sref="docker.configs.new">
|
<button type="button" class="btn btn-sm btn-primary" ui-sref="docker.configs.new">
|
||||||
<i class="fa fa-plus space-right" aria-hidden="true"></i>Add config
|
<i class="fa fa-plus space-right" aria-hidden="true"></i>Add config
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
angular.module('portainer.docker')
|
angular.module('portainer.docker')
|
||||||
.controller('CreateConfigController', ['$scope', '$state', 'Notifications', 'ConfigService', 'Authentication', 'FormValidator', 'ResourceControlService',
|
.controller('CreateConfigController', ['$scope', '$state', '$transition$', 'Notifications', 'ConfigService', 'Authentication', 'FormValidator', 'ResourceControlService',
|
||||||
function ($scope, $state, Notifications, ConfigService, Authentication, FormValidator, ResourceControlService) {
|
function ($scope, $state, $transition$, Notifications, ConfigService, Authentication, FormValidator, ResourceControlService) {
|
||||||
|
|
||||||
$scope.formValues = {
|
$scope.formValues = {
|
||||||
Name: '',
|
Name: '',
|
||||||
Labels: [],
|
Labels: [],
|
||||||
|
@ -90,4 +89,30 @@ function ($scope, $state, Notifications, ConfigService, Authentication, FormVali
|
||||||
$scope.editorUpdate = function(cm) {
|
$scope.editorUpdate = function(cm) {
|
||||||
$scope.formValues.ConfigContent = cm.getValue();
|
$scope.formValues.ConfigContent = cm.getValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function initView() {
|
||||||
|
if (!$transition$.params().id) {
|
||||||
|
$scope.formValues.displayCodeEditor = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigService.config($transition$.params().id)
|
||||||
|
.then(function success(data) {
|
||||||
|
$scope.formValues.Name = data.Name + '_copy';
|
||||||
|
$scope.formValues.Data = data.Data;
|
||||||
|
var labels = _.keys(data.Labels);
|
||||||
|
for (var i = 0; i < labels.length; i++) {
|
||||||
|
var labelName = labels[i];
|
||||||
|
var labelValue = data.Labels[labelName];
|
||||||
|
$scope.formValues.Labels.push({ name: labelName, value: labelValue});
|
||||||
|
}
|
||||||
|
$scope.formValues.displayCodeEditor = true;
|
||||||
|
})
|
||||||
|
.catch(function error(err) {
|
||||||
|
$scope.formValues.displayCodeEditor = true;
|
||||||
|
Notifications.error('Failure', err, 'Unable to clone config');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initView();
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
<!-- !name-input -->
|
<!-- !name-input -->
|
||||||
<!-- config-data -->
|
<!-- config-data -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12" ng-if="formValues.displayCodeEditor">
|
||||||
<code-editor
|
<code-editor
|
||||||
identifier="config-creation-editor"
|
identifier="config-creation-editor"
|
||||||
placeholder="Define or paste the content of your config here"
|
placeholder="Define or paste the content of your config here"
|
||||||
yml="false"
|
yml="false"
|
||||||
on-change="editorUpdate"
|
on-change="editorUpdate"
|
||||||
|
value="formValues.Data"
|
||||||
></code-editor>
|
></code-editor>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<td>
|
<td>
|
||||||
{{ config.Id }}
|
{{ config.Id }}
|
||||||
<button class="btn btn-xs btn-danger" ng-click="removeConfig(config.Id)"><i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Delete this config</button>
|
<button class="btn btn-xs btn-danger" ng-click="removeConfig(config.Id)"><i class="fa fa-trash-alt space-right" aria-hidden="true"></i>Delete this config</button>
|
||||||
|
<button class="btn btn-xs btn-primary" ui-sref="docker.configs.new({id: config.Id})"><i class="fa fa-copy space-right" aria-hidden="true"></i>Clone config</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue