Skip to content

Commit 4e7f9fa

Browse files
author
Oleksii Kurinnyi
committed
CHE-1771: add Runtime page to Workspace details.
Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com>
1 parent b322ab5 commit 4e7f9fa

55 files changed

Lines changed: 3801 additions & 107 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dashboard/bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"zeroclipboard": "2.2.0",
3434
"angular-uuid4": "0.3.0",
3535
"angular-file-upload": "2.0.0",
36-
"jquery": "2.1.3"
37-
},
38-
"devDependencies": {
36+
"jquery": "2.1.3",
37+
"js-yaml": "3.6.1"
3938
},
39+
"devDependencies": {},
4040
"resolutions": {
4141
"angular": "~1.4.8"
4242
},

dashboard/src/app/workspaces/create-workspace/select-stack/recipe/workspace-recipe.styl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
.recipe-widget
22
margin-left 10px
33

4-
.recipe-widget md-radio-button
5-
outline 0
4+
md-radio-button
5+
outline 0
66

7-
.recipe-editor
8-
min-width 500px
9-
max-width 1000px
10-
margin-top 20px
7+
.recipe-editor
8+
min-width 500px
9+
max-width 1000px
10+
margin-top 20px
1111

12-
.recipe-editor .CodeMirror
13-
border 1px solid $list-separator-color
14-
min-height 500px
12+
.recipe-editor .CodeMirror
13+
border 1px solid $list-separator-color
14+
min-height 500px
1515

16-
.recipe-docs-link
17-
margin-top 5px
16+
.recipe-docs-link
17+
margin-top 5px
1818

19-
.recipe-widget .recipe-url
20-
width calc(100% - 10px)
21-
margin-bottom 20px
19+
.recipe-url
20+
width calc(100% - 10px)
21+
margin-bottom 20px
2222

2323
.recipe-format .che-toggle-button-enabled
2424
color $primary-color !important
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright (c) 2015-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*/
11+
'use strict';
12+
13+
/**
14+
* @ngdoc controller
15+
* @name workspace.details.controller:WorkspaceEnvironmentsController
16+
* @description This class is handling the controller for details of workspace : section environments
17+
* @author Oleksii Kurinnyi
18+
*/
19+
export class WorkspaceEnvironmentsController {
20+
21+
/**
22+
* Default constructor that is using resource injection
23+
* @ngInject for Dependency injection
24+
*/
25+
constructor($timeout, cheEnvironmentRegistry) {
26+
this.cheEnvironmentRegistry = cheEnvironmentRegistry;
27+
28+
this.editorOptions = {
29+
lineWrapping: true,
30+
lineNumbers: false,
31+
readOnly: true,
32+
gutters: [],
33+
onLoad: (editor) => {
34+
$timeout(() => {
35+
editor.refresh();
36+
}, 1000);
37+
}
38+
};
39+
40+
this.machinesViewStatus = {};
41+
42+
this.init();
43+
}
44+
45+
/**
46+
* Sets initial values
47+
*/
48+
init() {
49+
this.newEnvironmentName = this.environmentName;
50+
this.environment = this.workspaceConfig.environments[this.environmentName];
51+
52+
this.recipeType = this.environment.recipe.type;
53+
this.environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(this.recipeType);
54+
55+
this.editorOptions.mode = this.environmentManager.editorMode;
56+
57+
this.machines = this.environmentManager.getMachines(this.environment);
58+
}
59+
60+
/**
61+
* Returns true if environment name is unique
62+
*
63+
* @param name {string} environment name to validate
64+
* @returns {boolean}
65+
*/
66+
isUnique(name) {
67+
return name === this.environmentName || !this.workspaceConfig.environments[name];
68+
}
69+
70+
/**
71+
* Updates name of environment
72+
* @param isFormValid {boolean}
73+
*/
74+
updateEnvironmentName(isFormValid) {
75+
if (!isFormValid || this.newEnvironmentName === this.environmentName) {
76+
return;
77+
}
78+
79+
this.workspaceConfig.environments[this.newEnvironmentName] = this.environment;
80+
delete this.workspaceConfig.environments[this.environmentName];
81+
82+
if (this.workspaceConfig.defaultEnv === this.environmentName) {
83+
this.workspaceConfig.defaultEnv = this.newEnvironmentName;
84+
}
85+
86+
this.doUpdateEnvironments();
87+
}
88+
89+
/**
90+
* Callback which is called in order to update environment config
91+
* @returns {Promise}
92+
*/
93+
updateEnvironmentConfig() {
94+
let newEnvironment = this.environmentManager.getEnvironment(this.environment, this.machines);
95+
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment;
96+
return this.doUpdateEnvironments().then(() => {
97+
this.init();
98+
});
99+
}
100+
101+
/**
102+
* Callback which is called in order to rename specified machine
103+
* @param oldName
104+
* @param newName
105+
* @returns {*}
106+
*/
107+
updateMachineName(oldName, newName) {
108+
let newEnvironment = this.environmentManager.renameMachine(this.environment, oldName, newName);
109+
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment;
110+
return this.doUpdateEnvironments().then(() => {
111+
this.init();
112+
})
113+
}
114+
115+
/**
116+
* Callback which is called in order to delete specified machine
117+
* @param name
118+
* @returns {*}
119+
*/
120+
deleteMachine(name) {
121+
let newEnvironment = this.environmentManager.deleteMachine(this.environment, name);
122+
this.workspaceConfig.environments[this.newEnvironmentName] = newEnvironment;
123+
return this.doUpdateEnvironments().then(() => {
124+
this.init();
125+
})
126+
}
127+
128+
/**
129+
* Calls parent controller's callback to update environment
130+
* @returns {IPromise<TResult>|*|Promise.<TResult>}
131+
*/
132+
doUpdateEnvironments() {
133+
return this.environmentOnChange();
134+
}
135+
136+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2015-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*/
11+
'use strict';
12+
13+
/**
14+
* @ngdoc directive
15+
* @name workspaces.details.directive:workspaceEnvironments
16+
* @restrict E
17+
* @element
18+
*
19+
* @description
20+
* <workspace-environments></workspace-environmentss>` for displaying workspace environments.
21+
*
22+
* @usage
23+
* <workspace-environments></workspace-environments>
24+
*
25+
* @author Oleksii Kurinnyi
26+
*/
27+
export class WorkspaceEnvironments {
28+
29+
/**
30+
* Default constructor that is using resource
31+
* @ngInject for Dependency injection
32+
*/
33+
constructor () {
34+
this.restrict = 'E';
35+
this.templateUrl = 'app/workspaces/workspace-details/environments/environments.html';
36+
37+
this.controller = 'WorkspaceEnvironmentsController';
38+
this.controllerAs = 'workspaceEnvironmentsController';
39+
this.bindToController = true;
40+
41+
this.scope = {
42+
environmentName: '=',
43+
environmentViewStatus: '=',
44+
workspaceConfig: '=',
45+
environmentOnChange: '&'
46+
}
47+
}
48+
}
49+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!--
2+
3+
Copyright (c) 2015 Codenvy, S.A.
4+
All rights reserved. This program and the accompanying materials
5+
are made available under the terms of the Eclipse Public License v1.0
6+
which accompanies this distribution, and is available at
7+
http://www.eclipse.org/legal/epl-v10.html
8+
9+
Contributors:
10+
Codenvy, S.A. - initial API and implementation
11+
12+
-->
13+
<div class="workspace-environments">
14+
15+
<!-- Name -->
16+
<che-label-container che-label-name="Name">
17+
<ng-form flex layout="column" name="workspaceEnvironmentsForm">
18+
<div layout="column" class="workspace-environments-input">
19+
<che-input che-form="workspaceEnvironmentsForm"
20+
che-name="name"
21+
che-place-holder="Name of the environment"
22+
aria-label="Name of the environment"
23+
ng-model="workspaceEnvironmentsController.newEnvironmentName"
24+
ng-change="workspaceEnvironmentsController.updateEnvironmentName(workspaceEnvironmentsForm.$valid)"
25+
ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 2000, 'blur': 0 } }"
26+
custom-validator="workspaceEnvironmentsController.isUnique($value)"
27+
required
28+
ng-maxlength="128"
29+
ng-pattern="/^[A-Za-z0-9_\-\.]+$/">
30+
<div ng-message="required">A name is required.</div>
31+
<div ng-message="pattern">The name should not contain special characters like space, dollar, etc.
32+
</div>
33+
<div ng-message="maxlength">The name has to be less than 128 characters long.</div>
34+
<div ng-message="md-maxlength">The name has to be less than 128 characters long.</div>
35+
<div ng-message="customValidator">This environment name is already used.</div>
36+
</che-input>
37+
</div>
38+
</ng-form>
39+
</che-label-container>
40+
41+
<!-- Machines -->
42+
<che-label-container ng-if="workspaceEnvironmentsController.environment.machines.length"
43+
che-label-name="Machines"
44+
class="che-label-container-last">
45+
</che-label-container>
46+
<workspace-machine-config ng-repeat="machine in workspaceEnvironmentsController.machines"
47+
machine-name="machine.name"
48+
machines-list="workspaceEnvironmentsController.machines"
49+
environment-manager="workspaceEnvironmentsController.environmentManager"
50+
machine-name-on-change="workspaceEnvironmentsController.updateMachineName(oldName,newName)"
51+
machine-config-on-change="workspaceEnvironmentsController.updateEnvironmentConfig()"
52+
machine-on-delete="workspaceEnvironmentsController.deleteMachine(name)"
53+
machine-is-opened="workspaceEnvironmentsController.machinesViewStatus[machine.name]"></workspace-machine-config>
54+
55+
<!-- Recipe Content-->
56+
<che-label-container che-label-name="Recipe"
57+
che-label-description="The contents of the runtime started by the workspace."
58+
ng-if="workspaceEnvironmentsController.environment.recipe.content">
59+
<div layout="row" layout-wrap>
60+
<div flex class="recipe-editor">
61+
<ui-codemirror ui-codemirror="workspaceEnvironmentsController.editorOptions"
62+
ng-model="workspaceEnvironmentsController.environment.recipe.content"></ui-codemirror>
63+
</div>
64+
</div>
65+
</che-label-container>
66+
<!-- OR Location -->
67+
<che-label-container che-label-name="Recipe Location"
68+
ng-if="workspaceEnvironmentsController.recipeType !== 'dockerimage' && workspaceEnvironmentsController.environment.recipe.location">
69+
<che-text-info che-text="workspaceEnvironmentsController.environment.recipe.location"
70+
che-href="workspaceEnvironmentsController.environment.recipe.location"
71+
che-copy-clipboard="true"
72+
class="recipe-location"></che-text-info>
73+
</che-label-container>
74+
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.workspace-environments
2+
padding 0 14px 14px
3+
4+
.workspace-environments-input
5+
margin -6px 0
6+
7+
.recipe-editor
8+
margin -4px 0
9+
min-width 500px
10+
max-width 1000px
11+
12+
.CodeMirror
13+
height auto
14+
border 1px solid $list-separator-color
15+
16+
.recipe-location a
17+
word-break break-all
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2015-2016 Codenvy, S.A.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Codenvy, S.A. - initial API and implementation
10+
*/
11+
'use strict';
12+
13+
/**
14+
* @ngdoc controller
15+
* @name list.environment.variables.controller:AddVariableDialogController
16+
* @description This class is handling the controller for the dialog box about adding the environment variable.
17+
* @author Oleksii Kurinnyi
18+
*/
19+
export class AddVariableDialogController {
20+
21+
/**
22+
* Default constructor that is using resource
23+
* @ngInject for Dependency injection
24+
*/
25+
constructor($mdDialog) {
26+
this.$mdDialog = $mdDialog;
27+
this.updateInProgress = false;
28+
29+
this.name = '';
30+
this.value = '';
31+
}
32+
33+
isUnique(name) {
34+
return !this.variables[name];
35+
}
36+
37+
/**
38+
* It will hide the dialog box.
39+
*/
40+
hide() {
41+
this.$mdDialog.hide();
42+
}
43+
44+
/**
45+
* Adds new environment variable
46+
*/
47+
addVariable() {
48+
this.updateInProgress = true;
49+
50+
this.callbackController.updateEnvVariable(this.name, this.value).finally(() => {
51+
this.updateInProgress = false;
52+
this.hide();
53+
});
54+
}
55+
56+
}

0 commit comments

Comments
 (0)