feat(builder): add project editor
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BootstrapConfig } from '../../../shared/models/config';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ProjectEditorIoService {
|
||||
exportBootstrap(config: BootstrapConfig): string {
|
||||
return JSON.stringify(config, null, 2);
|
||||
}
|
||||
|
||||
importBootstrap(raw: string): BootstrapConfig {
|
||||
return JSON.parse(raw) as BootstrapConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { BootstrapConfig } from '../../../shared/models/config';
|
||||
import { PlatformRuntimeService } from '../../../core/runtime/platform-runtime.service';
|
||||
import { LanguageService } from '../../../services/language.service';
|
||||
import { UiRuntimeFacade } from '../../../facades/runtime/ui-runtime.facade';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ProjectEditorPreviewService {
|
||||
private readonly runtime = inject(PlatformRuntimeService);
|
||||
private readonly router = inject(Router);
|
||||
private readonly languageService = inject(LanguageService);
|
||||
private readonly uiRuntime = inject(UiRuntimeFacade);
|
||||
|
||||
preview(bootstrap: BootstrapConfig): void {
|
||||
this.runtime.reloadFromBootstrap(bootstrap);
|
||||
this.uiRuntime.reloadFromBootstrap(bootstrap);
|
||||
void this.router.navigate([`/${this.languageService.currentLanguage()}`]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user