import { Component, inject } from '@angular/core';
import { ActionBarItemComponent, AlertService, AppStateService, BreadcrumbModule, C8yTranslateModule, HeaderModule, HelpModule, IconDirective, LoadingComponent } from '@c8y/ngx-components';
import { CommonModule } from '@angular/common';
import { RouterLink } from '@angular/router';
import { NamespaceItemComponent } from './namespace-item/namespace-item.component';
import { MessagingNamespacesService } from '../../api/services/messaging-namespaces.service';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@c8y/ngx-components";
export class NamespaceListComponent {
    constructor() {
        this.alertService = inject(AlertService);
        this.appState = inject(AppStateService);
        this.namespacesService = inject(MessagingNamespacesService);
        this.loading = true;
    }
    async ngOnInit() {
        await this.reload();
    }
    async reload() {
        this.loading = true;
        try {
            const currentTenantId = this.appState.currentTenant.value.name;
            this.namespacesDetails = await this.namespacesService.getNamespacesDetails(currentTenantId);
        }
        catch (e) {
            this.alertService.addServerFailure(e);
        }
        finally {
            this.loading = false;
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NamespaceListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NamespaceListComponent, isStandalone: true, selector: "app-namespace-list", ngImport: i0, template: "<c8y-title>{{ 'Messaging service' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'monitoring'\"\n    [label]=\"'Monitoring' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"'Messaging service' | translate\"></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n  <li>\n    <a\n      class=\"btn btn-link\"\n      title=\"{{ 'Reload' | translate }}\"\n      (click)=\"reload()\"\n    >\n      <i\n        c8yIcon=\"refresh\"\n        [ngClass]=\"{ 'icon-spin': loading }\"\n      ></i>\n      {{ 'Reload' | translate }}\n    </a>\n  </li>\n</c8y-action-bar-item>\n\n<c8y-help src=\"/docs/standard-tenant/monitoring/#messaging-service\"></c8y-help>\n\n<div\n  class=\"interact-grid\"\n  *ngIf=\"!loading; else loadingTemplate\"\n>\n  <a\n    class=\"card\"\n    *ngFor=\"let namespace of namespacesDetails\"\n    [routerLink]=\"['namespace', namespace.id]\"\n  >\n    <app-namespace-item\n      [namespaceName]=\"namespace.id\"\n      [namespace]=\"namespace.namespace\"\n    ></app-namespace-item>\n  </a>\n</div>\n\n<ng-template #loadingTemplate>\n  <c8y-loading></c8y-loading>\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: HeaderModule }, { kind: "component", type: i2.TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "ngmodule", type: HelpModule }, { kind: "component", type: i2.HelpComponent, selector: "c8y-help", inputs: ["src", "isCollapsed", "priority", "icon"] }, { kind: "ngmodule", type: C8yTranslateModule }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }, { kind: "component", type: NamespaceItemComponent, selector: "app-namespace-item", inputs: ["namespaceName", "namespace", "policies"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "ngmodule", type: BreadcrumbModule }, { kind: "component", type: i2.BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: i2.BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "component", type: ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NamespaceListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-namespace-list', imports: [
                        CommonModule,
                        HeaderModule,
                        HelpModule,
                        C8yTranslateModule,
                        NamespaceItemComponent,
                        RouterLink,
                        BreadcrumbModule,
                        ActionBarItemComponent,
                        IconDirective,
                        LoadingComponent
                    ], standalone: true, template: "<c8y-title>{{ 'Messaging service' | translate }}</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'monitoring'\"\n    [label]=\"'Monitoring' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item [label]=\"'Messaging service' | translate\"></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n  <li>\n    <a\n      class=\"btn btn-link\"\n      title=\"{{ 'Reload' | translate }}\"\n      (click)=\"reload()\"\n    >\n      <i\n        c8yIcon=\"refresh\"\n        [ngClass]=\"{ 'icon-spin': loading }\"\n      ></i>\n      {{ 'Reload' | translate }}\n    </a>\n  </li>\n</c8y-action-bar-item>\n\n<c8y-help src=\"/docs/standard-tenant/monitoring/#messaging-service\"></c8y-help>\n\n<div\n  class=\"interact-grid\"\n  *ngIf=\"!loading; else loadingTemplate\"\n>\n  <a\n    class=\"card\"\n    *ngFor=\"let namespace of namespacesDetails\"\n    [routerLink]=\"['namespace', namespace.id]\"\n  >\n    <app-namespace-item\n      [namespaceName]=\"namespace.id\"\n      [namespace]=\"namespace.namespace\"\n    ></app-namespace-item>\n  </a>\n</div>\n\n<ng-template #loadingTemplate>\n  <c8y-loading></c8y-loading>\n</ng-template>\n" }]
        }] });
//# sourceMappingURL=data:application/json;base64, 