import { ChangeDetectionStrategy, Component, contentChild, effect, inject, input, model, type TemplateRef, untracked, ViewEncapsulation, } from "@angular/core"; import { injectViewTitleSignal } from "../../core/routing/injectViewTitleSignal"; import { SdBusyContainer } from "../../core/busy/sd-busy-container"; import { SdSharedDataProvider } from "../../core/shared-data/sd-shared-data.provider"; import { SdToastProvider } from "../../core/toast/sd-toast.provider"; import { SdTopbar } from "../../layout/topbar/sd-topbar"; import { SdTopbarContainer } from "../../layout/topbar/sd-topbar-container"; import type { SdViewType } from "../../core/routing/injectViewTypeSignal"; import { NgIcon } from "@ng-icons/core"; import { tablerAlertTriangle } from "@ng-icons/tabler-icons"; import { NgTemplateOutlet } from "@angular/common"; @Component({ selector: "sd-base-container", changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, standalone: true, imports: [SdBusyContainer, NgIcon, SdTopbarContainer, NgTemplateOutlet, SdTopbar], template: ` @if (initialized()) { @if (restricted()) {



'{{ viewTitle() }}'에 대한 사용권한이 없습니다. 시스템 관리자에게 문의하세요.
} @else if (viewType() === "page") {

{{ viewTitle() }}

} @else { } }
@if (commandTplRef()) {
}
@if (contentTplRef()) { }
@if (bottomCommandTplRef()) {
}
`, }) export class SdBaseContainer { private readonly _sdSharedData = inject(SdSharedDataProvider); private readonly _sdToast = inject(SdToastProvider); viewTitle = injectViewTitleSignal(); ready = model(false); initialized = input(false); busyCount = model(0); restricted = input(false); viewType = input.required(); topbarTplRef = contentChild>("topbarTpl"); commandTplRef = contentChild>("commandTpl"); contentTplRef = contentChild>("contentTpl"); bottomCommandTplRef = contentChild>("bottomCommandTpl"); constructor() { effect(() => { if (this.restricted()) { this.ready.set(true); return; } void untracked(async () => { this.busyCount.update((v) => v + 1); await this._sdToast.try(async () => { await this._sdSharedData.wait(); }); this.busyCount.update((v) => v - 1); this.ready.set(true); }); }); } protected readonly tablerAlertTriangle = tablerAlertTriangle; }