Skip to content

Commit

Permalink
CHE-2451: workspace environment page enhancement
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
Oleksii Kurinnyi committed Sep 15, 2016
1 parent f117373 commit 0b74b41
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class WorkspaceEnvironmentsController {
}
};

this.machinesViewStatus = {};

this.init();
}

Expand Down Expand Up @@ -84,7 +86,9 @@ export class WorkspaceEnvironmentsController {
updateEnvironmentConfig() {
let newEnvironment = this.environmentManager.getEnvironment(this.environment, this.machines);
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment;
return this.doUpdateEnvironments();
return this.doUpdateEnvironments().then(() => {
this.init();
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class WorkspaceEnvironments {

this.scope = {
environmentName: '=',
environmentViewStatus: '=',
workspaceConfig: '=',
environmentOnChange: '&'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,23 @@
</ng-form>
</che-label-container>

<!-- Machines -->
<che-label-container ng-if="workspaceEnvironmentsController.environment.machines.length"
che-label-name="Machines"
class="che-label-container-last">
</che-label-container>
<workspace-machine-config ng-repeat="machine in workspaceEnvironmentsController.machines"
machine-name="machine.name"
machines-list="workspaceEnvironmentsController.machines"
environment-manager="workspaceEnvironmentsController.environmentManager"
machine-name-on-change="workspaceEnvironmentsController.updateMachineName(oldName,newName)"
machine-config-on-change="workspaceEnvironmentsController.updateEnvironmentConfig()"
machine-on-delete="workspaceEnvironmentsController.deleteMachine(name)"
machine-is-opened="workspaceEnvironmentsController.machinesViewStatus[machine.name]"></workspace-machine-config>

<!-- Recipe Content-->
<che-label-container che-label-name="Recipe"
che-label-description="The contents of the runtime started by the workspace."
ng-if="workspaceEnvironmentsController.environment.recipe.content">
<div layout="row" layout-wrap>
<div flex class="recipe-editor">
Expand All @@ -56,18 +71,4 @@
che-copy-clipboard="true"
class="recipe-location"></che-text-info>
</che-label-container>

<!-- Machines -->
<che-label-container ng-if="workspaceEnvironmentsController.environment.machines.length"
che-label-name="Machines"
class="che-label-container-last">
</che-label-container>
<workspace-machine-config ng-repeat="machine in workspaceEnvironmentsController.machines"
machine-name="machine.name"
machines-list="workspaceEnvironmentsController.machines"
environment-manager="workspaceEnvironmentsController.environmentManager"
machine-name-on-change="workspaceEnvironmentsController.updateMachineName(oldName,newName)"
machine-config-on-change="workspaceEnvironmentsController.updateEnvironmentConfig()"
machine-on-delete="workspaceEnvironmentsController.deleteMachine(name)"
machine-is-opened="$first"></workspace-machine-config>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,22 @@ export class WorkspaceMachineConfigController {
/**
* Modifies agents list in order to add or remove 'ws-agent'
*/
updateDev() {
enableDev() {
this.$timeout.cancel(this.timeoutPromise);

if (this.machineConfig.isDev === this.newDev) {
return;
}

this.timeoutPromise = this.$timeout(() => {
// remove ws-agent from machine which is the dev machine now
this.machinesList.forEach((machine) => {
if (this.environmentManager.isDev(machine)) {
this.environmentManager.setDev(machine, false);
}
});

// add ws-agent to current machine agents list
this.environmentManager.setDev(this.machine, this.newDev);

this.doUpdateConfig().then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
<!-- Title -->
<div class="config-title-row" layout="row"
layout-align="start center"
flex>
<div ng-click="workspaceMachineConfigController.machineIsOpened=!workspaceMachineConfigController.machineIsOpened">
flex
ng-click="workspaceMachineConfigController.machineIsOpened=!workspaceMachineConfigController.machineIsOpened"
mouseover="hover=true" mouseout="hover=false">
<div>
<i class="config-title-action-show fa"
ng-class="{'fa-chevron-circle-down': workspaceMachineConfigController.machineIsOpened, 'fa-chevron-circle-up': !workspaceMachineConfigController.machineIsOpened}"></i>
</div>
<div class="config-title">{{workspaceMachineConfigController.machineName}}</div>
<div class="config-title-action-edit"
tooltip="Edit"
ng-if="workspaceMachineConfigController.machineConfig.canRenameMachine"
ng-click="workspaceMachineConfigController.showEditDialog($event)">
<i class="config-title-action-edit fa fa-pencil" aria-hidden="true"></i>
Expand All @@ -36,32 +39,35 @@
ng-if="workspaceMachineConfigController.machineConfig.source">
<div class="config-paragraph">
<p ng-repeat="(key, val) in workspaceMachineConfigController.machineConfig.source">
<span class="recipe-item-name" ng-hide="$first && $last">{{key}}:</span>{{val}}
<span class="recipe-item-name">{{key}}:</span>{{val}}
</p>
</div>
</che-label-container>

<!-- RAM -->
<che-label-container che-label-name="RAM">
<ng-form flex layout="column" name="workspaceMachineConfigForm">
<che-workspace-ram-allocation-slider ng-model="workspaceMachineConfigController.newRam"
che-on-change="workspaceMachineConfigController.updateRam(workspaceMachineConfigForm.$valid)"></che-workspace-ram-allocation-slider>
</ng-form>
<div class="config-ram">
<ng-form flex layout="column" name="workspaceMachineConfigForm">
<che-workspace-ram-allocation-slider ng-model="workspaceMachineConfigController.newRam"
che-on-change="workspaceMachineConfigController.updateRam(workspaceMachineConfigForm.$valid)"></che-workspace-ram-allocation-slider>
</ng-form>
</div>
</che-label-container>

<!-- Is Dev -->
<che-label-container che-label-name="Dev">
<div class="config-dev-machine-switch">
<md-switch ng-model="workspaceMachineConfigController.newDev"
ng-change="workspaceMachineConfigController.updateDev()"
ng-change="workspaceMachineConfigController.enableDev()"
ng-disabled="workspaceMachineConfigController.machineConfig.isDev"
aria-label="Dev machine">
<span class="config-dev-machine-info">Used as dev machine, injects dev services into machine</span>
<span class="config-dev-machine-info">Injects terminal, SSH and IDE tooling.</span>
</md-switch>
</div>
</che-label-container>

<!-- Ports -->
<che-label-container che-label-name="Ports">
<che-label-container che-label-name="Exposed Ports">
<div class="config-params-table">
<list-ports servers="workspaceMachineConfigController.machineConfig.servers"
servers-on-change="workspaceMachineConfigController.updateServers()"></list-ports>
Expand All @@ -83,7 +89,7 @@
che-label-description="Environment should contain at least one machine."
ng-if="workspaceMachineConfigController.machineConfig.canDeleteMachine">
<che-button-danger che-button-title="Delete"
ng-disabled="workspaceMachineConfigController.machinesList.length === 1"
ng-disabled="workspaceMachineConfigController.machineConfig.isDev"
ng-click="workspaceMachineConfigController.deleteMachine()"></che-button-danger>
</che-label-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.config-title-row
padding 15px 0
border-bottom 1px solid $list-separator-color
cursor pointer

.config-title
padding 0 17px
Expand Down Expand Up @@ -36,6 +37,9 @@
color $disabled-color
margin-right 5px

.config-ram
margin-bottom -26px

.config-params
padding 0 70px
background-color $light-gray-color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class WorkspaceDetailsController {
defer.resolve();
return defer.promise;
}

return this.doUpdateWorkspace();
}

Expand All @@ -191,7 +192,7 @@ export class WorkspaceDetailsController {
promise.then((data) => {
this.workspaceName = data.config.name;
this.updateWorkspaceData();
this.cheNotification.showInfo('Workspace is successfully updated.');
this.cheNotification.showInfo('Workspace updated.');
return this.$location.path('/workspace/' + this.namespace + '/' + this.workspaceName);
}, (error) => {
this.isLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<!-- Environment tabs -->
<md-tab ng-repeat="(environmentName, environmentValue) in workspaceDetailsCtrl.copyWorkspaceDetails.config.environments">
<md-tab-label>
<span class="che-tab-label-title">Environments</span>
<span class="che-tab-label-title">Runtime</span>
</md-tab-label>
<md-tab-body>
<workspace-environments environment-name="environmentName"
Expand Down

0 comments on commit 0b74b41

Please sign in to comment.