diff --git a/dashboard/src/app/projects/create-project/create-project.controller.js b/dashboard/src/app/projects/create-project/create-project.controller.js old mode 100644 new mode 100755 index e59ff2f494..300bf24965 --- a/dashboard/src/app/projects/create-project/create-project.controller.js +++ b/dashboard/src/app/projects/create-project/create-project.controller.js @@ -21,8 +21,9 @@ export class CreateProjectCtrl { * Default constructor that is using resource * @ngInject for Dependency injection */ - constructor(cheAPI, $websocket, $routeParams, $filter, $timeout, $location, $mdDialog, $scope, $rootScope, createProjectSvc, lodash, $q) { + constructor(cheAPI, cheStack, $websocket, $routeParams, $filter, $timeout, $location, $mdDialog, $scope, $rootScope, createProjectSvc, lodash, $q) { this.cheAPI = cheAPI; + this.cheStack = cheStack; this.$websocket = $websocket; this.$timeout = $timeout; this.$location = $location; @@ -681,26 +682,26 @@ export class CreateProjectCtrl { // logic to decide if we create workspace based on a stack or reuse existing workspace var option; - var stack; + this.stack = null; if (this.stackTab === 'ready-to-go') { option = 'create-workspace'; - stack = this.readyToGoStack; + this.stack = this.readyToGoStack; } else if (this.stackTab === 'stack-library') { if (this.stackLibraryOption === 'existing-workspace') { option = 'reuse-workspace'; } else { - stack = this.stackLibraryUser; + this.stack = this.stackLibraryUser; option = 'create-workspace'; } } else if (this.stackTab === 'custom-stack') { - stack = null; + this.stack = null; option = 'create-workspace'; } // check workspace is selected if (option === 'create-workspace') { - if (stack) { + if (this.stack) { // needs to get recipe URL from stack - let promise = this.computeRecipeForStack(stack); + let promise = this.computeRecipeForStack(this.stack); promise.then((recipe) => { let findLink = this.lodash.find(recipe.links, function (link) { return link.rel === 'get recipe script'; @@ -774,8 +775,10 @@ export class CreateProjectCtrl { */ createWorkspace() { this.createProjectSvc.setWorkspaceOfProject(this.workspaceName); + let attributes = this.stack ? {stackId : this.stack.id} : {}; + //TODO: no account in che ? it's null when testing on localhost - let creationPromise = this.cheAPI.getWorkspace().createWorkspace(null, this.workspaceName, this.recipeUrl, this.workspaceRam); + let creationPromise = this.cheAPI.getWorkspace().createWorkspace(null, this.workspaceName, this.recipeUrl, this.workspaceRam, attributes); creationPromise.then((data) => { // init message bus if not there @@ -961,8 +964,12 @@ export class CreateProjectCtrl { this.workspaceSelected = workspace; this.workspaceName = workspace.config.name; this.stackLibraryOption = 'existing-workspace'; - - this.updateCurrentStack(null); + let stack = null; + if (workspace.attributes && workspace.attributes.stackId) { + let stackId = workspace.attributes.stackId; + stack = this.cheStack.getStackById(stackId); + } + this.updateCurrentStack(stack); this.generateProjectName(true); this.checkDisabledWorkspace(); } diff --git a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.js b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.js index 825ef24331..acb026ed17 100644 --- a/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.js +++ b/dashboard/src/app/workspaces/create-workspace/create-workspace.controller.js @@ -95,6 +95,7 @@ export class CreateWorkspaceCtrl { */ createWorkspace() { if (this.isCustomStack) { + this.stack = null; if (this.recipeUrl && this.recipeUrl.length > 0) { this.submitWorkspace(); } else { @@ -186,7 +187,9 @@ export class CreateWorkspaceCtrl { * Submit a new workspace from current workspace name, recipe url and workspace ram */ submitWorkspace() { - let creationPromise = this.cheAPI.getWorkspace().createWorkspace(null, this.workspaceName, this.recipeUrl, this.workspaceRam); + let attributes = this.stack ? {stackId: this.stack.id} : {}; + + let creationPromise = this.cheAPI.getWorkspace().createWorkspace(null, this.workspaceName, this.recipeUrl, this.workspaceRam, attributes); creationPromise.then((workspaceData) => { let infoMessage = 'Workspace ' + workspaceData.name + ' successfully created.'; this.cheNotification.showInfo(infoMessage); diff --git a/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.html b/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.html index 7d8669fc8b..510d41474d 100644 --- a/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.html +++ b/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.html @@ -9,6 +9,9 @@
{{workspace.config.name}}
+
+
Stack: {{workspace.attributes.stackId}}
+
{{getWorkspaceStackDetails()}}
diff --git a/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.styl b/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.styl index 0063041567..7bd72a6ad2 100644 --- a/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.styl +++ b/dashboard/src/app/workspaces/create-workspace/select-stack/stack-library/stack-library-workspace-selecter/che-stack-library-workspace-selecter.styl @@ -52,6 +52,12 @@ $che-stack-library-workspace-selecter-color = $label-info-color margin-top 4px color $secondary-color +.che-stack-library-workspace-selecter-workspace-stack + font-size 0.8em + border-bottom 1px solid $form-element-border-color + color $label-primary-color + padding 5px 10px + .che-stack-library-workspace-selecter md-icon font-size 60px text-align center diff --git a/dashboard/src/components/api/che-workspace.factory.js b/dashboard/src/components/api/che-workspace.factory.js index eabedaac5e..bc2aeee947 100644 --- a/dashboard/src/components/api/che-workspace.factory.js +++ b/dashboard/src/components/api/che-workspace.factory.js @@ -154,14 +154,14 @@ export class CheWorkspace { } - createWorkspace(accountId, workspaceName, recipeUrl, ram) { + createWorkspace(accountId, workspaceName, recipeUrl, ram, attributes) { // /api/workspace/config?account=accountId - + let attr = attributes ? attributes : {}; let data = { 'environments': [], 'name': workspaceName, - 'attributes': {}, + 'attributes': attributes, 'projects': [], 'defaultEnv': workspaceName, 'description': null,