feat: table metadata modal, versions tab (and link)

This commit is contained in:
Mihajlo Medjedovic 2024-03-25 22:41:00 +01:00
parent f8a14d4bde
commit b27fea5b91
10 changed files with 159 additions and 42 deletions

View File

@ -208,13 +208,16 @@
>{{ libdsParsed.tableName.replace('-FC', '') }}</a
>
</span>
<clr-tooltip-content
clrPosition="bottom-left"
clrSize="lg"
*clrIfOpen
>
{{ this.dsNote }}
</clr-tooltip-content>
<ng-container *ngIf="this.dsNote && this.dsNote.length > 0">
<clr-tooltip-content
clrPosition="bottom-left"
clrSize="lg"
*clrIfOpen
>
{{ this.dsNote }}
</clr-tooltip-content>
</ng-container>
</clr-tooltip>
<ng-container *ngIf="dataSource">
@ -843,6 +846,11 @@
</div>
</clr-modal>
<app-dataset-info [(open)]="datasetInfo" [dsmeta]="dsmeta"></app-dataset-info>
<app-dataset-info
[(open)]="datasetInfo"
[dsmeta]="dsmeta"
[versions]="versions"
(rowClicked)="datasetInfoModalRowClicked($event)">
</app-dataset-info>
<app-viewboxes [(viewboxModal)]="viewboxes"></app-viewboxes>

View File

@ -38,7 +38,8 @@ import { HotTableInterface } from '../models/HotTable.interface'
import {
$DataFormats,
DSMeta,
EditorsGetDataServiceResponse
EditorsGetDataServiceResponse,
Version
} from '../models/sas/editors-getdata.model'
import { DataFormat } from '../models/sas/common/DateFormat'
import SheetInfo from '../models/SheetInfo'
@ -121,6 +122,7 @@ export class EditorComponent implements OnInit, AfterViewInit {
datasetInfo: boolean = false
dsmeta: DSMeta[] = []
versions: Version[] = []
dsNote = ''
viewboxes: boolean = false
@ -2934,6 +2936,16 @@ export class EditorComponent implements OnInit, AfterViewInit {
}
}
datasetInfoModalRowClicked(value: Version | DSMeta) {
if ((<Version>value).LOAD_REF !== undefined) {
// Type is Version
const row = value as Version
const url = `/stage/${row.LOAD_REF}`
this.router.navigate([url])
}
}
viewboxManager() {
this.viewboxes = true
}
@ -3013,6 +3025,7 @@ export class EditorComponent implements OnInit, AfterViewInit {
this.cols = response.data.cols
this.dsmeta = response.data.dsmeta
this.versions = response.data.versions || []
const notes = this.dsmeta.find((item) => item.NAME === 'NOTES')
const longDesc = this.dsmeta.find((item) => item.NAME === 'DD_LONGDESC')

View File

@ -17,6 +17,7 @@ export interface EditorsGetDataSASResponse extends BaseSASResponse {
dqrules: DQRule[]
dsmeta: DSMeta[]
dqdata: DQData[]
versions: Version[]
cols: Col[]
maxvarlengths: Maxvarlength[]
xl_rules: any[]
@ -29,6 +30,16 @@ export interface DSMeta {
VALUE: string
}
export interface Version {
LOAD_REF: string;
USER_NM: string;
VERSION_DTTM: string;
VERSION_DESC: string;
CHANGED_RECORDS: number;
NEW_RECORDS: number;
DELETED_RECORDS: number;
}
export interface Sasdata {
_____DELETE__THIS__RECORD_____: string
PRIMARY_KEY_FIELD: number

View File

@ -6,25 +6,27 @@
>
<h3 class="modal-title center text-center color-darker-gray">Dataset Meta</h3>
<div class="modal-body">
<p *ngIf="dsmetaGroupped.length < 1" class="text-center">
<p *ngIf="dsmetaTabs.length < 1" class="text-center">
No dataset meta to show.
</p>
<clr-tabs clrLayout="vertical">
<clr-tab *ngFor="let dsmeta of dsmetaGroupped; let index = index">
<button clrTabLink id="link1">{{ dsmeta.group }}</button>
<clr-tab *ngFor="let tab of tabs; let index = index">
<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>
<clr-dg-column>Name</clr-dg-column>
<clr-dg-column>Value</clr-dg-column>
<ng-container *ngFor="let col of $any(tab.meta[0]) | keyvalue">
<clr-dg-column *ngIf="tab.colsToDisplay.length < 1 || tab.colsToDisplay.includes($any(col.key))">{{ col.key }}</clr-dg-column>
</ng-container>
<clr-dg-row *ngFor="let info of dsmeta.dsmeta">
<clr-dg-cell>{{ info.NAME }}</clr-dg-cell>
<clr-dg-cell>{{ info.VALUE }}</clr-dg-cell>
<clr-dg-row (click)="tab.onRowClick ? tab.onRowClick(info) : ''" class="clickable-row" *ngFor="let info of tab.meta">
<ng-container *ngFor="let col of $any(info) | keyvalue">
<clr-dg-cell *ngIf="tab.colsToDisplay.length < 1 || tab.colsToDisplay.includes($any(col.key))">{{ col.value }}</clr-dg-cell>
</ng-container>
</clr-dg-row>
</clr-datagrid>
</clr-tab-content>

View File

@ -13,4 +13,23 @@
}
}
}
}
clr-modal {
::ng-deep {
.modal-dialog {
height: 100%;
}
}
}
.clickable-row {
cursor: pointer;
}
::ng-deep {
.datagrid-table .datagrid-cell:focus {
outline: none;
outline-offset: 0;
}
}

View File

@ -7,8 +7,8 @@ import {
Output,
SimpleChanges
} from '@angular/core'
import { DSMeta } from 'src/app/models/sas/editors-getdata.model'
import { DSMetaGroupped } from './models/dsmeta-groupped.model'
import { DSMeta, Version } from 'src/app/models/sas/editors-getdata.model'
import { Tab } from './models/dsmeta-groupped.model'
@Component({
selector: 'app-dataset-info',
@ -18,10 +18,15 @@ import { DSMetaGroupped } from './models/dsmeta-groupped.model'
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>()
dsmetaGroupped: DSMetaGroupped[] = []
dsmetaTabs: Tab<DSMeta>[] = []
versionsTabs: Tab<Version>[] = []
tabs: Tab<DSMeta | Version>[] = []
constructor() {}
@ -30,28 +35,61 @@ export class DatasetInfoComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges): void {
if (changes.dsmeta?.currentValue?.length > 0) {
this.parseDSMeta()
this.parseVersions()
this.tabs = [
...[...this.dsmetaTabs],
...[...this.versionsTabs]
]
}
}
parseDSMeta() {
this.dsmetaGroupped = []
this.dsmetaTabs = []
for (let info of this.dsmeta) {
let groupIndex = this.dsmetaGroupped.findIndex(
(x) => x.group === info.ODS_TABLE
let groupIndex = this.dsmetaTabs.findIndex(
(x) => x.name === info.ODS_TABLE
)
if (groupIndex < 0)
groupIndex =
this.dsmetaGroupped.push({
group: info.ODS_TABLE,
dsmeta: []
this.dsmetaTabs.push({
name: info.ODS_TABLE,
title: 'Dataset Meta',
colsToDisplay: [
'NAME',
'VALUE'
],
meta: [],
onRowClick: (value: DSMeta) => {
this.rowClicked.emit(value)
},
}) - 1
this.dsmetaGroupped[groupIndex].dsmeta.push(info)
this.dsmetaTabs[groupIndex].meta.push(info)
}
}
parseVersions() {
this.versionsTabs = [
{
name: 'Table Versions',
title: 'Dataset Meta',
colsToDisplay: [
'LOAD_REF',
'USER_NM',
'VERSION_DTTM'
],
meta: this.versions,
onRowClick: (value: Version) => {
this.rowClicked.emit(value)
}
}
]
}
onOpenChange(open: boolean) {
this.open = open
this.openChange.emit(open)

View File

@ -1,6 +1,11 @@
import { DSMeta } from 'src/app/models/sas/editors-getdata.model'
export interface DSMetaGroupped {
group: string
dsmeta: DSMeta[]
export interface Tab<T> {
name: string
title: string
/**
* Columns to be displayed in the the grid
* If empty, all columns will be displayed
*/
colsToDisplay: string[]
meta: T[]
onRowClick?: (value: any) => void
}

View File

@ -379,13 +379,16 @@
<span clrTooltipTrigger *ngIf="tableTitle && tableTitle.length > 0">
{{ tableTitle?.replace('-FC', '') }}
</span>
<clr-tooltip-content
clrPosition="bottom-left"
clrSize="lg"
*clrIfOpen
>
{{ this.dsNote }}
</clr-tooltip-content>
<ng-container *ngIf="this.dsNote && this.dsNote.length > 0">
<clr-tooltip-content
clrPosition="bottom-left"
clrSize="lg"
*clrIfOpen
>
{{ this.dsNote }}
</clr-tooltip-content>
</ng-container>
</clr-tooltip>
<ng-container *ngIf="tableTitle && tableTitle.length > 0">
@ -667,6 +670,11 @@
</div>
</div>
<app-dataset-info [(open)]="datasetInfo" [dsmeta]="dsmeta"></app-dataset-info>
<app-dataset-info
[(open)]="datasetInfo"
[dsmeta]="dsmeta"
[versions]="versions"
(rowClicked)="datasetInfoModalRowClicked($event)">
</app-dataset-info>
<app-viewboxes [(viewboxModal)]="viewboxOpen"></app-viewboxes>

View File

@ -25,7 +25,7 @@ import { FilterGroup, FilterQuery } from '../models/FilterQuery'
import { HotTableInterface } from '../models/HotTable.interface'
import { LoggerService } from '../services/logger.service'
import Handsontable from 'handsontable'
import { $DataFormats, DSMeta } from '../models/sas/editors-getdata.model'
import { $DataFormats, DSMeta, Version } from '../models/sas/editors-getdata.model'
import { mergeColsRules } from '../shared/dc-validator/utils/mergeColsRules'
import { PublicViewtablesServiceResponse } from '../models/sas/public-viewtables.model'
import { PublicViewlibsServiceResponse } from '../models/sas/public-viewlibs.model'
@ -95,6 +95,7 @@ export class ViewerComponent implements AfterContentInit, AfterViewInit {
public $dataFormats: $DataFormats | null = null
public datasetInfo: boolean = false
public dsmeta: DSMeta[] = []
public versions: Version[] = []
public dsNote = ''
public licenceState = this.licenceService.licenceState
@ -247,6 +248,7 @@ export class ViewerComponent implements AfterContentInit, AfterViewInit {
this.hotTable.data = res.viewdata
this.$dataFormats = res.$viewdata
this.dsmeta = res.dsmeta
this.versions = res.versions || []
this.setDSNote()
this.numberOfRows = res.sasparams[0].NOBS
this.queryText = res.sasparams[0].FILTER_TEXT
@ -805,6 +807,7 @@ export class ViewerComponent implements AfterContentInit, AfterViewInit {
this.hotTable.data = res.viewdata
this.$dataFormats = res.$viewdata
this.dsmeta = res.dsmeta
this.versions = res.versions || []
this.setDSNote()
this.queryText = res.sasparams[0].FILTER_TEXT
let columns: any[] = []
@ -1019,6 +1022,16 @@ export class ViewerComponent implements AfterContentInit, AfterViewInit {
this.sasStoreService.removeClause()
}
public datasetInfoModalRowClicked(value: Version | DSMeta) {
if ((<Version>value).LOAD_REF !== undefined) {
// Type is Version
const row = value as Version
const url = `/stage/${row.LOAD_REF}`
this.router.navigate([url])
}
}
private setDSNote() {
const notes = this.dsmeta.find((item) => item.NAME === 'NOTES')
const longDesc = this.dsmeta.find((item) => item.NAME === 'DD_LONGDESC')

View File

@ -15,7 +15,7 @@ try {
writeFileSync(
file,
`//IMPORTANT: THIS FILE IS AUTO GENERATED BASED ON LICENCE.MD FILE!\nexport const EULA = \`\n${licence}\n\``,
`//IMPORTANT: THIS FILE IS AUTO GENERATED BASED ON LICENCE.MD FILE!\nexport const EULA = \`\n${licence}\n\`\n`,
{ encoding: 'utf-8' }
)