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