Skip to content

Commit

Permalink
Merge pull request #2403 from eclipse/ramSlider
Browse files Browse the repository at this point in the history
improve workspace RAM settings for add project flow
  • Loading branch information
Oleksii Orel authored Sep 12, 2016
2 parents 2eba0f0 + 319fb38 commit f303bb4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class CreateProjectController {
this.templatesChoice = 'templates-samples';

// default RAM value for workspaces
this.workspaceRam = 1000;
this.workspaceRam = 2 * Math.pow(1024,3);
this.websocketReconnect = 50;

this.generateWorkspaceName();
Expand Down Expand Up @@ -158,6 +158,16 @@ export class CreateProjectController {
$rootScope.showIDE = false;
}

/**
* Gets object keys from target object.
*
* @param targetObject
* @returns [*]
*/
getObjectKeys(targetObject) {
return Object.keys(targetObject);
}

/**
* Fetch workspaces when initializing
*/
Expand Down Expand Up @@ -837,11 +847,9 @@ export class CreateProjectController {
switch (this.stackTab) {
case 'ready-to-go':
source = this.getSourceFromStack(this.readyToGoStack);
this.stack = this.readyToGoStack;
break;
case 'stack-library':
source = this.getSourceFromStack(this.stackLibraryUser);
this.stack = this.stackLibraryUser;
break;
case 'custom-stack':
source.type = 'environment';
Expand All @@ -851,7 +859,6 @@ export class CreateProjectController {
} else {
source.content = this.recipeScript;
}
this.stack = null;
break;
}
this.createWorkspace(source);
Expand Down Expand Up @@ -1018,10 +1025,9 @@ export class CreateProjectController {
}

isReadyToCreate() {
let isCustomStack = this.stackTab === 'custom-stack';
let isCreateProjectInProgress = this.isCreateProjectInProgress();

if (!isCustomStack) {
if (!this.isCustomStack) {
return !isCreateProjectInProgress && this.isReady
}

Expand Down Expand Up @@ -1082,6 +1088,7 @@ export class CreateProjectController {
}

setStackTab(stackTab) {
this.isCustomStack = stackTab === 'custom-stack';
this.stackTab = stackTab;
}

Expand Down Expand Up @@ -1148,8 +1155,8 @@ export class CreateProjectController {
* @param stack the stack to use
*/
updateCurrentStack(stack) {
this.stack = stack;
this.currentStackTags = stack && stack.tags ? angular.copy(stack.tags) : null;

if (!stack) {
return;
}
Expand Down
19 changes: 17 additions & 2 deletions dashboard/src/app/projects/create-project/create-project.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,23 @@
</div>
</che-label-container>
<che-label-container che-label-name="RAM">
<che-workspace-ram-allocation-slider
ng-model="createProjectCtrl.workspaceRam"></che-workspace-ram-allocation-slider>
<div ng-hide="createProjectCtrl.isCustomStack"
data-ng-repeat="(environmentKey, environmentValue) in createProjectCtrl.stack.workspaceConfig.environments">
<span ng-if="createProjectCtrl.getObjectKeys(createProjectCtrl.stack.workspaceConfig.environments).length > 1"
class="workspace-environment-name">ENVIRONMENT: {{environmentKey}}</span>

<div>
<div data-ng-repeat="(machineKey, machineValue) in environmentValue.machines">
<div class="workspace-machine" ng-if="machineValue.attributes && machineValue.attributes.memoryLimitBytes">
<span ng-if="createProjectCtrl.getObjectKeys(environmentValue.machines).length > 1">MACHINE: {{machineKey}}</span>
<che-workspace-ram-allocation-slider
ng-model="machineValue.attributes.memoryLimitBytes"></che-workspace-ram-allocation-slider>
</div>
</div>
</div>
</div>
<che-workspace-ram-allocation-slider ng-show="createProjectCtrl.isCustomStack"
ng-model="createProjectCtrl.workspaceRam"></che-workspace-ram-allocation-slider>
</che-label-container>
</div>
</ng-form>
Expand Down
13 changes: 11 additions & 2 deletions dashboard/src/app/projects/create-project/create-project.styl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ che-button-primary#create-project-button-import button

md-select.create-project-select
width 100%
margin-top 0px
margin-bottom 0px
margin-top 0
margin-bottom 0

.projects-create-project > md-card:first-child .che-panel-content
padding 0
Expand Down Expand Up @@ -67,3 +67,12 @@ md-select.create-project-select

.che-label-container-content .create-project-nested-container
margin -25px 0

.workspace-environment-name + div
margin-top 8px

.workspace-machine
margin-left 45px

.che-ram-allocation-slider .slider-wrapper
margin-bottom -15px
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@
</che-input>
</div>
</che-label-container>
<che-label-container che-label-name="RAM" ng-init="createWorkspaceCtrl.isStackMemoryLimit = false">
<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"
class="workspace-environment-name">ENVIRONMENT: {{environmentKey}}</span>

<div>
<div data-ng-repeat="(machineKey, machineValue) in environmentValue.machines">
<div class="workspace-machine" ng-if="machineValue.attributes && machineValue.attributes.memoryLimitBytes">
<span ng-if="createWorkspaceCtrl.getObjectKeys(environmentValue.machines).length > 1">MACHINE: {{machineKey}}</span>
<che-workspace-ram-allocation-slider
ng-init="createWorkspaceCtrl.isStackMemoryLimit = true"
ng-model="machineValue.attributes.memoryLimitBytes"></che-workspace-ram-allocation-slider>
</div>
</div>
Expand Down

0 comments on commit f303bb4

Please sign in to comment.