dbgate-datalib 5.0.8 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/FreeTableGridDisplay.d.ts +8 -4
- package/lib/GridDisplay.d.ts +1 -1
- package/lib/PerspectiveCache.d.ts +39 -0
- package/lib/PerspectiveCache.js +99 -0
- package/lib/PerspectiveConfig.d.ts +85 -0
- package/lib/PerspectiveConfig.js +54 -0
- package/lib/PerspectiveDataLoader.d.ts +9 -0
- package/lib/PerspectiveDataLoader.js +139 -0
- package/lib/PerspectiveDataProvider.d.ts +42 -0
- package/lib/PerspectiveDataProvider.js +181 -0
- package/lib/PerspectiveDisplay.d.ts +55 -0
- package/lib/PerspectiveDisplay.js +229 -0
- package/lib/PerspectiveTreeNode.d.ts +174 -0
- package/lib/PerspectiveTreeNode.js +959 -0
- package/lib/TableGridDisplay.d.ts +8 -4
- package/lib/ViewGridDisplay.d.ts +8 -4
- package/lib/index.d.ts +7 -0
- package/lib/index.js +12 -1
- package/lib/processPerspectiveDefaultColunns.d.ts +4 -0
- package/lib/processPerspectiveDefaultColunns.js +128 -0
- package/lib/tests/PerspectiveDisplay.test.d.ts +1 -0
- package/lib/tests/PerspectiveDisplay.test.js +94 -0
- package/lib/tests/artistDataAlbum.d.ts +20 -0
- package/lib/tests/artistDataAlbum.js +58 -0
- package/lib/tests/artistDataAlbumTrack.d.ts +20 -0
- package/lib/tests/artistDataAlbumTrack.js +79 -0
- package/lib/tests/artistDataFlat.d.ts +10 -0
- package/lib/tests/artistDataFlat.js +23 -0
- package/lib/tests/chinookDbInfo.d.ts +2 -0
- package/lib/tests/chinookDbInfo.js +1775 -0
- package/package.json +9 -4
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PerspectiveDataProvider = exports.PERSPECTIVE_PAGE_SIZE = void 0;
|
|
27
|
+
const debug_1 = __importDefault(require("debug"));
|
|
28
|
+
exports.PERSPECTIVE_PAGE_SIZE = 100;
|
|
29
|
+
const dbg = (0, debug_1.default)('dbgate:PerspectiveDataProvider');
|
|
30
|
+
class PerspectiveDataProvider {
|
|
31
|
+
constructor(cache, loader) {
|
|
32
|
+
this.cache = cache;
|
|
33
|
+
this.loader = loader;
|
|
34
|
+
}
|
|
35
|
+
loadData(props) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
dbg('load data', props);
|
|
38
|
+
// console.log('LOAD DATA', props);
|
|
39
|
+
if (props.bindingColumns) {
|
|
40
|
+
return this.loadDataNested(props);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return this.loadDataFlat(props);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
loadDataNested(props) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const tableCache = this.cache.getTableCache(props);
|
|
50
|
+
const uncached = tableCache.getUncachedBindingGroups(props);
|
|
51
|
+
if (uncached.length > 0) {
|
|
52
|
+
const counts = yield this.loader.loadGrouping(Object.assign(Object.assign({}, props), { bindingValues: uncached }));
|
|
53
|
+
// console.log('COUNTS', counts);
|
|
54
|
+
for (const resetItem of uncached) {
|
|
55
|
+
tableCache.storeGroupSize(props, resetItem, 0);
|
|
56
|
+
}
|
|
57
|
+
for (const countItem of counts) {
|
|
58
|
+
const { _perspective_group_size_ } = countItem, fields = __rest(countItem, ["_perspective_group_size_"]);
|
|
59
|
+
tableCache.storeGroupSize(props, props.bindingColumns.map(col => fields[col]), _perspective_group_size_);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const rows = [];
|
|
63
|
+
// console.log('CACHE', tableCache.bindingGroups);
|
|
64
|
+
let groupIndex = 0;
|
|
65
|
+
let loadCalled = false;
|
|
66
|
+
let shouldReturn = false;
|
|
67
|
+
for (; groupIndex < props.bindingValues.length; groupIndex++) {
|
|
68
|
+
const groupValues = props.bindingValues[groupIndex];
|
|
69
|
+
const group = tableCache.getBindingGroup(groupValues);
|
|
70
|
+
if (!group.loadedAll) {
|
|
71
|
+
if (loadCalled) {
|
|
72
|
+
shouldReturn = true;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// we need to load next data
|
|
76
|
+
yield this.loadNextGroup(props, groupIndex);
|
|
77
|
+
loadCalled = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// console.log('GRP', groupValues, group);
|
|
81
|
+
rows.push(...group.loadedRows);
|
|
82
|
+
if (rows.length >= props.topCount || shouldReturn) {
|
|
83
|
+
return {
|
|
84
|
+
rows: rows.slice(0, props.topCount),
|
|
85
|
+
incomplete: props.topCount < rows.length || !group.loadedAll || groupIndex < props.bindingValues.length - 1,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (groupIndex >= props.bindingValues.length) {
|
|
90
|
+
// all groups are fully loaded
|
|
91
|
+
return { rows, incomplete: false };
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
loadNextGroup(props, groupIndex) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const tableCache = this.cache.getTableCache(props);
|
|
98
|
+
const planLoadingGroupIndexes = [];
|
|
99
|
+
const planLoadingGroups = [];
|
|
100
|
+
let planLoadRowCount = 0;
|
|
101
|
+
const loadPlanned = () => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
// console.log(
|
|
103
|
+
// 'LOAD PLANNED',
|
|
104
|
+
// planLoadingGroupIndexes,
|
|
105
|
+
// planLoadingGroupIndexes.map(idx => props.bindingValues[idx])
|
|
106
|
+
// );
|
|
107
|
+
const rows = yield this.loader.loadData(Object.assign(Object.assign({}, props), { bindingValues: planLoadingGroupIndexes.map(idx => props.bindingValues[idx]) }));
|
|
108
|
+
// console.log('LOADED PLANNED', rows);
|
|
109
|
+
// distribute rows into groups
|
|
110
|
+
for (const row of rows) {
|
|
111
|
+
const group = planLoadingGroups.find(x => x.matchRow(row));
|
|
112
|
+
if (group) {
|
|
113
|
+
group.loadedRows.push(row);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const group of planLoadingGroups) {
|
|
117
|
+
group.loadedAll = true;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
for (; groupIndex < props.bindingValues.length; groupIndex++) {
|
|
121
|
+
const groupValues = props.bindingValues[groupIndex];
|
|
122
|
+
const group = tableCache.getBindingGroup(groupValues);
|
|
123
|
+
if (!group)
|
|
124
|
+
continue;
|
|
125
|
+
if (group.loadedAll)
|
|
126
|
+
continue;
|
|
127
|
+
if (group.groupSize == 0) {
|
|
128
|
+
group.loadedAll = true;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (group.groupSize >= exports.PERSPECTIVE_PAGE_SIZE) {
|
|
132
|
+
if (planLoadingGroupIndexes.length > 0) {
|
|
133
|
+
yield loadPlanned();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const nextRows = yield this.loader.loadData(Object.assign(Object.assign({}, props), { topCount: null, range: {
|
|
137
|
+
offset: group.loadedRows.length,
|
|
138
|
+
limit: exports.PERSPECTIVE_PAGE_SIZE,
|
|
139
|
+
}, bindingValues: [group.bindingValues] }));
|
|
140
|
+
group.loadedRows = [...group.loadedRows, ...nextRows];
|
|
141
|
+
group.loadedAll = nextRows.length < exports.PERSPECTIVE_PAGE_SIZE;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
if (planLoadRowCount + group.groupSize > exports.PERSPECTIVE_PAGE_SIZE) {
|
|
146
|
+
yield loadPlanned();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
planLoadingGroupIndexes.push(groupIndex);
|
|
150
|
+
planLoadingGroups.push(group);
|
|
151
|
+
planLoadRowCount += group.groupSize;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (planLoadingGroupIndexes.length > 0) {
|
|
155
|
+
yield loadPlanned();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
loadDataFlat(props) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const tableCache = this.cache.getTableCache(props);
|
|
162
|
+
if (props.topCount <= tableCache.loadedCount) {
|
|
163
|
+
return tableCache.getRowsResult(props);
|
|
164
|
+
}
|
|
165
|
+
// load missing rows
|
|
166
|
+
tableCache.dataColumns = props.dataColumns;
|
|
167
|
+
const nextRows = yield this.loader.loadData(Object.assign(Object.assign({}, props), { topCount: null, range: {
|
|
168
|
+
offset: tableCache.loadedCount,
|
|
169
|
+
limit: props.topCount - tableCache.loadedCount,
|
|
170
|
+
} }));
|
|
171
|
+
if (nextRows.errorMessage) {
|
|
172
|
+
throw new Error(nextRows.errorMessage);
|
|
173
|
+
}
|
|
174
|
+
tableCache.loadedRows = [...tableCache.loadedRows, ...nextRows];
|
|
175
|
+
tableCache.loadedAll = nextRows.length < props.topCount - tableCache.loadedCount;
|
|
176
|
+
// const rows=tableCache.getRows(props);
|
|
177
|
+
return tableCache.getRowsResult(props);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.PerspectiveDataProvider = PerspectiveDataProvider;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { PerspectiveTreeNode } from './PerspectiveTreeNode';
|
|
2
|
+
export declare class PerspectiveDisplayColumn {
|
|
3
|
+
display: PerspectiveDisplay;
|
|
4
|
+
title: string;
|
|
5
|
+
dataField: string;
|
|
6
|
+
parentNodes: PerspectiveTreeNode[];
|
|
7
|
+
colSpanAtLevel: {};
|
|
8
|
+
columnIndex: number;
|
|
9
|
+
dataNode: PerspectiveTreeNode;
|
|
10
|
+
constructor(display: PerspectiveDisplay);
|
|
11
|
+
get rowSpan(): number;
|
|
12
|
+
showParent(level: number): boolean;
|
|
13
|
+
getColSpan(level: number): any;
|
|
14
|
+
isVisible(level: number): boolean;
|
|
15
|
+
get columnLevel(): number;
|
|
16
|
+
getParentName(level: any): any;
|
|
17
|
+
getParentNode(level: any): PerspectiveTreeNode;
|
|
18
|
+
getParentTableDesignerId(level: any): string;
|
|
19
|
+
}
|
|
20
|
+
interface PerspectiveSubRowCollection {
|
|
21
|
+
rows: CollectedPerspectiveDisplayRow[];
|
|
22
|
+
}
|
|
23
|
+
interface CollectedPerspectiveDisplayRow {
|
|
24
|
+
columnIndexes: number[];
|
|
25
|
+
rowData: any[];
|
|
26
|
+
subRowCollections: PerspectiveSubRowCollection[];
|
|
27
|
+
incompleteRowsIndicator?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare class PerspectiveDisplayRow {
|
|
30
|
+
display: PerspectiveDisplay;
|
|
31
|
+
constructor(display: PerspectiveDisplay);
|
|
32
|
+
rowData: any[];
|
|
33
|
+
rowSpans: number[];
|
|
34
|
+
rowCellSkips: boolean[];
|
|
35
|
+
rowJoinIds: number[];
|
|
36
|
+
}
|
|
37
|
+
export declare class PerspectiveDisplay {
|
|
38
|
+
root: PerspectiveTreeNode;
|
|
39
|
+
columns: PerspectiveDisplayColumn[];
|
|
40
|
+
rows: PerspectiveDisplayRow[];
|
|
41
|
+
readonly columnLevelCount: number;
|
|
42
|
+
loadIndicatorsCounts: {
|
|
43
|
+
[designerId: string]: number;
|
|
44
|
+
};
|
|
45
|
+
constructor(root: PerspectiveTreeNode, rows: any[]);
|
|
46
|
+
private getRowAt;
|
|
47
|
+
fillColumns(children: PerspectiveTreeNode[], parentNodes: PerspectiveTreeNode[]): void;
|
|
48
|
+
processColumn(node: PerspectiveTreeNode, parentNodes: PerspectiveTreeNode[]): void;
|
|
49
|
+
findColumnIndexFromNode(node: PerspectiveTreeNode): number;
|
|
50
|
+
collectRows(sourceRows: any[], nodes: PerspectiveTreeNode[]): CollectedPerspectiveDisplayRow[];
|
|
51
|
+
fillRowSpans(): void;
|
|
52
|
+
mergeRows(collectedRows: CollectedPerspectiveDisplayRow[]): void;
|
|
53
|
+
mergeRow(collectedRow: CollectedPerspectiveDisplayRow, rowIndex: number): number;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PerspectiveDisplay = exports.PerspectiveDisplayRow = exports.PerspectiveDisplayColumn = void 0;
|
|
7
|
+
const max_1 = __importDefault(require("lodash/max"));
|
|
8
|
+
const fill_1 = __importDefault(require("lodash/fill"));
|
|
9
|
+
const findIndex_1 = __importDefault(require("lodash/findIndex"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const dbg = (0, debug_1.default)('dbgate:PerspectiveDisplay');
|
|
12
|
+
let lastJoinId = 0;
|
|
13
|
+
function getJoinId() {
|
|
14
|
+
lastJoinId += 1;
|
|
15
|
+
return lastJoinId;
|
|
16
|
+
}
|
|
17
|
+
class PerspectiveDisplayColumn {
|
|
18
|
+
constructor(display) {
|
|
19
|
+
this.display = display;
|
|
20
|
+
this.parentNodes = [];
|
|
21
|
+
this.colSpanAtLevel = {};
|
|
22
|
+
this.columnIndex = 0;
|
|
23
|
+
this.dataNode = null;
|
|
24
|
+
}
|
|
25
|
+
get rowSpan() {
|
|
26
|
+
return this.display.columnLevelCount - this.parentNodes.length;
|
|
27
|
+
}
|
|
28
|
+
showParent(level) {
|
|
29
|
+
return !!this.colSpanAtLevel[level];
|
|
30
|
+
}
|
|
31
|
+
getColSpan(level) {
|
|
32
|
+
return this.colSpanAtLevel[level];
|
|
33
|
+
}
|
|
34
|
+
isVisible(level) {
|
|
35
|
+
return level == this.columnLevel;
|
|
36
|
+
}
|
|
37
|
+
get columnLevel() {
|
|
38
|
+
return this.parentNodes.length;
|
|
39
|
+
}
|
|
40
|
+
getParentName(level) {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = this.parentNodes[level]) === null || _a === void 0 ? void 0 : _a.title;
|
|
43
|
+
}
|
|
44
|
+
getParentNode(level) {
|
|
45
|
+
return this.parentNodes[level];
|
|
46
|
+
}
|
|
47
|
+
getParentTableDesignerId(level) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return ((_a = this.parentNodes[level]) === null || _a === void 0 ? void 0 : _a.headerTableAttributes) ? (_b = this.parentNodes[level]) === null || _b === void 0 ? void 0 : _b.designerId : '';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.PerspectiveDisplayColumn = PerspectiveDisplayColumn;
|
|
53
|
+
class PerspectiveDisplayRow {
|
|
54
|
+
constructor(display) {
|
|
55
|
+
this.display = display;
|
|
56
|
+
this.rowData = [];
|
|
57
|
+
this.rowSpans = null;
|
|
58
|
+
this.rowCellSkips = null;
|
|
59
|
+
this.rowJoinIds = [];
|
|
60
|
+
this.rowData = (0, fill_1.default)(Array(display.columns.length), undefined);
|
|
61
|
+
this.rowSpans = (0, fill_1.default)(Array(display.columns.length), 1);
|
|
62
|
+
this.rowJoinIds = (0, fill_1.default)(Array(display.columns.length), 0);
|
|
63
|
+
this.rowCellSkips = (0, fill_1.default)(Array(display.columns.length), false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.PerspectiveDisplayRow = PerspectiveDisplayRow;
|
|
67
|
+
class PerspectiveDisplay {
|
|
68
|
+
constructor(root, rows) {
|
|
69
|
+
this.root = root;
|
|
70
|
+
this.columns = [];
|
|
71
|
+
this.rows = [];
|
|
72
|
+
this.loadIndicatorsCounts = {};
|
|
73
|
+
// dbg('source rows', rows);
|
|
74
|
+
this.fillColumns(root.childNodes, [root]);
|
|
75
|
+
if (this.columns.length > 0) {
|
|
76
|
+
this.columns[0].colSpanAtLevel[0] = this.columns.length;
|
|
77
|
+
}
|
|
78
|
+
this.columnLevelCount = (0, max_1.default)(this.columns.map(x => x.parentNodes.length)) + 1;
|
|
79
|
+
const collectedRows = this.collectRows(rows, root.childNodes);
|
|
80
|
+
dbg('collected rows', collectedRows);
|
|
81
|
+
// console.log('COLLECTED', JSON.stringify(collectedRows, null, 2));
|
|
82
|
+
// this.mergeRows(collectedRows);
|
|
83
|
+
this.mergeRows(collectedRows);
|
|
84
|
+
// dbg('merged rows', this.rows);
|
|
85
|
+
// console.log(
|
|
86
|
+
// 'MERGED',
|
|
87
|
+
// this.rows.map(r =>
|
|
88
|
+
// r.incompleteRowsIndicator
|
|
89
|
+
// ? `************************************ ${r.incompleteRowsIndicator.join('|')}`
|
|
90
|
+
// : r.rowData.join('|')
|
|
91
|
+
// )
|
|
92
|
+
// );
|
|
93
|
+
}
|
|
94
|
+
getRowAt(rowIndex) {
|
|
95
|
+
while (this.rows.length <= rowIndex) {
|
|
96
|
+
this.rows.push(new PerspectiveDisplayRow(this));
|
|
97
|
+
}
|
|
98
|
+
return this.rows[rowIndex];
|
|
99
|
+
}
|
|
100
|
+
fillColumns(children, parentNodes) {
|
|
101
|
+
for (const child of children) {
|
|
102
|
+
if (child.isCheckedColumn || child.isCheckedNode) {
|
|
103
|
+
this.processColumn(child, parentNodes);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
processColumn(node, parentNodes) {
|
|
108
|
+
if (node.isCheckedColumn) {
|
|
109
|
+
const column = new PerspectiveDisplayColumn(this);
|
|
110
|
+
column.title = node.columnTitle;
|
|
111
|
+
column.dataField = node.dataField;
|
|
112
|
+
column.parentNodes = parentNodes;
|
|
113
|
+
column.display = this;
|
|
114
|
+
column.columnIndex = this.columns.length;
|
|
115
|
+
column.dataNode = node;
|
|
116
|
+
this.columns.push(column);
|
|
117
|
+
}
|
|
118
|
+
if (node.isExpandable && node.isCheckedNode) {
|
|
119
|
+
const countBefore = this.columns.length;
|
|
120
|
+
this.fillColumns(node.childNodes, [...parentNodes, node]);
|
|
121
|
+
if (this.columns.length > countBefore) {
|
|
122
|
+
this.columns[countBefore].colSpanAtLevel[parentNodes.length] = this.columns.length - countBefore;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
findColumnIndexFromNode(node) {
|
|
127
|
+
return (0, findIndex_1.default)(this.columns, x => { var _a, _b, _c; return x.dataNode.columnName == node.columnName && ((_b = (_a = x.dataNode) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.designerId) == ((_c = node === null || node === void 0 ? void 0 : node.parentNode) === null || _c === void 0 ? void 0 : _c.designerId); });
|
|
128
|
+
}
|
|
129
|
+
// findColumnIndexFromNode(node: PerspectiveTreeNode) {
|
|
130
|
+
// return _findIndex(this.columns, x => x.dataNode.designerId == node.designerId);
|
|
131
|
+
// }
|
|
132
|
+
collectRows(sourceRows, nodes) {
|
|
133
|
+
// console.log('********** COLLECT ROWS', sourceRows);
|
|
134
|
+
const columnNodes = nodes.filter(x => x.isCheckedColumn);
|
|
135
|
+
const treeNodes = nodes.filter(x => x.isCheckedNode);
|
|
136
|
+
// console.log('columnNodes', columnNodes);
|
|
137
|
+
// console.log('treeNodes', treeNodes);
|
|
138
|
+
const columnIndexes = columnNodes.map(node => this.findColumnIndexFromNode(node));
|
|
139
|
+
const res = [];
|
|
140
|
+
for (const sourceRow of sourceRows) {
|
|
141
|
+
// console.log('PROCESS SOURCE', sourceRow);
|
|
142
|
+
// row.startIndex = startIndex;
|
|
143
|
+
const rowData = columnNodes.map(node => sourceRow[node.codeName]);
|
|
144
|
+
const subRowCollections = [];
|
|
145
|
+
for (const node of treeNodes) {
|
|
146
|
+
if (sourceRow[node.fieldName]) {
|
|
147
|
+
const subrows = {
|
|
148
|
+
rows: this.collectRows(sourceRow[node.fieldName], node.childNodes),
|
|
149
|
+
};
|
|
150
|
+
subRowCollections.push(subrows);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
res.push({
|
|
154
|
+
rowData,
|
|
155
|
+
columnIndexes,
|
|
156
|
+
subRowCollections,
|
|
157
|
+
incompleteRowsIndicator: sourceRow.incompleteRowsIndicator,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return res;
|
|
161
|
+
}
|
|
162
|
+
fillRowSpans() {
|
|
163
|
+
for (let col = 0; col < this.columns.length; col++) {
|
|
164
|
+
// let lastFilledJoinId = null;
|
|
165
|
+
let lastFilledRow = 0;
|
|
166
|
+
let rowIndex = 0;
|
|
167
|
+
for (const row of this.rows) {
|
|
168
|
+
if (row.rowData[col] === undefined &&
|
|
169
|
+
row.rowJoinIds[col] == this.rows[lastFilledRow].rowJoinIds[col] &&
|
|
170
|
+
row.rowJoinIds[col]) {
|
|
171
|
+
row.rowCellSkips[col] = true;
|
|
172
|
+
this.rows[lastFilledRow].rowSpans[col] = rowIndex - lastFilledRow + 1;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
lastFilledRow = rowIndex;
|
|
176
|
+
}
|
|
177
|
+
rowIndex++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
mergeRows(collectedRows) {
|
|
182
|
+
let rowIndex = 0;
|
|
183
|
+
for (const collectedRow of collectedRows) {
|
|
184
|
+
const count = this.mergeRow(collectedRow, rowIndex);
|
|
185
|
+
rowIndex += count;
|
|
186
|
+
}
|
|
187
|
+
this.fillRowSpans();
|
|
188
|
+
}
|
|
189
|
+
mergeRow(collectedRow, rowIndex) {
|
|
190
|
+
var _a;
|
|
191
|
+
if (((_a = collectedRow.incompleteRowsIndicator) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
192
|
+
for (const indicator of collectedRow.incompleteRowsIndicator) {
|
|
193
|
+
if (!this.loadIndicatorsCounts[indicator]) {
|
|
194
|
+
this.loadIndicatorsCounts[indicator] = rowIndex;
|
|
195
|
+
}
|
|
196
|
+
if (rowIndex < this.loadIndicatorsCounts[indicator]) {
|
|
197
|
+
this.loadIndicatorsCounts[indicator] = rowIndex;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
const mainRow = this.getRowAt(rowIndex);
|
|
203
|
+
for (let i = 0; i < collectedRow.columnIndexes.length; i++) {
|
|
204
|
+
mainRow.rowData[collectedRow.columnIndexes[i]] = collectedRow.rowData[i];
|
|
205
|
+
}
|
|
206
|
+
let rowCount = 1;
|
|
207
|
+
for (const subrows of collectedRow.subRowCollections) {
|
|
208
|
+
let additionalRowCount = 0;
|
|
209
|
+
let currentRowIndex = rowIndex;
|
|
210
|
+
for (const subrow of subrows.rows) {
|
|
211
|
+
const count = this.mergeRow(subrow, currentRowIndex);
|
|
212
|
+
additionalRowCount += count;
|
|
213
|
+
currentRowIndex += count;
|
|
214
|
+
}
|
|
215
|
+
if (additionalRowCount > rowCount) {
|
|
216
|
+
rowCount = additionalRowCount;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const joinId = getJoinId();
|
|
220
|
+
for (let radd = 0; radd < rowCount; radd++) {
|
|
221
|
+
const row = this.getRowAt(rowIndex + radd);
|
|
222
|
+
for (let i = 0; i < collectedRow.columnIndexes.length; i++) {
|
|
223
|
+
row.rowJoinIds[collectedRow.columnIndexes[i]] = joinId;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return rowCount;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.PerspectiveDisplay = PerspectiveDisplay;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { ColumnInfo, DatabaseInfo, ForeignKeyInfo, NamedObjectInfo, TableInfo, ViewInfo } from 'dbgate-types';
|
|
2
|
+
import { ChangePerspectiveConfigFunc, MultipleDatabaseInfo, PerspectiveConfig, PerspectiveCustomJoinConfig, PerspectiveFilterColumnInfo, PerspectiveNodeConfig, PerspectiveReferenceConfig } from './PerspectiveConfig';
|
|
3
|
+
import { PerspectiveDatabaseConfig, PerspectiveDataLoadProps, PerspectiveDataProvider } from './PerspectiveDataProvider';
|
|
4
|
+
import { FilterType } from 'dbgate-filterparser/lib/types';
|
|
5
|
+
import { Condition } from 'dbgate-sqltree';
|
|
6
|
+
export interface PerspectiveDataLoadPropsWithNode {
|
|
7
|
+
props: PerspectiveDataLoadProps;
|
|
8
|
+
node: PerspectiveTreeNode;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class PerspectiveTreeNode {
|
|
11
|
+
dbs: MultipleDatabaseInfo;
|
|
12
|
+
config: PerspectiveConfig;
|
|
13
|
+
setConfig: ChangePerspectiveConfigFunc;
|
|
14
|
+
parentNode: PerspectiveTreeNode;
|
|
15
|
+
dataProvider: PerspectiveDataProvider;
|
|
16
|
+
databaseConfig: PerspectiveDatabaseConfig;
|
|
17
|
+
designerId: string;
|
|
18
|
+
constructor(dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, parentNode: PerspectiveTreeNode, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, designerId: string);
|
|
19
|
+
readonly nodeConfig: PerspectiveNodeConfig;
|
|
20
|
+
readonly parentNodeConfig: PerspectiveNodeConfig;
|
|
21
|
+
abstract get title(): any;
|
|
22
|
+
abstract get codeName(): any;
|
|
23
|
+
abstract get isExpandable(): any;
|
|
24
|
+
childNodesCache: PerspectiveTreeNode[];
|
|
25
|
+
get childNodes(): PerspectiveTreeNode[];
|
|
26
|
+
abstract generateChildNodes(): PerspectiveTreeNode[];
|
|
27
|
+
abstract get icon(): string;
|
|
28
|
+
get fieldName(): any;
|
|
29
|
+
get headerTableAttributes(): any;
|
|
30
|
+
get dataField(): any;
|
|
31
|
+
get tableCode(): any;
|
|
32
|
+
get namedObject(): NamedObjectInfo;
|
|
33
|
+
abstract getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
|
34
|
+
get isRoot(): boolean;
|
|
35
|
+
get rootNode(): PerspectiveTreeNode;
|
|
36
|
+
get isSortable(): boolean;
|
|
37
|
+
matchChildRow(parentRow: any, childRow: any): boolean;
|
|
38
|
+
hasTableCode(code: string): any;
|
|
39
|
+
get level(): any;
|
|
40
|
+
get isExpanded(): boolean;
|
|
41
|
+
get isCheckedColumn(): boolean;
|
|
42
|
+
get isChecked(): boolean;
|
|
43
|
+
get isCheckedNode(): boolean;
|
|
44
|
+
get isSecondaryChecked(): boolean;
|
|
45
|
+
get secondaryCheckable(): boolean;
|
|
46
|
+
get columnTitle(): any;
|
|
47
|
+
get filterType(): FilterType;
|
|
48
|
+
get columnName(): any;
|
|
49
|
+
get customJoinConfig(): PerspectiveCustomJoinConfig;
|
|
50
|
+
get db(): DatabaseInfo;
|
|
51
|
+
get isCircular(): boolean;
|
|
52
|
+
hasDesignerIdInIncestors(designerId: string): boolean;
|
|
53
|
+
getChildMatchColumns(): any[];
|
|
54
|
+
getParentMatchColumns(): any[];
|
|
55
|
+
parseFilterCondition(source?: any): any;
|
|
56
|
+
get hasUncheckedNodeInPath(): any;
|
|
57
|
+
get childDataColumn(): any;
|
|
58
|
+
toggleExpanded(value?: boolean): void;
|
|
59
|
+
toggleChecked(value?: boolean): void;
|
|
60
|
+
toggleCheckedNode(value?: boolean): void;
|
|
61
|
+
toggleSecondaryChecked(value?: boolean): void;
|
|
62
|
+
createReferenceConfigColumns(): PerspectiveReferenceConfig['columns'];
|
|
63
|
+
ensureNodeConfig(cfg: PerspectiveConfig): [PerspectiveConfig, PerspectiveNodeConfig];
|
|
64
|
+
includeInNodeSet(field: 'expandedColumns' | 'uncheckedColumns' | 'checkedColumns', isIncluded: boolean): void;
|
|
65
|
+
getFilter(): string;
|
|
66
|
+
getDataLoadColumns(): any[];
|
|
67
|
+
getChildrenCondition(source?: any): Condition;
|
|
68
|
+
getOrderBy(table: TableInfo | ViewInfo): PerspectiveDataLoadProps['orderBy'];
|
|
69
|
+
getBaseTables(): any[];
|
|
70
|
+
getBaseTableFromThis(): any;
|
|
71
|
+
get filterInfo(): PerspectiveFilterColumnInfo;
|
|
72
|
+
findChildNodeByUniquePath(uniquePath: string[]): any;
|
|
73
|
+
findNodeByDesignerId(designerId: string): PerspectiveTreeNode;
|
|
74
|
+
get supportsParentFilter(): boolean;
|
|
75
|
+
get isParentFilter(): boolean;
|
|
76
|
+
buildParentFilterConditions(): Condition[];
|
|
77
|
+
getParentJoinCondition(alias: string, parentAlias: string): Condition[];
|
|
78
|
+
get sortOrder(): "ASC" | "DESC";
|
|
79
|
+
get sortOrderIndex(): number;
|
|
80
|
+
}
|
|
81
|
+
export declare class PerspectiveTableColumnNode extends PerspectiveTreeNode {
|
|
82
|
+
column: ColumnInfo;
|
|
83
|
+
table: TableInfo | ViewInfo;
|
|
84
|
+
foreignKey: ForeignKeyInfo;
|
|
85
|
+
refTable: TableInfo;
|
|
86
|
+
isView: boolean;
|
|
87
|
+
isTable: boolean;
|
|
88
|
+
constructor(column: ColumnInfo, table: TableInfo | ViewInfo, dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, parentNode: PerspectiveTreeNode, designerId: string);
|
|
89
|
+
matchChildRow(parentRow: any, childRow: any): boolean;
|
|
90
|
+
getChildMatchColumns(): string[];
|
|
91
|
+
getParentMatchColumns(): string[];
|
|
92
|
+
getParentJoinCondition(alias: string, parentAlias: string): Condition[];
|
|
93
|
+
createReferenceConfigColumns(): PerspectiveReferenceConfig['columns'];
|
|
94
|
+
getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
|
95
|
+
get icon(): "img circular" | "img autoincrement" | "img foreign-key" | "img column";
|
|
96
|
+
get codeName(): string;
|
|
97
|
+
get columnName(): string;
|
|
98
|
+
get fieldName(): string;
|
|
99
|
+
get title(): string;
|
|
100
|
+
get isExpandable(): boolean;
|
|
101
|
+
get isSortable(): boolean;
|
|
102
|
+
get filterType(): FilterType;
|
|
103
|
+
get isCircular(): boolean;
|
|
104
|
+
get isSecondaryChecked(): boolean;
|
|
105
|
+
get isChecked(): boolean;
|
|
106
|
+
get secondaryCheckable(): boolean;
|
|
107
|
+
toggleChecked(value?: boolean): void;
|
|
108
|
+
toggleSecondaryChecked(value?: boolean): void;
|
|
109
|
+
generateChildNodes(): PerspectiveTreeNode[];
|
|
110
|
+
getBaseTableFromThis(): TableInfo;
|
|
111
|
+
get filterInfo(): PerspectiveFilterColumnInfo;
|
|
112
|
+
parseFilterCondition(source?: any): Condition;
|
|
113
|
+
get headerTableAttributes(): {
|
|
114
|
+
schemaName: string;
|
|
115
|
+
pureName: string;
|
|
116
|
+
conid: string;
|
|
117
|
+
database: string;
|
|
118
|
+
};
|
|
119
|
+
get tableCode(): string;
|
|
120
|
+
get namedObject(): NamedObjectInfo;
|
|
121
|
+
}
|
|
122
|
+
export declare class PerspectiveTableNode extends PerspectiveTreeNode {
|
|
123
|
+
table: TableInfo | ViewInfo;
|
|
124
|
+
dataProvider: PerspectiveDataProvider;
|
|
125
|
+
constructor(table: TableInfo | ViewInfo, dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, parentNode: PerspectiveTreeNode, designerId: string);
|
|
126
|
+
getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
|
127
|
+
get codeName(): string;
|
|
128
|
+
get title(): string;
|
|
129
|
+
get isExpandable(): boolean;
|
|
130
|
+
generateChildNodes(): PerspectiveTreeNode[];
|
|
131
|
+
get icon(): string;
|
|
132
|
+
getBaseTableFromThis(): TableInfo | ViewInfo;
|
|
133
|
+
get headerTableAttributes(): {
|
|
134
|
+
schemaName: string;
|
|
135
|
+
pureName: string;
|
|
136
|
+
conid: string;
|
|
137
|
+
database: string;
|
|
138
|
+
};
|
|
139
|
+
get tableCode(): string;
|
|
140
|
+
get namedObject(): NamedObjectInfo;
|
|
141
|
+
}
|
|
142
|
+
export declare class PerspectiveTableReferenceNode extends PerspectiveTableNode {
|
|
143
|
+
foreignKey: ForeignKeyInfo;
|
|
144
|
+
dataProvider: PerspectiveDataProvider;
|
|
145
|
+
isMultiple: boolean;
|
|
146
|
+
constructor(foreignKey: ForeignKeyInfo, table: TableInfo, dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, isMultiple: boolean, parentNode: PerspectiveTreeNode, designerId: string);
|
|
147
|
+
matchChildRow(parentRow: any, childRow: any): boolean;
|
|
148
|
+
getChildMatchColumns(): string[];
|
|
149
|
+
getParentMatchColumns(): string[];
|
|
150
|
+
getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
|
151
|
+
createReferenceConfigColumns(): PerspectiveReferenceConfig['columns'];
|
|
152
|
+
get columnTitle(): string;
|
|
153
|
+
get title(): string;
|
|
154
|
+
get codeName(): string;
|
|
155
|
+
get isChecked(): boolean;
|
|
156
|
+
toggleChecked(value?: boolean): void;
|
|
157
|
+
getParentJoinCondition(alias: string, parentAlias: string): Condition[];
|
|
158
|
+
}
|
|
159
|
+
export declare class PerspectiveCustomJoinTreeNode extends PerspectiveTableNode {
|
|
160
|
+
customJoin: PerspectiveCustomJoinConfig;
|
|
161
|
+
dataProvider: PerspectiveDataProvider;
|
|
162
|
+
constructor(customJoin: PerspectiveCustomJoinConfig, table: TableInfo | ViewInfo, dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, parentNode: PerspectiveTreeNode, designerId: string);
|
|
163
|
+
matchChildRow(parentRow: any, childRow: any): boolean;
|
|
164
|
+
getChildMatchColumns(): string[];
|
|
165
|
+
getParentMatchColumns(): string[];
|
|
166
|
+
getNodeLoadProps(parentRows: any[]): PerspectiveDataLoadProps;
|
|
167
|
+
get icon(): string;
|
|
168
|
+
get codeName(): string;
|
|
169
|
+
get customJoinConfig(): PerspectiveCustomJoinConfig;
|
|
170
|
+
get isChecked(): boolean;
|
|
171
|
+
toggleChecked(value?: boolean): void;
|
|
172
|
+
getParentJoinCondition(alias: string, parentAlias: string): Condition[];
|
|
173
|
+
}
|
|
174
|
+
export declare function getTableChildPerspectiveNodes(table: TableInfo | ViewInfo, dbs: MultipleDatabaseInfo, config: PerspectiveConfig, setConfig: ChangePerspectiveConfigFunc, dataProvider: PerspectiveDataProvider, databaseConfig: PerspectiveDatabaseConfig, parentNode: PerspectiveTreeNode): any[];
|