src/app/shared/dataset-info/dataset-info.component.ts

Implements

OnInit OnChanges

Metadata

Relationships

Used by

Depends on

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor()

Inputs

dsmeta
Type : DSMeta[]
Default value : []
open
Type : boolean
Default value : false
versions
Type : Version[]
Default value : []

Outputs

openChange
Type : EventEmitter
rowClicked
Type : EventEmitter

Methods

ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnInit
ngOnInit()
Returns : void
onCloseClick
onCloseClick()
Returns : void
onOpenChange
onOpenChange(open: boolean)
Parameters :
Name Type Optional
open boolean No
Returns : void
parseDSMeta
parseDSMeta()
Returns : void
parseVersions
parseVersions()
Returns : void

Properties

dsmetaTabs
Type : Tab<DSMeta>[]
Default value : []
tabs
Type : Tab<DSMeta | Version>[]
Default value : []
versionsTabs
Type : Tab<Version>[]
Default value : []
import {
  Component,
  EventEmitter,
  Input,
  OnChanges,
  OnInit,
  Output,
  SimpleChanges,
  ViewEncapsulation
} from '@angular/core'
import { DSMeta, Version } from 'src/app/models/sas/editors-getdata.model'
import { Tab } from './models/dsmeta-groupped.model'

@Component({
  selector: 'app-dataset-info',
  templateUrl: './dataset-info.component.html',
  styleUrls: ['./dataset-info.component.scss'],
  encapsulation: ViewEncapsulation.None,
  standalone: false
})
export class DatasetInfoComponent implements OnInit, OnChanges {
  @Input() open: boolean = false
  @Input() dsmeta: DSMeta[] = []
  @Input() versions: Version[] = []

  @Output() openChange = new EventEmitter<boolean>()
  @Output() rowClicked = new EventEmitter<Version | DSMeta>()

  dsmetaTabs: Tab<DSMeta>[] = []
  versionsTabs: Tab<Version>[] = []

  tabs: Tab<DSMeta | Version>[] = []

  constructor() {}

  ngOnInit(): void {}

  ngOnChanges(changes: SimpleChanges): void {
    if (changes.dsmeta?.currentValue?.length > 0) {
      this.parseDSMeta()
      this.parseVersions()

      this.tabs = [...[...this.dsmetaTabs], ...[...this.versionsTabs]]
    }
  }

  parseDSMeta() {
    this.dsmetaTabs = []

    for (let info of this.dsmeta) {
      let groupIndex = this.dsmetaTabs.findIndex(
        (x) => x.name === info.ODS_TABLE
      )

      if (groupIndex < 0)
        groupIndex =
          this.dsmetaTabs.push({
            name: info.ODS_TABLE,
            title: 'Dataset Meta',
            colsToDisplay: [{ colKey: 'NAME' }, { colKey: 'VALUE' }],
            meta: [],
            onRowClick: (value: DSMeta) => {
              this.rowClicked.emit(value)
            }
          }) - 1

      this.dsmetaTabs[groupIndex].meta.push(info)
    }
  }

  parseVersions() {
    this.versionsTabs = [
      {
        name: 'VERSIONS',
        title: 'Dataset Meta',
        colsToDisplay: [
          { colKey: 'LOAD_REF' },
          { colKey: 'USER_NM' },
          { colKey: 'VERSION_DTTM' },
          { colKey: 'NEW_RECORDS', colName: 'ADD' },
          { colKey: 'CHANGED_RECORDS', colName: 'MOD' },
          { colKey: 'DELETED_RECORDS', colName: 'DEL' },
          { colKey: 'VERSION_DESC' }
        ],
        meta: this.versions,
        onRowClick: (value: Version) => {
          this.rowClicked.emit(value)
        }
      }
    ]
  }

  onOpenChange(open: boolean) {
    this.open = open
    this.openChange.emit(open)
  }

  onCloseClick() {
    this.onOpenChange(false)
  }
}
<clr-modal
  [clrModalOpen]="open"
  (clrModalOpenChange)="onOpenChange($event)"
  [clrModalSize]="'xl'"
  [clrModalClosable]="true"
>
  <h3 class="modal-title center text-center color-darker-gray">Dataset Meta</h3>
  <div class="modal-body">
    @if (dsmetaTabs.length < 1) {
      <p class="text-center">No dataset meta to show.</p>
    }

    <clr-tabs clrLayout="vertical">
      @for (tab of tabs; track tab; let index = $index) {
        <clr-tab>
          <button clrTabLink id="link1">{{ tab.name }}</button>
          <clr-tab-content
            id="content1"
            *clrIfActive="index === 0"
            class="d-flex clr-justify-content-center w-100"
          >
            <clr-datagrid>
              @for (col of tab.colsToDisplay; track col) {
                <clr-dg-column>{{ col.colName || col.colKey }}</clr-dg-column>
              }
              @for (info of tab.meta; track info) {
                <clr-dg-row
                  (click)="tab.onRowClick ? tab.onRowClick(info) : ''"
                  class="clickable-row"
                >
                  @for (col of tab.colsToDisplay; track col) {
                    <clr-dg-cell>{{ info[col.colKey] }}</clr-dg-cell>
                  }
                </clr-dg-row>
              }
            </clr-datagrid>
          </clr-tab-content>
        </clr-tab>
      }
    </clr-tabs>
  </div>
  <div class="modal-footer">
    <button
      type="button"
      class="btn btn-sm btn-info-outline"
      (click)="onCloseClick()"
    >
      Close
    </button>
  </div>
</clr-modal>

./dataset-info.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""