we-report-angular 0.8.0 → 0.9.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/esm2022/lib/designer/database-source-editor.component.mjs +182 -22
- package/esm2022/lib/locales/de.mjs +4 -1
- package/esm2022/lib/locales/es.mjs +4 -1
- package/esm2022/lib/locales/fr.mjs +4 -1
- package/esm2022/lib/we-report-locale.mjs +7 -1
- package/fesm2022/we-report-angular.mjs +198 -23
- package/fesm2022/we-report-angular.mjs.map +1 -1
- package/lib/designer/database-source-editor.component.d.ts +18 -1
- package/lib/we-report-locale.d.ts +3 -0
- package/package.json +2 -2
|
@@ -274,6 +274,9 @@ const weReportLocaleEn = {
|
|
|
274
274
|
addFilter: 'Add condition',
|
|
275
275
|
sortBy: 'Sort by',
|
|
276
276
|
maxRows: 'Max rows',
|
|
277
|
+
summarize: 'Summarize in the database',
|
|
278
|
+
summarizeHint: 'One row per group: the ticked columns, __count (rows in the group) and each total. The database reads the whole table; the report gets only the groups.',
|
|
279
|
+
addDbTotal: 'Add total',
|
|
277
280
|
opLike: 'contains (like)',
|
|
278
281
|
opIsEmpty: 'is empty',
|
|
279
282
|
opIsNotEmpty: 'is not empty',
|
|
@@ -764,6 +767,9 @@ const weReportLocaleTr = {
|
|
|
764
767
|
addFilter: 'Koşul ekle',
|
|
765
768
|
sortBy: 'Sırala',
|
|
766
769
|
maxRows: 'En fazla satır',
|
|
770
|
+
summarize: 'Veritabanında özetle',
|
|
771
|
+
summarizeHint: 'Her grup için bir satır: işaretli sütunlar, __count (gruptaki satır sayısı) ve her toplam. Tabloyu veritabanı okur; rapora yalnız gruplar gelir.',
|
|
772
|
+
addDbTotal: 'Toplam ekle',
|
|
767
773
|
opLike: 'içerir (like)',
|
|
768
774
|
opIsEmpty: 'boş',
|
|
769
775
|
opIsNotEmpty: 'boş değil',
|
|
@@ -1260,6 +1266,9 @@ const weReportLocaleDe = {
|
|
|
1260
1266
|
addFilter: 'Bedingung hinzufügen',
|
|
1261
1267
|
sortBy: 'Sortieren nach',
|
|
1262
1268
|
maxRows: 'Max. Zeilen',
|
|
1269
|
+
summarize: 'In der Datenbank zusammenfassen',
|
|
1270
|
+
summarizeHint: 'Eine Zeile je Gruppe: die angekreuzten Spalten, __count (Zeilen der Gruppe) und jede Summe. Die Datenbank liest die ganze Tabelle, der Bericht erhält nur die Gruppen.',
|
|
1271
|
+
addDbTotal: 'Summe hinzufügen',
|
|
1263
1272
|
opLike: 'enthält (like)',
|
|
1264
1273
|
opIsEmpty: 'ist leer',
|
|
1265
1274
|
opIsNotEmpty: 'ist nicht leer',
|
|
@@ -1752,6 +1761,9 @@ const weReportLocaleFr = {
|
|
|
1752
1761
|
addFilter: 'Ajouter une condition',
|
|
1753
1762
|
sortBy: 'Trier par',
|
|
1754
1763
|
maxRows: 'Lignes max.',
|
|
1764
|
+
summarize: 'Résumer dans la base de données',
|
|
1765
|
+
summarizeHint: 'Une ligne par groupe : les colonnes cochées, __count (lignes du groupe) et chaque total. La base lit toute la table ; le rapport ne reçoit que les groupes.',
|
|
1766
|
+
addDbTotal: 'Ajouter un total',
|
|
1755
1767
|
opLike: 'contient (like)',
|
|
1756
1768
|
opIsEmpty: 'est vide',
|
|
1757
1769
|
opIsNotEmpty: 'n’est pas vide',
|
|
@@ -2244,6 +2256,9 @@ const weReportLocaleEs = {
|
|
|
2244
2256
|
addFilter: 'Añadir condición',
|
|
2245
2257
|
sortBy: 'Ordenar por',
|
|
2246
2258
|
maxRows: 'Máx. filas',
|
|
2259
|
+
summarize: 'Resumir en la base de datos',
|
|
2260
|
+
summarizeHint: 'Una fila por grupo: las columnas marcadas, __count (filas del grupo) y cada total. La base de datos lee toda la tabla; el informe solo recibe los grupos.',
|
|
2261
|
+
addDbTotal: 'Añadir total',
|
|
2247
2262
|
opLike: 'contiene (like)',
|
|
2248
2263
|
opIsEmpty: 'está vacío',
|
|
2249
2264
|
opIsNotEmpty: 'no está vacío',
|
|
@@ -6441,7 +6456,7 @@ const CHART_TYPES = [
|
|
|
6441
6456
|
{ type: 'databar', label: 'chartDataBar' },
|
|
6442
6457
|
{ type: 'gauge', label: 'chartGauge' },
|
|
6443
6458
|
];
|
|
6444
|
-
const AGGREGATES = [
|
|
6459
|
+
const AGGREGATES$1 = [
|
|
6445
6460
|
{ value: 'sum', label: 'aggSum' },
|
|
6446
6461
|
{ value: 'count', label: 'aggCount' },
|
|
6447
6462
|
{ value: 'avg', label: 'aggAvg' },
|
|
@@ -6495,7 +6510,7 @@ class PropertyPanelComponent {
|
|
|
6495
6510
|
cultures = CULTURES;
|
|
6496
6511
|
labelSheets = LABEL_SHEETS;
|
|
6497
6512
|
currencies = CURRENCIES;
|
|
6498
|
-
aggregates = AGGREGATES;
|
|
6513
|
+
aggregates = AGGREGATES$1;
|
|
6499
6514
|
conditionOps = CONDITION_OPS;
|
|
6500
6515
|
controls = computed(() => this.state.selectedControls());
|
|
6501
6516
|
control = computed(() => (this.controls().length === 1 ? this.controls()[0] : null));
|
|
@@ -6952,6 +6967,25 @@ function nonNegative(value) {
|
|
|
6952
6967
|
}
|
|
6953
6968
|
|
|
6954
6969
|
const OPERATORS = ['=', '!=', '<', '<=', '>', '>=', 'like', 'isNull', 'notNull'];
|
|
6970
|
+
const AGGREGATES = ['sum', 'avg', 'min', 'max', 'count'];
|
|
6971
|
+
/** The protocol's limits (protocol/schemas/query.json) */
|
|
6972
|
+
const MAX_GROUP_COLUMNS = 8;
|
|
6973
|
+
const MAX_AGGREGATES = 32;
|
|
6974
|
+
/**
|
|
6975
|
+
* Field names for the totals (`sum_total`, `avg_price` …), numbered when the same total is asked
|
|
6976
|
+
* twice or the name is a group column's.
|
|
6977
|
+
*/
|
|
6978
|
+
function withNames(list, groupBy = []) {
|
|
6979
|
+
const used = new Set(groupBy);
|
|
6980
|
+
return list.map((a) => {
|
|
6981
|
+
const base = `${a.fn}_${a.column}`.replace(/[^A-Za-z0-9_]/g, '_').slice(0, 60);
|
|
6982
|
+
let as = base;
|
|
6983
|
+
for (let n = 2; used.has(as); n++)
|
|
6984
|
+
as = `${base}_${n}`;
|
|
6985
|
+
used.add(as);
|
|
6986
|
+
return { ...a, as };
|
|
6987
|
+
});
|
|
6988
|
+
}
|
|
6955
6989
|
/**
|
|
6956
6990
|
* Visual query builder for a database source: backend → connection → table → columns → filters
|
|
6957
6991
|
* → order → limit, or free SQL where the connection allows it. Produces protocol/schemas/query.json.
|
|
@@ -6965,6 +6999,11 @@ class DatabaseSourceEditorComponent {
|
|
|
6965
6999
|
edit = output();
|
|
6966
7000
|
backend = inject(WeReportBackendService);
|
|
6967
7001
|
operators = OPERATORS;
|
|
7002
|
+
aggregateFns = AGGREGATES;
|
|
7003
|
+
maxGroupColumns = MAX_GROUP_COLUMNS;
|
|
7004
|
+
maxAggregates = MAX_AGGREGATES;
|
|
7005
|
+
/** What the backend can do (`info.capabilities`); empty for a backend older than protocol 1.2. */
|
|
7006
|
+
capabilities = signal({});
|
|
6968
7007
|
connections = signal([]);
|
|
6969
7008
|
schema = signal(null);
|
|
6970
7009
|
status = signal(null);
|
|
@@ -6973,6 +7012,13 @@ class DatabaseSourceEditorComponent {
|
|
|
6973
7012
|
query = computed(() => this.source().query ?? { table: '' });
|
|
6974
7013
|
connection = computed(() => this.connections().find((c) => c.id === this.source().connectionId) ?? null);
|
|
6975
7014
|
tableColumns = computed(() => this.schema()?.tables.find((t) => t.name === this.query().table)?.columns ?? []);
|
|
7015
|
+
/** A summarized source keeps its groups; one that already groups stays editable on any backend. */
|
|
7016
|
+
canGroup = computed(() => !!this.capabilities()['groups'] || !!this.query().groupBy?.length);
|
|
7017
|
+
/** Grouped, the database can only order by a group column. */
|
|
7018
|
+
orderColumns = computed(() => {
|
|
7019
|
+
const groupBy = this.query().groupBy;
|
|
7020
|
+
return groupBy?.length ? this.tableColumns().filter((c) => groupBy.includes(c.name)) : this.tableColumns();
|
|
7021
|
+
});
|
|
6976
7022
|
constructor() {
|
|
6977
7023
|
// Reconnect automatically when the dialog opens on an existing source with a known backend.
|
|
6978
7024
|
effect(() => {
|
|
@@ -6990,8 +7036,9 @@ class DatabaseSourceEditorComponent {
|
|
|
6990
7036
|
if (!this.backend.url())
|
|
6991
7037
|
return;
|
|
6992
7038
|
try {
|
|
6993
|
-
const list = await backendClient.connections(this.options);
|
|
7039
|
+
const [list, info] = await Promise.all([backendClient.connections(this.options), backendClient.info(this.options).catch(() => null)]);
|
|
6994
7040
|
this.connections.set(list);
|
|
7041
|
+
this.capabilities.set(info?.capabilities ?? {});
|
|
6995
7042
|
this.status.set({ ok: true, message: this.strings().connected.replace('{0}', String(list.length)) });
|
|
6996
7043
|
if (connectionId && list.some((c) => c.id === connectionId))
|
|
6997
7044
|
await this.loadSchema(connectionId);
|
|
@@ -7042,6 +7089,48 @@ class DatabaseSourceEditorComponent {
|
|
|
7042
7089
|
q.columns = next.length === all.length ? undefined : next;
|
|
7043
7090
|
}, 'columns');
|
|
7044
7091
|
}
|
|
7092
|
+
toggleGroup(name, on) {
|
|
7093
|
+
const all = this.tableColumns().map((c) => c.name);
|
|
7094
|
+
this.setQuery((q) => {
|
|
7095
|
+
const next = all.filter((c) => (c === name ? on : !!q.groupBy?.includes(c))).slice(0, MAX_GROUP_COLUMNS);
|
|
7096
|
+
// The database returns the group columns, __count and the totals: a column list does not apply.
|
|
7097
|
+
if (next.length) {
|
|
7098
|
+
q.groupBy = next;
|
|
7099
|
+
delete q.columns;
|
|
7100
|
+
if (q.aggregates)
|
|
7101
|
+
q.aggregates = withNames(q.aggregates, next);
|
|
7102
|
+
}
|
|
7103
|
+
else {
|
|
7104
|
+
delete q.groupBy;
|
|
7105
|
+
delete q.aggregates;
|
|
7106
|
+
}
|
|
7107
|
+
if (next.length && q.orderBy?.some((o) => !next.includes(o.column)))
|
|
7108
|
+
delete q.orderBy;
|
|
7109
|
+
}, 'group');
|
|
7110
|
+
}
|
|
7111
|
+
addAggregate() {
|
|
7112
|
+
const column = (this.tableColumns().find((c) => c.type === 'number') ?? this.tableColumns()[0])?.name;
|
|
7113
|
+
if (column)
|
|
7114
|
+
this.setQuery((q) => (q.aggregates = withNames([...(q.aggregates ?? []), { column, fn: 'sum', as: '' }].slice(0, MAX_AGGREGATES), q.groupBy)), 'aggregate-add');
|
|
7115
|
+
}
|
|
7116
|
+
setAggregate(i, fn, column) {
|
|
7117
|
+
this.setQuery((q) => {
|
|
7118
|
+
if (!q.aggregates?.[i] || !AGGREGATES.includes(fn))
|
|
7119
|
+
return;
|
|
7120
|
+
q.aggregates[i] = { column, fn: fn, as: '' };
|
|
7121
|
+
q.aggregates = withNames(q.aggregates, q.groupBy);
|
|
7122
|
+
}, `aggregate-${i}`);
|
|
7123
|
+
}
|
|
7124
|
+
removeAggregate(i) {
|
|
7125
|
+
this.setQuery((q) => {
|
|
7126
|
+
const rest = withNames((q.aggregates ?? []).filter((_, j) => j !== i), q.groupBy);
|
|
7127
|
+
q.aggregates = rest.length ? rest : undefined;
|
|
7128
|
+
}, 'aggregate-remove');
|
|
7129
|
+
}
|
|
7130
|
+
aggregateLabel(fn) {
|
|
7131
|
+
const s = this.strings();
|
|
7132
|
+
return { sum: s.aggSum, avg: s.aggAvg, min: s.aggMin, max: s.aggMax, count: s.aggCount }[fn];
|
|
7133
|
+
}
|
|
7045
7134
|
addWhere() {
|
|
7046
7135
|
const first = this.tableColumns()[0]?.name ?? '';
|
|
7047
7136
|
this.setQuery((q) => (q.where = [...(q.where ?? []), { column: first, op: '=', value: '' }]), 'where-add');
|
|
@@ -7153,17 +7242,60 @@ class DatabaseSourceEditorComponent {
|
|
|
7153
7242
|
</select>
|
|
7154
7243
|
</label>
|
|
7155
7244
|
@if (tableColumns().length) {
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
<div
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7245
|
+
@let grouped = !!query().groupBy?.length;
|
|
7246
|
+
@if (!grouped) {
|
|
7247
|
+
<div>
|
|
7248
|
+
<span class="dbe__label">{{ s.columns }}</span>
|
|
7249
|
+
<div class="dbe__columns">
|
|
7250
|
+
@for (col of tableColumns(); track col.name) {
|
|
7251
|
+
<label class="dbe__check">
|
|
7252
|
+
<input type="checkbox" [checked]="isColumnOn(col.name)" (change)="toggleColumn(col.name, $any($event.target).checked)" />
|
|
7253
|
+
{{ col.name }}
|
|
7254
|
+
</label>
|
|
7255
|
+
}
|
|
7256
|
+
</div>
|
|
7257
|
+
</div>
|
|
7258
|
+
}
|
|
7259
|
+
@if (canGroup()) {
|
|
7260
|
+
<div>
|
|
7261
|
+
<span class="dbe__label">{{ s.summarize }}</span>
|
|
7262
|
+
<div class="dbe__columns">
|
|
7263
|
+
@for (col of tableColumns(); track col.name) {
|
|
7264
|
+
<label class="dbe__check">
|
|
7265
|
+
<input
|
|
7266
|
+
type="checkbox"
|
|
7267
|
+
[checked]="query().groupBy?.includes(col.name)"
|
|
7268
|
+
[disabled]="!query().groupBy?.includes(col.name) && (query().groupBy?.length ?? 0) >= maxGroupColumns"
|
|
7269
|
+
(change)="toggleGroup(col.name, $any($event.target).checked)"
|
|
7270
|
+
/>
|
|
7271
|
+
{{ col.name }}
|
|
7272
|
+
</label>
|
|
7273
|
+
}
|
|
7274
|
+
</div>
|
|
7275
|
+
@if (grouped) {
|
|
7276
|
+
<small class="dbe__hint">{{ s.summarizeHint }}</small>
|
|
7277
|
+
@for (a of query().aggregates ?? []; track $index; let i = $index) {
|
|
7278
|
+
<div class="dbe__row">
|
|
7279
|
+
<select (change)="setAggregate(i, $any($event.target).value, a.column)" [attr.aria-label]="s.chartAggregate">
|
|
7280
|
+
@for (fn of aggregateFns; track fn) {
|
|
7281
|
+
<option [value]="fn" [selected]="fn === a.fn">{{ aggregateLabel(fn) }}</option>
|
|
7282
|
+
}
|
|
7283
|
+
</select>
|
|
7284
|
+
<select class="dbe__grow" (change)="setAggregate(i, a.fn, $any($event.target).value)" [attr.aria-label]="s.columns">
|
|
7285
|
+
@for (col of tableColumns(); track col.name) {
|
|
7286
|
+
<option [value]="col.name" [selected]="col.name === a.column">{{ col.name }}</option>
|
|
7287
|
+
}
|
|
7288
|
+
</select>
|
|
7289
|
+
<span class="dbe__hint">{{ a.as }}</span>
|
|
7290
|
+
<button type="button" (click)="removeAggregate(i)" [attr.aria-label]="s.delete">×</button>
|
|
7291
|
+
</div>
|
|
7292
|
+
}
|
|
7293
|
+
@if ((query().aggregates?.length ?? 0) < maxAggregates) {
|
|
7294
|
+
<button type="button" class="dbe__link" (click)="addAggregate()">+ {{ s.addDbTotal }}</button>
|
|
7295
|
+
}
|
|
7164
7296
|
}
|
|
7165
7297
|
</div>
|
|
7166
|
-
|
|
7298
|
+
}
|
|
7167
7299
|
<div>
|
|
7168
7300
|
<span class="dbe__label">{{ s.filters }}</span>
|
|
7169
7301
|
@for (w of query().where ?? []; track $index; let i = $index) {
|
|
@@ -7199,7 +7331,7 @@ class DatabaseSourceEditorComponent {
|
|
|
7199
7331
|
<span>{{ s.sortBy }}</span>
|
|
7200
7332
|
<select (change)="setOrder($any($event.target).value, query().orderBy?.[0]?.dir ?? 'asc')">
|
|
7201
7333
|
<option value="" [selected]="!query().orderBy?.length">—</option>
|
|
7202
|
-
@for (col of
|
|
7334
|
+
@for (col of orderColumns(); track col.name) {
|
|
7203
7335
|
<option [value]="col.name" [selected]="col.name === query().orderBy?.[0]?.column">{{ col.name }}</option>
|
|
7204
7336
|
}
|
|
7205
7337
|
</select>
|
|
@@ -7282,17 +7414,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
7282
7414
|
</select>
|
|
7283
7415
|
</label>
|
|
7284
7416
|
@if (tableColumns().length) {
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
<div
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7417
|
+
@let grouped = !!query().groupBy?.length;
|
|
7418
|
+
@if (!grouped) {
|
|
7419
|
+
<div>
|
|
7420
|
+
<span class="dbe__label">{{ s.columns }}</span>
|
|
7421
|
+
<div class="dbe__columns">
|
|
7422
|
+
@for (col of tableColumns(); track col.name) {
|
|
7423
|
+
<label class="dbe__check">
|
|
7424
|
+
<input type="checkbox" [checked]="isColumnOn(col.name)" (change)="toggleColumn(col.name, $any($event.target).checked)" />
|
|
7425
|
+
{{ col.name }}
|
|
7426
|
+
</label>
|
|
7427
|
+
}
|
|
7428
|
+
</div>
|
|
7429
|
+
</div>
|
|
7430
|
+
}
|
|
7431
|
+
@if (canGroup()) {
|
|
7432
|
+
<div>
|
|
7433
|
+
<span class="dbe__label">{{ s.summarize }}</span>
|
|
7434
|
+
<div class="dbe__columns">
|
|
7435
|
+
@for (col of tableColumns(); track col.name) {
|
|
7436
|
+
<label class="dbe__check">
|
|
7437
|
+
<input
|
|
7438
|
+
type="checkbox"
|
|
7439
|
+
[checked]="query().groupBy?.includes(col.name)"
|
|
7440
|
+
[disabled]="!query().groupBy?.includes(col.name) && (query().groupBy?.length ?? 0) >= maxGroupColumns"
|
|
7441
|
+
(change)="toggleGroup(col.name, $any($event.target).checked)"
|
|
7442
|
+
/>
|
|
7443
|
+
{{ col.name }}
|
|
7444
|
+
</label>
|
|
7445
|
+
}
|
|
7446
|
+
</div>
|
|
7447
|
+
@if (grouped) {
|
|
7448
|
+
<small class="dbe__hint">{{ s.summarizeHint }}</small>
|
|
7449
|
+
@for (a of query().aggregates ?? []; track $index; let i = $index) {
|
|
7450
|
+
<div class="dbe__row">
|
|
7451
|
+
<select (change)="setAggregate(i, $any($event.target).value, a.column)" [attr.aria-label]="s.chartAggregate">
|
|
7452
|
+
@for (fn of aggregateFns; track fn) {
|
|
7453
|
+
<option [value]="fn" [selected]="fn === a.fn">{{ aggregateLabel(fn) }}</option>
|
|
7454
|
+
}
|
|
7455
|
+
</select>
|
|
7456
|
+
<select class="dbe__grow" (change)="setAggregate(i, a.fn, $any($event.target).value)" [attr.aria-label]="s.columns">
|
|
7457
|
+
@for (col of tableColumns(); track col.name) {
|
|
7458
|
+
<option [value]="col.name" [selected]="col.name === a.column">{{ col.name }}</option>
|
|
7459
|
+
}
|
|
7460
|
+
</select>
|
|
7461
|
+
<span class="dbe__hint">{{ a.as }}</span>
|
|
7462
|
+
<button type="button" (click)="removeAggregate(i)" [attr.aria-label]="s.delete">×</button>
|
|
7463
|
+
</div>
|
|
7464
|
+
}
|
|
7465
|
+
@if ((query().aggregates?.length ?? 0) < maxAggregates) {
|
|
7466
|
+
<button type="button" class="dbe__link" (click)="addAggregate()">+ {{ s.addDbTotal }}</button>
|
|
7467
|
+
}
|
|
7293
7468
|
}
|
|
7294
7469
|
</div>
|
|
7295
|
-
|
|
7470
|
+
}
|
|
7296
7471
|
<div>
|
|
7297
7472
|
<span class="dbe__label">{{ s.filters }}</span>
|
|
7298
7473
|
@for (w of query().where ?? []; track $index; let i = $index) {
|
|
@@ -7328,7 +7503,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
7328
7503
|
<span>{{ s.sortBy }}</span>
|
|
7329
7504
|
<select (change)="setOrder($any($event.target).value, query().orderBy?.[0]?.dir ?? 'asc')">
|
|
7330
7505
|
<option value="" [selected]="!query().orderBy?.length">—</option>
|
|
7331
|
-
@for (col of
|
|
7506
|
+
@for (col of orderColumns(); track col.name) {
|
|
7332
7507
|
<option [value]="col.name" [selected]="col.name === query().orderBy?.[0]?.column">{{ col.name }}</option>
|
|
7333
7508
|
}
|
|
7334
7509
|
</select>
|