import { Component } from '@angular/core';
import { NgIf } from '@angular/common';
import { MaterialModule } from '../../../material.module';
import { TechlifyListingControllerInterface } from '../../../base-model';
import * as i0 from "@angular/core";
import * as i1 from "../../../company-information/client.service";
import * as i2 from "@angular/material/table";
import * as i3 from "@angular/material/card";
import * as i4 from "@angular/material/progress-bar";
export class TenantListWidgetComponent extends TechlifyListingControllerInterface {
    constructor(service) {
        super();
        this.service = service;
        this.displayedColumns = [
            '#',
            'Name',
            'Users',
        ];
    }
    ngOnInit() {
        this.loadData();
    }
    loadData() {
        const params = {
            page: this.page,
            perPage: this.perPage,
            num_items: this.perPage + '|' + this.page,
            withCount: 'users',
        };
        this.isWorking = true;
        this.service.index(params).subscribe({
            next: (response) => {
                this.models = this.models?.concat(response?.data);
                this.lastPage = response?.last_page;
                this.isWorking = false;
            },
            error: () => { this.isWorking = false; }
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TenantListWidgetComponent, deps: [{ token: i1.ClientService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: TenantListWidgetComponent, isStandalone: true, selector: "app-tenant-list-widget", usesInheritance: true, ngImport: i0, template: "<mat-card>\n  <mat-card-content>\n    <mat-card-title>Tenants</mat-card-title>\n  </mat-card-content>\n  <mat-card-content class=\"p-0\">\n    <table mat-table [dataSource]=\"models\" class=\"w-100\">\n      <!-- # Column -->\n      <ng-container matColumnDef=\"#\">\n        <th mat-header-cell *matHeaderCellDef> # </th>\n        <td mat-cell *matCellDef=\"let element; let i = index;\"> {{ i + 1 }} </td>\n      </ng-container>\n\n      <!-- Name Column -->\n      <ng-container matColumnDef=\"Name\">\n        <th mat-header-cell *matHeaderCellDef> Name </th>\n        <td mat-cell *matCellDef=\"let element\"> {{ element?.name }}</td>\n      </ng-container>\n\n      <!-- Users Column -->\n      <ng-container matColumnDef=\"Users\">\n        <th mat-header-cell *matHeaderCellDef> Users </th>\n        <td mat-cell *matCellDef=\"let element\">{{ element?.users_count }}</td>\n      </ng-container>\n\n      <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n      <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n    </table>\n    <mat-progress-bar mode=\"indeterminate\" *ngIf=\"isWorking\"></mat-progress-bar>\n  </mat-card-content>\n</mat-card>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: MaterialModule }, { kind: "component", type: i2.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i2.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i2.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i2.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i2.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i2.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i2.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i2.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i2.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i2.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: i3.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i3.MatCardContent, selector: "mat-card-content" }, { kind: "directive", type: i3.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "component", type: i4.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: TenantListWidgetComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-tenant-list-widget', standalone: true, imports: [
                        MaterialModule,
                        NgIf
                    ], template: "<mat-card>\n  <mat-card-content>\n    <mat-card-title>Tenants</mat-card-title>\n  </mat-card-content>\n  <mat-card-content class=\"p-0\">\n    <table mat-table [dataSource]=\"models\" class=\"w-100\">\n      <!-- # Column -->\n      <ng-container matColumnDef=\"#\">\n        <th mat-header-cell *matHeaderCellDef> # </th>\n        <td mat-cell *matCellDef=\"let element; let i = index;\"> {{ i + 1 }} </td>\n      </ng-container>\n\n      <!-- Name Column -->\n      <ng-container matColumnDef=\"Name\">\n        <th mat-header-cell *matHeaderCellDef> Name </th>\n        <td mat-cell *matCellDef=\"let element\"> {{ element?.name }}</td>\n      </ng-container>\n\n      <!-- Users Column -->\n      <ng-container matColumnDef=\"Users\">\n        <th mat-header-cell *matHeaderCellDef> Users </th>\n        <td mat-cell *matCellDef=\"let element\">{{ element?.users_count }}</td>\n      </ng-container>\n\n      <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\n      <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\"></tr>\n    </table>\n    <mat-progress-bar mode=\"indeterminate\" *ngIf=\"isWorking\"></mat-progress-bar>\n  </mat-card-content>\n</mat-card>\n" }]
        }], ctorParameters: () => [{ type: i1.ClientService }] });
//# sourceMappingURL=data:application/json;base64, 