@lumeer/pivot 0.0.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/.eslintrc.json +35 -0
- package/README.md +24 -0
- package/ng-package.json +7 -0
- package/package.json +14 -0
- package/src/lib/directives/lmr-templates.directive.ts +11 -0
- package/src/lib/lmr-pivot-table.component.html +69 -0
- package/src/lib/lmr-pivot-table.component.scss +69 -0
- package/src/lib/lmr-pivot-table.component.ts +108 -0
- package/src/lib/lmr-pivot-table.module.ts +28 -0
- package/src/lib/pipes/contrast-color.pipe.ts +33 -0
- package/src/lib/pipes/pivot-data-empty.pipe.ts +36 -0
- package/src/lib/pipes/pivot-table-value.pipe.ts +32 -0
- package/src/lib/util/lmr-pivot-config.ts +68 -0
- package/src/lib/util/lmr-pivot-constants.ts +13 -0
- package/src/lib/util/lmr-pivot-data.ts +57 -0
- package/src/lib/util/lmr-pivot-table.ts +38 -0
- package/src/lib/util/pivot-data-converter.spec.ts +647 -0
- package/src/lib/util/pivot-data-converter.ts +803 -0
- package/src/lib/util/pivot-table-converter.spec.ts +1045 -0
- package/src/lib/util/pivot-table-converter.ts +1118 -0
- package/src/lib/util/pivot-util.ts +92 -0
- package/src/public-api.ts +11 -0
- package/tsconfig.lib.json +14 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../.eslintrc.json",
|
|
3
|
+
"ignorePatterns": [
|
|
4
|
+
"!**/*"
|
|
5
|
+
],
|
|
6
|
+
"overrides": [
|
|
7
|
+
{
|
|
8
|
+
"files": [
|
|
9
|
+
"*.ts"
|
|
10
|
+
],
|
|
11
|
+
"rules": {
|
|
12
|
+
"@angular-eslint/directive-selector": [
|
|
13
|
+
"error",
|
|
14
|
+
{
|
|
15
|
+
"type": "attribute",
|
|
16
|
+
"style": "camelCase"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"@angular-eslint/component-selector": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
"type": "element",
|
|
23
|
+
"style": "kebab-case"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"files": [
|
|
30
|
+
"*.html"
|
|
31
|
+
],
|
|
32
|
+
"rules": {}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# LmrPivotTable
|
|
2
|
+
|
|
3
|
+
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Run `ng generate component component-name --project lmr-pivot-table` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project lmr-pivot-table`.
|
|
8
|
+
> Note: Don't forget to add `--project lmr-pivot-table` or else it will be added to the default project in your `angular.json` file.
|
|
9
|
+
|
|
10
|
+
## Build
|
|
11
|
+
|
|
12
|
+
Run `ng build lmr-pivot-table` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
13
|
+
|
|
14
|
+
## Publishing
|
|
15
|
+
|
|
16
|
+
After building your library with `ng build lmr-pivot-table`, go to the dist folder `cd dist/lmr-pivot-table` and run `npm publish`.
|
|
17
|
+
|
|
18
|
+
## Running unit tests
|
|
19
|
+
|
|
20
|
+
Run `ng test lmr-pivot-table` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
21
|
+
|
|
22
|
+
## Further help
|
|
23
|
+
|
|
24
|
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
package/ng-package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lumeer/pivot",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^16.2.12",
|
|
6
|
+
"@angular/core": "^16.2.12",
|
|
7
|
+
"@lumeer/data-filters": "^0.8.4",
|
|
8
|
+
"@lumeer/utils": "^0.1.3"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"tslib": "^2.6.2"
|
|
12
|
+
},
|
|
13
|
+
"sideEffects": false
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {Directive, TemplateRef} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({ selector: '[lmr-empty-tables-tmp]' })
|
|
4
|
+
export class LmrEmptyTablesTemplateDirective {
|
|
5
|
+
constructor(public template: TemplateRef<any>) { }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@Directive({ selector: '[lmr-table-cell-tmp]' })
|
|
9
|
+
export class LmrTableCellTemplateDirective {
|
|
10
|
+
constructor(public template: TemplateRef<any>) { }
|
|
11
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<ng-container *ngIf="{pivotTables: pivotTables$ | async, pivotData: pivotData$ | async} as data">
|
|
2
|
+
<ng-container *ngIf="data.pivotTables?.length && !(data.pivotData | pivotDataEmpty)">
|
|
3
|
+
<table *ngFor="let pivotTable of data.pivotTables; let first"
|
|
4
|
+
class="table table-without-padding table-borderless table-md"
|
|
5
|
+
[class.mt-4]="!first">
|
|
6
|
+
<tr *ngFor="let rowCells of pivotTable.cells; let rowIndex = index">
|
|
7
|
+
|
|
8
|
+
<ng-container *ngFor="let cell of rowCells; let cellIndex = index">
|
|
9
|
+
<td *ngIf="cell && {hasValue: cell | pivotTableCellHasValue} as cellData"
|
|
10
|
+
class="cell {{cell.constraint ? (cell.constraint.type | lowercase) : ''}} text-truncate"
|
|
11
|
+
[style.max-width.px]="300"
|
|
12
|
+
[class.sticky-start]="cell.stickyStart"
|
|
13
|
+
[class.sticky-top]="cell.stickyTop"
|
|
14
|
+
[rowSpan]="cell.rowSpan"
|
|
15
|
+
[colSpan]="cell.colSpan"
|
|
16
|
+
[style.top.px]="cell.stickyTop ? (rowIndex * 40) : undefined"
|
|
17
|
+
[style.left.px]="cell.stickyStart ? (cellIndex * 150) : undefined"
|
|
18
|
+
[ngClass]="cell.cssClass"
|
|
19
|
+
[style.background]="cell.background"
|
|
20
|
+
[style.color]="cell.background && (cell.background | contrastColor)">
|
|
21
|
+
<ng-container *ngIf="cell.summary">
|
|
22
|
+
<div class="d-flex align-items-center h-100">
|
|
23
|
+
<span class="summary" [class.me-2]="cellData.hasValue">{{cell.summary}}</span>
|
|
24
|
+
<ng-container *ngIf="cellData.hasValue">
|
|
25
|
+
<ng-template #defaultTableCellTemplate>
|
|
26
|
+
<span class="flex-grow-1 h-100 text-truncate d-inline-block">
|
|
27
|
+
{{ cell.value }}
|
|
28
|
+
</span>
|
|
29
|
+
</ng-template>
|
|
30
|
+
|
|
31
|
+
<ng-template
|
|
32
|
+
[ngTemplateOutlet]="tableCellTemplate || defaultTableCellTemplate"
|
|
33
|
+
[ngTemplateOutletContext]="{ value: cell.value, cell: cell }">
|
|
34
|
+
</ng-template>
|
|
35
|
+
</ng-container>
|
|
36
|
+
</div>
|
|
37
|
+
</ng-container>
|
|
38
|
+
<ng-container *ngIf="!cell.summary">
|
|
39
|
+
<ng-container *ngIf="cellData.hasValue">
|
|
40
|
+
<ng-template #defaultTableCellTemplate>
|
|
41
|
+
<span class="d-inline-block">
|
|
42
|
+
{{ cell.value }}
|
|
43
|
+
</span>
|
|
44
|
+
</ng-template>
|
|
45
|
+
|
|
46
|
+
<ng-template
|
|
47
|
+
[ngTemplateOutlet]="tableCellTemplate || defaultTableCellTemplate"
|
|
48
|
+
[ngTemplateOutletContext]="{ value: cell.value, cell: cell }">
|
|
49
|
+
</ng-template>
|
|
50
|
+
</ng-container>
|
|
51
|
+
<ng-container *ngIf="!cellData.hasValue"> </ng-container>
|
|
52
|
+
</ng-container>
|
|
53
|
+
</td>
|
|
54
|
+
</ng-container>
|
|
55
|
+
</tr>
|
|
56
|
+
</table>
|
|
57
|
+
</ng-container>
|
|
58
|
+
|
|
59
|
+
<ng-container *ngIf="!data.pivotTables?.length || (data.pivotData | pivotDataEmpty)">
|
|
60
|
+
<ng-template #defaultEmptyTablesTemplate>
|
|
61
|
+
<div> </div>
|
|
62
|
+
</ng-template>
|
|
63
|
+
|
|
64
|
+
<ng-template
|
|
65
|
+
[ngTemplateOutlet]="emptyTablesTemplate || defaultEmptyTablesTemplate"
|
|
66
|
+
[ngTemplateOutletContext]="{ }">
|
|
67
|
+
</ng-template>
|
|
68
|
+
</ng-container>
|
|
69
|
+
</ng-container>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.table {
|
|
2
|
+
border-spacing: 0;
|
|
3
|
+
border-collapse: separate;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.pivot-data-cell,
|
|
7
|
+
.pivot-data-group-cell {
|
|
8
|
+
text-align: right;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.pivot-column-header-cell,
|
|
12
|
+
.pivot-row-header-cell,
|
|
13
|
+
.pivot-data-group-cell,
|
|
14
|
+
.pivot-row-group-header-cell,
|
|
15
|
+
.pivot-column-group-header-cell {
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
border: 1px #f8f9fa solid;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.pivot-row-header-cell,
|
|
21
|
+
.pivot-row-group-header-cell,
|
|
22
|
+
.pivot-empty-cell {
|
|
23
|
+
&.sticky-start {
|
|
24
|
+
position: sticky;
|
|
25
|
+
width: 150px;
|
|
26
|
+
min-width: 150px;
|
|
27
|
+
max-width: 150px !important;
|
|
28
|
+
z-index: 9;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.pivot-column-header-cell,
|
|
33
|
+
.pivot-column-group-header-cell,
|
|
34
|
+
.pivot-empty-cell {
|
|
35
|
+
&.sticky-top {
|
|
36
|
+
position: sticky;
|
|
37
|
+
z-index: 10;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.pivot-empty-cell {
|
|
42
|
+
background: white;
|
|
43
|
+
border: 1px white solid;
|
|
44
|
+
|
|
45
|
+
&.sticky-top {
|
|
46
|
+
z-index: 11;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cell.color {
|
|
51
|
+
padding: 0 !important;
|
|
52
|
+
height: 30px;
|
|
53
|
+
|
|
54
|
+
.summary {
|
|
55
|
+
padding-left: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
data-input-preview.clickable-cell {
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
|
|
62
|
+
&:hover {
|
|
63
|
+
text-decoration: underline;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.data-input {
|
|
68
|
+
min-height: 30px;
|
|
69
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {ChangeDetectionStrategy, Component, ContentChild, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, TemplateRef} from '@angular/core';
|
|
2
|
+
import {LmrPivotConfig, LmrPivotStrings, LmrPivotTransform} from './util/lmr-pivot-config';
|
|
3
|
+
import {Collection, ConstraintData, DocumentsAndLinksData, LinkType, Query} from '@lumeer/data-filters';
|
|
4
|
+
import {PivotDataConverter} from './util/pivot-data-converter';
|
|
5
|
+
import {LmrPivotData} from './util/lmr-pivot-data';
|
|
6
|
+
import {asyncScheduler, BehaviorSubject, filter, map, Observable, tap, throttleTime} from 'rxjs';
|
|
7
|
+
import {LmrPivotTable, LmrPivotTableCell} from './util/lmr-pivot-table';
|
|
8
|
+
import {PivotTableConverter} from './util/pivot-table-converter';
|
|
9
|
+
import {LmrEmptyTablesTemplateDirective, LmrTableCellTemplateDirective} from './directives/lmr-templates.directive';
|
|
10
|
+
|
|
11
|
+
interface Data {
|
|
12
|
+
collections: Collection[];
|
|
13
|
+
linkTypes: LinkType[];
|
|
14
|
+
data: DocumentsAndLinksData;
|
|
15
|
+
query: Query;
|
|
16
|
+
constraintData: ConstraintData;
|
|
17
|
+
config: LmrPivotConfig;
|
|
18
|
+
transform: LmrPivotTransform;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Component({
|
|
22
|
+
selector: 'lmr-pivot-table',
|
|
23
|
+
templateUrl: 'lmr-pivot-table.component.html',
|
|
24
|
+
styleUrls: ['./lmr-pivot-table.component.scss'],
|
|
25
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
+
})
|
|
27
|
+
export class LmrPivotTableComponent implements OnInit, OnChanges {
|
|
28
|
+
|
|
29
|
+
@Input()
|
|
30
|
+
public collections: Collection[];
|
|
31
|
+
|
|
32
|
+
@Input()
|
|
33
|
+
public data: DocumentsAndLinksData;
|
|
34
|
+
|
|
35
|
+
@Input()
|
|
36
|
+
public linkTypes: LinkType[];
|
|
37
|
+
|
|
38
|
+
@Input()
|
|
39
|
+
public query: Query;
|
|
40
|
+
|
|
41
|
+
@Input()
|
|
42
|
+
public constraintData: ConstraintData;
|
|
43
|
+
|
|
44
|
+
@Input()
|
|
45
|
+
public config: LmrPivotConfig;
|
|
46
|
+
|
|
47
|
+
@Input()
|
|
48
|
+
public transform: LmrPivotTransform;
|
|
49
|
+
|
|
50
|
+
@Input()
|
|
51
|
+
public strings: LmrPivotStrings;
|
|
52
|
+
|
|
53
|
+
@Output()
|
|
54
|
+
public cellClick = new EventEmitter<LmrPivotTableCell>();
|
|
55
|
+
|
|
56
|
+
@Output()
|
|
57
|
+
public pivotDataChange = new EventEmitter<LmrPivotData>();
|
|
58
|
+
|
|
59
|
+
@ContentChild(LmrEmptyTablesTemplateDirective, { read: TemplateRef }) emptyTablesTemplate: TemplateRef<any>;
|
|
60
|
+
@ContentChild(LmrTableCellTemplateDirective, { read: TemplateRef }) tableCellTemplate: TemplateRef<any>;
|
|
61
|
+
|
|
62
|
+
private readonly pivotTransformer = new PivotDataConverter();
|
|
63
|
+
private readonly pivotTableConverter: PivotTableConverter = new PivotTableConverter();
|
|
64
|
+
|
|
65
|
+
private dataSubject = new BehaviorSubject<Data>(null);
|
|
66
|
+
|
|
67
|
+
public pivotData$: Observable<LmrPivotData>;
|
|
68
|
+
public pivotTables$: Observable<LmrPivotTable[]>;
|
|
69
|
+
|
|
70
|
+
public ngOnInit() {
|
|
71
|
+
const observable = this.dataSubject.pipe(filter(data => !!data));
|
|
72
|
+
|
|
73
|
+
this.pivotData$ = observable.pipe(
|
|
74
|
+
throttleTime(200, asyncScheduler, {trailing: true, leading: true}),
|
|
75
|
+
map(data => this.handleData(data)),
|
|
76
|
+
tap(data => this.pivotDataChange.emit(data)),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
this.pivotTables$ = this.pivotData$.pipe(
|
|
80
|
+
map(data => this.pivotTableConverter.createTables(data, this.strings))
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private handleData(data: Data): LmrPivotData {
|
|
85
|
+
return this.pivotTransformer.createData(
|
|
86
|
+
data.config,
|
|
87
|
+
data.transform,
|
|
88
|
+
data.collections,
|
|
89
|
+
data.linkTypes,
|
|
90
|
+
data.data,
|
|
91
|
+
data.query,
|
|
92
|
+
data.constraintData
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public ngOnChanges(changes: SimpleChanges) {
|
|
97
|
+
this.dataSubject.next({
|
|
98
|
+
config: this.config,
|
|
99
|
+
transform: this.transform,
|
|
100
|
+
collections: this.collections,
|
|
101
|
+
linkTypes: this.linkTypes,
|
|
102
|
+
data: this.data,
|
|
103
|
+
query: this.query,
|
|
104
|
+
constraintData: this.constraintData,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {NgModule} from '@angular/core';
|
|
2
|
+
import {CommonModule} from '@angular/common';
|
|
3
|
+
import {LmrPivotTableComponent} from './lmr-pivot-table.component';
|
|
4
|
+
import {PivotDataEmptyPipe} from './pipes/pivot-data-empty.pipe';
|
|
5
|
+
import {PivotTableCellHasValuePipe} from './pipes/pivot-table-value.pipe';
|
|
6
|
+
import {ContrastColorPipe} from './pipes/contrast-color.pipe';
|
|
7
|
+
import {LmrEmptyTablesTemplateDirective, LmrTableCellTemplateDirective} from './directives/lmr-templates.directive';
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
declarations: [
|
|
11
|
+
LmrPivotTableComponent,
|
|
12
|
+
PivotDataEmptyPipe,
|
|
13
|
+
PivotTableCellHasValuePipe,
|
|
14
|
+
ContrastColorPipe,
|
|
15
|
+
LmrEmptyTablesTemplateDirective,
|
|
16
|
+
LmrTableCellTemplateDirective,
|
|
17
|
+
],
|
|
18
|
+
imports: [
|
|
19
|
+
CommonModule,
|
|
20
|
+
],
|
|
21
|
+
exports: [
|
|
22
|
+
LmrPivotTableComponent,
|
|
23
|
+
LmrEmptyTablesTemplateDirective,
|
|
24
|
+
LmrTableCellTemplateDirective,
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
export class LmrPivotTableModule {
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lumeer: Modern Data Definition and Processing Platform
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) since 2017 Lumeer.io, s.r.o. and/or its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import {Injectable, Pipe, PipeTransform} from '@angular/core';
|
|
20
|
+
import {contrastColor} from '../util/pivot-util';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@Pipe({
|
|
24
|
+
name: 'contrastColor',
|
|
25
|
+
})
|
|
26
|
+
@Injectable({
|
|
27
|
+
providedIn: 'root',
|
|
28
|
+
})
|
|
29
|
+
export class ContrastColorPipe implements PipeTransform {
|
|
30
|
+
public transform(color: string, returnCodes?: {dark: string; light: string}, opacity?: number): string {
|
|
31
|
+
return contrastColor(color, returnCodes, opacity);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lumeer: Modern Data Definition and Processing Platform
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) since 2017 Lumeer.io, s.r.o. and/or its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
20
|
+
|
|
21
|
+
import {LmrPivotData} from '../util/lmr-pivot-data';
|
|
22
|
+
|
|
23
|
+
@Pipe({
|
|
24
|
+
name: 'pivotDataEmpty',
|
|
25
|
+
})
|
|
26
|
+
export class PivotDataEmptyPipe implements PipeTransform {
|
|
27
|
+
public transform(value: LmrPivotData): boolean {
|
|
28
|
+
let anythingToDisplay = false;
|
|
29
|
+
|
|
30
|
+
value?.data?.forEach(d => {
|
|
31
|
+
anythingToDisplay = anythingToDisplay || d.columnHeaders?.length > 0 || d.rowHeaders?.length > 0;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return !anythingToDisplay;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lumeer: Modern Data Definition and Processing Platform
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) since 2017 Lumeer.io, s.r.o. and/or its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
20
|
+
|
|
21
|
+
import {isNotNullOrUndefined} from '@lumeer/utils';
|
|
22
|
+
|
|
23
|
+
import {LmrPivotTableCell} from '../util/lmr-pivot-table';
|
|
24
|
+
|
|
25
|
+
@Pipe({
|
|
26
|
+
name: 'pivotTableCellHasValue',
|
|
27
|
+
})
|
|
28
|
+
export class PivotTableCellHasValuePipe implements PipeTransform {
|
|
29
|
+
public transform(cell: LmrPivotTableCell): boolean {
|
|
30
|
+
return isNotNullOrUndefined(cell.value) && String(cell.value).trim() !== '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {Constraint, DataAggregationType, QueryAttribute, QueryStem} from '@lumeer/data-filters';
|
|
2
|
+
|
|
3
|
+
export interface LmrPivotConfig {
|
|
4
|
+
version?: LmrPivotConfigVersion;
|
|
5
|
+
stemsConfigs: LmrPivotStemConfig[];
|
|
6
|
+
mergeTables?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface LmrPivotTransform {
|
|
10
|
+
checkValidConstraintOverride?: (c1: Constraint, c2: Constraint) => Constraint;
|
|
11
|
+
translateAggregation?: (type: DataAggregationType) => string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LmrPivotStrings {
|
|
15
|
+
summaryString: string;
|
|
16
|
+
headerSummaryString: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LmrPivotStemConfig {
|
|
20
|
+
stem?: QueryStem;
|
|
21
|
+
rowAttributes: LmrPivotRowAttribute[];
|
|
22
|
+
columnAttributes: LmrPivotColumnAttribute[];
|
|
23
|
+
valueAttributes: LmrPivotValueAttribute[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export enum LmrPivotConfigVersion {
|
|
27
|
+
V1 = '1',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface LmrPivotAttribute extends QueryAttribute {}
|
|
31
|
+
|
|
32
|
+
export interface LmrPivotRowColumnAttribute extends LmrPivotAttribute {
|
|
33
|
+
showSums?: boolean;
|
|
34
|
+
sticky?: boolean;
|
|
35
|
+
sort?: LmrPivotSort;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface LmrPivotRowAttribute extends LmrPivotRowColumnAttribute {}
|
|
39
|
+
|
|
40
|
+
export interface LmrPivotColumnAttribute extends LmrPivotRowColumnAttribute {}
|
|
41
|
+
|
|
42
|
+
export interface LmrPivotSortValue {
|
|
43
|
+
title: string;
|
|
44
|
+
isSummary?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface LmrPivotSortList {
|
|
48
|
+
valueTitle: string;
|
|
49
|
+
values: LmrPivotSortValue[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface LmrPivotSort {
|
|
53
|
+
attribute?: LmrPivotAttribute;
|
|
54
|
+
list?: LmrPivotSortList;
|
|
55
|
+
asc: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export enum LmrPivotValueType {
|
|
59
|
+
Default = 'default',
|
|
60
|
+
ColumnPercentage = 'column',
|
|
61
|
+
RowPercentage = 'row',
|
|
62
|
+
AllPercentage = 'all',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface LmrPivotValueAttribute extends LmrPivotAttribute {
|
|
66
|
+
aggregation: DataAggregationType;
|
|
67
|
+
valueType?: LmrPivotValueType;
|
|
68
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const COLOR_GRAY100 = '#f8f9fa';
|
|
2
|
+
export const COLOR_GRAY200 = '#ecf0f1';
|
|
3
|
+
export const COLOR_GRAY300 = '#dee2e6';
|
|
4
|
+
export const COLOR_GRAY400 = '#ced4da';
|
|
5
|
+
export const COLOR_GRAY500 = '#b4bcc2';
|
|
6
|
+
export const COLOR_GRAY600 = '#95a5a6';
|
|
7
|
+
export const COLOR_GRAY700 = '#7b8a8b';
|
|
8
|
+
export const COLOR_GRAY800 = '#343a40';
|
|
9
|
+
export const COLOR_GRAY900 = '#212529';
|
|
10
|
+
|
|
11
|
+
export const COLOR_PRIMARY = '#253746';
|
|
12
|
+
|
|
13
|
+
export const COLOR_LIGHT = COLOR_GRAY200;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lumeer: Modern Data Definition and Processing Platform
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) since 2017 Lumeer.io, s.r.o. and/or its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import {Constraint, ConstraintData, DataAggregationType, DataResource} from '@lumeer/data-filters';
|
|
20
|
+
import {LmrPivotSort, LmrPivotValueType} from './lmr-pivot-config';
|
|
21
|
+
|
|
22
|
+
export interface LmrPivotData {
|
|
23
|
+
data: LmrPivotStemData[];
|
|
24
|
+
|
|
25
|
+
constraintData?: ConstraintData;
|
|
26
|
+
mergeTables?: boolean;
|
|
27
|
+
ableToMerge?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface LmrPivotStemData {
|
|
31
|
+
columnHeaders: LmrPivotDataHeader[];
|
|
32
|
+
rowHeaders: LmrPivotDataHeader[];
|
|
33
|
+
valueTitles: string[];
|
|
34
|
+
values: any[][];
|
|
35
|
+
dataResources: DataResource[][][];
|
|
36
|
+
valuesConstraints?: Constraint[];
|
|
37
|
+
valueTypes?: LmrPivotValueType[];
|
|
38
|
+
valueAggregations?: DataAggregationType[];
|
|
39
|
+
|
|
40
|
+
rowShowSums: boolean[];
|
|
41
|
+
rowSticky: boolean[];
|
|
42
|
+
rowSorts?: LmrPivotSort[];
|
|
43
|
+
columnShowSums: boolean[];
|
|
44
|
+
columnSticky: boolean[];
|
|
45
|
+
columnSorts?: LmrPivotSort[];
|
|
46
|
+
hasAdditionalColumnLevel?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface LmrPivotDataHeader {
|
|
50
|
+
title: string;
|
|
51
|
+
children?: LmrPivotDataHeader[];
|
|
52
|
+
targetIndex?: number;
|
|
53
|
+
color: string;
|
|
54
|
+
isValueHeader: boolean;
|
|
55
|
+
constraint?: Constraint;
|
|
56
|
+
attributeName?: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lumeer: Modern Data Definition and Processing Platform
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) since 2017 Lumeer.io, s.r.o. and/or its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import {Constraint, DataResource} from '@lumeer/data-filters';
|
|
20
|
+
|
|
21
|
+
export interface LmrPivotTable {
|
|
22
|
+
cells: LmrPivotTableCell[][];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LmrPivotTableCell {
|
|
26
|
+
value: any;
|
|
27
|
+
dataResources?: DataResource[];
|
|
28
|
+
constraint?: Constraint;
|
|
29
|
+
summary?: string;
|
|
30
|
+
rowSpan: number;
|
|
31
|
+
colSpan: number;
|
|
32
|
+
cssClass: string;
|
|
33
|
+
isHeader: boolean;
|
|
34
|
+
background?: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
stickyTop?: boolean;
|
|
37
|
+
stickyStart?: boolean;
|
|
38
|
+
}
|