mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 23:41:55 +00:00
Merge pull request #8 from avatao-content/routing
Add routing support (depends on backend multi-websocket support)
This commit is contained in:
commit
958239a681
21
src/app/app-routing.module.ts
Normal file
21
src/app/app-routing.module.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||
import { WebideComponent } from './webide/webide.component';
|
||||
import { TerminalComponent } from './terminal/terminal.component';
|
||||
import { MessagesComponent } from './messages/messages.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
|
||||
{ path: 'dashboard', component: DashboardComponent},
|
||||
{ path: 'webide', component: WebideComponent },
|
||||
{ path: 'shell', component: TerminalComponent },
|
||||
{ path: 'messages', component: MessagesComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [ RouterModule.forRoot(routes) ],
|
||||
exports: [ RouterModule ],
|
||||
})
|
||||
export class AppRoutingModule {}
|
@ -1,11 +1 @@
|
||||
<app-header></app-header>
|
||||
<div class="container-fluid">
|
||||
<div class="row tfw-first-row">
|
||||
<div class="col-sm"><app-login></app-login></div>
|
||||
<div class="col-sm-6"><app-webide></app-webide></div>
|
||||
<div class="col-sm"><app-messages></app-messages></div>
|
||||
</div>
|
||||
<div class="row tfw-second-row">
|
||||
<div class="col-sm"><app-terminal></app-terminal></div>
|
||||
</div>
|
||||
</div>
|
||||
<router-outlet></router-outlet>
|
||||
|
@ -1,5 +0,0 @@
|
||||
.tfw-first-row {
|
||||
height: 40vh;
|
||||
}
|
||||
|
||||
.tfw-second-row {}
|
@ -1,20 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { WebSocketService } from './websocket.service';
|
||||
import { FSMUpdateService } from './fsmupdate.service';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'app';
|
||||
|
||||
constructor(private webSocketService: WebSocketService, private fsmUpdateService: FSMUpdateService) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.webSocketService.connect();
|
||||
this.webSocketService.send('reset', '');
|
||||
this.fsmUpdateService.init();
|
||||
}
|
||||
export class AppComponent {
|
||||
constructor() {}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import { AceEditorModule } from 'ng2-ace-editor';
|
||||
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||
import { HeaderComponent } from './header/header.component';
|
||||
import { LoginComponent } from './login/login.component';
|
||||
import { MarkdownService } from './markdown.service';
|
||||
@ -16,6 +17,7 @@ import { MessagesComponent } from './messages/messages.component';
|
||||
import { WebSocketService } from './websocket.service';
|
||||
import { TerminalComponent } from './terminal/terminal.component';
|
||||
import { FSMUpdateService } from './fsmupdate.service';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -25,7 +27,8 @@ import { FSMUpdateService } from './fsmupdate.service';
|
||||
LoginComponent,
|
||||
WebideComponent,
|
||||
MessagesComponent,
|
||||
TerminalComponent
|
||||
TerminalComponent,
|
||||
DashboardComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
@ -33,6 +36,7 @@ import { FSMUpdateService } from './fsmupdate.service';
|
||||
HttpClientModule,
|
||||
NgbModule.forRoot(),
|
||||
AceEditorModule,
|
||||
AppRoutingModule,
|
||||
],
|
||||
providers: [
|
||||
MarkdownService,
|
||||
|
11
src/app/dashboard/dashboard.component.html
Normal file
11
src/app/dashboard/dashboard.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<app-header></app-header>
|
||||
<div class="container-fluid">
|
||||
<div class="row tfw-first-row">
|
||||
<div class="col-sm"><app-login></app-login></div>
|
||||
<div class="col-sm-6"><app-webide></app-webide></div>
|
||||
<div class="col-sm"><app-messages></app-messages></div>
|
||||
</div>
|
||||
<div class="row tfw-second-row">
|
||||
<div class="col-sm"><app-terminal></app-terminal></div>
|
||||
</div>
|
||||
</div>
|
5
src/app/dashboard/dashboard.component.scss
Normal file
5
src/app/dashboard/dashboard.component.scss
Normal file
@ -0,0 +1,5 @@
|
||||
.tfw-first-row {
|
||||
height: 40vh;
|
||||
}
|
||||
|
||||
.tfw-second-row {}
|
10
src/app/dashboard/dashboard.component.ts
Normal file
10
src/app/dashboard/dashboard.component.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent {
|
||||
constructor() {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { MarkdownService } from '../markdown.service';
|
||||
import { WebSocketService } from '../websocket.service';
|
||||
|
||||
@ -13,7 +13,8 @@ export class MessagesComponent implements OnInit {
|
||||
messages: Message[] = [];
|
||||
constructor(
|
||||
private markdownService: MarkdownService,
|
||||
private websocketService: WebSocketService
|
||||
private websocketService: WebSocketService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) {}
|
||||
|
||||
convert(text: string) {
|
||||
@ -21,12 +22,13 @@ export class MessagesComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.websocketService.connect();
|
||||
this.websocketService.observeAnchor<Message>('message').subscribe(
|
||||
(event) => {
|
||||
this.messages.push(event.data);
|
||||
event.data.message = this.convert(event.data.message);
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ export class WebideComponent implements OnInit {
|
||||
private changeDetectorRef: ChangeDetectorRef) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.webSocketService.connect();
|
||||
this.subscribeWS();
|
||||
this.requestCode();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user