Skip to content

Commit d2677a2

Browse files
committed
fix ids params
1 parent f507651 commit d2677a2

5 files changed

Lines changed: 100 additions & 50 deletions

File tree

.idea/workspace.xml

Lines changed: 18 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-table/backend/routeHandler.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ const bodyParser = require('body-parser');
44
module.exports = function configureRoutes(options) {
55
options.router.use(bodyParser.json());
66

7-
function sanitizeTemplateData(templateFields) {
8-
if (templateFields) {
9-
if (templateFields.hasOwnProperty('nodeset')) {
10-
templateFields['nodeset'] = templateFields['nodeset'].split(',');
11-
} else if (templateFields.hasOwnProperty('edgeset')) {
12-
templateFields['edgeset'] = templateFields['edgeset'].split(',');
7+
function sanitizeTemplateData(templateFieldsParams, templateFieldsQuery) {
8+
templateFieldsQuery.forEach(queryParam => {
9+
if (queryParam.type === 'nodeset' || queryParam.type === 'edgeset') {
10+
templateFieldsParams[queryParam.key] = templateFieldsParams[queryParam.key].split(',');
1311
}
14-
}
15-
return templateFields;
12+
});
13+
return templateFieldsParams;
1614
}
1715

1816
function checkPluginsConfiguration(schemaTypes, entityType, itemType, properties) {
@@ -57,20 +55,22 @@ module.exports = function configureRoutes(options) {
5755
});
5856

5957
options.router.post('/runQueryByIDPlugin', async (req, res) => {
58+
console.log(req.body);
6059
const data = {
6160
id: +req.body.queryParams.global.queryId,
6261
sourceKey: req.body.queryParams.global.sourceKey,
6362
limit: +req.body.queryParams.global.limit
6463
};
6564
if (req.body.query.templateFields) {
66-
data.templateData = sanitizeTemplateData(req.body.queryParams.templateFields);
65+
data.templateData = sanitizeTemplateData(req.body.queryParams.templateFields, req.body.query.templateFields);
6766
}
67+
console.log(data);
6868
try {
6969
const queryResult = await options.getRestClient(req).graphQuery.runQueryById(data);
7070
res.status(200);
7171
res.contentType('application/json');
7272
res.send(JSON.stringify(queryResult));
73-
} catch (e) {
73+
} catch(e) {
7474
res.status(400);
7575
res.contentType('application/json');
7676
res.send(JSON.stringify({status: 400, body: {error: e.originalResponse.body}}));
@@ -79,12 +79,17 @@ module.exports = function configureRoutes(options) {
7979
});
8080

8181
options.router.get('/getSchema', async (req, res) => {
82-
const schemaResult = await options.getRestClient(req).graphSchema.getTypesWithAccess({
83-
entityType: options.configuration.entityType || 'node',
84-
sourceKey: req.query.sourceKey
85-
});
86-
res.status(200);
87-
res.contentType('application/json');
88-
res.send(JSON.stringify(schemaResult));
82+
try {
83+
const schemaResult = await options.getRestClient(req).graphSchema.getTypesWithAccess({
84+
entityType: options.configuration.entityType || 'node',
85+
sourceKey: req.query.sourceKey
86+
});
87+
res.status(200);
88+
res.contentType('application/json');
89+
res.send(JSON.stringify(schemaResult));
90+
} catch(e) {
91+
res.status(412);
92+
res.send(JSON.stringify({status: 412, body: e}));
93+
}
8994
});
9095
};

data-table/public/css/main.css

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ body {
33
font-family: 'roboto', sans-serif;
44
font-style: normal;
55
margin: 0 !important;
6+
background-color: #F8F8F8;
67
}
78

89
.table--container {
@@ -15,7 +16,6 @@ body {
1516
align-items: center;
1617
justify-content: center;
1718
width: 100%;
18-
background-color: #F8F8F8;
1919
}
2020

2121
.container__card {
@@ -245,12 +245,16 @@ body {
245245
display: flex;
246246
flex-wrap: wrap;
247247
max-height: 180px;
248-
overflow-y: scroll;
248+
overflow-y: auto;
249249
}
250250

251251
.checkbox-column {
252252
width: 100%;
253253
padding-bottom: 12px;
254+
color: #303030;
255+
font-size: 14px;
256+
font-weight: 500;
257+
line-height: 16px;
254258
}
255259

256260
.modal__footer {
@@ -290,6 +294,7 @@ svg.stroke {
290294
color: #303030;
291295
font-size: 14px;
292296
line-height: 20px;
297+
width: 100%;
293298
}
294299

295300

@@ -299,6 +304,10 @@ svg.stroke {
299304
border-radius: 4px !important;
300305
}
301306

307+
/*.tabulator-row:last-child .tabulator-cell {
308+
border-bottom: none !important;
309+
}*/
310+
302311
.tabulator-cell {
303312
height: 44px;
304313
padding: 12px !important;
@@ -315,18 +324,14 @@ svg.stroke {
315324
padding: 8px !important;
316325
}
317326

318-
.tabulator-col::first-letter {
319-
text-transform: uppercase !important;
320-
}
321-
322-
323327
.tabulator-footer {
324328
padding: 0 !important;
325329
background-color: #fff !important;
326330
display: flex !important;
327331
flex-wrap: nowrap !important;
328332
align-items: center !important;
329333
justify-content: flex-end !important;
334+
border: none !important;
330335
}
331336

332337
.tabulator-page {
@@ -379,3 +384,7 @@ svg.stroke {
379384
.pagination__button {
380385
margin-left: 4px;
381386
}
387+
388+
.btn__page {
389+
width: 72px;
390+
}

data-table/public/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</div>
4646
<div class="button__container">
4747
<button class="btn btn__secondary hide" id="button-edit">EDIT COLUMNS</button>
48-
<button class="btn btn__primary hide" id="button-export">EXPORT CSV</button>
48+
<button class="btn btn__primary hide" id="button-export">EXPORT TO CSV</button>
4949
</div>
5050

5151
<!--------------------Table content-------------------->
@@ -56,7 +56,7 @@
5656
<div class="pagination-action">
5757
<button id="pagination-first" class="btn__secondary btn">FIRST</button>
5858
<button id="pagination-prev" class="btn__secondary pagination__button btn">PREV</button>
59-
<button id="pagination-page" class="btn__secondary pagination__button"></button>
59+
<button id="pagination-page" class="btn__secondary pagination__button btn__page"></button>
6060
<button id="pagination-next" class="btn__secondary pagination__button btn">NEXT</button>
6161
<button id="pagination-last" class="btn__secondary pagination__button btn">LAST</button>
6262
</div>
@@ -80,8 +80,8 @@
8080

8181
</div>
8282
<div class="modal__footer">
83-
<button class="btn btn__secondary margin-right__4" id="cancel">Cancel</button>
84-
<button class="btn btn__primary" id="confirm">Confirm</button>
83+
<button class="btn btn__secondary margin-right__4" id="cancel">CANCEL</button>
84+
<button class="btn btn__primary" id="confirm">CONFIRM</button>
8585
</div>
8686

8787
</div>

data-table/public/js/main.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ function parseQueryParams() {
112112
}
113113
}
114114
});
115-
console.log(result);
116115
queryParams = result;
117116
}
118117

@@ -216,7 +215,7 @@ function truncateColumnTitle(cell) {
216215
}
217216

218217
function truncateFieldValue(cell) {
219-
return truncateText(cell.getValue());
218+
return truncateText(cell.getValue(), 38);
220219
}
221220

222221
function truncateText(text = '', maxLength = 50) {
@@ -230,7 +229,7 @@ function truncateText(text = '', maxLength = 50) {
230229
function getFieldTooltip(cell) {
231230
if (cell.getValue() && cell.getValue().length > 50) {
232231
if (cell.getValue().length > 300) {
233-
return cell.getValue().slice(0, 299);
232+
return `${cell.getValue().slice(0, 299)}...`;
234233
}
235234
return cell.getValue();
236235
}
@@ -298,7 +297,7 @@ function getTableData(queryResult) {
298297
for (let [key, value] of Object.entries(item.data.properties)) {
299298
if (typeof value === 'object') {
300299
if (value.value && (value.type === 'date' || value.type === 'datetime')) {
301-
item.data.properties[key] = (new Date(value.value)).toISOString();
300+
item.data.properties[key] = formatDate(value.value, value.type === 'datetime');
302301
} else {
303302
item.data.properties[key] = value.value || value.original;
304303
}
@@ -308,6 +307,42 @@ function getTableData(queryResult) {
308307
});
309308
}
310309

310+
function formatDate(isoString, isDatetime) {
311+
// The date received from the server will be always in seconds
312+
const dateObject = new Date(isoString);
313+
314+
if (isNaN(dateObject.getUTCFullYear())) {
315+
return null;
316+
}
317+
let formattedDate =
318+
dateObject.getFullYear() +
319+
'-' +
320+
((dateObject.getUTCMonth() + 1).toString().length === 1
321+
? '0' + (dateObject.getUTCMonth() + 1)
322+
: dateObject.getUTCMonth() + 1) +
323+
'-' +
324+
(dateObject.getUTCDate().toString().length === 1
325+
? '0' + dateObject.getUTCDate()
326+
: dateObject.getUTCDate());
327+
328+
if (isDatetime) {
329+
formattedDate +=
330+
' ' +
331+
(dateObject.getUTCHours().toString().length === 1
332+
? '0' + dateObject.getUTCHours()
333+
: dateObject.getUTCHours()) +
334+
':' +
335+
(dateObject.getUTCMinutes().toString().length === 1
336+
? '0' + dateObject.getUTCMinutes()
337+
: dateObject.getUTCMinutes()) +
338+
':' +
339+
(dateObject.getUTCSeconds().toString().length === 1
340+
? '0' + dateObject.getUTCSeconds()
341+
: dateObject.getUTCSeconds());
342+
}
343+
return formattedDate;
344+
}
345+
311346
function getTooltipsHeader(column) {
312347
if (column.getDefinition().title && column.getDefinition().title.length * 8 > 300) {
313348
return column.getDefinition().title;
@@ -504,7 +539,7 @@ function fillDataTable() {
504539
data: tableData, //assign data to table
505540
layout: 'fitDataFill', //fit columns to width of table
506541
columns: tableStructure,
507-
height: 482,
542+
height: 481,
508543
tooltipGenerationMode: 'hover'
509544
});
510545
alignRightHeaders();

0 commit comments

Comments
 (0)