mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-04-02 13:22:39 +00:00
84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { WebSocketService } from './websocket.service';
|
|
import { Subject, BehaviorSubject, merge } from 'rxjs';
|
|
import { ConfigServiceBase } from './config.service.base';
|
|
|
|
@Injectable()
|
|
export class DashboardConfigService extends ConfigServiceBase {
|
|
keys = ['frontend.dashboard'];
|
|
|
|
layout = new BehaviorSubject<string>('terminal-ide-web');
|
|
hideMessages = new BehaviorSubject<boolean>(false);
|
|
iframeUrl = new BehaviorSubject<string>('');
|
|
showUrlBar = new BehaviorSubject<boolean>(false);
|
|
terminalMenuItem = new BehaviorSubject<string>('terminal');
|
|
reloadIframeOnDeploy = new BehaviorSubject<boolean>(false);
|
|
enabledLayouts = new BehaviorSubject<Array<string>>([
|
|
'terminal-ide-web',
|
|
'terminal-ide-vertical',
|
|
'terminal-web',
|
|
'ide-web-vertical',
|
|
'terminal-ide-horizontal',
|
|
'terminal-only',
|
|
'ide-only',
|
|
'web-only'
|
|
]);
|
|
}
|
|
|
|
@Injectable()
|
|
export class IdeConfigService extends ConfigServiceBase {
|
|
keys = ['frontend.ide'];
|
|
|
|
autoSaveInterval = new BehaviorSubject<number>(444);
|
|
showDeployButton = new BehaviorSubject<boolean>(true);
|
|
deployButtonText = new BehaviorSubject<any>({
|
|
'TODEPLOY': 'Deploy',
|
|
'DEPLOYED': 'Deployed',
|
|
'DEPLOYING': 'Reloading app...',
|
|
'FAILED': 'Deployment failed'
|
|
});
|
|
}
|
|
|
|
@Injectable()
|
|
export class SiteConfigService extends ConfigServiceBase {
|
|
keys = ['frontend.site'];
|
|
|
|
askReloadSite = new BehaviorSubject<boolean>(false);
|
|
documentTitle = new BehaviorSubject<string>('Avatao Tutorials');
|
|
}
|
|
|
|
@Injectable()
|
|
export class ConfigReadyService {
|
|
configDone = new Subject<void>();
|
|
readyNotifiers: Array<any>;
|
|
|
|
constructor(
|
|
private webSocketService: WebSocketService,
|
|
private ide: IdeConfigService,
|
|
private dashboard: DashboardConfigService,
|
|
private site: SiteConfigService
|
|
) {
|
|
this.readyNotifiers = [
|
|
this.ide.configDone,
|
|
this.dashboard.configDone,
|
|
this.site.configDone
|
|
];
|
|
}
|
|
|
|
init() {
|
|
this.webSocketService.connect();
|
|
|
|
const recvdConfigDone = new Subject<void>();
|
|
this.readyNotifiers.push(recvdConfigDone);
|
|
this.webSocketService.observeControl<any>('frontend.ready').subscribe(() => {
|
|
recvdConfigDone.next();
|
|
recvdConfigDone.complete();
|
|
});
|
|
|
|
merge(...this.readyNotifiers).subscribe({complete: () => {
|
|
this.configDone.next();
|
|
this.configDone.complete();
|
|
}});
|
|
}
|
|
}
|