-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-1771: add Runtime page to Workspace details.
Signed-off-by: Oleksii Kurinnyi <[email protected]>
- Loading branch information
Oleksii Kurinnyi
committed
Sep 16, 2016
1 parent
d075948
commit f77c667
Showing
54 changed files
with
3,722 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
dashboard/src/app/workspaces/create-workspace/select-stack/recipe/workspace-recipe.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
dashboard/src/app/workspaces/workspace-details/environments/environments.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (c) 2015-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc controller | ||
* @name workspace.details.controller:WorkspaceEnvironmentsController | ||
* @description This class is handling the controller for details of workspace : section environments | ||
* @author Oleksii Kurinnyi | ||
*/ | ||
export class WorkspaceEnvironmentsController { | ||
|
||
/** | ||
* Default constructor that is using resource injection | ||
* @ngInject for Dependency injection | ||
*/ | ||
constructor($q, $log, $scope, $timeout, cheEnvironmentRegistry) { | ||
this.$q = $q; | ||
this.$log = $log; | ||
this.$scope = $scope; | ||
this.cheEnvironmentRegistry = cheEnvironmentRegistry; | ||
|
||
this.editorOptions = { | ||
lineWrapping: true, | ||
lineNumbers: false, | ||
readOnly: true, | ||
gutters: [], | ||
onLoad: (editor) => { | ||
$timeout(() => { | ||
editor.refresh(); | ||
}, 1000); | ||
} | ||
}; | ||
|
||
this.machinesViewStatus = {}; | ||
|
||
this.init(); | ||
} | ||
|
||
/** | ||
* Sets initial values | ||
*/ | ||
init() { | ||
this.newEnvironmentName = this.environmentName; | ||
this.environment = this.workspaceConfig.environments[this.environmentName]; | ||
|
||
this.recipeType = this.environment.recipe.type; | ||
this.environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(this.recipeType); | ||
|
||
this.editorOptions.mode = this.environmentManager.editorMode; | ||
|
||
this.machines = this.environmentManager.getMachines(this.environment); | ||
} | ||
|
||
/** | ||
* Updates name of environment | ||
* @param isFormValid {boolean} | ||
*/ | ||
updateEnvironmentName(isFormValid) { | ||
if (!isFormValid || this.newEnvironmentName === this.environmentName) { | ||
return; | ||
} | ||
|
||
this.workspaceConfig.environments[this.newEnvironmentName] = this.environment; | ||
delete this.workspaceConfig.environments[this.environmentName]; | ||
|
||
if (this.workspaceConfig.defaultEnv === this.environmentName) { | ||
this.workspaceConfig.defaultEnv = this.newEnvironmentName; | ||
} | ||
|
||
this.doUpdateEnvironments(); | ||
} | ||
|
||
/** | ||
* Callback which is called in order to update environment config | ||
* @returns {Promise} | ||
*/ | ||
updateEnvironmentConfig() { | ||
let newEnvironment = this.environmentManager.getEnvironment(this.environment, this.machines); | ||
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment; | ||
return this.doUpdateEnvironments().then(() => { | ||
this.init(); | ||
}); | ||
} | ||
|
||
/** | ||
* Callback which is called in order to rename specified machine | ||
* @param oldName | ||
* @param newName | ||
* @returns {*} | ||
*/ | ||
updateMachineName(oldName, newName) { | ||
let newEnvironment = this.environmentManager.renameMachine(this.environment, oldName, newName); | ||
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment; | ||
return this.doUpdateEnvironments().then(() => { | ||
this.init(); | ||
}) | ||
} | ||
|
||
/** | ||
* Callback which is called in order to delete specified machine | ||
* @param name | ||
* @returns {*} | ||
*/ | ||
deleteMachine(name) { | ||
let newEnvironment = this.environmentManager.deleteMachine(this.environment, name); | ||
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment; | ||
return this.doUpdateEnvironments().then(() => { | ||
this.init(); | ||
}) | ||
} | ||
|
||
/** | ||
* Calls parent controller's callback to update environment | ||
* @returns {IPromise<TResult>|*|Promise.<TResult>} | ||
*/ | ||
doUpdateEnvironments() { | ||
return this.environmentOnChange(); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
dashboard/src/app/workspaces/workspace-details/environments/environments.directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2015-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc directive | ||
* @name workspaces.details.directive:workspaceEnvironments | ||
* @restrict E | ||
* @element | ||
* | ||
* @description | ||
* <workspace-environments></workspace-environmentss>` for displaying workspace environments. | ||
* | ||
* @usage | ||
* <workspace-environments></workspace-environments> | ||
* | ||
* @author Oleksii Kurinnyi | ||
*/ | ||
export class WorkspaceEnvironments { | ||
|
||
/** | ||
* Default constructor that is using resource | ||
* @ngInject for Dependency injection | ||
*/ | ||
constructor () { | ||
this.restrict = 'E'; | ||
this.templateUrl = 'app/workspaces/workspace-details/environments/environments.html'; | ||
|
||
this.controller = 'WorkspaceEnvironmentsController'; | ||
this.controllerAs = 'workspaceEnvironmentsController'; | ||
this.bindToController = true; | ||
|
||
this.scope = { | ||
environmentName: '=', | ||
environmentViewStatus: '=', | ||
workspaceConfig: '=', | ||
environmentOnChange: '&' | ||
} | ||
} | ||
} | ||
|
74 changes: 74 additions & 0 deletions
74
dashboard/src/app/workspaces/workspace-details/environments/environments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
Copyright (c) 2015 Codenvy, S.A. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Codenvy, S.A. - initial API and implementation | ||
--> | ||
<div class="workspace-environments"> | ||
|
||
<!-- Name --> | ||
<che-label-container che-label-name="Name"> | ||
<ng-form flex layout="column" name="workspaceEnvironmentsForm"> | ||
<div layout="column" class="workspace-environments-input"> | ||
<che-input che-form="workspaceEnvironmentsForm" | ||
che-name="name" | ||
che-place-holder="Name of the environment" | ||
aria-label="Name of the environment" | ||
ng-model="workspaceEnvironmentsController.newEnvironmentName" | ||
ng-change="workspaceEnvironmentsController.updateEnvironmentName(workspaceEnvironmentsForm.$valid)" | ||
ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 2000, 'blur': 0 } }" | ||
required | ||
ng-maxlength="128" | ||
ng-pattern="/^[A-Za-z0-9_\-\.]+$/"> | ||
<div ng-message="required">A name is required.</div> | ||
<div ng-message="pattern">The name should not contain special characters like space, dollar, etc. | ||
</div> | ||
<div ng-message="maxlength">The name has to be less than 128 characters long.</div> | ||
<div ng-message="md-maxlength">The name has to be less than 128 characters long.</div> | ||
<!-- TODO --> | ||
<div ng-message="uniqueWorkspaceName">This environment name is already used.</div> | ||
</che-input> | ||
</div> | ||
</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"> | ||
<ui-codemirror ui-codemirror="workspaceEnvironmentsController.editorOptions" | ||
ng-model="workspaceEnvironmentsController.environment.recipe.content"></ui-codemirror> | ||
</div> | ||
</div> | ||
</che-label-container> | ||
<!-- OR Location --> | ||
<che-label-container che-label-name="Recipe Location" | ||
ng-if="workspaceEnvironmentsController.recipeType !== 'dockerimage' && workspaceEnvironmentsController.environment.recipe.location"> | ||
<che-text-info che-text="workspaceEnvironmentsController.environment.recipe.location" | ||
che-href="workspaceEnvironmentsController.environment.recipe.location" | ||
che-copy-clipboard="true" | ||
class="recipe-location"></che-text-info> | ||
</che-label-container> | ||
</div> |
17 changes: 17 additions & 0 deletions
17
dashboard/src/app/workspaces/workspace-details/environments/environments.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.workspace-environments | ||
padding 0 14px 14px | ||
|
||
.workspace-environments-input | ||
margin -6px 0 | ||
|
||
.recipe-editor | ||
margin -4px 0 | ||
min-width 500px | ||
max-width 1000px | ||
|
||
.CodeMirror | ||
height auto | ||
border 1px solid $list-separator-color | ||
|
||
.recipe-location a | ||
word-break break-all |
56 changes: 56 additions & 0 deletions
56
...ils/environments/list-env-variables/add-variable-dialog/add-variable-dialog.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2015-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc controller | ||
* @name list.environment.variables.controller:AddVariableDialogController | ||
* @description This class is handling the controller for the dialog box about adding the environment variable. | ||
* @author Oleksii Kurinnyi | ||
*/ | ||
export class AddVariableDialogController { | ||
|
||
/** | ||
* Default constructor that is using resource | ||
* @ngInject for Dependency injection | ||
*/ | ||
constructor($mdDialog) { | ||
this.$mdDialog = $mdDialog; | ||
this.updateInProgress = false; | ||
|
||
this.name = ''; | ||
this.value = ''; | ||
} | ||
|
||
isUnique(name) { | ||
return !this.variables[name]; | ||
} | ||
|
||
/** | ||
* It will hide the dialog box. | ||
*/ | ||
hide() { | ||
this.$mdDialog.hide(); | ||
} | ||
|
||
/** | ||
* Adds new environment variable | ||
*/ | ||
addVariable() { | ||
this.updateInProgress = true; | ||
|
||
this.callbackController.updateEnvVariable(this.name, this.value).finally(() => { | ||
this.updateInProgress = false; | ||
this.hide(); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.