mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 20:51:57 +00:00
Refactor project to use config file
This commit is contained in:
parent
1b2b1c9f8d
commit
0682e53511
@ -6,14 +6,15 @@ import { WebideComponent } from './webide/webide.component';
|
|||||||
import { TerminalComponent } from './terminal/terminal.component';
|
import { TerminalComponent } from './terminal/terminal.component';
|
||||||
import { MessagesComponent } from './messages/messages.component';
|
import { MessagesComponent } from './messages/messages.component';
|
||||||
import { TestmessengerComponent } from './testmessenger/testmessenger.component';
|
import { TestmessengerComponent } from './testmessenger/testmessenger.component';
|
||||||
|
import { config } from './config';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
|
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
|
||||||
{ path: 'dashboard', component: DashboardComponent},
|
{ path: config.dashboard.route, component: DashboardComponent},
|
||||||
{ path: 'webide', component: WebideComponent },
|
{ path: config.webide.route, component: WebideComponent },
|
||||||
{ path: 'shell', component: TerminalComponent },
|
{ path: config.terminal.route, component: TerminalComponent },
|
||||||
{ path: 'messages', component: MessagesComponent },
|
{ path: config.messages.route, component: MessagesComponent },
|
||||||
{ path: 'testmessenger', component: TestmessengerComponent }
|
{ path: config.testmessenger.route, component: TestmessengerComponent }
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
23
src/app/config.ts
Normal file
23
src/app/config.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export const config = {
|
||||||
|
dashboard: {
|
||||||
|
'route': 'dashboard',
|
||||||
|
'defaultLayout': 'vraw-open'
|
||||||
|
},
|
||||||
|
webide: {
|
||||||
|
'route': 'webide',
|
||||||
|
'autoSaveInterval': 1000,
|
||||||
|
'defaultCode': 'Loading your file...',
|
||||||
|
'defaultLanguage': 'text',
|
||||||
|
'deployProcessName': 'login'
|
||||||
|
},
|
||||||
|
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 { Subscription } from 'rxjs/Subscription';
|
||||||
import { WebSocketService } from '../services/websocket.service';
|
import { WebSocketService } from '../services/websocket.service';
|
||||||
import { LayoutCommand } from './layout-command';
|
import { LayoutCommand } from './layout-command';
|
||||||
|
import { config } from '../config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
@ -12,7 +13,7 @@ import { LayoutCommand } from './layout-command';
|
|||||||
export class DashboardComponent implements OnInit, OnDestroy {
|
export class DashboardComponent implements OnInit, OnDestroy {
|
||||||
deploying = false;
|
deploying = false;
|
||||||
deploymentNotificationSubscription: Subscription;
|
deploymentNotificationSubscription: Subscription;
|
||||||
layout = 'vraw-open';
|
layout: string = config.dashboard.defaultLayout;
|
||||||
command_handlers = {'layout': this.layoutHandler.bind(this)};
|
command_handlers = {'layout': this.layoutHandler.bind(this)};
|
||||||
|
|
||||||
constructor(private deploymentNotificationService: DeploymentNotificationService,
|
constructor(private deploymentNotificationService: DeploymentNotificationService,
|
||||||
|
@ -4,6 +4,7 @@ import { WebSocketService } from '../services/websocket.service';
|
|||||||
|
|
||||||
import { Message } from './message';
|
import { Message } from './message';
|
||||||
import { MessageControl } from './messagecontrol';
|
import { MessageControl } from './messagecontrol';
|
||||||
|
import { config } from '../config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-messages',
|
selector: 'app-messages',
|
||||||
@ -12,7 +13,7 @@ import { MessageControl } from './messagecontrol';
|
|||||||
})
|
})
|
||||||
export class MessagesComponent implements OnInit {
|
export class MessagesComponent implements OnInit {
|
||||||
messages: Message[] = [];
|
messages: Message[] = [];
|
||||||
showNextButton = false;
|
showNextButton: boolean = config.messages.showNextButton;
|
||||||
command_handlers = {'showbutton': this.showButton.bind(this)};
|
command_handlers = {'showbutton': this.showButton.bind(this)};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -16,12 +16,10 @@ import { SourceCode } from './source-code';
|
|||||||
import { WebSocketService } from '../services/websocket.service';
|
import { WebSocketService } from '../services/websocket.service';
|
||||||
import { ProcessManagerService } from '../services/processmanager.service';
|
import { ProcessManagerService } from '../services/processmanager.service';
|
||||||
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
import { DeploymentNotificationService } from '../services/deployment-notification.service';
|
||||||
|
import { config } from '../config';
|
||||||
|
|
||||||
const modelist = brace.acequire('ace/ext/modelist');
|
const modelist = brace.acequire('ace/ext/modelist');
|
||||||
|
|
||||||
const defaultSourceCode = 'Loading your file...';
|
|
||||||
const autosave_interval = 1000;
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-webide',
|
selector: 'app-webide',
|
||||||
templateUrl: './webide.component.html',
|
templateUrl: './webide.component.html',
|
||||||
@ -29,9 +27,9 @@ const autosave_interval = 1000;
|
|||||||
})
|
})
|
||||||
export class WebideComponent implements OnInit {
|
export class WebideComponent implements OnInit {
|
||||||
key_id = 'webide';
|
key_id = 'webide';
|
||||||
filename = 'demo.js';
|
filename = '';
|
||||||
code: string = defaultSourceCode;
|
code: string = config.webide.defaultCode;
|
||||||
language = 'javascript';
|
language: string = config.webide.defaultLanguage;
|
||||||
theme = 'cobalt';
|
theme = 'cobalt';
|
||||||
directory = '';
|
directory = '';
|
||||||
files: string[];
|
files: string[];
|
||||||
@ -54,8 +52,8 @@ export class WebideComponent implements OnInit {
|
|||||||
this.subscribeWS();
|
this.subscribeWS();
|
||||||
this.requestCode();
|
this.requestCode();
|
||||||
this.processManagerService.init();
|
this.processManagerService.init();
|
||||||
this.processManagerService.subscribeCallback('login', (event) => { this.setDeployButtonState('DEPLOYED'); });
|
this.processManagerService.subscribeCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('DEPLOYED'); });
|
||||||
this.processManagerService.subscribeErrorCallback('login', (event) => { this.setDeployButtonState('FAILED'); });
|
this.processManagerService.subscribeErrorCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); });
|
||||||
this.resetAutoSaveCountdown();
|
this.resetAutoSaveCountdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ export class WebideComponent implements OnInit {
|
|||||||
if (this.autosave) {
|
if (this.autosave) {
|
||||||
clearInterval(this.autosave);
|
clearInterval(this.autosave);
|
||||||
}
|
}
|
||||||
this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, autosave_interval);
|
this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
tabSwitchButtonHandler(file) {
|
tabSwitchButtonHandler(file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user