mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 03:45:59 +00:00
removed perspective intersection observer
This commit is contained in:
@@ -4,7 +4,7 @@ import { format } from 'path';
|
||||
import { PerspectiveBindingGroup, PerspectiveCache } from './PerspectiveCache';
|
||||
import { PerspectiveDataLoader } from './PerspectiveDataLoader';
|
||||
|
||||
const PERSPECTIVE_PAGE_SIZE = 100;
|
||||
export const PERSPECTIVE_PAGE_SIZE = 10;
|
||||
|
||||
export interface PerspectiveDatabaseConfig {
|
||||
conid: string;
|
||||
|
||||
@@ -76,13 +76,14 @@ export class PerspectiveDisplayRow {
|
||||
rowCellSkips: boolean[] = null;
|
||||
|
||||
rowJoinIds: number[] = [];
|
||||
incompleteRowsIndicator: string[] = null;
|
||||
// incompleteRowsIndicator: string[] = null;
|
||||
}
|
||||
|
||||
export class PerspectiveDisplay {
|
||||
columns: PerspectiveDisplayColumn[] = [];
|
||||
rows: PerspectiveDisplayRow[] = [];
|
||||
readonly columnLevelCount: number;
|
||||
loadIndicatorsCounts: { [uniqueName: string]: number } = {};
|
||||
|
||||
constructor(public root: PerspectiveTreeNode, rows: any[]) {
|
||||
// dbg('source rows', rows);
|
||||
@@ -92,7 +93,7 @@ export class PerspectiveDisplay {
|
||||
}
|
||||
this.columnLevelCount = _max(this.columns.map(x => x.parentNodes.length)) + 1;
|
||||
const collectedRows = this.collectRows(rows, root.childNodes);
|
||||
// dbg('collected rows', collectedRows);
|
||||
dbg('collected rows', collectedRows);
|
||||
// console.log('COLLECTED', JSON.stringify(collectedRows, null, 2));
|
||||
// this.mergeRows(collectedRows);
|
||||
this.mergeRows(collectedRows);
|
||||
@@ -212,16 +213,22 @@ export class PerspectiveDisplay {
|
||||
}
|
||||
|
||||
mergeRow(collectedRow: CollectedPerspectiveDisplayRow, rowIndex: number): number {
|
||||
if (collectedRow.incompleteRowsIndicator?.length > 0) {
|
||||
for (const indicator of collectedRow.incompleteRowsIndicator) {
|
||||
if (!this.loadIndicatorsCounts[indicator]) {
|
||||
this.loadIndicatorsCounts[indicator] = rowIndex;
|
||||
}
|
||||
if (rowIndex < this.loadIndicatorsCounts[indicator]) {
|
||||
this.loadIndicatorsCounts[indicator] = rowIndex;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const mainRow = this.getRowAt(rowIndex);
|
||||
for (let i = 0; i < collectedRow.columnIndexes.length; i++) {
|
||||
mainRow.rowData[collectedRow.columnIndexes[i]] = collectedRow.rowData[i];
|
||||
}
|
||||
if (collectedRow.incompleteRowsIndicator) {
|
||||
mainRow.incompleteRowsIndicator = [
|
||||
...(mainRow.incompleteRowsIndicator || []),
|
||||
...collectedRow.incompleteRowsIndicator,
|
||||
];
|
||||
}
|
||||
|
||||
let rowCount = 1;
|
||||
for (const subrows of collectedRow.subRowCollections) {
|
||||
|
||||
@@ -12,13 +12,17 @@ test('test flat view', () => {
|
||||
const root = new PerspectiveTableNode(artistTable, chinookDbInfo, createPerspectiveConfig(), null, null, null, null);
|
||||
const display = new PerspectiveDisplay(root, artistDataFlat);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(5);
|
||||
// console.log(display.loadIndicatorsCounts);
|
||||
// console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(4);
|
||||
expect(display.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['AC/DC'],
|
||||
})
|
||||
);
|
||||
expect(display.loadIndicatorsCounts).toEqual({
|
||||
Artist: 4,
|
||||
});
|
||||
});
|
||||
|
||||
test('test one level nesting', () => {
|
||||
@@ -34,8 +38,9 @@ test('test one level nesting', () => {
|
||||
);
|
||||
const display = new PerspectiveDisplay(root, artistDataAlbum);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(7);
|
||||
console.log(display.loadIndicatorsCounts);
|
||||
// console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(6);
|
||||
expect(display.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['AC/DC', 'For Those About To Rock We Salute You'],
|
||||
@@ -63,6 +68,11 @@ test('test one level nesting', () => {
|
||||
rowSpans: [1, 1],
|
||||
})
|
||||
);
|
||||
|
||||
expect(display.loadIndicatorsCounts).toEqual({
|
||||
Artist: 6,
|
||||
'Artist.Album': 6,
|
||||
});
|
||||
});
|
||||
|
||||
test('test two level nesting', () => {
|
||||
@@ -79,7 +89,7 @@ test('test two level nesting', () => {
|
||||
const display = new PerspectiveDisplay(root, artistDataAlbumTrack);
|
||||
|
||||
console.log(display.rows);
|
||||
expect(display.rows.length).toEqual(9);
|
||||
expect(display.rows.length).toEqual(8);
|
||||
expect(display.rows[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
rowData: ['AC/DC', 'For Those About To Rock We Salute You', 'For Those About To Rock (We Salute You)'],
|
||||
|
||||
@@ -1,55 +1,56 @@
|
||||
export default [
|
||||
{
|
||||
"ArtistId": 1,
|
||||
"Name": "AC/DC",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "For Those About To Rock We Salute You",
|
||||
"ArtistId": 1
|
||||
},
|
||||
{
|
||||
"Title": "Let There Be Rock",
|
||||
"ArtistId": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 2,
|
||||
"Name": "Accept",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Balls to the Wall",
|
||||
"ArtistId": 2
|
||||
},
|
||||
{
|
||||
"Title": "Restless and Wild",
|
||||
"ArtistId": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 3,
|
||||
"Name": "Aerosmith",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Big Ones",
|
||||
"ArtistId": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ArtistId": 4,
|
||||
"Name": "Alanis Morissette",
|
||||
"Album": [
|
||||
{
|
||||
"Title": "Jagged Little Pill",
|
||||
"ArtistId": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"incompleteRowsIndicator": [
|
||||
"Artist"
|
||||
]
|
||||
}
|
||||
]
|
||||
{
|
||||
ArtistId: 1,
|
||||
Name: 'AC/DC',
|
||||
Album: [
|
||||
{
|
||||
Title: 'For Those About To Rock We Salute You',
|
||||
ArtistId: 1,
|
||||
},
|
||||
{
|
||||
Title: 'Let There Be Rock',
|
||||
ArtistId: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
ArtistId: 2,
|
||||
Name: 'Accept',
|
||||
Album: [
|
||||
{
|
||||
Title: 'Balls to the Wall',
|
||||
ArtistId: 2,
|
||||
},
|
||||
{
|
||||
Title: 'Restless and Wild',
|
||||
ArtistId: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
ArtistId: 3,
|
||||
Name: 'Aerosmith',
|
||||
Album: [
|
||||
{
|
||||
Title: 'Big Ones',
|
||||
ArtistId: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
ArtistId: 4,
|
||||
Name: 'Alanis Morissette',
|
||||
Album: [
|
||||
{
|
||||
Title: 'Jagged Little Pill',
|
||||
ArtistId: 4,
|
||||
},
|
||||
{
|
||||
incompleteRowsIndicator: ['Artist.Album'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
incompleteRowsIndicator: ['Artist'],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user