import { __decorate, __metadata } from "tslib";
import { Component } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { TranslateService } from '@ngx-translate/core';
import { API } from '../../../api';
import { IdentityResourceVO } from '../vo/identity-resource.vo';
var IdentityIdentityResourceComponent = /** @class */ (function () {
    function IdentityIdentityResourceComponent(nzMessageService, translateService) {
        this.nzMessageService = nzMessageService;
        this.translateService = translateService;
        this.identityIdentityResourceCreateComponentProp = {
            visible: false,
        };
        this.identityIdentityResourceUpdateComponentProp = {
            visible: false,
            identityResource: new IdentityResourceVO(),
        };
        this.identityResources = [];
        this.identityResourcesFetching = false;
    }
    IdentityIdentityResourceComponent.prototype.deleteIdentityResource = function (item) {
        var _this = this;
        item.deleting = true;
        API.Identity.IdentityResourceController.Remove({
            identityResourceName: item.name,
        }).subscribe({
            next: function () {
                item.deleting = false;
                _this.nzMessageService.success(_this.translateService.instant('projects/fe-ng/src/lib/page/identity/identity-resource/identity--identity-resource.delete_successfully'));
                _this.fetchIdentityResources();
            },
            error: function () {
                item.deleting = false;
            },
        });
    };
    IdentityIdentityResourceComponent.prototype.fetchIdentityResources = function () {
        var _this = this;
        this.identityResourcesFetching = true;
        API.Identity.IdentityResourceController.List().subscribe({
            next: function (data) {
                _this.identityResources = IdentityResourceVO.fromArray(data);
                _this.identityResourcesFetching = false;
            },
            error: function () {
                _this.identityResourcesFetching = false;
            },
        });
    };
    IdentityIdentityResourceComponent.prototype.handleIdentityIdentityResourceCreateComponentOk = function () {
        this.fetchIdentityResources();
    };
    IdentityIdentityResourceComponent.prototype.handleIdentityIdentityResourceUpdateComponentOk = function () {
        this.fetchIdentityResources();
    };
    IdentityIdentityResourceComponent.prototype.ngOnInit = function () {
        this.fetchIdentityResources();
    };
    IdentityIdentityResourceComponent.prototype.openIdentityIdentityResourceCreateComponent = function () {
        this.identityIdentityResourceCreateComponentProp.visible = true;
    };
    IdentityIdentityResourceComponent.prototype.openIdentityIdentityResourceUpdateComponent = function (item) {
        this.identityIdentityResourceUpdateComponentProp.identityResource = item;
        this.identityIdentityResourceUpdateComponentProp.visible = true;
    };
    IdentityIdentityResourceComponent.ctorParameters = function () { return [
        { type: NzMessageService },
        { type: TranslateService }
    ]; };
    IdentityIdentityResourceComponent = __decorate([
        Component({
            selector: 'kg---identity--identity-resource',
            template: "<page-header title=\"\"></page-header>\n\n<nz-card\n  [ngStyle]=\"{\n    marginBottom: '0px',\n    height: 'calc(100% - 42px)'\n  }\"\n  [nzBodyStyle]=\"{\n    padding: '10px',\n    height: '100%'\n  }\"\n  [nzBordered]=\"false\"\n>\n  <div>\n    <button\n      (click)=\"fetchIdentityResources()\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      [nzLoading]=\"identityResourcesFetching\"\n      class=\"btn-outline-primary\"\n      nz-button\n    >\n      <i nz-icon nzTheme=\"outline\" nzType=\"reload\"></i>\n      {{ 'app__refresh' | i18n }}\n    </button>\n\n    <button\n      (click)=\"openIdentityIdentityResourceCreateComponent()\"\n      [disabled]=\"identityResourcesFetching\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      nz-button\n      nzType=\"primary\"\n    >\n      <i nz-icon nzTheme=\"outline\" nzType=\"plus-circle\"></i>\n      {{ 'app__create' | i18n }}\n    </button>\n  </div>\n\n  <nz-table\n    #table\n    [className]=\"'table-responsive'\"\n    [ngStyle]=\"{ marginTop: '10px', clear: 'both' }\"\n    [nzData]=\"identityResources\"\n    [nzFrontPagination]=\"false\"\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\n    [nzLoading]=\"identityResourcesFetching\"\n    [nzScroll]=\"{ x: '700px', y: 'auto' }\"\n    [nzShowPagination]=\"false\"\n    [nzWidthConfig]=\"['200px', '300px', '200px']\"\n    nzSize=\"small\"\n  >\n    <thead>\n      <tr>\n        <th>{{ 'app__name' | i18n }}</th>\n        <th>\n          {{ 'app__description' | i18n }}\n        </th>\n        <th [nzRight]=\"'0px'\" class=\"text-center\">{{ 'app__action' | i18n }}</th>\n      </tr>\n    </thead>\n\n    <tbody>\n      <ng-container *ngFor=\"let item of table.data\">\n        <tr>\n          <td [nzBreakWord]=\"true\">{{ item.name }}</td>\n\n          <td [nzBreakWord]=\"true\">{{ item.description }}</td>\n\n          <td [nzRight]=\"'0px'\" class=\"text-right\">\n            <button\n              (click)=\"openIdentityIdentityResourceUpdateComponent(item)\"\n              [disabled]=\"item.deleting\"\n              [ngStyle]=\"{ height: '28px' }\"\n              class=\"btn-outline-primary\"\n              nz-button\n              nzSize=\"small\"\n            >\n              <i nz-icon nzTheme=\"outline\" nzType=\"form\"></i>\n              {{ 'app__update' | i18n }}\n            </button>\n\n            <button\n              (nzOnConfirm)=\"deleteIdentityResource(item)\"\n              [ngStyle]=\"{ height: '28px' }\"\n              [nzLoading]=\"item.deleting\"\n              [nzPopconfirmTitle]=\"'app__confirm_delete_message' | i18n\"\n              class=\"btn-outline-warning\"\n              nz-button\n              nz-popconfirm\n              nzPopconfirmPlacement=\"topRight\"\n              nzSize=\"small\"\n            >\n              <i nz-icon nzTheme=\"outline\" nzType=\"delete\"></i>\n              {{ 'app__delete' | i18n }}\n            </button>\n          </td>\n        </tr>\n      </ng-container>\n    </tbody>\n\n    <ng-template #loadingIndicatorTpl>\n      <i\n        [ngStyle]=\"{\n          fontSize: '24px',\n          marginTop: '10px'\n        }\"\n        nz-icon\n        nzTheme=\"outline\"\n        nzType=\"loading\"\n      ></i>\n    </ng-template>\n  </nz-table>\n</nz-card>\n\n<kg---identity--identity-resource--create\n  (ok)=\"handleIdentityIdentityResourceCreateComponentOk()\"\n  [(visible)]=\"identityIdentityResourceCreateComponentProp.visible\"\n></kg---identity--identity-resource--create>\n\n<kg---identity--identity-resource--update\n  (ok)=\"handleIdentityIdentityResourceUpdateComponentOk()\"\n  [(visible)]=\"identityIdentityResourceUpdateComponentProp.visible\"\n  [identityResource]=\"identityIdentityResourceUpdateComponentProp.identityResource\"\n></kg---identity--identity-resource--update>\n",
            styles: [":host ::ng-deep .ant-card{margin-bottom:10px}:host ::ng-deep .ant-card .ant-card-head{min-height:auto;padding:0 12px}:host ::ng-deep nz-table.table-responsive{height:calc(100% - 42px)}:host ::ng-deep nz-table.table-responsive .ant-spin-nested-loading .ant-spin-container .ant-table .ant-table-content .ant-table-scroll .ant-table-body{height:calc(100% - 37px)!important}"]
        }),
        __metadata("design:paramtypes", [NzMessageService, TranslateService])
    ], IdentityIdentityResourceComponent);
    return IdentityIdentityResourceComponent;
}());
export { IdentityIdentityResourceComponent };
//# sourceMappingURL=data:application/json;base64, 