You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/10/07 12:16:44 UTC
[incubator-dlab] 03/04: [DLAB-1119]: added webterminal changes
This is an automated email from the ASF dual-hosted git repository.
ankovalyshyn pushed a commit to branch DLAB-1119-2
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit de24b6d6ab414dfe3b5596e5e10362f0a9e2f1e2
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Mon Oct 7 13:10:50 2019 +0300
[DLAB-1119]: added webterminal changes
---
.../webapp/src/app/core/util/checkUtils.ts | 5 +++
.../webapp/src/app/core/util/fileUtils.ts | 15 +++++++++
.../src/app/webterminal/webterminal.component.html | 6 +++-
.../src/app/webterminal/webterminal.component.scss | 16 ++++++++--
.../src/app/webterminal/webterminal.component.ts | 36 +++++++++++++++-------
5 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/checkUtils.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/checkUtils.ts
index f975d90..3b3d3e3 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/util/checkUtils.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/checkUtils.ts
@@ -43,4 +43,9 @@ export class CheckUtils {
public static delimitersFiltering(resource): string {
return resource.replace(RegExp(PATTERNS.delimitersRegex, 'g'), '').toString().toLowerCase();
}
+
+ public static decodeUnicode(str) {
+ str = str.replace(/\\/g, "%");
+ return unescape(str);
+ }
}
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts b/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
index 0a3a32c..98ec0f5 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/util/fileUtils.ts
@@ -36,4 +36,19 @@ export class FileUtils {
}
window.URL.revokeObjectURL(url);
}
+
+
+ public static copyToClipboard(val: string) {
+ const selBox = document.createElement('textarea');
+ selBox.style.position = 'fixed';
+ selBox.style.left = '0';
+ selBox.style.top = '0';
+ selBox.style.opacity = '0';
+ selBox.value = val;
+ document.body.appendChild(selBox);
+ selBox.focus();
+ selBox.select();
+ document.execCommand('copy');
+ document.body.removeChild(selBox);
+ }
}
diff --git a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.html b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.html
index d99bf42..1f5d4ca 100644
--- a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.html
@@ -17,4 +17,8 @@
~ under the License.
-->
-<div id="display" #display></div>
+<div id="main-guacamole-ui">
+ <div id="state"> {{ state }} </div>
+
+ <div #terminal id="display" class="guac-display guac-loading"></div>
+</div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.scss b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.scss
index cdf9269..d17e197 100644
--- a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.scss
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.scss
@@ -16,15 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
#terminal {
- height: 100vh;
+ // height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
+ background-attachment: red;
}
+
@media screen and (min-width: 1281px) {
#terminal {
justify-content: center;
}
}
+
+.guac-display {
+ display: flex;
+ justify-content: center;
+
+ zoom: .85 !important;
+ -moz-transform: scale(.85);
+
+ margin-top: 10px
+}
diff --git a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.ts b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.ts
index d6cd8e8..f8761a2 100644
--- a/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.ts
@@ -17,22 +17,32 @@
* under the License.
*/
-import { Component, OnInit, ViewEncapsulation, ViewContainerRef, ViewChild, Inject } from '@angular/core';
+import { Component, OnInit, ElementRef, ViewEncapsulation, ViewContainerRef, ViewChild, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { ActivatedRoute } from '@angular/router';
import Guacamole from 'guacamole-common-js';
+import { environment } from '../../environments/environment';
+
+// we can now access environment.apiUrl
+const API_URL = environment.apiUrl;
+
import { StorageService } from '../core/services';
+import { FileUtils } from '../core/util';
@Component({
selector: 'dlab-webterminal',
templateUrl: './webterminal.component.html',
- styleUrls: ['./webterminal.component.scss']
+ styleUrls: ['./webterminal.component.scss'],
+ encapsulation: ViewEncapsulation.None
})
export class WebterminalComponent implements OnInit {
public id: string;
public endpoint: string;
- @ViewChild('terminal', { read: ViewContainerRef, static: false }) terminal: ViewContainerRef;
+ public state: string = '';
+ public layer;
+ @ViewChild('terminal', { read: ElementRef, static: false }) terminal: ElementRef;
+ @ViewChild('clip', { static: true }) clip;
constructor(
@@ -44,13 +54,14 @@ export class WebterminalComponent implements OnInit {
ngOnInit() {
this.id = this.route.snapshot.paramMap.get('id');
this.endpoint = this.route.snapshot.paramMap.get('endpoint');
- console.log(this.id);
this.open(this.id, this.endpoint);
}
public open(id_parameter: string, endpoint_parameter: string) {
+ // added to simplify development process
+ const url = environment.production ? window.location.origin : API_URL;
const tunnel = new Guacamole.HTTPTunnel(
- `${window.location.origin}/api/tunnel`, false,
+ `${url}/api/tunnel`, false,
{ 'Authorization': `Bearer ${this.storageService.getToken()}` }
);
@@ -58,9 +69,9 @@ export class WebterminalComponent implements OnInit {
const display = document.getElementById('display');
display.appendChild(guac.getDisplay().getElement());
- const guacDisplay = guac.getDisplay();
- const layer = guacDisplay.getDefaultLayer();
- guac.connect("{\"host\" : \""+ id_parameter + "\", \"endpoint\" : \"" + endpoint_parameter + "\"}");
+ this.layer = guac.getDisplay().getDefaultLayer();
+
+ guac.connect(`{"host" : "${id_parameter}", "endpoint" : "${endpoint_parameter}"}`);
// Error handler
guac.onerror = (error) => console.log(error.message);
@@ -68,11 +79,14 @@ export class WebterminalComponent implements OnInit {
// Mouse
const mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
- mouse.onmousemove = (mouseState) => guac.sendMouseState(mouseState);
+ mouse.onmousemove = (mouseState) => {
+ mouseState.x = mouseState.x + 95;
+ mouseState.y = mouseState.y + 45;
+ guac.sendMouseState(mouseState);
+ }
- // Keyboard
const keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = (keysym) => guac.sendKeyEvent(1, keysym);
keyboard.onkeyup = (keysym) => guac.sendKeyEvent(0, keysym);
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org