import {Component, Input, OnInit} from '@angular/core';
import {EditorService} from '../../../service/editor.service';

@Component({
    selector: 'noded-database-page',
    template: `
        <div class="container" *ngIf="ready">
            <editor-database [nodeId]="nodeId" [editorUUID]="this.editorService.instanceUUID" [fullPage]="true"></editor-database>
        </div>
    `,
    styles: [
        `
            .container {
                height: 100%;
            }

            editor-database {
                height: 100%;
                display: flex;
            }
        `,
    ],
})
export class DatabasePageComponent implements OnInit {
    @Input() nodeId: string;
    @Input() pageId: string;

    public ready = false;

    constructor(
        public editorService: EditorService,
    ) {
        this.editorService = editorService.getEditor();
    }

    ngOnInit() {
        this.editorService.startEditing(this.pageId).then(() => {
            this.ready = true;
        });
    }
}
