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.identityResourcesFetching = false;
        this.identityResources = [];
        this.identityIdentityResourceCreateComponentProp = {
            visible: false,
        };
        this.identityIdentityResourceUpdateComponentProp = {
            visible: false,
            identityResource: new IdentityResourceVO(),
        };
    }
    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.prototype.handleIdentityIdentityResourceCreateComponentOk = function () {
        this.fetchIdentityResources();
    };
    IdentityIdentityResourceComponent.prototype.handleIdentityIdentityResourceUpdateComponentOk = function () {
        this.fetchIdentityResources();
    };
    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.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.ctorParameters = function () { return [
        { type: NzMessageService },
        { type: TranslateService }
    ]; };
    IdentityIdentityResourceComponent = __decorate([
        Component({
            selector: 'kg---identity--identity-resource',
            template: "<page-header title=\"\"></page-header>\r\n\r\n<nz-card\r\n  [ngStyle]=\"{\r\n    marginBottom: '0px',\r\n    height: 'calc(100% - 42px)'\r\n  }\"\r\n  [nzBodyStyle]=\"{\r\n    padding: '10px',\r\n    height: '100%'\r\n  }\"\r\n  [nzBordered]=\"false\"\r\n>\r\n  <div>\r\n    <button\r\n      (click)=\"fetchIdentityResources()\"\r\n      [ngStyle]=\"{\r\n        float: 'left',\r\n        marginBottom: '10px'\r\n      }\"\r\n      [nzLoading]=\"identityResourcesFetching\"\r\n      class=\"btn-outline-primary\"\r\n      nz-button\r\n    >\r\n      <i nz-icon nzType=\"reload\" nzTheme=\"outline\"></i>\r\n      {{ 'app.common.refresh' | i18n }}\r\n    </button>\r\n\r\n    <button\r\n      (click)=\"openIdentityIdentityResourceCreateComponent()\"\r\n      [disabled]=\"identityResourcesFetching\"\r\n      [ngStyle]=\"{\r\n        float: 'left',\r\n        marginBottom: '10px'\r\n      }\"\r\n      nz-button\r\n      nzType=\"primary\"\r\n    >\r\n      <i nz-icon nzType=\"plus-circle\" nzTheme=\"outline\"></i>\r\n      {{ 'app.common.create' | i18n }}\r\n    </button>\r\n  </div>\r\n\r\n  <nz-table\r\n    #table\r\n    [className]=\"'table-responsive'\"\r\n    [ngStyle]=\"{ marginTop: '10px', clear: 'both' }\"\r\n    [nzData]=\"identityResources\"\r\n    [nzFrontPagination]=\"false\"\r\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\r\n    [nzLoading]=\"identityResourcesFetching\"\r\n    [nzScroll]=\"{ x: '700px', y: 'auto' }\"\r\n    [nzShowPagination]=\"false\"\r\n    [nzWidthConfig]=\"['200px', '300px', '200px']\"\r\n    nzSize=\"small\"\r\n  >\r\n    <thead>\r\n      <tr>\r\n        <th>{{ 'app.common.name' | i18n }}</th>\r\n        <th>\r\n          {{ 'app.common.description' | i18n }}\r\n        </th>\r\n        <th [nzRight]=\"'0px'\" class=\"text-center\">{{ 'app.common.action' | i18n }}</th>\r\n      </tr>\r\n    </thead>\r\n\r\n    <tbody>\r\n      <ng-container *ngFor=\"let item of table.data\">\r\n        <tr>\r\n          <td [nzBreakWord]=\"true\">{{ item.name }}</td>\r\n\r\n          <td [nzBreakWord]=\"true\">{{ item.description }}</td>\r\n\r\n          <td class=\"text-right\" [nzRight]=\"'0px'\">\r\n            <button\r\n              (click)=\"openIdentityIdentityResourceUpdateComponent(item)\"\r\n              [disabled]=\"item.deleting\"\r\n              [ngStyle]=\"{ height: '28px' }\"\r\n              class=\"btn-outline-primary\"\r\n              nz-button\r\n              nzSize=\"small\"\r\n            >\r\n              <i nz-icon nzType=\"form\" nzTheme=\"outline\"></i>\r\n              {{ 'app.common.update' | i18n }}\r\n            </button>\r\n\r\n            <button\r\n              (nzOnConfirm)=\"deleteIdentityResource(item)\"\r\n              [ngStyle]=\"{ height: '28px' }\"\r\n              [nzLoading]=\"item.deleting\"\r\n              [nzTitle]=\"'app.common.confirm-deletion' | i18n\"\r\n              class=\"btn-outline-warning\"\r\n              nz-button\r\n              nz-popconfirm\r\n              nzPlacement=\"topRight\"\r\n              nzSize=\"small\"\r\n            >\r\n              <i nz-icon nzType=\"delete\" nzTheme=\"outline\"></i>\r\n              {{ 'app.common.delete' | i18n }}\r\n            </button>\r\n          </td>\r\n        </tr>\r\n      </ng-container>\r\n    </tbody>\r\n\r\n    <ng-template #loadingIndicatorTpl>\r\n      <i\r\n        [ngStyle]=\"{\r\n          fontSize: '24px',\r\n          marginTop: '10px'\r\n        }\"\r\n        nz-icon\r\n        nzTheme=\"outline\"\r\n        nzType=\"loading\"\r\n      ></i>\r\n    </ng-template>\r\n  </nz-table>\r\n</nz-card>\r\n\r\n<kg---identity--identity-resource--create\r\n  (ok)=\"handleIdentityIdentityResourceCreateComponentOk()\"\r\n  [(visible)]=\"identityIdentityResourceCreateComponentProp.visible\"\r\n></kg---identity--identity-resource--create>\r\n\r\n<kg---identity--identity-resource--update\r\n  (ok)=\"handleIdentityIdentityResourceUpdateComponentOk()\"\r\n  [(visible)]=\"identityIdentityResourceUpdateComponentProp.visible\"\r\n  [identityResource]=\"identityIdentityResourceUpdateComponentProp.identityResource\"\r\n></kg---identity--identity-resource--update>\r\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, 