import { Component, Input, Output, EventEmitter } from '@angular/core';
import { AddressSpaceService } from './address-space.service';
import { omit } from 'lodash-es';
export class OpcuaAddressSpaceDetailComponent {
    constructor(addressSpaceService) {
        this.addressSpaceService = addressSpaceService;
        this.selected = false;
        this.showDetails = false;
        this.toggleAttrDetail = new EventEmitter();
    }
    set node(n) {
        this._node = n;
        if (n) {
            this.setNodeData(n);
        }
        else {
            // remove details from current view
            this.showDetails = false;
        }
    }
    setNodeData(nodeData) {
        this.showDetails = true;
        const { attributes, references } = nodeData;
        this.nodeDataRef = references;
        const omitList = [
            'attributes',
            'references',
            'children',
            'currentlyLoadingChildren',
            'expanded',
            'browsePath',
            'relativePath',
            'parentNode'
        ];
        this.nodeDataAttr = Object.assign({}, attributes, omit(nodeData, omitList));
    }
    toggleDetail(node) {
        this.showDetails = !this.showDetails;
        this.toggleAttrDetail.emit(node);
    }
    navigateTo(ancestors) {
        const nodeNavData = {
            node: this._node,
            selectedAncestorIds: ancestors
        };
        this.toggleDetail(this._node);
        this.addressSpaceService.triggerNodeToOpen(nodeNavData);
    }
}
OpcuaAddressSpaceDetailComponent.decorators = [
    { type: Component, args: [{
                selector: 'opcua-address-space-detail',
                template: "<div\n  class=\"card flex-scroll m-b-4 split-row-2 animated fast\"\n  style=\"pointer-events: all\"\n  [ngClass]=\"{ fadeInRightBig: showDetails, fadeOutRightBig: !showDetails }\"\n>\n  <div class=\"card-header separator \">\n    <h4>{{ 'Attributes' | translate }}</h4>\n    <button\n      class=\"close flex-item-right visible-sm visible-xs\"\n      title=\"{{ 'Close' | translate }}\"\n      (click)=\"toggleDetail(nodeDataAttr)\"\n    >\n      &times;\n    </button>\n  </div>\n  <div class=\"card-inner-scroll\">\n    <div class=\"card-block\">\n      <table class=\"table table-striped table-condensed\">\n        <colgroup>\n          <col width=\"50%\" />\n          <col width=\"50%\" />\n        </colgroup>\n        <thead>\n          <tr>\n            <th>{{ 'Attribute' | translate }}</th>\n            <th>{{ 'Value' | translate }}</th>\n          </tr>\n        </thead>\n        <tbody>\n          <tr *ngFor=\"let item of nodeDataAttr | keyvalue\">\n            <td>{{ item.key }}</td>\n            <td *ngIf=\"item.key === 'absolutePaths'\" class=\"text-break-word\">\n              {{ item.value | json }}\n            </td>\n            <td *ngIf=\"item.key === 'ancestorNodeIds'\" class=\"text-break-word\">\n              <a *ngFor=\"let value of item.value\" (click)=\"navigateTo(value)\">\n                {{ value | json }}</a\n              >\n            </td>\n            <td *ngIf=\"item.key !== 'absolutePaths' && item.key !== 'ancestorNodeIds'\">\n              {{ item.value }}\n            </td>\n          </tr>\n        </tbody>\n      </table>\n    </div>\n  </div>\n</div>\n<div\n  class=\"card flex-scroll split-row-2 animated fast\"\n  style=\"pointer-events: all\"\n  [ngClass]=\"{ fadeInRightBig: showDetails, fadeOutRightBig: !showDetails }\"\n>\n  <div class=\"card-header separator\">\n    <h4>{{ 'References' | translate }}</h4>\n  </div>\n  <div class=\"card-inner-scroll\">\n    <div class=\"card-block\">\n      <table class=\"table table-striped table-condensed\">\n        <colgroup>\n          <col width=\"50%\" />\n          <col width=\"50%\" />\n        </colgroup>\n        <thead>\n          <tr>\n            <th>{{ 'Attribute' | translate }}</th>\n            <th>{{ 'Value' | translate }}</th>\n          </tr>\n        </thead>\n        <tbody>\n          <tr *ngFor=\"let item of nodeDataRef\">\n            <td>{{ item.referenceLabel }}</td>\n            <td class=\"text-break-word\">{{ item.targetLabel }}</td>\n          </tr>\n        </tbody>\n      </table>\n    </div>\n  </div>\n</div>\n"
            },] }
];
OpcuaAddressSpaceDetailComponent.ctorParameters = () => [
    { type: AddressSpaceService }
];
OpcuaAddressSpaceDetailComponent.propDecorators = {
    node: [{ type: Input }],
    toggleAttrDetail: [{ type: Output }]
};
//# sourceMappingURL=data:application/json;base64, 