@dashboard-designer/core 0.2.2 → 0.2.4
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/dist/index.d.ts +86 -2
- package/dist/index.js +133 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,12 @@ interface ContainerLabelItem {
|
|
|
110
110
|
fontSize?: number;
|
|
111
111
|
targetDashboardId?: string;
|
|
112
112
|
drillTitle?: string;
|
|
113
|
+
/** Hyperlink template (see resolveHyperlink). Takes precedence over targetDashboardId. */
|
|
114
|
+
url?: string;
|
|
115
|
+
/** Open url in a new browser tab (default true). */
|
|
116
|
+
urlNewTab?: boolean;
|
|
117
|
+
/** Runtime only: query row the label was built from, for {{field:...}} link tokens. */
|
|
118
|
+
linkRow?: Record<string, unknown>;
|
|
113
119
|
}
|
|
114
120
|
/** Styles and drill target applied to every label generated from a query column. */
|
|
115
121
|
interface ContainerLabelTemplate {
|
|
@@ -118,6 +124,9 @@ interface ContainerLabelTemplate {
|
|
|
118
124
|
fontSize?: number;
|
|
119
125
|
targetDashboardId?: string;
|
|
120
126
|
drillTitle?: string;
|
|
127
|
+
/** Hyperlink template; {{value}} is the label text, {{field:Column}} reads the label's row. */
|
|
128
|
+
url?: string;
|
|
129
|
+
urlNewTab?: boolean;
|
|
121
130
|
}
|
|
122
131
|
type LabelContainerSource = 'static' | 'query';
|
|
123
132
|
interface QueryLabelDrillDown {
|
|
@@ -175,6 +184,7 @@ interface Dashboard {
|
|
|
175
184
|
exportOptions?: DashboardExportOptions;
|
|
176
185
|
/** View-mode display preferences (widget chrome, etc.). */
|
|
177
186
|
displayOptions?: DashboardDisplayOptions;
|
|
187
|
+
printSettings?: DashboardPrintSettings;
|
|
178
188
|
layout: GridItem[];
|
|
179
189
|
globalFilters: FilterDef[];
|
|
180
190
|
widgets: Widget[];
|
|
@@ -276,6 +286,8 @@ interface DashboardVersion extends DashboardVersionMeta {
|
|
|
276
286
|
dashboard: Dashboard;
|
|
277
287
|
}
|
|
278
288
|
interface ConnectionConfig {
|
|
289
|
+
/** Environment connection variable (synthetic data-source option). */
|
|
290
|
+
variableName?: string;
|
|
279
291
|
id: string;
|
|
280
292
|
name: string;
|
|
281
293
|
provider: DbProvider;
|
|
@@ -326,7 +338,7 @@ interface ExecuteQueryRequest {
|
|
|
326
338
|
type VariableValue = string | number | boolean | null;
|
|
327
339
|
interface DashboardVariable {
|
|
328
340
|
name: string;
|
|
329
|
-
type: 'string' | 'number' | 'boolean';
|
|
341
|
+
type: 'string' | 'number' | 'boolean' | 'connection';
|
|
330
342
|
description?: string;
|
|
331
343
|
defaultValue?: VariableValue;
|
|
332
344
|
}
|
|
@@ -364,6 +376,52 @@ declare function resolveLabelClickAction(chartOptions: Record<string, unknown>,
|
|
|
364
376
|
declare function getLabelClickUrl(chartOptions: Record<string, unknown>): string | undefined;
|
|
365
377
|
/** Whether a label URL click opens a new browser tab (default true). */
|
|
366
378
|
declare function labelClickOpensNewTab(chartOptions: Record<string, unknown>): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Hyperlink on a chart, table, KPI or timeline widget, stored in chartOptions:
|
|
381
|
+
* `hyperlinkUrl`, `hyperlinkNewTab`, `hyperlinkColumn` (table only).
|
|
382
|
+
*
|
|
383
|
+
* The URL is a template. Tokens:
|
|
384
|
+
* - `{{var:Name}}` dashboard / host variable value (e.g. `{{var:url}}`)
|
|
385
|
+
* - `{{field:Col}}` column of the clicked row / point
|
|
386
|
+
* - `{{value}}` clicked category, cell or label text
|
|
387
|
+
*
|
|
388
|
+
* A token at the very start of the URL is inserted as-is, so a variable can hold the whole
|
|
389
|
+
* base address (`{{var:url}}/record/{{field:Id}}`). Tokens anywhere else are URL-encoded.
|
|
390
|
+
*/
|
|
391
|
+
interface WidgetHyperlink {
|
|
392
|
+
url: string;
|
|
393
|
+
newTab: boolean;
|
|
394
|
+
/** Table only: render this column's cells as links. Empty = whole row is clickable. */
|
|
395
|
+
column?: string;
|
|
396
|
+
}
|
|
397
|
+
interface HyperlinkContext {
|
|
398
|
+
variables?: Record<string, VariableValue>;
|
|
399
|
+
row?: Record<string, unknown>;
|
|
400
|
+
value?: unknown;
|
|
401
|
+
}
|
|
402
|
+
type HyperlinkResult = {
|
|
403
|
+
ok: true;
|
|
404
|
+
url: string;
|
|
405
|
+
} | {
|
|
406
|
+
ok: false;
|
|
407
|
+
error: string;
|
|
408
|
+
};
|
|
409
|
+
declare function getWidgetHyperlink(chartOptions: Record<string, unknown>): WidgetHyperlink | undefined;
|
|
410
|
+
/** Read a row value by exact key, then by bare column name (`table.col` vs `col`). */
|
|
411
|
+
declare function readRowField(row: Record<string, unknown> | undefined, field: string): unknown;
|
|
412
|
+
/** Variable names referenced by a link template (`{{var:Name}}`). */
|
|
413
|
+
declare function hyperlinkVariableNames(template: string): string[];
|
|
414
|
+
/**
|
|
415
|
+
* True for http(s), mailto, tel and relative links (`/path`, `#/route`, `?q=1`, `page.html`).
|
|
416
|
+
* Blocks `javascript:`, `data:`, `vbscript:` and other schemes.
|
|
417
|
+
*/
|
|
418
|
+
declare function isSafeHyperlink(url: string): boolean;
|
|
419
|
+
/** Resolve a link template against variables and the clicked row. Never throws. */
|
|
420
|
+
declare function resolveHyperlink(template: string | undefined, context?: HyperlinkContext): HyperlinkResult;
|
|
421
|
+
/** Replace `{{var:Name}}` tokens in display text; unknown variables are left visible. */
|
|
422
|
+
declare function resolveDisplayText(text: string, variables?: Record<string, VariableValue>): string;
|
|
423
|
+
/** Open a resolved link the same way for every widget. */
|
|
424
|
+
declare function openHyperlink(url: string, newTab: boolean): void;
|
|
367
425
|
/** Parsed KPI default when query returns no rows or an empty value. */
|
|
368
426
|
declare function getKpiDefaultValue(chartOptions: Record<string, unknown>): unknown | undefined;
|
|
369
427
|
declare function createChartAxisGuideline(axis?: ChartGuidelineAxis, value?: string): ChartAxisGuideline;
|
|
@@ -371,5 +429,31 @@ declare function normalizeChartAxisGuidelines(raw: unknown): ChartAxisGuideline[
|
|
|
371
429
|
declare function createEmptyDashboard(partial?: Partial<Dashboard>): Dashboard;
|
|
372
430
|
declare function createEmptyWidget(type?: WidgetType): Widget;
|
|
373
431
|
declare function createId(): string;
|
|
432
|
+
/** Connection variables have environment-owned values, never dashboard defaults. */
|
|
433
|
+
declare function connectionVariableNames(dashboard: Dashboard): string[];
|
|
434
|
+
declare function portableDashboard(dashboard: Dashboard): Dashboard;
|
|
435
|
+
/** Defaults for the print dialog. Printed-by is supplied by the host or signed-in user. */
|
|
436
|
+
interface DashboardPrintHeader {
|
|
437
|
+
enabled?: boolean;
|
|
438
|
+
repeat?: boolean;
|
|
439
|
+
logoUrl?: string;
|
|
440
|
+
organization?: string;
|
|
441
|
+
title?: string;
|
|
442
|
+
printedBy?: string;
|
|
443
|
+
showPrintedOn?: boolean;
|
|
444
|
+
fields?: Array<{
|
|
445
|
+
label: string;
|
|
446
|
+
value: string;
|
|
447
|
+
}>;
|
|
448
|
+
}
|
|
449
|
+
/** Saved dashboard defaults. User identity and print time are resolved at print time. */
|
|
450
|
+
interface DashboardPrintSettings {
|
|
451
|
+
orientation?: 'portrait' | 'landscape';
|
|
452
|
+
layout?: 'designed' | 'one-column' | 'two-column';
|
|
453
|
+
header?: Omit<DashboardPrintHeader, 'printedBy'> & {
|
|
454
|
+
showPrintedBy?: boolean;
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
declare function resolvePrintHeader(title: string, settings?: DashboardPrintSettings, runtime?: DashboardPrintHeader, user?: string): DashboardPrintHeader;
|
|
374
458
|
|
|
375
|
-
export { type AuthConfig, type AuthMode, type ChartAxisGuideline, type ChartGuidelineAxis, type ConnectionConfig, type ContainerLabelItem, type ContainerLabelLayout, type ContainerLabelTemplate, DASHBOARD_FILE_FORMAT, DASHBOARD_FILE_VERSION, DB_PROVIDERS, DEFAULT_CHART_COLORS, DEFAULT_THEME_ACCENT, type Dashboard, type DashboardAclEntry, type DashboardDisplayOptions, type DashboardEmailOptions, type DashboardExportOptions, type DashboardFileEnvelope, type DashboardPermission, type DashboardTheme, type DashboardVariable, type DashboardVersion, type DashboardVersionMeta, type DataBinding, type DbProvider, type DrillDownDef, type EmbedTokenRequest, type EmbedTokenResponse, type ExecuteQueryRequest, type FilterDef, type FilterOperator, type GridItem, type JoinDef, type JoinType, LEGACY_LABEL_FOREGROUND, type LabelClickAction, type LabelContainerSource, type ProcedureParameter, type ProcedureWhereClause, type QueryColumn, type QueryDef, type QueryLabelDrillDown, type QueryResult, RTL_LOCALES, THEME_PRESETS, type User, type UserRole, type VariableValue, WIDGET_TYPES, type Widget, type WidgetType, buildContainerLabelsFromQuery, buildDashboardExportFile, buildProcedureWhereClause, cloneDashboardForImport, createChartAxisGuideline, createContainerLabelItem, createEmptyDashboard, createEmptyWidget, createId, getKpiDefaultValue, getLabelClickUrl, hasContainerLabelCustomStyles, hasContainerLabelTemplateCustomStyles, isDefaultDashboardTheme, labelClickOpensNewTab, labelWidgetShowsHeader, matchThemePreset, normalizeChartAxisGuidelines, normalizeContainerLabelTemplate, normalizeContainerLabels, normalizeQueryLabelDrillDowns, parseDashboardImport, parseStoredProcedureName, resetContainerLabelItemStyles, resetContainerLabelTemplateStyles, resolveDashboardDir, resolveDashboardTheme, resolveDashboardVariables, resolveDisplayOptions, resolveEmailOptions, resolveExportOptions, resolveFilterVariables, resolveLabelClickAction, resolveLabelContainerSource, resolveProcedureParameterValue, resolveRequestVariables, resolveVariableValue, sanitizeLabelStyleBackground, sanitizeLabelStyleColor };
|
|
459
|
+
export { type AuthConfig, type AuthMode, type ChartAxisGuideline, type ChartGuidelineAxis, type ConnectionConfig, type ContainerLabelItem, type ContainerLabelLayout, type ContainerLabelTemplate, DASHBOARD_FILE_FORMAT, DASHBOARD_FILE_VERSION, DB_PROVIDERS, DEFAULT_CHART_COLORS, DEFAULT_THEME_ACCENT, type Dashboard, type DashboardAclEntry, type DashboardDisplayOptions, type DashboardEmailOptions, type DashboardExportOptions, type DashboardFileEnvelope, type DashboardPermission, type DashboardPrintHeader, type DashboardPrintSettings, type DashboardTheme, type DashboardVariable, type DashboardVersion, type DashboardVersionMeta, type DataBinding, type DbProvider, type DrillDownDef, type EmbedTokenRequest, type EmbedTokenResponse, type ExecuteQueryRequest, type FilterDef, type FilterOperator, type GridItem, type HyperlinkContext, type HyperlinkResult, type JoinDef, type JoinType, LEGACY_LABEL_FOREGROUND, type LabelClickAction, type LabelContainerSource, type ProcedureParameter, type ProcedureWhereClause, type QueryColumn, type QueryDef, type QueryLabelDrillDown, type QueryResult, RTL_LOCALES, THEME_PRESETS, type User, type UserRole, type VariableValue, WIDGET_TYPES, type Widget, type WidgetHyperlink, type WidgetType, buildContainerLabelsFromQuery, buildDashboardExportFile, buildProcedureWhereClause, cloneDashboardForImport, connectionVariableNames, createChartAxisGuideline, createContainerLabelItem, createEmptyDashboard, createEmptyWidget, createId, getKpiDefaultValue, getLabelClickUrl, getWidgetHyperlink, hasContainerLabelCustomStyles, hasContainerLabelTemplateCustomStyles, hyperlinkVariableNames, isDefaultDashboardTheme, isSafeHyperlink, labelClickOpensNewTab, labelWidgetShowsHeader, matchThemePreset, normalizeChartAxisGuidelines, normalizeContainerLabelTemplate, normalizeContainerLabels, normalizeQueryLabelDrillDowns, openHyperlink, parseDashboardImport, parseStoredProcedureName, portableDashboard, readRowField, resetContainerLabelItemStyles, resetContainerLabelTemplateStyles, resolveDashboardDir, resolveDashboardTheme, resolveDashboardVariables, resolveDisplayOptions, resolveDisplayText, resolveEmailOptions, resolveExportOptions, resolveFilterVariables, resolveHyperlink, resolveLabelClickAction, resolveLabelContainerSource, resolvePrintHeader, resolveProcedureParameterValue, resolveRequestVariables, resolveVariableValue, sanitizeLabelStyleBackground, sanitizeLabelStyleColor };
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ function buildDashboardExportFile(dashboard) {
|
|
|
82
82
|
format: DASHBOARD_FILE_FORMAT,
|
|
83
83
|
version: DASHBOARD_FILE_VERSION,
|
|
84
84
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
85
|
-
dashboard:
|
|
85
|
+
dashboard: portableDashboard(dashboard)
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function remapFilterIds(filters, idMap) {
|
|
@@ -298,6 +298,7 @@ function resolveDashboardVariables(dashboard, predefined = [], runtime = {}) {
|
|
|
298
298
|
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(variable.name)) throw new Error(`Invalid variable name: ${variable.name}`);
|
|
299
299
|
if (seen.has(variable.name)) throw new Error(`Duplicate variable name: ${variable.name}`);
|
|
300
300
|
seen.add(variable.name);
|
|
301
|
+
if (variable.type === "connection") continue;
|
|
301
302
|
let value = variable.defaultValue;
|
|
302
303
|
if (predefined.some((p) => p.name === variable.name) && Object.prototype.hasOwnProperty.call(dashboard.variableDefaults ?? {}, variable.name))
|
|
303
304
|
value = dashboard.variableDefaults[variable.name];
|
|
@@ -356,7 +357,9 @@ function normalizeContainerLabels(raw) {
|
|
|
356
357
|
),
|
|
357
358
|
fontSize: typeof o.fontSize === "number" ? o.fontSize : void 0,
|
|
358
359
|
targetDashboardId: typeof o.targetDashboardId === "string" ? o.targetDashboardId : void 0,
|
|
359
|
-
drillTitle: typeof o.drillTitle === "string" ? o.drillTitle : void 0
|
|
360
|
+
drillTitle: typeof o.drillTitle === "string" ? o.drillTitle : void 0,
|
|
361
|
+
url: typeof o.url === "string" && o.url.trim() ? o.url : void 0,
|
|
362
|
+
urlNewTab: o.urlNewTab === false ? false : void 0
|
|
360
363
|
});
|
|
361
364
|
}
|
|
362
365
|
return out;
|
|
@@ -376,6 +379,8 @@ function resetContainerLabelItemStyles(item) {
|
|
|
376
379
|
const next = { id: item.id, text: item.text };
|
|
377
380
|
if (item.targetDashboardId) next.targetDashboardId = item.targetDashboardId;
|
|
378
381
|
if (item.drillTitle) next.drillTitle = item.drillTitle;
|
|
382
|
+
if (item.url) next.url = item.url;
|
|
383
|
+
if (item.urlNewTab === false) next.urlNewTab = false;
|
|
379
384
|
return next;
|
|
380
385
|
}
|
|
381
386
|
function normalizeContainerLabelTemplate(raw) {
|
|
@@ -388,7 +393,9 @@ function normalizeContainerLabelTemplate(raw) {
|
|
|
388
393
|
),
|
|
389
394
|
fontSize: typeof o.fontSize === "number" ? o.fontSize : void 0,
|
|
390
395
|
targetDashboardId: typeof o.targetDashboardId === "string" ? o.targetDashboardId : void 0,
|
|
391
|
-
drillTitle: typeof o.drillTitle === "string" ? o.drillTitle : void 0
|
|
396
|
+
drillTitle: typeof o.drillTitle === "string" ? o.drillTitle : void 0,
|
|
397
|
+
url: typeof o.url === "string" && o.url.trim() ? o.url : void 0,
|
|
398
|
+
urlNewTab: o.urlNewTab === false ? false : void 0
|
|
392
399
|
};
|
|
393
400
|
}
|
|
394
401
|
function hasContainerLabelTemplateCustomStyles(template) {
|
|
@@ -400,6 +407,8 @@ function resetContainerLabelTemplateStyles(template) {
|
|
|
400
407
|
const next = {};
|
|
401
408
|
if (template.targetDashboardId) next.targetDashboardId = template.targetDashboardId;
|
|
402
409
|
if (template.drillTitle) next.drillTitle = template.drillTitle;
|
|
410
|
+
if (template.url) next.url = template.url;
|
|
411
|
+
if (template.urlNewTab === false) next.urlNewTab = false;
|
|
403
412
|
return next;
|
|
404
413
|
}
|
|
405
414
|
function resolveLabelContainerSource(chartOptions) {
|
|
@@ -442,7 +451,11 @@ function buildContainerLabelsFromQuery(rows, columns, dimensionField, template,
|
|
|
442
451
|
backgroundColor: template.backgroundColor,
|
|
443
452
|
fontSize: template.fontSize,
|
|
444
453
|
targetDashboardId,
|
|
445
|
-
drillTitle
|
|
454
|
+
drillTitle,
|
|
455
|
+
// A per-value rule (open dashboard / no action) overrides the shared link.
|
|
456
|
+
url: override ? void 0 : template.url,
|
|
457
|
+
urlNewTab: template.urlNewTab,
|
|
458
|
+
linkRow: row
|
|
446
459
|
});
|
|
447
460
|
}
|
|
448
461
|
return labels;
|
|
@@ -463,6 +476,86 @@ function getLabelClickUrl(chartOptions) {
|
|
|
463
476
|
function labelClickOpensNewTab(chartOptions) {
|
|
464
477
|
return chartOptions.clickUrlNewTab !== false;
|
|
465
478
|
}
|
|
479
|
+
var HYPERLINK_TOKEN = /\{\{\s*(?:(var|field)\s*:\s*([^}]+?)|(value))\s*\}\}/g;
|
|
480
|
+
var SAFE_LINK_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto", "tel"]);
|
|
481
|
+
function getWidgetHyperlink(chartOptions) {
|
|
482
|
+
const url = typeof chartOptions.hyperlinkUrl === "string" ? chartOptions.hyperlinkUrl.trim() : "";
|
|
483
|
+
if (!url) return void 0;
|
|
484
|
+
const column = typeof chartOptions.hyperlinkColumn === "string" && chartOptions.hyperlinkColumn.trim() ? chartOptions.hyperlinkColumn.trim() : void 0;
|
|
485
|
+
return { url, newTab: chartOptions.hyperlinkNewTab !== false, column };
|
|
486
|
+
}
|
|
487
|
+
function readRowField(row, field) {
|
|
488
|
+
if (!row) return void 0;
|
|
489
|
+
if (Object.prototype.hasOwnProperty.call(row, field)) return row[field];
|
|
490
|
+
const bare = field.includes(".") ? field.slice(field.lastIndexOf(".") + 1) : field;
|
|
491
|
+
if (Object.prototype.hasOwnProperty.call(row, bare)) return row[bare];
|
|
492
|
+
const lower = bare.toLowerCase();
|
|
493
|
+
const key = Object.keys(row).find((k) => {
|
|
494
|
+
const kb = k.includes(".") ? k.slice(k.lastIndexOf(".") + 1) : k;
|
|
495
|
+
return kb.toLowerCase() === lower;
|
|
496
|
+
});
|
|
497
|
+
return key === void 0 ? void 0 : row[key];
|
|
498
|
+
}
|
|
499
|
+
function hyperlinkVariableNames(template) {
|
|
500
|
+
const names = /* @__PURE__ */ new Set();
|
|
501
|
+
for (const m of template.matchAll(HYPERLINK_TOKEN)) if (m[1] === "var") names.add(m[2].trim());
|
|
502
|
+
return [...names];
|
|
503
|
+
}
|
|
504
|
+
function isSafeHyperlink(url) {
|
|
505
|
+
const compact = url.replace(/[\u0000-\u0020\u007f]+/g, "");
|
|
506
|
+
if (!compact) return false;
|
|
507
|
+
if (compact.startsWith("//")) return true;
|
|
508
|
+
const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(compact)?.[1];
|
|
509
|
+
if (!scheme) return !/^[a-z][a-z0-9+.-]*%3a/i.test(compact);
|
|
510
|
+
return SAFE_LINK_SCHEMES.has(scheme.toLowerCase());
|
|
511
|
+
}
|
|
512
|
+
function hyperlinkValueText(value) {
|
|
513
|
+
if (value == null) return "";
|
|
514
|
+
if (value instanceof Date) return value.toISOString();
|
|
515
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
516
|
+
return String(value);
|
|
517
|
+
}
|
|
518
|
+
function resolveHyperlink(template, context = {}) {
|
|
519
|
+
const source = (template ?? "").trim();
|
|
520
|
+
if (!source) return { ok: false, error: "No link URL is configured." };
|
|
521
|
+
const variables = context.variables ?? {};
|
|
522
|
+
let error;
|
|
523
|
+
const url = source.replace(HYPERLINK_TOKEN, (token, kind, rawName, isValue, offset) => {
|
|
524
|
+
let raw;
|
|
525
|
+
if (isValue) {
|
|
526
|
+
raw = context.value;
|
|
527
|
+
} else if (kind === "var") {
|
|
528
|
+
const name = rawName.trim();
|
|
529
|
+
if (!Object.prototype.hasOwnProperty.call(variables, name) || variables[name] === void 0) {
|
|
530
|
+
error ??= `Link variable "${name}" has no value.`;
|
|
531
|
+
return "";
|
|
532
|
+
}
|
|
533
|
+
raw = variables[name];
|
|
534
|
+
} else {
|
|
535
|
+
const name = rawName.trim();
|
|
536
|
+
raw = readRowField(context.row, name);
|
|
537
|
+
if (raw === void 0 && context.row) {
|
|
538
|
+
error ??= `Link field "${name}" is not in the query result.`;
|
|
539
|
+
return "";
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
const text = hyperlinkValueText(raw);
|
|
543
|
+
return offset === 0 ? text.trim() : encodeURIComponent(text);
|
|
544
|
+
}).trim();
|
|
545
|
+
if (error) return { ok: false, error };
|
|
546
|
+
if (!url) return { ok: false, error: "The link URL resolved to an empty value." };
|
|
547
|
+
if (!isSafeHyperlink(url)) return { ok: false, error: "This link uses a blocked URL scheme." };
|
|
548
|
+
return { ok: true, url };
|
|
549
|
+
}
|
|
550
|
+
function resolveDisplayText(text, variables = {}) {
|
|
551
|
+
if (!text.includes("{{")) return text;
|
|
552
|
+
return text.replace(/\{\{\s*var\s*:\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (token, name) => Object.prototype.hasOwnProperty.call(variables, name) && variables[name] !== void 0 ? hyperlinkValueText(variables[name]) : token);
|
|
553
|
+
}
|
|
554
|
+
function openHyperlink(url, newTab) {
|
|
555
|
+
if (typeof window === "undefined") return;
|
|
556
|
+
if (newTab) window.open(url, "_blank", "noopener,noreferrer");
|
|
557
|
+
else window.location.assign(url);
|
|
558
|
+
}
|
|
466
559
|
function getKpiDefaultValue(chartOptions) {
|
|
467
560
|
const raw = chartOptions.defaultValue;
|
|
468
561
|
if (raw == null) return void 0;
|
|
@@ -515,6 +608,7 @@ function createEmptyDashboard(partial) {
|
|
|
515
608
|
theme: partial?.theme,
|
|
516
609
|
exportOptions: partial?.exportOptions,
|
|
517
610
|
displayOptions: partial?.displayOptions,
|
|
611
|
+
printSettings: partial?.printSettings,
|
|
518
612
|
layout: partial?.layout ?? [],
|
|
519
613
|
globalFilters: partial?.globalFilters ?? [],
|
|
520
614
|
widgets: partial?.widgets ?? [],
|
|
@@ -608,6 +702,31 @@ function createId() {
|
|
|
608
702
|
function cryptoRandomId() {
|
|
609
703
|
return createId();
|
|
610
704
|
}
|
|
705
|
+
function connectionVariableNames(dashboard) {
|
|
706
|
+
return [.../* @__PURE__ */ new Set([
|
|
707
|
+
...(dashboard.variables ?? []).filter((v) => v.type === "connection").map((v) => v.name),
|
|
708
|
+
...dashboard.widgets.map((w) => /^connvar:([A-Za-z_][A-Za-z0-9_]*)$/.exec(w.query.connectionId)?.[1]).filter((v) => !!v)
|
|
709
|
+
])];
|
|
710
|
+
}
|
|
711
|
+
function portableDashboard(dashboard) {
|
|
712
|
+
const copy = structuredClone(dashboard);
|
|
713
|
+
const names = connectionVariableNames(copy);
|
|
714
|
+
copy.variables = [...(copy.variables ?? []).filter((v) => v.type !== "connection"), ...names.map((name) => ({ name, type: "connection" }))];
|
|
715
|
+
for (const name of names) if (copy.variableDefaults) delete copy.variableDefaults[name];
|
|
716
|
+
return copy;
|
|
717
|
+
}
|
|
718
|
+
function resolvePrintHeader(title, settings, runtime, user) {
|
|
719
|
+
const saved = settings?.header;
|
|
720
|
+
return {
|
|
721
|
+
enabled: true,
|
|
722
|
+
repeat: true,
|
|
723
|
+
showPrintedOn: true,
|
|
724
|
+
...saved,
|
|
725
|
+
...runtime,
|
|
726
|
+
title: runtime?.title || saved?.title || title,
|
|
727
|
+
printedBy: saved?.showPrintedBy === false ? void 0 : runtime?.printedBy ?? user
|
|
728
|
+
};
|
|
729
|
+
}
|
|
611
730
|
export {
|
|
612
731
|
DASHBOARD_FILE_FORMAT,
|
|
613
732
|
DASHBOARD_FILE_VERSION,
|
|
@@ -622,6 +741,7 @@ export {
|
|
|
622
741
|
buildDashboardExportFile,
|
|
623
742
|
buildProcedureWhereClause,
|
|
624
743
|
cloneDashboardForImport,
|
|
744
|
+
connectionVariableNames,
|
|
625
745
|
createChartAxisGuideline,
|
|
626
746
|
createContainerLabelItem,
|
|
627
747
|
createEmptyDashboard,
|
|
@@ -629,9 +749,12 @@ export {
|
|
|
629
749
|
createId,
|
|
630
750
|
getKpiDefaultValue,
|
|
631
751
|
getLabelClickUrl,
|
|
752
|
+
getWidgetHyperlink,
|
|
632
753
|
hasContainerLabelCustomStyles,
|
|
633
754
|
hasContainerLabelTemplateCustomStyles,
|
|
755
|
+
hyperlinkVariableNames,
|
|
634
756
|
isDefaultDashboardTheme,
|
|
757
|
+
isSafeHyperlink,
|
|
635
758
|
labelClickOpensNewTab,
|
|
636
759
|
labelWidgetShowsHeader,
|
|
637
760
|
matchThemePreset,
|
|
@@ -639,19 +762,25 @@ export {
|
|
|
639
762
|
normalizeContainerLabelTemplate,
|
|
640
763
|
normalizeContainerLabels,
|
|
641
764
|
normalizeQueryLabelDrillDowns,
|
|
765
|
+
openHyperlink,
|
|
642
766
|
parseDashboardImport,
|
|
643
767
|
parseStoredProcedureName,
|
|
768
|
+
portableDashboard,
|
|
769
|
+
readRowField,
|
|
644
770
|
resetContainerLabelItemStyles,
|
|
645
771
|
resetContainerLabelTemplateStyles,
|
|
646
772
|
resolveDashboardDir,
|
|
647
773
|
resolveDashboardTheme,
|
|
648
774
|
resolveDashboardVariables,
|
|
649
775
|
resolveDisplayOptions,
|
|
776
|
+
resolveDisplayText,
|
|
650
777
|
resolveEmailOptions,
|
|
651
778
|
resolveExportOptions,
|
|
652
779
|
resolveFilterVariables,
|
|
780
|
+
resolveHyperlink,
|
|
653
781
|
resolveLabelClickAction,
|
|
654
782
|
resolveLabelContainerSource,
|
|
783
|
+
resolvePrintHeader,
|
|
655
784
|
resolveProcedureParameterValue,
|
|
656
785
|
resolveRequestVariables,
|
|
657
786
|
resolveVariableValue,
|