From 52cfd4bf5545599636f1d2f972ace4f2dd45a393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 25 Apr 2018 11:48:15 +0200 Subject: [PATCH] Refactor WebComponent and iframing to be mutually exclusive, strip old app --- proxy.conf.json | 2 +- src/app/app.module.ts | 8 +++-- src/app/config.ts | 3 +- src/app/dashboard/dashboard.component.html | 13 ++++--- src/app/dashboard/dashboard.component.ts | 1 + src/app/messages/messages.component.html | 1 - src/app/pipes/safe.pipe.ts | 13 +++++++ src/app/web/web.component.html | 41 ++-------------------- src/app/web/web.component.ts | 34 +++--------------- src/app/web/web.ts | 8 ----- 10 files changed, 37 insertions(+), 87 deletions(-) create mode 100644 src/app/pipes/safe.pipe.ts delete mode 100644 src/app/web/web.ts diff --git a/proxy.conf.json b/proxy.conf.json index 234cd6c..3e340aa 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -11,7 +11,7 @@ "ws": true }, - "/login": { + "/webservice": { "target": "http://localhost:8888", "secure": false } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d829e55..c8cddd0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,7 +10,7 @@ import { AppComponent } from './app.component'; import { DashboardComponent } from './dashboard/dashboard.component'; import { HeaderComponent } from './header/header.component'; import { SidebarComponent } from './sidebar/sidebar.component'; -import { LoginComponent } from './web/web.component'; +import { WebComponent } from './web/web.component'; import { MarkdownService } from './services/markdown.service'; import { TerminadoService } from './services/terminado.service'; import { IdeComponent } from './ide/ide.component'; @@ -22,6 +22,7 @@ import { ProcessManagerService } from './services/processmanager.service'; import { AppRoutingModule } from './app-routing.module'; import { TestmessengerComponent } from './testmessenger/testmessenger.component'; import { DeploymentNotificationService } from './services/deployment-notification.service'; +import { SafePipe } from './pipes/safe.pipe'; @NgModule({ @@ -29,12 +30,13 @@ import { DeploymentNotificationService } from './services/deployment-notificatio AppComponent, HeaderComponent, SidebarComponent, - LoginComponent, + WebComponent, IdeComponent, MessagesComponent, TerminalComponent, DashboardComponent, - TestmessengerComponent + TestmessengerComponent, + SafePipe ], imports: [ BrowserModule, diff --git a/src/app/config.ts b/src/app/config.ts index 44b3ab7..fb1847e 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -22,6 +22,7 @@ export const config = { 'ide-only', 'web-only' ], + iframeUrl: '/webservice', hide_messages: false }, ide: { @@ -29,7 +30,7 @@ export const config = { autoSaveInterval: 444, defaultCode: 'Loading your file...', defaultLanguage: 'text', - deployProcessName: 'login', + deployProcessName: 'webservice', showDeployButton: true }, terminal: { diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 677463a..40b3cdb 100755 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -4,11 +4,14 @@
-
- -
+ +
+ +
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 716d6a9..8728bf5 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -16,6 +16,7 @@ export class DashboardComponent implements OnInit, OnDestroy { deploymentNotificationSubscription: Subscription; layout: string = config.dashboard.currentLayout; hide_messages: boolean = config.dashboard.hide_messages; + iframeUrl: string = config.dashboard.iframeUrl; command_handlers = {'layout': this.layoutHandler.bind(this), 'reload_frontend': this.reloadFrontendHandlder.bind(this)}; diff --git a/src/app/messages/messages.component.html b/src/app/messages/messages.component.html index ba57822..6b5b47b 100755 --- a/src/app/messages/messages.component.html +++ b/src/app/messages/messages.component.html @@ -12,4 +12,3 @@
- diff --git a/src/app/pipes/safe.pipe.ts b/src/app/pipes/safe.pipe.ts new file mode 100644 index 0000000..28f18bd --- /dev/null +++ b/src/app/pipes/safe.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; + +@Pipe({ + name: 'safe' +}) +export class SafePipe implements PipeTransform { + constructor (private sanitizer: DomSanitizer) {} + + transform(value: string, args?: any): any { + return this.sanitizer.bypassSecurityTrustResourceUrl(value); + } +} diff --git a/src/app/web/web.component.html b/src/app/web/web.component.html index c85a8c4..63f9bf4 100644 --- a/src/app/web/web.component.html +++ b/src/app/web/web.component.html @@ -1,39 +1,2 @@ - -
- -
+

WebComponent is here!

+

Edit me if you want to write your own component in Angular!

diff --git a/src/app/web/web.component.ts b/src/app/web/web.component.ts index dd136b0..2f9b010 100644 --- a/src/app/web/web.component.ts +++ b/src/app/web/web.component.ts @@ -1,36 +1,12 @@ -import { HttpClient } from '@angular/common/http'; -import { Component, OnDestroy, OnInit } from '@angular/core'; -import { Observable } from 'rxjs/Observable'; -import { Login } from './web'; -import { DeploymentNotificationService } from '../services/deployment-notification.service'; -import { Subscription } from 'rxjs/Subscription'; +// Edit me if you want to write your own component in Angular! +import { Component } from '@angular/core'; +import { config } from '../config' @Component({ selector: 'app-web', templateUrl: './web.component.html', styleUrls: ['./web.component.scss'] }) -export class LoginComponent { - model = new Login('', ''); - submitted = false; - is_admin: boolean; - logged_in_email: string; - - constructor( - private http: HttpClient - ) {} - - onSubmit() { - this.postLogin(this.model).subscribe( - res => { - this.logged_in_email = res['email']; - this.is_admin = res['is_admin']; - } - ); - this.submitted = true; - } - - postLogin(login: Login): Observable { - return this.http.post('/web', login); - } +export class WebComponent { + constructor() {} } diff --git a/src/app/web/web.ts b/src/app/web/web.ts deleted file mode 100644 index 4413aad..0000000 --- a/src/app/web/web.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class Login { - - constructor( - public email: string, - public password: string - ) {} - -}