Skip to content

Commit 4a23411

Browse files
committed
clean code and add comments
1 parent c25b084 commit 4a23411

4 files changed

Lines changed: 164 additions & 44 deletions

File tree

backend/routeHandler.js

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

7+
/**
8+
* sanitize the templateData attribute for runQueryByID parameter
9+
* @param templateFieldsParams
10+
* @param templateFieldsQuery
11+
* @returns {*}
12+
*/
713
function sanitizeTemplateData(templateFieldsParams, templateFieldsQuery) {
814
templateFieldsQuery.forEach(queryParam => {
915
if (queryParam.type === 'nodeset' || queryParam.type === 'edgeset') {
@@ -13,6 +19,14 @@ module.exports = function configureRoutes(options) {
1319
return templateFieldsParams;
1420
}
1521

22+
/**
23+
* check if the plugin configuration is valid
24+
* @param schemaTypes
25+
* @param entityType
26+
* @param itemType
27+
* @param properties
28+
* @returns {{message: string}|{message: string}|{message: string}|null|{message: string}}
29+
*/
1630
function checkPluginsConfiguration(schemaTypes, entityType, itemType, properties) {
1731
if (entityType && entityType !== 'node' && entityType !== 'edge') {
1832
return {message: 'Invalid plugin configuration “entityType” (must be “node” or “edge”)'};
@@ -55,7 +69,6 @@ module.exports = function configureRoutes(options) {
5569
});
5670

5771
options.router.post('/runQueryByIDPlugin', async (req, res) => {
58-
console.log(req.body);
5972
const data = {
6073
id: +req.body.queryParams.global.queryId,
6174
sourceKey: req.body.queryParams.global.sourceKey,
@@ -64,16 +77,16 @@ module.exports = function configureRoutes(options) {
6477
if (req.body.query.templateFields) {
6578
data.templateData = sanitizeTemplateData(req.body.queryParams.templateFields, req.body.query.templateFields);
6679
}
67-
console.log(data);
6880
try {
6981
const queryResult = await options.getRestClient(req).graphQuery.runQueryById(data);
7082
res.status(200);
7183
res.contentType('application/json');
7284
res.send(JSON.stringify(queryResult));
73-
} catch(e) {
85+
} catch (e) {
7486
res.status(400);
7587
res.contentType('application/json');
76-
res.send(JSON.stringify({status: 400, body: {error: e.originalResponse.body}}));
88+
const error = e.originalResponse.body ? e.originalResponse.body : e;
89+
res.send(JSON.stringify({status: 400, body: {error}}));
7790
}
7891

7992
});
@@ -87,7 +100,7 @@ module.exports = function configureRoutes(options) {
87100
res.status(200);
88101
res.contentType('application/json');
89102
res.send(JSON.stringify(schemaResult));
90-
} catch(e) {
103+
} catch (e) {
91104
res.status(412);
92105
res.send(JSON.stringify({status: 412, body: e}));
93106
}

public/css/main.css

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ body {
111111
position: static;
112112
margin: 0;
113113
visibility: visible;
114-
opacity: 1;
115114
}
116115

117116
.spinner:before {
@@ -185,12 +184,6 @@ body {
185184
margin-right: 20px;
186185
}
187186

188-
/*.warning_img {
189-
height: 16px;
190-
width: 16px;
191-
background-color: #FFFFFF;
192-
}*/
193-
194187
.button__container {
195188
display: flex;
196189
padding: 40px 20px 16px 20px;
@@ -304,10 +297,6 @@ svg.stroke {
304297
border-radius: 4px !important;
305298
}
306299

307-
/*.tabulator-row:last-child .tabulator-cell {
308-
border-bottom: none !important;
309-
}*/
310-
311300
.tabulator-cell {
312301
height: 44px;
313302
padding: 12px !important;

public/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<meta name="theme-color" content="#fafafa">
1818
</head>
1919

20-
<body id="body">
20+
<body>
2121

2222
<!--------------------Loader-------------------->
2323
<div class="loader__curtain" id="loader">
@@ -44,14 +44,14 @@
4444

4545
</div>
4646
<div class="button__container">
47-
<button class="btn btn__secondary hide" id="button-edit">EDIT COLUMNS</button>
48-
<button class="btn btn__primary hide" id="button-export">EXPORT TO CSV</button>
47+
<button class="btn btn__secondary" id="button-edit">EDIT COLUMNS</button>
48+
<button class="btn btn__primary" id="button-export">EXPORT TO CSV</button>
4949
</div>
5050

5151
<!--------------------Table content-------------------->
5252
<div id="table" class="table--container"></div>
5353
<!-------------------- Pagination-------------------->
54-
<div class="pagination hide" id="pagination">
54+
<div class="pagination" id="pagination">
5555
<div class="pagination__details" id="pagination-details"></div>
5656
<div class="pagination-action">
5757
<button id="pagination-first" class="btn__secondary btn">FIRST</button>

0 commit comments

Comments
 (0)