You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/07/25 11:31:29 UTC

[incubator-dlab] 07/12: [DLAB-4]: fixed location and token for connection

This is an automated email from the ASF dual-hosted git repository.

bhliva pushed a commit to branch v2.1.1
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 1a7be785a6206e6613d972a91085eb769110f0c2
Author: Andriana Kovalyshyn <an...@epam.com>
AuthorDate: Mon May 13 12:55:39 2019 +0300

    [DLAB-4]: fixed location and token for connection
---
 .../src/app/webterminal/webterminal.component.scss |  9 +++++++-
 .../src/app/webterminal/webterminal.component.ts   | 26 ++++++++++------------
 2 files changed, 20 insertions(+), 15 deletions(-)

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 57b8cc4..cdf9269 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
@@ -19,5 +19,12 @@
  
 #terminal {
   height: 100vh;
-  display: block;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+@media screen and (min-width: 1281px) {
+  #terminal {
+    justify-content: center;
+  }
 }
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 eae2e12..e11964f 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,12 +17,13 @@
  * under the License.
  */
 
-import { Component, OnInit, ViewEncapsulation, ViewContainerRef, ViewChild, Renderer2, ElementRef, Inject } from '@angular/core';
+import { Component, OnInit, ViewEncapsulation, ViewContainerRef, ViewChild, Inject } from '@angular/core';
 import { DOCUMENT } from '@angular/common';
 import { ActivatedRoute } from '@angular/router';
-
 import Guacamole from 'guacamole-common-js';
 
+import { StorageService } from '../core/services';
+
 @Component({
   selector: 'dlab-webterminal',
   templateUrl: './webterminal.component.html',
@@ -33,9 +34,8 @@ export class WebterminalComponent implements OnInit {
   @ViewChild('terminal', { read: ViewContainerRef }) terminal: ViewContainerRef;
 
   constructor(
-    private elementRef: ElementRef,
-    private renderer: Renderer2,
     private route: ActivatedRoute,
+    private storageService: StorageService,
     @Inject(DOCUMENT) private document) {
   }
 
@@ -45,33 +45,31 @@ export class WebterminalComponent implements OnInit {
     this.open(this.id);
   }
 
-  open(parameters) {
-
+  public open(id_parameter: string) {
     const tunnel = new Guacamole.HTTPTunnel(
-      'https://localhost:8443/api/tunnel', false,
-      { 'Authorization': 'Bearer token123' }
+      `${window.location.origin}/api/tunnel`, false,
+      { 'Authorization': `Bearer ${this.storageService.getToken()}` }
     );
+
     const guac = new Guacamole.Client(tunnel);
     const display = document.getElementById('display');
 
     display.appendChild(guac.getDisplay().getElement());
-
-    guac.connect('52.10.77.216');
+    const guacDisplay = guac.getDisplay();
+    const layer = guacDisplay.getDefaultLayer();
+    guac.connect(id_parameter);
 
     // Error handler
-    guac.onerror = (error) => alert(error);
+    guac.onerror = (error) => console.log(error.message);
     window.onunload = () => guac.disconnect();
 
     // Mouse
     const mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
-
     mouse.onmousemove = (mouseState) => guac.sendMouseState(mouseState);
 
     // Keyboard
     const keyboard = new Guacamole.Keyboard(document);
-
     keyboard.onkeydown = (keysym) => guac.sendKeyEvent(1, keysym);
-
     keyboard.onkeyup = (keysym) => guac.sendKeyEvent(0, keysym);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org