commit
4048fd1049
|
|
@ -154,9 +154,9 @@ export class CreateWorkspaceController {
|
|||
this.submitWorkspace(source);
|
||||
}
|
||||
} else if (this.selectSourceOption === 'select-source-import') {
|
||||
let workspaceConfig = this.importWorkspace.length > 0 ? angular.fromJson(this.importWorkspace) : {};
|
||||
workspaceConfig.name = this.workspaceName;
|
||||
let creationPromise = this.cheAPI.getWorkspace().createWorkspaceFromConfig(null, workspaceConfig);
|
||||
this.importWorkspaceConfig.name = this.workspaceName;
|
||||
this.setEnvironment(this.importWorkspaceConfig);
|
||||
let creationPromise = this.cheAPI.getWorkspace().createWorkspaceFromConfig(null, this.importWorkspaceConfig);
|
||||
this.redirectAfterSubmitWorkspace(creationPromise);
|
||||
} else {
|
||||
//check predefined recipe location
|
||||
|
|
@ -171,6 +171,41 @@ export class CreateWorkspaceController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform actions when content of workspace config is changed.
|
||||
*/
|
||||
onWorkspaceSourceChange() {
|
||||
this.importWorkspaceConfig = null;
|
||||
this.importWorkspaceMachines = null;
|
||||
|
||||
if (this.importWorkspace && this.importWorkspace.length > 0) {
|
||||
try {
|
||||
this.importWorkspaceConfig = angular.fromJson(this.importWorkspace);
|
||||
this.workspaceName = this.importWorkspaceConfig.name;
|
||||
let environment = this.importWorkspaceConfig.environments[this.importWorkspaceConfig.defaultEnv];
|
||||
let recipeType = environment.recipe.type;
|
||||
let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType);
|
||||
this.importWorkspaceMachines = environmentManager.getMachines(environment);
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of environments to be displayed.
|
||||
*
|
||||
* @returns {*} list of environments
|
||||
*/
|
||||
getEnvironments() {
|
||||
if (this.selectSourceOption === 'select-source-import') {
|
||||
return (this.importWorkspaceConfig && this.importWorkspaceConfig.environments) ? this.importWorkspaceConfig.environments : [];
|
||||
} else if (this.stack) {
|
||||
return this.stack.workspaceConfig.environments;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects machine source from pointed stack.
|
||||
*
|
||||
|
|
@ -242,9 +277,14 @@ export class CreateWorkspaceController {
|
|||
this.$rootScope.$broadcast('recent-workspace:set', workspaceId);
|
||||
}
|
||||
|
||||
getStackMachines(environment) {
|
||||
getMachines(environment) {
|
||||
let recipeType = environment.recipe.type;
|
||||
let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType);
|
||||
|
||||
if (this.selectSourceOption === 'select-source-import') {
|
||||
return this.importWorkspaceMachines;
|
||||
}
|
||||
|
||||
if (!this.stackMachines[this.stack.id]) {
|
||||
this.stackMachines[this.stack.id] = environmentManager.getMachines(environment);
|
||||
}
|
||||
|
|
@ -269,6 +309,6 @@ export class CreateWorkspaceController {
|
|||
|
||||
let recipeType = environment.recipe.type;
|
||||
let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType);
|
||||
workspace.environments[workspace.defaultEnv] = environmentManager.getEnvironment(environment, this.getStackMachines(environment));
|
||||
workspace.environments[workspace.defaultEnv] = environmentManager.getEnvironment(environment, this.getMachines(environment));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<che-label-container che-label-name="Import workspace"
|
||||
ng-if="createWorkspaceCtrl.selectSourceOption === 'select-source-import'">
|
||||
<ui-codemirror class="workspace-editor" ui-codemirror="createWorkspaceCtrl.editorOptions"
|
||||
ng-model="createWorkspaceCtrl.importWorkspace"></ui-codemirror>
|
||||
ng-model="createWorkspaceCtrl.importWorkspace" ng-change="createWorkspaceCtrl.onWorkspaceSourceChange()"></ui-codemirror>
|
||||
</che-label-container>
|
||||
|
||||
<che-label-container ng-if="createWorkspaceCtrl.selectSourceOption === 'select-source-recipe'"
|
||||
|
|
@ -67,12 +67,12 @@
|
|||
</che-label-container>
|
||||
<che-label-container che-label-name="RAM">
|
||||
<div ng-hide="createWorkspaceCtrl.isCustomStack"
|
||||
data-ng-repeat="(environmentKey, environmentValue) in createWorkspaceCtrl.stack.workspaceConfig.environments">
|
||||
<span ng-if="createWorkspaceCtrl.getObjectKeys(createWorkspaceCtrl.stack.workspaceConfig.environments).length > 1"
|
||||
data-ng-repeat="(environmentKey, environmentValue) in createWorkspaceCtrl.getEnvironments()">
|
||||
<span ng-if="createWorkspaceCtrl.getObjectKeys(createWorkspaceCtrl.getEnvironments()).length > 1"
|
||||
class="workspace-environment-name">ENVIRONMENT: {{environmentKey}}</span>
|
||||
|
||||
<div>
|
||||
<div data-ng-repeat="machine in createWorkspaceCtrl.getStackMachines(environmentValue)">
|
||||
<div data-ng-repeat="machine in createWorkspaceCtrl.getMachines(environmentValue)">
|
||||
<div class="workspace-machine" ng-if="machine.attributes && machine.attributes.memoryLimitBytes">
|
||||
<span ng-if="$first !== $last">MACHINE: {{machine.name}}</span>
|
||||
<che-workspace-ram-allocation-slider
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
-->
|
||||
<che-toolbar che-title="Workspaces" border-none></che-toolbar>
|
||||
<che-description che-link-title="Learn more." che-link="https://eclipse-che.readme.io/docs/environments">A workspace is where your projects live and run. Create workspaces from stacks that define projects, runtimes, and commands.</che-description>
|
||||
<che-description che-link-title="Learn more." che-link="https://eclipse-che.readme.io/docs/introduction">A workspace is where your projects live and run. Create workspaces from stacks that define projects, runtimes, and commands.</che-description>
|
||||
<md-content md-scroll-y flex layout="column" md-theme="maincontent-theme">
|
||||
<md-progress-linear md-mode="indeterminate" class="workspaces-list-progress"
|
||||
ng-show="listWorkspacesCtrl.isInfoLoading"></md-progress-linear>
|
||||
|
|
|
|||
Loading…
Reference in New Issue