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:25 UTC
[incubator-dlab] 03/12: [DLAB-4]: added web terminal component
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 255cb90c631d8a52affc1add7872f4cbca44b3b3
Author: Andriana Kovalyshyn <an...@epam.com>
AuthorDate: Tue May 7 17:09:43 2019 +0300
[DLAB-4]: added web terminal component
---
.../resources/webapp/src/app/webterminal/index.ts | 36 ++++++++++
.../src/app/webterminal/webterminal.component.html | 20 ++++++
.../src/app/webterminal/webterminal.component.scss | 23 +++++++
.../src/app/webterminal/webterminal.component.ts | 77 ++++++++++++++++++++++
4 files changed, 156 insertions(+)
diff --git a/services/self-service/src/main/resources/webapp/src/app/webterminal/index.ts b/services/self-service/src/main/resources/webapp/src/app/webterminal/index.ts
new file mode 100644
index 0000000..5b01d6a
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/index.ts
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
+import { MaterialModule } from '../shared/material.module';
+import { WebterminalComponent } from './webterminal.component';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FormsModule,
+ ReactiveFormsModule,
+ MaterialModule
+ ],
+ declarations: [WebterminalComponent],
+ exports: [WebterminalComponent]
+})
+export class WebterminalModule { }
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
new file mode 100644
index 0000000..d99bf42
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.html
@@ -0,0 +1,20 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+-->
+
+<div id="display" #display></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
new file mode 100644
index 0000000..57b8cc4
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.scss
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#terminal {
+ height: 100vh;
+ display: block;
+}
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
new file mode 100644
index 0000000..eae2e12
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/webterminal/webterminal.component.ts
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Component, OnInit, ViewEncapsulation, ViewContainerRef, ViewChild, Renderer2, ElementRef, Inject } from '@angular/core';
+import { DOCUMENT } from '@angular/common';
+import { ActivatedRoute } from '@angular/router';
+
+import Guacamole from 'guacamole-common-js';
+
+@Component({
+ selector: 'dlab-webterminal',
+ templateUrl: './webterminal.component.html',
+ styleUrls: ['./webterminal.component.scss']
+})
+export class WebterminalComponent implements OnInit {
+ public id: string;
+ @ViewChild('terminal', { read: ViewContainerRef }) terminal: ViewContainerRef;
+
+ constructor(
+ private elementRef: ElementRef,
+ private renderer: Renderer2,
+ private route: ActivatedRoute,
+ @Inject(DOCUMENT) private document) {
+ }
+
+ ngOnInit() {
+ this.id = this.route.snapshot.paramMap.get('id');
+ console.log(this.id);
+ this.open(this.id);
+ }
+
+ open(parameters) {
+
+ const tunnel = new Guacamole.HTTPTunnel(
+ 'https://localhost:8443/api/tunnel', false,
+ { 'Authorization': 'Bearer token123' }
+ );
+ const guac = new Guacamole.Client(tunnel);
+ const display = document.getElementById('display');
+
+ display.appendChild(guac.getDisplay().getElement());
+
+ guac.connect('52.10.77.216');
+
+ // Error handler
+ guac.onerror = (error) => alert(error);
+ 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