import { Component } from '@angular/core';
import { DATA_GRID_CONFIGURATION_CONTEXT_PROVIDER, DATA_GRID_CONFIGURATION_STRATEGY, UserPreferencesConfigurationStrategy } from '@c8y/ngx-components';
import { DeviceGridService } from '@c8y/ngx-components/device-grid';
import { BsModalService } from 'ngx-bootstrap/modal';
import { AddSmartGroupComponent } from './add-smart-group.component';
import { DeviceListExtensionService } from './device-list-extension.service';
import * as i0 from "@angular/core";
import * as i1 from "@c8y/ngx-components/device-grid";
import * as i2 from "ngx-bootstrap/modal";
import * as i3 from "./device-list-extension.service";
import * as i4 from "@c8y/ngx-components";
import * as i5 from "@angular/common";
export class DeviceListComponent {
    constructor(deviceGridService, bsModalService, deviceListExtensionService) {
        this.deviceGridService = deviceGridService;
        this.bsModalService = bsModalService;
        this.GRID_CONFIG_KEY = 'device-grid-all';
        this.count$ = this.deviceGridService.getTotal({});
        this.columns$ = deviceListExtensionService.items$;
    }
    getGridConfigContext() {
        return {
            key: this.GRID_CONFIG_KEY,
            defaultColumns: this.deviceGridService.getDefaultColumns(),
            legacyConfigKey: 'all-devices-columns-meta_',
            legacyFilterKey: 'all-devices-columns-config'
        };
    }
    async createSmartGroup() {
        const initialState = {
            configKey: this.GRID_CONFIG_KEY,
            deviceQuery: this.deviceQueryStringOutput
        };
        this.bsModalService.show(AddSmartGroupComponent, {
            class: 'modal-sm',
            ariaDescribedby: 'modal-body',
            ariaLabelledBy: 'modal-title',
            ignoreBackdropClick: true,
            keyboard: false,
            initialState
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceListComponent, deps: [{ token: i1.DeviceGridService }, { token: i2.BsModalService }, { token: i3.DeviceListExtensionService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: DeviceListComponent, selector: "c8y-device-list", providers: [
            {
                provide: DATA_GRID_CONFIGURATION_STRATEGY,
                useClass: UserPreferencesConfigurationStrategy
            },
            {
                provide: DATA_GRID_CONFIGURATION_CONTEXT_PROVIDER,
                useExisting: DeviceListComponent
            }
        ], ngImport: i0, template: "<c8y-title>\n  {{ 'All devices' | translate }}\n</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'exchange'\"\n    [label]=\"'Devices' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    [icon]=\"'c8y-device-management'\"\n    [label]=\"'All devices' | translate\"\n  ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n  <button\n    class=\"btn btn-link\"\n    title=\"{{ 'Add smart group' | translate }}\"\n    (click)=\"createSmartGroup()\"\n  >\n    <i c8yIcon=\"c8y-group-smart\"></i>\n    {{ 'Add smart group' | translate }}\n  </button>\n</c8y-action-bar-item>\n\n<c8y-help\n  src=\"/docs/device-management-application/viewing-all-devices/#viewing-all-devices\"\n></c8y-help>\n\n<div class=\"content-fullpage border-top border-bottom\">\n  <c8y-device-grid\n    [columns]=\"columns$ | async\"\n    [infiniteScroll]=\"(count$ | async) === undefined ? 'auto' : undefined\"\n    (onDeviceQueryStringChange)=\"deviceQueryStringOutput = $event\"\n    c8yProductExperience\n    [actionName]=\"'allDevices'\"\n  ></c8y-device-grid>\n</div>\n", dependencies: [{ kind: "component", type: i4.ActionBarItemComponent, selector: "c8y-action-bar-item", inputs: ["placement", "priority", "itemClass", "injector", "groupId", "inGroupPriority"] }, { kind: "component", type: i4.BreadcrumbComponent, selector: "c8y-breadcrumb" }, { kind: "component", type: i4.BreadcrumbItemComponent, selector: "c8y-breadcrumb-item", inputs: ["icon", "translate", "label", "path", "injector"] }, { kind: "directive", type: i4.IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "component", type: i4.TitleComponent, selector: "c8y-title", inputs: ["pageTitleUpdate"] }, { kind: "directive", type: i4.ProductExperienceDirective, selector: "[c8yProductExperience]", inputs: ["actionName", "actionData", "inherit", "suppressDataOverriding"] }, { kind: "component", type: i4.HelpComponent, selector: "c8y-help", inputs: ["src", "isCollapsed", "priority", "icon"] }, { kind: "component", type: i1.DeviceGridComponent, selector: "c8y-device-grid", inputs: ["dataCallback", "refresh", "title", "loadMoreItemsLabel", "loadingItemsLabel", "legacyConfigKey", "legacyFilterKey", "columns", "pagination", "infiniteScroll", "actionControls", "selectable", "singleSelection", "baseQuery", "bulkActionControls", "headerActionControls", "childDeviceGrid", "parentDeviceId", "withChildren", "showSearch", "activeClassName"], outputs: ["onColumnsChange", "onFilterChange", "onDeviceQueryStringChange", "itemsSelect"] }, { kind: "pipe", type: i4.C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DeviceListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-device-list', providers: [
                        {
                            provide: DATA_GRID_CONFIGURATION_STRATEGY,
                            useClass: UserPreferencesConfigurationStrategy
                        },
                        {
                            provide: DATA_GRID_CONFIGURATION_CONTEXT_PROVIDER,
                            useExisting: DeviceListComponent
                        }
                    ], template: "<c8y-title>\n  {{ 'All devices' | translate }}\n</c8y-title>\n\n<c8y-breadcrumb>\n  <c8y-breadcrumb-item\n    [icon]=\"'exchange'\"\n    [label]=\"'Devices' | translate\"\n  ></c8y-breadcrumb-item>\n  <c8y-breadcrumb-item\n    [icon]=\"'c8y-device-management'\"\n    [label]=\"'All devices' | translate\"\n  ></c8y-breadcrumb-item>\n</c8y-breadcrumb>\n\n<c8y-action-bar-item [placement]=\"'right'\">\n  <button\n    class=\"btn btn-link\"\n    title=\"{{ 'Add smart group' | translate }}\"\n    (click)=\"createSmartGroup()\"\n  >\n    <i c8yIcon=\"c8y-group-smart\"></i>\n    {{ 'Add smart group' | translate }}\n  </button>\n</c8y-action-bar-item>\n\n<c8y-help\n  src=\"/docs/device-management-application/viewing-all-devices/#viewing-all-devices\"\n></c8y-help>\n\n<div class=\"content-fullpage border-top border-bottom\">\n  <c8y-device-grid\n    [columns]=\"columns$ | async\"\n    [infiniteScroll]=\"(count$ | async) === undefined ? 'auto' : undefined\"\n    (onDeviceQueryStringChange)=\"deviceQueryStringOutput = $event\"\n    c8yProductExperience\n    [actionName]=\"'allDevices'\"\n  ></c8y-device-grid>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.DeviceGridService }, { type: i2.BsModalService }, { type: i3.DeviceListExtensionService }] });
//# sourceMappingURL=data:application/json;base64, 