1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 06:49:40 +02:00

refactor(code-editor): introduce code-editor component (#1674)

* refactor(code-editor): introduce code-editor component

* refactor(code-editor): add some extra validation
This commit is contained in:
Anthony Lapenna 2018-02-27 08:19:21 +01:00 committed by GitHub
parent eb43579378
commit 9b80b6adb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 104 additions and 94 deletions

View file

@ -1,6 +1,6 @@
angular.module('portainer.docker')
.controller('StackController', ['$q', '$scope', '$state', '$transition$', '$document', 'StackService', 'NodeService', 'ServiceService', 'TaskService', 'ServiceHelper', 'CodeMirrorService', 'Notifications', 'FormHelper', 'EndpointProvider',
function ($q, $scope, $state, $transition$, $document, StackService, NodeService, ServiceService, TaskService, ServiceHelper, CodeMirrorService, Notifications, FormHelper, EndpointProvider) {
.controller('StackController', ['$q', '$scope', '$state', '$transition$', 'StackService', 'NodeService', 'ServiceService', 'TaskService', 'ServiceHelper', 'Notifications', 'FormHelper', 'EndpointProvider',
function ($q, $scope, $state, $transition$, StackService, NodeService, ServiceService, TaskService, ServiceHelper, Notifications, FormHelper, EndpointProvider) {
$scope.state = {
actionInProgress: false,
@ -12,9 +12,7 @@ function ($q, $scope, $state, $transition$, $document, StackService, NodeService
};
$scope.deployStack = function () {
// The codemirror editor does not work with ng-model so we need to retrieve
// the value directly from the editor.
var stackFile = $scope.editor.getValue();
var stackFile = $scope.stackFileContent;
var env = FormHelper.removeInvalidEnvVars($scope.stack.Env);
var prune = $scope.formValues.Prune;
@ -63,13 +61,6 @@ function ($q, $scope, $state, $transition$, $document, StackService, NodeService
.then(function success(data) {
$scope.stackFileContent = data.stackFile;
$document.ready(function() {
var webEditorElement = $document[0].getElementById('web-editor');
if (webEditorElement) {
$scope.editor = CodeMirrorService.applyCodeMirrorOnElement(webEditorElement, true, false);
}
});
$scope.nodes = data.nodes;
var services = data.services;
@ -89,5 +80,9 @@ function ($q, $scope, $state, $transition$, $document, StackService, NodeService
});
}
$scope.editorUpdate = function(cm) {
$scope.stackFileContent = cm.getValue();
};
initView();
}]);