-
-
-
-
-
-
-
-
@@ -35,17 +34,17 @@
-
-
+
+
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts
index d4b8194..41272e0 100644
--- a/src/app/dashboard/dashboard.component.ts
+++ b/src/app/dashboard/dashboard.component.ts
@@ -3,9 +3,7 @@ import { DeploymentNotificationService } from '../services/deployment-notificati
import { Subscription } from 'rxjs';
import { WebSocketService } from '../services/websocket.service';
import { WebSocketMessage } from '../message-types/websocket-message';
-import { HideMessagesMessage, LayoutMessage, TerminalMenuItemMessage } from '../message-types/dashboard-messages';
-import { config } from '../config';
-import { LogMessage } from '../message-types/log-message';
+import { DashboardConfigService } from '../services/config.service';
import { HttpClient } from '@angular/common/http';
import { delay, retryWhen, tap } from 'rxjs/operators';
@@ -18,22 +16,19 @@ export class DashboardComponent implements OnInit, OnDestroy {
deploying = false;
polling = false;
deploymentNotificationSubscription: Subscription;
- @ViewChild('webiframe', {static: true}) webiframe: ElementRef;
- @ViewChild('tfwmessages', {static: true}) messages: ElementRef;
- @ViewChild('urlbar', {static: true}) urlbar: ElementRef;
+ @ViewChild('webiframe', {static: false}) webiframe: ElementRef;
+ @ViewChild('tfwmessages', {static: false}) messages: ElementRef;
+ @ViewChild('urlbar', {static: false}) urlbar: ElementRef;
- layout: string = config.dashboard.currentLayout;
- hideMessages: boolean = config.dashboard.hideMessages;
- iframeUrl: string = config.dashboard.iframeUrl;
- showUrlBar = config.dashboard.showUrlBar;
- actualIframeUrl: string = this.iframeUrl;
- selectedTerminalMenuItem: string = config.dashboard.terminalOrConsole;
+ layout = this.configService.layout;
+ hideMessages = this.configService.hideMessages;
+ showUrlBar = this.configService.showUrlBar;
+ iframeUrl = this.configService.iframeUrl;
+ actualIframeUrl = this.iframeUrl.value;
+ terminalMenuItem = this.configService.terminalMenuItem;
iframeReloadSubscription: Subscription;
command_handlers = {
- 'dashboard.layout': this.layoutHandler.bind(this),
- 'dashboard.hideMessages': this.hideMessagesHandler.bind(this),
- 'dashboard.terminalMenuItem': this.terminalMenuItemHandler.bind(this),
'dashboard.reloadFrontend': this.reloadFrontendHandlder.bind(this),
'dashboard.reloadIframe': this.reloadIframeHandler.bind(this)
};
@@ -41,13 +36,20 @@ export class DashboardComponent implements OnInit, OnDestroy {
constructor(private deploymentNotificationService: DeploymentNotificationService,
private webSocketService: WebSocketService,
private changeDetectorRef: ChangeDetectorRef,
- private http: HttpClient) {}
+ private http: HttpClient,
+ private configService: DashboardConfigService) {}
ngOnInit() {
this.webSocketService.connect();
+ this.configService.init();
+ this.subscribeResizeOnLayoutChange();
this.initCommandHandling();
this.initDeploymentNotifications();
- this.sendReadyIfNeeded();
+ this.sendReady();
+ }
+
+ subscribeResizeOnLayoutChange() {
+ this.configService.layout.subscribe(() => this.emitResizeEvent());
}
initCommandHandling() {
@@ -61,7 +63,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.deploymentNotificationSubscription = this.deploymentNotificationService.deploying.subscribe(
(deploying) => {
this.deploying = deploying;
- if (!deploying && config.ide.reloadIframeOnDeploy) {
+ if (!deploying && this.configService.reloadIframeOnDeploy.value) {
if (this.polling) {
this.iframeReloadSubscription.unsubscribe();
}
@@ -70,26 +72,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
});
}
- sendReadyIfNeeded() {
- if (config.dashboard.sendReadyAfterPageReload) {
- setTimeout(() => this.webSocketService.send({'key': 'frontend.ready'}));
- }
- }
-
- layoutHandler(message: LayoutMessage) {
- if (config.dashboard.enabledLayouts.includes(message.value)) {
- this.setLayout(message.value);
- } else {
- console.log('Invalid ide layout "' + message.value + '" received!');
- }
- }
-
- hideMessagesHandler(message: HideMessagesMessage) {
- this.hideMessages = message.value;
- }
-
- terminalMenuItemHandler(message: TerminalMenuItemMessage) {
- this.selectTerminalMenuItem(message.value);
+ sendReady() {
+ setTimeout(() => this.webSocketService.send({'key': 'frontend.ready'}));
}
reloadFrontendHandlder(message: WebSocketMessage) {
@@ -101,7 +85,11 @@ export class DashboardComponent implements OnInit, OnDestroy {
}
setLayout(layout: string) {
- this.layout = layout;
+ this.layout.next(layout);
+ this.emitResizeEvent();
+ }
+
+ emitResizeEvent() {
// We need to trigger a 'resize' event manually, otherwise editor stays collapsed
// editor 'resize' event listener requires a parameter of force=true
setTimeout(() => window.dispatchEvent(new Event('resize', {force: true} as any)), 0);
@@ -124,7 +112,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
if (!item.match('(terminal|console)')) {
return;
}
- this.selectedTerminalMenuItem = item;
+ this.terminalMenuItem.next(item);
}
scrollMessagesToBottom(): void {
diff --git a/src/app/ide/ide.component.html b/src/app/ide/ide.component.html
index 17dad4b..aa018a6 100644
--- a/src/app/ide/ide.component.html
+++ b/src/app/ide/ide.component.html
@@ -14,7 +14,7 @@
-
diff --git a/src/app/ide/ide.component.ts b/src/app/ide/ide.component.ts
index 252b2ec..7b8ad82 100644
--- a/src/app/ide/ide.component.ts
+++ b/src/app/ide/ide.component.ts
@@ -4,7 +4,7 @@ import { WebSocketMessage } from '../message-types/websocket-message';
import { IDEMessage } from '../message-types/ide-message';
import { DeployMessage } from '../message-types/deploy-message';
import { DeploymentNotificationService } from '../services/deployment-notification.service';
-import { config } from '../config';
+import { IdeConfigService } from '../services/config.service';
import { LanguageMap } from './language-map';
import { first } from 'rxjs/operators';
@@ -31,19 +31,19 @@ export class IdeComponent implements OnInit {
files: string[];
filename = '';
- code: string = config.ide.defaultCode;
+ code = 'Loading your file...';
codeState = CodeState.SAVED;
deployButtonState = DeployButtonState.DEPLOYED;
- deployButtonText = config.ide.deployButtonText;
- showDeployButton: boolean = config.ide.showDeployButton;
+ deployButtonText = this.configService.deployButtonText;
+ showDeployButton = this.configService.showDeployButton;
autosave = null;
editorOptions = {
theme: 'vs-dark',
- language: config.ide.defaultLanguage,
+ language: 'text',
glyphMargin: false,
- minimap: {enabled: config.ide.showMiniMap}
+ minimap: {enabled: false}
};
command_handlers = {
@@ -54,10 +54,12 @@ export class IdeComponent implements OnInit {
constructor(private webSocketService: WebSocketService,
private changeDetectorRef: ChangeDetectorRef,
- private deploymentNotificationService: DeploymentNotificationService) { }
+ private deploymentNotificationService: DeploymentNotificationService,
+ private configService: IdeConfigService) {}
ngOnInit() {
this.webSocketService.connect();
+ this.configService.init();
this.subscribeWS();
this.subscribeFirstLanguageDetection();
this.requestCode();
@@ -77,7 +79,7 @@ export class IdeComponent implements OnInit {
subscribeFirstLanguageDetection() {
this.webSocketService.observeKey