Skip to content

Commit 66d4f89

Browse files
linkurious-infraenysaminerhanemidavidrapinyigitakbulut
authored
Release 1.0.9 [ci:run] (#40)
* Bump patch version [ci:run] * [renovate] Target develop for vulns * LKE-8090 fix(queryParsing): use URLSearchParams to get url query params #38 * Fix license year & owner * Lke 1588 add truncated option (#3) Data Table plugin: Add an option to show long text --------- Co-authored-by: Edward Nys <edward@linkurio.us> Co-authored-by: aminerhanemi <amine@linkurio.us> Co-authored-by: david <david@linkurio.us> Co-authored-by: Yiğit Akbulut <29952103+yigitakbulut@users.noreply.github.com>
1 parent d9292db commit 66d4f89

File tree

10 files changed

+85
-61
lines changed

10 files changed

+85
-61
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.0.8
2+
current_version = 1.0.9
33
commit = False
44
tag = False
55
serialize =

.github/renovate.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"github>Linkurious/renovate-config:meta",
55
"regexManagers:dockerfileVersions"
66
],
7+
"vulnerabilityAlerts": {
8+
"baseBranches": ["develop"]
9+
},
710
"baseBranches": ["develop"],
811
"prConcurrentLimit": 10
912
}

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.8
1+
1.0.9

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2023 Linkurious SAS
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ This plugin supports the following URL parameters in the query string:
4545
| `param_number_{{Encoded field name}}` | number (**optional**) | *For query templates*, any numerical parameter of the template. | `param_number_age=30` |
4646
| `param_string_{{Encoded field name}}` | string (**optional**) | *For query templates*, any string parameter of the template. | `param_string_city=Paris` |
4747
| `param_ids_{{Encoded field name}}` | comma-separated list (**optional**) | *For query templates*, any edgeset/nodeset parameter of the template. | `param_ids_target_ids=1,50,12` |
48+
| `showLongValues` | boolean (**optional**) | Avoids truncation of long texts. | `showLongValues=false` |
4849

4950
### Usage with standard queries
5051

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-table",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"pluginApiVersion": "1.0.0",
55
"publicRoute": "public",
66
"singlePageAppIndex": "index.html",

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linkurious/lke-plugin-data-table",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"description": "Data-table plugin for Linkurious Enterprise",
55
"main": "index.js",
66
"homepage": "https://github.com/Linkurious/lke-plugin-data-table#readme",

public/css/main.css

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,16 @@ svg.stroke {
297297
border-radius: 4px !important;
298298
}
299299

300-
.tabulator-cell {
301-
height: 44px;
302-
padding: 12px !important;
303-
border-bottom: 1px solid #aaa !important;
304-
background-color: #fff !important;
300+
.tabulator-row .tabulator-cell {
301+
padding: 12px;
302+
border-bottom: 1px solid #aaa;
303+
background-color: #fff;
304+
white-space: pre-wrap;
305+
max-width: 300px;
306+
}
307+
308+
.tabulator .tabulator-header .tabulator-col {
309+
max-width: 300px;
305310
}
306311

307312
.tabulator-row {

public/js/main.js

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ let tableStructure;
44
let schema;
55
let table;
66
let query;
7+
let isShowingLongValues;
78
let pluginConfiguration;
89
const headersToAlignRight = [];
910
const loaderElement = document.getElementById('loader');
@@ -111,57 +112,57 @@ async function runQueryByID(query) {
111112
* set queryParams as a json object containing the query parameters
112113
*/
113114
function parseQueryParams() {
114-
const url = location.search;
115-
const query = url.substr(1);
116-
const result = {global: {}, templateFields: {}};
117-
query.split('&').forEach((param) => {
118-
const item = param.split('=');
119-
const parameter = getParameter(item);
120-
if (parameter) {
121-
if (parameter.type === 'global') {
122-
result.global[decodeURIComponent(parameter.key)] = parameter.value;
123-
} else if (parameter.type === 'templateField') {
124-
result.templateFields[decodeURIComponent(parameter.key)] = parameter.value;
125-
}
126-
}
127-
});
128-
queryParams = result;
115+
const result = {global: {}, templateFields: {}};
116+
const parameters = new URLSearchParams(location.search);
117+
parameters.forEach((value, key) => {
118+
const parameter = getParameter(value, key);
119+
if (parameter) {
120+
if (parameter.type === 'global') {
121+
result.global[decodeURIComponent(parameter.key)] = parameter.value;
122+
} else if (parameter.type === 'templateField') {
123+
result.templateFields[decodeURIComponent(parameter.key)] = parameter.value;
124+
}
125+
}
126+
});
127+
queryParams = result;
129128
}
130129

131130
/**
132131
* check if the query-param is allowed
133-
* @param item
134-
*/
135-
function getParameter(item) {
136-
const allowedParams = {
137-
oneOf: [
138-
'sourceKey',
139-
'limit',
140-
'queryId',
141-
'queryName'
142-
],
143-
startWith: [
144-
'param_number_',
145-
'param_ids_',
146-
'param_string_'
147-
]
148-
};
149-
const decodedValue = decodeURIComponent(item[1]);
150-
if (allowedParams.oneOf.includes(item[0])) {
151-
return {key: item[0], value: decodedValue, type: 'global'};
152-
} else {
153-
const prefix = allowedParams.startWith.find((prefix) => item[0].startsWith(prefix));
154-
switch (prefix) {
155-
case 'param_number_':
156-
return {key: item[0].replace('param_number_', ''), value: +decodedValue, type: 'templateField'};
157-
case 'param_ids_':
158-
return {key: item[0].replace('param_ids_', ''), value: decodedValue, type: 'templateField'};
159-
case 'param_string_':
160-
return {key: item[0].replace('param_string_', ''), value: decodedValue, type: 'templateField'};
161-
default:
162-
return false;
163-
}
132+
* @param value
133+
* @param key
134+
*/
135+
function getParameter(value, key) {
136+
const allowedParams = {
137+
oneOf: [
138+
'sourceKey',
139+
'limit',
140+
'queryId',
141+
'queryName',
142+
'showLongValues'
143+
],
144+
startWith: [
145+
'param_number_',
146+
'param_ids_',
147+
'param_string_'
148+
]
149+
};
150+
const decodedValue = decodeURIComponent(value);
151+
if (allowedParams.oneOf.includes(key)) {
152+
return {key: key, value: decodedValue, type: 'global'};
153+
} else {
154+
const prefix = allowedParams.startWith.find((prefix) => key.startsWith(prefix));
155+
switch (prefix) {
156+
case 'param_number_':
157+
return {key: key.replace('param_number_', ''), value: +decodedValue, type: 'templateField'};
158+
case 'param_ids_':
159+
return {key: key.replace('param_ids_', ''), value: decodedValue, type: 'templateField'};
160+
case 'param_string_':
161+
return {key: key.replace('param_string_', ''), value: decodedValue, type: 'templateField'};
162+
default:
163+
return false;
164164
}
165+
}
165166
}
166167

167168
/**
@@ -253,7 +254,12 @@ async function validatePluginConfiguration() {
253254
* @param cell
254255
* @returns {string}
255256
*/
256-
function truncateTableText(cell) {
257+
function formatTableCell(cell) {
258+
cell.getElement().setAttribute("dir", "auto"); //Add support for right to left text
259+
260+
if (isShowingLongValues) {
261+
return cell.getValue();
262+
}
257263
return truncateText(cell.getValue(), 38);
258264
}
259265

@@ -343,9 +349,9 @@ function getTableStructure(schemaStructure) {
343349
title: property.propertyKey,
344350
field: escapeDotCharacters(property.propertyKey),
345351
align: align,
346-
titleFormatter: truncateTableText,
352+
titleFormatter: formatTableCell,
347353
headerSort: false,
348-
formatter: truncateTableText,
354+
formatter: formatTableCell,
349355
tooltip: getFieldTooltip
350356
};
351357
});
@@ -710,6 +716,15 @@ async function getQuery() {
710716
}
711717
}
712718

719+
function parseBool(val) {
720+
if ((typeof val === 'string' && (val.toLowerCase() === 'true' || val.toLowerCase() === 'yes')) || val === 1)
721+
return true;
722+
else if ((typeof val === 'string' && (val.toLowerCase() === 'false' || val.toLowerCase() === 'no')) || val === 0)
723+
return false;
724+
725+
return false;
726+
}
727+
713728
/**
714729
* start the plugin table
715730
* @returns {Promise<void>}
@@ -718,6 +733,7 @@ async function main() {
718733
loaderElement.classList.add('active');
719734
parseQueryParams();
720735
try {
736+
isShowingLongValues = parseBool(queryParams.global.showLongValues);
721737
validateGlobalQueryParams(queryParams.global);
722738
query = JSON.parse((await getQuery()).response).body;
723739
validateTemplateFieldsParams(query);
@@ -730,7 +746,6 @@ async function main() {
730746
} catch(e) {
731747
handleError(e);
732748
}
733-
734749
}
735750

736751
main();

0 commit comments

Comments
 (0)