import { __decorate, __metadata } from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ScopeVO } from '../../../vo/scope.vo';
import { API } from '../../../../../api';
let IdentityApiResourceUpdateScopeComponent = class IdentityApiResourceUpdateScopeComponent {
    constructor() {
        this.apiResourceName = '';
        this.identityApiResourceUpdateScopeCreateComponentProp = { visible: false };
        this.scopes = [];
        this.scopesFetching = false;
        this.visible = false;
        this.visibleChange = new EventEmitter();
    }
    deleteScope(item) {
        item.deleting = true;
        API.Identity.ApiResourceController.RemoveScope(new API.Identity.ApiResourceController.RemoveScopeParam({
            scope: item.name,
            resource: this.apiResourceName,
        })).subscribe({
            next: () => {
                item.deleting = false;
                this.fetchScopes();
            },
            error: () => {
                item.deleting = false;
            },
        });
    }
    fetchScopes() {
        this.scopesFetching = true;
        API.Identity.ApiResourceController.Scopes({
            resource: this.apiResourceName,
        }).subscribe({
            next: (data) => {
                this.scopes = ScopeVO.fromArray(data);
                this.scopesFetching = false;
            },
            error: () => {
                this.scopesFetching = false;
            },
        });
    }
    handleAfterOpen() {
        this.fetchScopes();
    }
    handleCancel() {
        this.visibleChange.emit(false);
    }
    handleIdentityApiResourceUpdateScopeCreateComponentOk() {
        this.fetchScopes();
    }
    openIdentityClientsUpdateClaimCreateComponent() {
        this.identityApiResourceUpdateScopeCreateComponentProp.visible = true;
    }
};
__decorate([
    Input(),
    __metadata("design:type", String)
], IdentityApiResourceUpdateScopeComponent.prototype, "apiResourceName", void 0);
__decorate([
    Input(),
    __metadata("design:type", Boolean)
], IdentityApiResourceUpdateScopeComponent.prototype, "visible", void 0);
__decorate([
    Output(),
    __metadata("design:type", EventEmitter)
], IdentityApiResourceUpdateScopeComponent.prototype, "visibleChange", void 0);
IdentityApiResourceUpdateScopeComponent = __decorate([
    Component({
        selector: 'kg---identity--api-resource--update--scope',
        template: "<nz-modal\n  (nzAfterOpen)=\"handleAfterOpen()\"\n  (nzOnCancel)=\"handleCancel()\"\n  [nzBodyStyle]=\"{\n    padding: '12px 16px 16px 16px'\n  }\"\n  [nzKeyboard]=\"false\"\n  [nzMaskClosable]=\"false\"\n  [nzTitle]=\"'projects/fe-ng/src/lib/page/identity/api-resource/update/scope/identity--api-resource--update--scope.title' | i18n\"\n  [nzVisible]=\"visible\"\n  nzWidth=\"1198px\"\n>\n  <div>\n    <button\n      (click)=\"fetchScopes()\"\n      [ngStyle]=\"{\n        float: 'left',\n        marginBottom: '10px'\n      }\"\n      [nzLoading]=\"scopesFetching\"\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)=\"openIdentityClientsUpdateClaimCreateComponent()\"\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    [ngStyle]=\"{ marginTop: '10px', clear: 'both' }\"\n    [nzData]=\"scopes\"\n    [nzFrontPagination]=\"false\"\n    [nzLoadingIndicator]=\"loadingIndicatorTpl\"\n    [nzLoading]=\"scopesFetching\"\n    [nzScroll]=\"{ x: '1400px' }\"\n    [nzShowPagination]=\"false\"\n    [nzWidthConfig]=\"['200px', '200px', '200px', '100px', '200px', '100px', '300px', '100px']\"\n    nzSize=\"small\"\n  >\n    <thead>\n      <tr>\n        <th>{{ 'app__name' | i18n }}</th>\n\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/api-resource/update/scope/identity--api-resource--update--scope.display_name' | i18n }}\n        </th>\n\n        <th>{{ 'app__description' | i18n }}</th>\n\n        <th>{{ 'app__required' | i18n }}</th>\n\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/api-resource/update/scope/identity--api-resource--update--scope.show_in_discovery_document' | i18n }}\n        </th>\n\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/api-resource/update/scope/identity--api-resource--update--scope.emphasize' | i18n }}\n        </th>\n\n        <th>\n          {{ 'projects/fe-ng/src/lib/page/identity/api-resource/update/scope/identity--api-resource--update--scope.user_claims' | i18n }}\n        </th>\n\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.displayName }}</td>\n\n          <td [nzBreakWord]=\"true\">{{ item.description }}</td>\n\n          <td>\n            <kg--yes-or-no [value]=\"item.required\"></kg--yes-or-no>\n          </td>\n\n          <td>\n            <kg--yes-or-no [value]=\"item.showInDiscoveryDocument\"></kg--yes-or-no>\n          </td>\n\n          <td>\n            <kg--yes-or-no [value]=\"item.emphasize\"></kg--yes-or-no>\n          </td>\n\n          <td [nzBreakWord]=\"true\">{{ item.userClaims }}</td>\n\n          <td [nzRight]=\"'0px'\" class=\"text-right\">\n            <button\n              (nzOnConfirm)=\"deleteScope(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\n  <div *nzModalFooter>\n    <button (click)=\"handleCancel()\" nz-button nzType=\"default\">\n      <i nz-icon nzTheme=\"outline\" nzType=\"stop\"></i>\n      {{ 'app__cancel' | i18n }}\n    </button>\n  </div>\n</nz-modal>\n\n<kg---identity--api-resource--update--scope--create\n  (ok)=\"handleIdentityApiResourceUpdateScopeCreateComponentOk()\"\n  [(visible)]=\"identityApiResourceUpdateScopeCreateComponentProp.visible\"\n  [apiResourceName]=\"apiResourceName\"\n></kg---identity--api-resource--update--scope--create>\n"
    })
], IdentityApiResourceUpdateScopeComponent);
export { IdentityApiResourceUpdateScopeComponent };
//# sourceMappingURL=data:application/json;base64, 