mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 21:51:57 +00:00
Merge pull request #19 from avatao-content/config_refactor
Config refactor
This commit is contained in:
commit
2d82b83b06
@ -6,14 +6,15 @@ import { WebideComponent } from './webide/webide.component';
|
||||
import { TerminalComponent } from './terminal/terminal.component';
|
||||
import { MessagesComponent } from './messages/messages.component';
|
||||
import { TestmessengerComponent } from './testmessenger/testmessenger.component';
|
||||
import { config } from './config';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
|
||||
{ path: 'dashboard', component: DashboardComponent},
|
||||
{ path: 'webide', component: WebideComponent },
|
||||
{ path: 'shell', component: TerminalComponent },
|
||||
{ path: 'messages', component: MessagesComponent },
|
||||
{ path: 'testmessenger', component: TestmessengerComponent }
|
||||
{ path: config.dashboard.route, component: DashboardComponent},
|
||||
{ path: config.webide.route, component: WebideComponent },
|
||||
{ path: config.terminal.route, component: TerminalComponent },
|
||||
{ path: config.messages.route, component: MessagesComponent },
|
||||
{ path: config.testmessenger.route, component: TestmessengerComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
24
src/app/config.ts
Normal file
24
src/app/config.ts
Normal file
@ -0,0 +1,24 @@
|
||||
export const config = {
|
||||
dashboard: {
|
||||
'route': 'dashboard',
|
||||
'defaultLayout': 'vraw-open'
|
||||
},
|
||||
webide: {
|
||||
'route': 'webide',
|
||||
'autoSaveInterval': 1000,
|
||||
'defaultCode': 'Loading your file...',
|
||||
'defaultLanguage': 'text',
|
||||
'deployProcessName': 'login',
|
||||
'showDeployButton': true
|
||||
},
|
||||
terminal: {
|
||||
'route': 'shell'
|
||||
},
|
||||
messages: {
|
||||
'route': 'messages',
|
||||
'showNextButton': false
|
||||
},
|
||||
testmessenger: {
|
||||
'route': 'testmessenger'
|
||||
}
|
||||
};
|
@ -3,6 +3,7 @@ import { DeploymentNotificationService } from '../services/deployment-notificati
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { WebSocketService } from '../services/websocket.service';
|
||||
import { LayoutCommand } from './layout-command';
|
||||
import { config } from '../config';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -12,7 +13,7 @@ import { LayoutCommand } from './layout-command';
|
||||
export class DashboardComponent implements OnInit, OnDestroy {
|
||||
deploying = false;
|
||||
deploymentNotificationSubscription: Subscription;
|
||||
layout = 'vraw-open';
|
||||
layout: string = config.dashboard.defaultLayout;
|
||||
command_handlers = {'layout': this.layoutHandler.bind(this)};
|
||||
|
||||
constructor(private deploymentNotificationService: DeploymentNotificationService,
|
||||
@ -33,8 +34,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
layoutHandler(data: LayoutCommand) {
|
||||
if (data.layout.match('vraw-open|vraw-closed|hraw|default-open|default-closed')) {
|
||||
this.layout = data.layout;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('Invalid webide layout "' + data.layout + '" received!');
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,10 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.component.html',
|
||||
styleUrls: ['./header.component.scss']
|
||||
})
|
||||
export class HeaderComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
export class HeaderComponent {
|
||||
constructor() {}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { WebSocketService } from '../services/websocket.service';
|
||||
|
||||
import { Message } from './message';
|
||||
import { MessageControl } from './messagecontrol';
|
||||
import { config } from '../config';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
@ -12,7 +13,7 @@ import { MessageControl } from './messagecontrol';
|
||||
})
|
||||
export class MessagesComponent implements OnInit {
|
||||
messages: Message[] = [];
|
||||
showNextButton = false;
|
||||
showNextButton: boolean = config.messages.showNextButton;
|
||||
command_handlers = {'showbutton': this.showButton.bind(this)};
|
||||
|
||||
constructor(
|
||||
|
@ -1,5 +1,5 @@
|
||||
export class WSMessage<T> {
|
||||
key: string;
|
||||
trigger?: string;
|
||||
data: T; // TODO: sane annotation
|
||||
data: T;
|
||||
}
|
||||
|
@ -14,7 +14,8 @@
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm tfw-deploy-btn-group">
|
||||
<button type="submit"
|
||||
<button *ngIf="showDeployButton"
|
||||
type="submit"
|
||||
class="btn tfw-deploy-btn tao-grid-top-center"
|
||||
(click)="sendCodeIfDirty(); deployCode()"
|
||||
[disabled]="deployButtonState === 'DEPLOYING' || deployButtonState === 'DEPLOYED'"
|
||||
|
@ -16,12 +16,10 @@ import { SourceCode } from './source-code';
|
||||
import { WebSocketService } from '../services/websocket.service';
|
||||
import { ProcessManagerService } from '../services/processmanager.service';
|
||||
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
||||
import { config } from '../config';
|
||||
|
||||
const modelist = brace.acequire('ace/ext/modelist');
|
||||
|
||||
const defaultSourceCode = 'Loading your file...';
|
||||
const autosave_interval = 1000;
|
||||
|
||||
@Component({
|
||||
selector: 'app-webide',
|
||||
templateUrl: './webide.component.html',
|
||||
@ -29,14 +27,15 @@ const autosave_interval = 1000;
|
||||
})
|
||||
export class WebideComponent implements OnInit {
|
||||
key_id = 'webide';
|
||||
filename = 'demo.js';
|
||||
code: string = defaultSourceCode;
|
||||
language = 'javascript';
|
||||
filename = '';
|
||||
code: string = config.webide.defaultCode;
|
||||
language: string = config.webide.defaultLanguage;
|
||||
theme = 'cobalt';
|
||||
directory = '';
|
||||
files: string[];
|
||||
codeState = 'SAVED';
|
||||
deployButtonState = 'DEPLOYED';
|
||||
showDeployButton: boolean = config.webide.showDeployButton;
|
||||
autosave = null;
|
||||
command_handlers = {'reload': this.reloadHandler.bind(this),
|
||||
'read': this.readHandler.bind(this),
|
||||
@ -54,8 +53,8 @@ export class WebideComponent implements OnInit {
|
||||
this.subscribeWS();
|
||||
this.requestCode();
|
||||
this.processManagerService.init();
|
||||
this.processManagerService.subscribeCallback('login', (event) => { this.setDeployButtonState('DEPLOYED'); });
|
||||
this.processManagerService.subscribeErrorCallback('login', (event) => { this.setDeployButtonState('FAILED'); });
|
||||
this.processManagerService.subscribeCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('DEPLOYED'); });
|
||||
this.processManagerService.subscribeErrorCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); });
|
||||
this.resetAutoSaveCountdown();
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ export class WebideComponent implements OnInit {
|
||||
if (this.autosave) {
|
||||
clearInterval(this.autosave);
|
||||
}
|
||||
this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, autosave_interval);
|
||||
this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval);
|
||||
}
|
||||
|
||||
tabSwitchButtonHandler(file) {
|
||||
|
Loading…
Reference in New Issue
Block a user