zet-lib 1.0.33 → 1.0.35

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.
@@ -13,6 +13,8 @@ const Util = require('./Util');
13
13
  const moduleLib = require('./moduleLib');
14
14
  const myCache = require('./cache');
15
15
  const ejs = require('ejs');
16
+ var app = express();
17
+ const path = require('path');
16
18
 
17
19
  const nots = ['index','uploads','js','css','log','generator','zmenu','zgenerator','zfields','zrole','zfunction','zgrid','zgrid_default', 'zuser','zreport','zpage','zlayout','zerror','zuser_company','zconfig'];
18
20
  //const nots = [];
@@ -73,14 +75,15 @@ router.get('/', csrfProtection, async (req, res) => {
73
75
  approvalDatas: approvalDatas,
74
76
  sorting: sorting,
75
77
  lock: lock,
76
- routeName:res.locals.routeName,
77
- //endHTML : Util.readFile(`./views/generatorjs.ejs`)
78
- //renderBody: "zgenerator/index.ejs",
79
- renderEnd: "zgenerator/indexjs.ejs"
78
+ routeName:res.locals.routeName
80
79
  };
81
- let dataRender = zRoute.renderHTML(renderData);
82
- dataRender.bodyHTML = ejs.render(body, dataRender);
83
- res.render('layouts/generator',dataRender);
80
+
81
+ const bodyHTML = ejs.render(body, renderData);
82
+ const endHTML = ejs.render(Util.readFile(require.resolve(__dirname + '/views/generatorjs.ejs')), renderData);
83
+ let dataRender = renderData;
84
+ dataRender.bodyHTML = bodyHTML;
85
+ dataRender.endHTML = endHTML;
86
+ res.render(require.resolve(__dirname + '/views/generator_layout.ejs'), dataRender);
84
87
  });
85
88
 
86
89
  router.post('/fields', async (req, res) => {
package/lib/zdataTable.js CHANGED
@@ -1,137 +1,144 @@
1
1
  /**
2
2
  * Created by sintret dev on 1/6/2022.
3
3
  */
4
- const Util = require("./Util");
4
+ const Util = require('./Util')
5
5
 
6
6
  class dataTable {
7
- constructor(visibles) {
8
- this.visibles = visibles; //array object
9
- this.setColumns = "";
10
- this.setTable = "";
11
- this.MYMODEL = null;
12
- this.searchColumns = {};
13
- this.relations;
14
- this.routeName;
15
- this.types = {};
16
- this.levels = {};
17
- }
7
+ constructor(visibles) {
8
+ this.visibles = visibles //array object
9
+ this.setColumns = ''
10
+ this.setTable = ''
11
+ this.srcScript = 'https://cdn.datatables.net/v/bs5/dt-1.11.3/date-1.1.1/fc-4.0.1/fh-3.2.1/r-2.2.9/rg-1.1.4/sc-2.0.5/sl-1.3.4/datatables.min.js'
12
+ this.dataTableScript = '/js/datatable-default.js';
13
+ this.dataTableButtons = '/js/datatable-buttons.js';
14
+ this.customButtons = '';
15
+ this.MYMODEL = null
16
+ this.searchColumns = {}
17
+ this.relations;
18
+ this.routeName;
19
+ this.types = {}
20
+ this.levels = {}
21
+ }
18
22
 
19
- // for filter html
20
- set filterMODEL(obj) {
21
- this.MYMODEL = obj.MYMODEL;
22
- this.relations = obj.relations;
23
- this.routeName = this.MYMODEL.routeName;
24
- this.types = obj.TYPES;
25
- delete obj.MYMODEL;
26
- delete obj.relations;
27
- delete obj.TYPES;
28
- this.searchColumns = obj;
29
- }
23
+ // for filter html
24
+ set filterMODEL(obj) {
25
+ this.MYMODEL = obj.MYMODEL
26
+ this.relations = obj.relations
27
+ this.routeName = this.MYMODEL.routeName
28
+ this.types = obj.TYPES
29
+ delete obj.MYMODEL
30
+ delete obj.relations
31
+ delete obj.TYPES
32
+ this.searchColumns = obj
33
+ }
30
34
 
31
- get columns() {
32
- if (this.setColumns)
33
- return this.setColumns;
34
- let html = '';
35
- for (var key in this.visibles) {
36
- html += `<th id="data_${key}_label">${this.visibles[key]}</th>`;
37
- }
38
- return html;
35
+ get columns() {
36
+ if (this.setColumns)
37
+ return this.setColumns
38
+ let html = ''
39
+ for (const key in this.visibles) {
40
+ html += `<th id="data_${key}_label">${this.visibles[key]}</th>`
39
41
  }
42
+ return html
43
+ }
40
44
 
41
- get columnsFilter() {
42
- let html = '<tr class="filters">';
43
- for (var key in this.visibles) {
44
- html += `<th id="data_${key}">${this.searchColumns[key]}</th>`;
45
- }
46
- html += '</tr>';
47
- return html;
45
+ get columnsFilter() {
46
+ let html = '<tr class="filters">'
47
+ for (const key in this.visibles) {
48
+ html += `<th id="data_${key}">${this.searchColumns[key]}</th>`
48
49
  }
50
+ html += '</tr>'
51
+ return html
52
+ }
49
53
 
50
- /*
51
- Create table html header
52
- */
53
- get table() {
54
- if (this.setTable)
55
- return this.setTable;
56
- return `<table id="dataTable" class="display table table-hover table-responsive" style="width:100%">
54
+ /*
55
+ Create table html header
56
+ */
57
+ get table() {
58
+ if (this.setTable)
59
+ return this.setTable
60
+ return `<table id="dataTable" class="display table table-hover table-responsive" style="width:100%">
57
61
  <thead>${this.columns} ${this.columnsFilter}</thead>
58
- </table>`;
59
- }
62
+ </table>`
63
+ }
60
64
 
61
65
  get buttons() {
62
- let html = `<div class="dataTables_wrapper dt-bootstrap5 no-footer "><div class="dt-buttons btn-group flex-wrap">`;
66
+ let html = `<div class="dataTables_wrapper dt-bootstrap5 no-footer "><div class="dt-buttons btn-group flex-wrap">`
63
67
  if (this.levels.create) {
64
- html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><span><i class="fas fa-plus"></i><span>${LANGUAGE.create}</span></span></button>`
68
+ html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd image-button boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/plus.svg" class="icons-bg-black"> ${LANGUAGE.create}</button>`
65
69
  }
66
70
  if (this.levels.import) {
67
- html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><span><i class="fas fa-exchange-alt"></i> <span>${LANGUAGE.import}</span></span></button>`;
71
+ html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> ${LANGUAGE.import}</span></span></button>`
68
72
  }
69
- html += `<button title="${LANGUAGE.setting_info}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><span><i class="fas fa-cog"></i> <span>${LANGUAGE.settings}</span></span></button>`;
70
- html += `<button class="btn refresh gridreload boxy-small dimens2x" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><span><i class="fas fa-sync"></i><span></span></span></button>`;
73
+ html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`
74
+ html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`
71
75
  if (this.levels.export) {
72
76
  html += `<div class="btn-group" role="group">
73
- <button id="dropdownExport" type="button" class="btn dropdown-toggle boxy-small dimens2x" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
74
- <i class="fas fa-cloud-download-alt"></i> ${LANGUAGE.download}
77
+ <button id="dropdownExport" type="button" class="btn dropdown-toggle boxy-small dimens2x image-button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
78
+ <img src="/assets/icons/download.svg" class="icons-bg-black"> ${LANGUAGE.download}
75
79
  </button>
76
- <div class="dropdown-menu dimens3x" aria-labelledby="dropdownExport">`;
77
- html += `<a class="dropdown-header">Excel</a>`;
78
- html += `<a class="dropdown-item export-search-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel</a>`;
79
- html += `<a class="dropdown-item export-search-raw" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.import}) </a>`;
80
- html += `<a class="dropdown-item export-all-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.all}) </a>`;
81
- html += `<hr>`;
82
- html += `<a class="dropdown-header">PDF</a>`;
83
- html += `<a class="dropdown-item export-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF </a>`;
84
- html += `<a class="dropdown-item export-all-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF (${LANGUAGE.all}) </a>`;
85
- html += `</div>`;
80
+ <div class="dropdown-menu dimens3x" aria-labelledby="dropdownExport">`
81
+ html += `<a class="dropdown-header">Excel</a>`
82
+ html += `<a class="dropdown-item export-search-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel</a>`
83
+ html += `<a class="dropdown-item export-search-raw" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.import}) </a>`
84
+ html += `<a class="dropdown-item export-all-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.all}) </a>`
85
+ html += `<hr>`
86
+ html += `<a class="dropdown-header">PDF</a>`
87
+ html += `<a class="dropdown-item export-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF </a>`
88
+ html += `<a class="dropdown-item export-all-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF (${LANGUAGE.all}) </a>`
89
+ html += `</div>`
86
90
  }
87
- html += `</div></div>`;
88
-
89
- return html;
91
+ html += `</div></div>`
92
+ return html
90
93
  }
91
94
 
92
- get buttons2() {
93
- let html = `<div class="dataTables_wrapper dt-bootstrap5 no-footer "><div class="dt-buttons btn-group flex-wrap">`;
94
- if (this.levels.create) {
95
- html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd image-button boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/plus.svg" class="icons-bg-black"> ${LANGUAGE.create}</button>`
96
- }
97
- if (this.levels.import) {
98
- html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> ${LANGUAGE.import}</span></span></button>`;
99
- }
100
- html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`;
101
- html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`;
102
- if (this.levels.export) {
103
- html += `<div class="btn-group" role="group">
95
+ get buttons2() {
96
+ let html = `<div class="dataTables_wrapper dt-bootstrap5 no-footer "><div class="dt-buttons btn-group flex-wrap">`
97
+ if (this.levels.create) {
98
+ html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd image-button boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/plus.svg" class="icons-bg-black"> ${LANGUAGE.create}</button>`
99
+ }
100
+ if (this.levels.import) {
101
+ html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> ${LANGUAGE.import}</span></span></button>`
102
+ }
103
+ html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`
104
+ html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`
105
+ if (this.levels.export) {
106
+ html += `<div class="btn-group" role="group">
104
107
  <button id="dropdownExport" type="button" class="btn dropdown-toggle boxy-small dimens2x image-button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
105
108
  <img src="/assets/icons/download.svg" class="icons-bg-black"> ${LANGUAGE.download}
106
109
  </button>
107
- <div class="dropdown-menu dimens3x" aria-labelledby="dropdownExport">`;
108
- html += `<a class="dropdown-header">Excel</a>`;
109
- html += `<a class="dropdown-item export-search-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel</a>`;
110
- html += `<a class="dropdown-item export-search-raw" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.import}) </a>`;
111
- html += `<a class="dropdown-item export-all-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.all}) </a>`;
112
- html += `<hr>`;
113
- html += `<a class="dropdown-header">PDF</a>`;
114
- html += `<a class="dropdown-item export-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF </a>`;
115
- html += `<a class="dropdown-item export-all-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF (${LANGUAGE.all}) </a>`;
116
- html += `</div>`;
117
- }
118
- html += `</div></div>`;
119
- return html;
110
+ <div class="dropdown-menu dimens3x" aria-labelledby="dropdownExport">`
111
+ html += `<a class="dropdown-header">Excel</a>`
112
+ html += `<a class="dropdown-item export-search-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel</a>`
113
+ html += `<a class="dropdown-item export-search-raw" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.import}) </a>`
114
+ html += `<a class="dropdown-item export-all-prety" href="#"><i class="text-success fa fa-file-excel-o"></i>Excel (${LANGUAGE.all}) </a>`
115
+ html += `<hr>`
116
+ html += `<a class="dropdown-header">PDF</a>`
117
+ html += `<a class="dropdown-item export-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF </a>`
118
+ html += `<a class="dropdown-item export-all-pdf" href="#"><i class="text-success fa fa-file-excel-o"></i>PDF (${LANGUAGE.all}) </a>`
119
+ html += `</div>`
120
120
  }
121
+ html += `</div></div>`
122
+ return html
123
+ }
121
124
 
122
- get scripts() {
123
- let script = '<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/dt-1.11.3/date-1.1.1/fc-4.0.1/fh-3.2.1/r-2.2.9/rg-1.1.4/sc-2.0.5/sl-1.3.4/datatables.min.js"></script>';
124
- script += `<script>${Util.newLine}`;
125
- script += `var dataTableFields = ${JSON.stringify(Object.keys(this.visibles,null,2))};${Util.newLine}`;
126
- script += `var dataTableTypes = ${JSON.stringify(this.types,null,2)};${Util.newLine}`;
127
- script += `var dataTableRoute = "${this.routeName}";${Util.newLine}`;
128
- script += `</script>${Util.newLine}`;
129
- script += `<script type="text/javascript" src="/js/datatable.js"></script>${Util.newLine}`;
130
- if (this.searchColumns.FILTERKEY) {
131
- script += `<script>$(function () { setTimeout(function () { ${this.searchColumns.FILTERKEY} },500) });</script>${Util.newLine}`;
132
- }
133
- return script;
125
+
126
+ get scripts() {
127
+ let script = `<script type="text/javascript" src="${this.srcScript}"></script>`
128
+ script += `<script>${Util.newLine}`
129
+ script += `var dataTableFields = ${JSON.stringify(Object.keys(this.visibles, null, 2))};${Util.newLine}`
130
+ script += `var dataTableTypes = ${JSON.stringify(this.types, null, 2)};${Util.newLine}`
131
+ script += `var dataTableRoute = "${this.routeName}";${Util.newLine}`;
132
+ script += `</script>${Util.newLine}`
133
+ script += `<script type="text/javascript" src="${this.dataTableScript}"></script>${Util.newLine}`
134
+ if (this.searchColumns.FILTERKEY) {
135
+ script += `<script>$(function () { setTimeout(function () { ${this.searchColumns.FILTERKEY} },500) });</script>${Util.newLine}`
134
136
  }
137
+ script += `<script type="text/javascript" src="${this.dataTableButtons}"></script>${Util.newLine}`
138
+
139
+ return script
140
+ }
141
+
135
142
  }
136
143
 
137
- module.exports = dataTable;
144
+ module.exports = dataTable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"