mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2024-11-01 12:11:21 +00:00
Implement state recovery, make ask before reload opt-in
This commit is contained in:
parent
362804f54d
commit
bc50d52f4d
@ -17,6 +17,7 @@ export class AppComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.titleService.setTitle(this.documentTitle);
|
this.titleService.setTitle(this.documentTitle);
|
||||||
|
if (config.dashboard.askReloadSite) {
|
||||||
window.addEventListener('beforeunload', (event) => {
|
window.addEventListener('beforeunload', (event) => {
|
||||||
const confirmationMessage = 'Refreshing this page may mess up your challenge/tutorial state. Are you sure?';
|
const confirmationMessage = 'Refreshing this page may mess up your challenge/tutorial state. Are you sure?';
|
||||||
event.returnValue = confirmationMessage;
|
event.returnValue = confirmationMessage;
|
||||||
@ -24,3 +25,4 @@ export class AppComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@ export const config = {
|
|||||||
dashboard: {
|
dashboard: {
|
||||||
route: 'dashboard',
|
route: 'dashboard',
|
||||||
triggerFirstFSMStep: 'step_1',
|
triggerFirstFSMStep: 'step_1',
|
||||||
|
askReloadSite: false,
|
||||||
|
recoverAfterPageReload: true,
|
||||||
terminalOrConsole: 'terminal',
|
terminalOrConsole: 'terminal',
|
||||||
currentLayout: 'terminal-ide-web',
|
currentLayout: 'terminal-ide-web',
|
||||||
enabledLayouts: [
|
enabledLayouts: [
|
||||||
|
@ -44,6 +44,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
this.initCommandHandling();
|
this.initCommandHandling();
|
||||||
this.initDeploymentNotifications();
|
this.initDeploymentNotifications();
|
||||||
this.triggerFirstFSMStepIfNeeded();
|
this.triggerFirstFSMStepIfNeeded();
|
||||||
|
this.recoverIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
initCommandHandling() {
|
initCommandHandling() {
|
||||||
@ -74,6 +75,12 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recoverIfNeeded() {
|
||||||
|
if (config.dashboard.recoverAfterPageReload) {
|
||||||
|
setTimeout(() => this.webSocketService.sendJSON({'key': 'recover'}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
layoutHandler(data: LayoutCommand) {
|
layoutHandler(data: LayoutCommand) {
|
||||||
if (config.dashboard.enabledLayouts.includes(data.value)) {
|
if (config.dashboard.enabledLayouts.includes(data.value)) {
|
||||||
this.setLayout(data.value);
|
this.setLayout(data.value);
|
||||||
|
Loading…
Reference in New Issue
Block a user