express-sweet-generator 2.0.3 → 2.0.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/README.md +2 -0
- package/package.json +1 -1
- package/templates/cjs/public/build/editPersonal.js +54 -2
- package/templates/cjs/public/build/login.js +54 -2
- package/templates/cjs/public/build/users.js +163 -4
- package/templates/client/src/api/UserApi.js +1 -1
- package/templates/client/src/{pages/editPersonal.js → editPersonal.js} +1 -1
- package/templates/client/src/{pages/login.js → login.js} +1 -1
- package/templates/client/src/shared/Api.js +51 -0
- package/templates/client/src/shared/Datatable.js +104 -0
- package/templates/client/src/{pages/users.js → users.js} +4 -3
- package/templates/client/webpack.config.js +3 -3
- package/templates/esm/public/build/editPersonal.js +54 -2
- package/templates/esm/public/build/login.js +54 -2
- package/templates/esm/public/build/users.js +163 -4
- package/templates/cjs/public/build/theme/js/custom/authentication/sign-in/two-steps.js +0 -140
- package/templates/cjs/public/build/theme/js/custom/pages/user-profile/followers.js +0 -97
- package/templates/cjs/public/build/theme/js/custom/utilities/modals/create-project.js +0 -0
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.css +0 -1
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.eot +0 -0
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.html +0 -1253
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.scss +0 -361
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.svg +0 -264
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.ttf +0 -0
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff +0 -0
- package/templates/cjs/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff2 +0 -0
- package/templates/esm/public/build/theme/js/custom/authentication/sign-in/two-steps.js +0 -140
- package/templates/esm/public/build/theme/js/custom/pages/user-profile/followers.js +0 -97
- package/templates/esm/public/build/theme/js/custom/utilities/modals/create-project.js +0 -0
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.css +0 -1
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.eot +0 -0
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.html +0 -1253
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.scss +0 -361
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.svg +0 -264
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.ttf +0 -0
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff +0 -0
- package/templates/esm/public/build/theme/plugins/global/fonts/fonticon/fonticon.woff2 +0 -0
- /package/templates/client/src/{pages/editPersonal.css → editPersonal.css} +0 -0
- /package/templates/client/src/{pages/login.css → login.css} +0 -0
- /package/templates/client/src/{pages → modals}/UserModal.js +0 -0
- /package/templates/client/src/{pages/users.css → users.css} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# EXPRESS SWEET
|
|
2
2
|
[EXPRESS SWEET](https://www.npmjs.com/package/express-sweet)'s application generator.
|
|
3
3
|
|
|
4
|
+
A comprehensive list of changes in each version may be found in the [CHANGELOG](CHANGELOG.md).
|
|
5
|
+
|
|
4
6
|
## Installation
|
|
5
7
|
```sh
|
|
6
8
|
npm install -g express-sweet-generator
|
package/package.json
CHANGED
|
@@ -86,10 +86,62 @@ var __webpack_exports__ = {};
|
|
|
86
86
|
|
|
87
87
|
// EXTERNAL MODULE: ./node_modules/metronic-extension/dist/build.js
|
|
88
88
|
var build = __webpack_require__(236);
|
|
89
|
+
;// CONCATENATED MODULE: ./src/shared/Api.js
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Base API client class.
|
|
94
|
+
*/
|
|
95
|
+
/* harmony default export */ const Api = (class extends build.components.Api {
|
|
96
|
+
/**
|
|
97
|
+
* Initializes the API client.
|
|
98
|
+
* @param {string} path The base URL for requests.
|
|
99
|
+
*/
|
|
100
|
+
constructor(path) {
|
|
101
|
+
super(path, null, {
|
|
102
|
+
headers: {
|
|
103
|
+
// Indicate an AJAX request to the server.
|
|
104
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// /**
|
|
110
|
+
// * Initializes the API client.
|
|
111
|
+
// * @param {string} path The base URL for requests.
|
|
112
|
+
// * @param {string} [origin] The origin for requests.
|
|
113
|
+
// * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
|
|
114
|
+
// */
|
|
115
|
+
// constructor(path, origin, options) {
|
|
116
|
+
// super(path, origin, Object.assign({}, {
|
|
117
|
+
// headers: {
|
|
118
|
+
// // Indicate an AJAX request to the server.
|
|
119
|
+
// 'X-Requested-With': 'XMLHttpRequest',
|
|
120
|
+
// },
|
|
121
|
+
// }, options));
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handles API errors.
|
|
126
|
+
* @param {number} code The HTTP status code.
|
|
127
|
+
* @param {Error} err The error object.
|
|
128
|
+
* @return {void}
|
|
129
|
+
*/
|
|
130
|
+
errorHook(code, err) {
|
|
131
|
+
// Check if the error object and request properties exist to avoid runtime errors
|
|
132
|
+
if (err && err.request && err.request.responseURL) {
|
|
133
|
+
const {pathname} = new URL(err.request.responseURL);
|
|
134
|
+
if (pathname !== '/api/users/login' && code === 401) {
|
|
135
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
136
|
+
location.replace('/');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
89
141
|
;// CONCATENATED MODULE: ./src/api/UserApi.js
|
|
90
142
|
|
|
91
143
|
|
|
92
|
-
/* harmony default export */ const UserApi = (class extends
|
|
144
|
+
/* harmony default export */ const UserApi = (class extends components.Api {
|
|
93
145
|
constructor() {
|
|
94
146
|
super('/api/users');
|
|
95
147
|
}
|
|
@@ -122,7 +174,7 @@ var build = __webpack_require__(236);
|
|
|
122
174
|
return this.client.put('/profile', formData);
|
|
123
175
|
}
|
|
124
176
|
});
|
|
125
|
-
;// CONCATENATED MODULE: ./src/
|
|
177
|
+
;// CONCATENATED MODULE: ./src/editPersonal.js
|
|
126
178
|
|
|
127
179
|
|
|
128
180
|
|
|
@@ -86,10 +86,62 @@ var __webpack_exports__ = {};
|
|
|
86
86
|
|
|
87
87
|
// EXTERNAL MODULE: ./node_modules/metronic-extension/dist/build.js
|
|
88
88
|
var build = __webpack_require__(236);
|
|
89
|
+
;// CONCATENATED MODULE: ./src/shared/Api.js
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Base API client class.
|
|
94
|
+
*/
|
|
95
|
+
/* harmony default export */ const Api = (class extends build.components.Api {
|
|
96
|
+
/**
|
|
97
|
+
* Initializes the API client.
|
|
98
|
+
* @param {string} path The base URL for requests.
|
|
99
|
+
*/
|
|
100
|
+
constructor(path) {
|
|
101
|
+
super(path, null, {
|
|
102
|
+
headers: {
|
|
103
|
+
// Indicate an AJAX request to the server.
|
|
104
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// /**
|
|
110
|
+
// * Initializes the API client.
|
|
111
|
+
// * @param {string} path The base URL for requests.
|
|
112
|
+
// * @param {string} [origin] The origin for requests.
|
|
113
|
+
// * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
|
|
114
|
+
// */
|
|
115
|
+
// constructor(path, origin, options) {
|
|
116
|
+
// super(path, origin, Object.assign({}, {
|
|
117
|
+
// headers: {
|
|
118
|
+
// // Indicate an AJAX request to the server.
|
|
119
|
+
// 'X-Requested-With': 'XMLHttpRequest',
|
|
120
|
+
// },
|
|
121
|
+
// }, options));
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handles API errors.
|
|
126
|
+
* @param {number} code The HTTP status code.
|
|
127
|
+
* @param {Error} err The error object.
|
|
128
|
+
* @return {void}
|
|
129
|
+
*/
|
|
130
|
+
errorHook(code, err) {
|
|
131
|
+
// Check if the error object and request properties exist to avoid runtime errors
|
|
132
|
+
if (err && err.request && err.request.responseURL) {
|
|
133
|
+
const {pathname} = new URL(err.request.responseURL);
|
|
134
|
+
if (pathname !== '/api/users/login' && code === 401) {
|
|
135
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
136
|
+
location.replace('/');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
89
141
|
;// CONCATENATED MODULE: ./src/api/UserApi.js
|
|
90
142
|
|
|
91
143
|
|
|
92
|
-
/* harmony default export */ const UserApi = (class extends
|
|
144
|
+
/* harmony default export */ const UserApi = (class extends components.Api {
|
|
93
145
|
constructor() {
|
|
94
146
|
super('/api/users');
|
|
95
147
|
}
|
|
@@ -122,7 +174,7 @@ var build = __webpack_require__(236);
|
|
|
122
174
|
return this.client.put('/profile', formData);
|
|
123
175
|
}
|
|
124
176
|
});
|
|
125
|
-
;// CONCATENATED MODULE: ./src/
|
|
177
|
+
;// CONCATENATED MODULE: ./src/login.js
|
|
126
178
|
|
|
127
179
|
|
|
128
180
|
|
|
@@ -156,10 +156,168 @@ var build = __webpack_require__(776);
|
|
|
156
156
|
var build_default = /*#__PURE__*/__webpack_require__.n(build);
|
|
157
157
|
// EXTERNAL MODULE: ./node_modules/metronic-extension/dist/build.js
|
|
158
158
|
var dist_build = __webpack_require__(236);
|
|
159
|
+
;// CONCATENATED MODULE: ./src/shared/Datatable.js
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Custom DataTable class extending Metronic's Datatable component.
|
|
164
|
+
*/
|
|
165
|
+
/* harmony default export */ const Datatable = (class extends dist_build.components.Datatable {
|
|
166
|
+
/**
|
|
167
|
+
* Initializes the DataTable with custom options.
|
|
168
|
+
* @param {string|HTMLTableElement|JQuery} table The table element selector, DOM element, or jQuery object.
|
|
169
|
+
* @param {object} options The DataTable options.
|
|
170
|
+
*/
|
|
171
|
+
constructor(table, options) {
|
|
172
|
+
// Initialize options with default values.
|
|
173
|
+
options = Object.assign({
|
|
174
|
+
// Option to show the column visibility toggle button.
|
|
175
|
+
columnVisibility: false,
|
|
176
|
+
|
|
177
|
+
// Selector for columns to be visible by default.
|
|
178
|
+
visibleColumns: undefined,
|
|
179
|
+
}, options);
|
|
180
|
+
|
|
181
|
+
if (options.columnVisibility) {
|
|
182
|
+
// If column visibility option is enabled.
|
|
183
|
+
// Place the column visibility toggle button in the DOM.
|
|
184
|
+
options.dom = `<'row align-items-center'<'col dataTables_pager'p><'col-auto'B>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`;
|
|
185
|
+
|
|
186
|
+
// Add the column visibility toggle button.
|
|
187
|
+
options.buttons = {
|
|
188
|
+
dom: {
|
|
189
|
+
button: {
|
|
190
|
+
className: null,
|
|
191
|
+
},
|
|
192
|
+
buttonLiner: {
|
|
193
|
+
tag: null,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
buttons: [
|
|
197
|
+
{
|
|
198
|
+
extend: 'colvis',
|
|
199
|
+
columns: options.visibleColumns,
|
|
200
|
+
text: '<i class="ki-solid ki-gear fs-1"></i>',
|
|
201
|
+
// className: 'btn btn-sm btn-icon btn-color-primary btn-active-light-primary',
|
|
202
|
+
className: 'btn btn-icon btn-color-gray-500 btn-active-color-primary',
|
|
203
|
+
align: 'container',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Remove custom options as they are no longer needed.
|
|
209
|
+
delete options.columnVisibility;
|
|
210
|
+
delete options.visibleColumns;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Generates a unique state key for the DataTable.
|
|
215
|
+
* @param {object} settings DataTables settings object.
|
|
216
|
+
* @return {string} The generated state key.
|
|
217
|
+
*/
|
|
218
|
+
const getStateKey = (settings) => {
|
|
219
|
+
let stateKey = settings.sTableId;
|
|
220
|
+
stateKey += '_';
|
|
221
|
+
stateKey += location.pathname;
|
|
222
|
+
if (settings.nTable.getAttribute('data-ref')) {
|
|
223
|
+
stateKey += '/_';
|
|
224
|
+
stateKey += settings.nTable.getAttribute('data-ref');
|
|
225
|
+
}
|
|
226
|
+
return stateKey;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
// // Set locale to Japanese.
|
|
231
|
+
// options.locale = 'ja';
|
|
232
|
+
|
|
233
|
+
// Save sorting criteria.
|
|
234
|
+
options.stateSave = true;
|
|
235
|
+
options.stateSaveCallback = (settings, data) => {
|
|
236
|
+
// Save state with a name that doesn't conflict with other tables.
|
|
237
|
+
localStorage.setItem(getStateKey(settings), JSON.stringify(data));
|
|
238
|
+
};
|
|
239
|
+
options.stateLoadCallback = (settings) => {
|
|
240
|
+
// Return the saved state.
|
|
241
|
+
return JSON.parse(localStorage.getItem(getStateKey(settings)));
|
|
242
|
+
};
|
|
243
|
+
options.stateSaveParams = (settings, data) => {
|
|
244
|
+
// Don't save search criteria and offset.
|
|
245
|
+
delete data.search;
|
|
246
|
+
delete data.start;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
super(table, options);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Handles AJAX errors.
|
|
254
|
+
* @param {number} code The HTTP status code of the error.
|
|
255
|
+
* @return {void}
|
|
256
|
+
*/
|
|
257
|
+
ajaxErrorHook(code) {
|
|
258
|
+
if (code === 401) {
|
|
259
|
+
// Redirect to login page if authentication error occurs.
|
|
260
|
+
location.replace('/');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
;// CONCATENATED MODULE: ./src/shared/Api.js
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Base API client class.
|
|
270
|
+
*/
|
|
271
|
+
/* harmony default export */ const Api = (class extends dist_build.components.Api {
|
|
272
|
+
/**
|
|
273
|
+
* Initializes the API client.
|
|
274
|
+
* @param {string} path The base URL for requests.
|
|
275
|
+
*/
|
|
276
|
+
constructor(path) {
|
|
277
|
+
super(path, null, {
|
|
278
|
+
headers: {
|
|
279
|
+
// Indicate an AJAX request to the server.
|
|
280
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// /**
|
|
286
|
+
// * Initializes the API client.
|
|
287
|
+
// * @param {string} path The base URL for requests.
|
|
288
|
+
// * @param {string} [origin] The origin for requests.
|
|
289
|
+
// * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
|
|
290
|
+
// */
|
|
291
|
+
// constructor(path, origin, options) {
|
|
292
|
+
// super(path, origin, Object.assign({}, {
|
|
293
|
+
// headers: {
|
|
294
|
+
// // Indicate an AJAX request to the server.
|
|
295
|
+
// 'X-Requested-With': 'XMLHttpRequest',
|
|
296
|
+
// },
|
|
297
|
+
// }, options));
|
|
298
|
+
// }
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Handles API errors.
|
|
302
|
+
* @param {number} code The HTTP status code.
|
|
303
|
+
* @param {Error} err The error object.
|
|
304
|
+
* @return {void}
|
|
305
|
+
*/
|
|
306
|
+
errorHook(code, err) {
|
|
307
|
+
// Check if the error object and request properties exist to avoid runtime errors
|
|
308
|
+
if (err && err.request && err.request.responseURL) {
|
|
309
|
+
const {pathname} = new URL(err.request.responseURL);
|
|
310
|
+
if (pathname !== '/api/users/login' && code === 401) {
|
|
311
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
312
|
+
location.replace('/');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
});
|
|
159
317
|
;// CONCATENATED MODULE: ./src/api/UserApi.js
|
|
160
318
|
|
|
161
319
|
|
|
162
|
-
/* harmony default export */ const UserApi = (class extends
|
|
320
|
+
/* harmony default export */ const UserApi = (class extends components.Api {
|
|
163
321
|
constructor() {
|
|
164
322
|
super('/api/users');
|
|
165
323
|
}
|
|
@@ -192,7 +350,7 @@ var dist_build = __webpack_require__(236);
|
|
|
192
350
|
return this.client.put('/profile', formData);
|
|
193
351
|
}
|
|
194
352
|
});
|
|
195
|
-
;// CONCATENATED MODULE: ./src/
|
|
353
|
+
;// CONCATENATED MODULE: ./src/modals/UserModal.js
|
|
196
354
|
|
|
197
355
|
|
|
198
356
|
|
|
@@ -552,7 +710,8 @@ var dist_build = __webpack_require__(236);
|
|
|
552
710
|
dist_build.components.Dialog.close();
|
|
553
711
|
}
|
|
554
712
|
});
|
|
555
|
-
;// CONCATENATED MODULE: ./src/
|
|
713
|
+
;// CONCATENATED MODULE: ./src/users.js
|
|
714
|
+
|
|
556
715
|
|
|
557
716
|
|
|
558
717
|
|
|
@@ -560,7 +719,7 @@ var dist_build = __webpack_require__(236);
|
|
|
560
719
|
|
|
561
720
|
|
|
562
721
|
function initTable() {
|
|
563
|
-
userTable = new
|
|
722
|
+
userTable = new Datatable(ref.userTable, {
|
|
564
723
|
ajax: {
|
|
565
724
|
url: '/api/users',
|
|
566
725
|
data: d => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {components} from 'metronic-extension';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base API client class.
|
|
5
|
+
*/
|
|
6
|
+
export default class extends components.Api {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the API client.
|
|
9
|
+
* @param {string} path The base URL for requests.
|
|
10
|
+
*/
|
|
11
|
+
constructor(path) {
|
|
12
|
+
super(path, null, {
|
|
13
|
+
headers: {
|
|
14
|
+
// Indicate an AJAX request to the server.
|
|
15
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// /**
|
|
21
|
+
// * Initializes the API client.
|
|
22
|
+
// * @param {string} path The base URL for requests.
|
|
23
|
+
// * @param {string} [origin] The origin for requests.
|
|
24
|
+
// * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
|
|
25
|
+
// */
|
|
26
|
+
// constructor(path, origin, options) {
|
|
27
|
+
// super(path, origin, Object.assign({}, {
|
|
28
|
+
// headers: {
|
|
29
|
+
// // Indicate an AJAX request to the server.
|
|
30
|
+
// 'X-Requested-With': 'XMLHttpRequest',
|
|
31
|
+
// },
|
|
32
|
+
// }, options));
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Handles API errors.
|
|
37
|
+
* @param {number} code The HTTP status code.
|
|
38
|
+
* @param {Error} err The error object.
|
|
39
|
+
* @return {void}
|
|
40
|
+
*/
|
|
41
|
+
errorHook(code, err) {
|
|
42
|
+
// Check if the error object and request properties exist to avoid runtime errors
|
|
43
|
+
if (err && err.request && err.request.responseURL) {
|
|
44
|
+
const {pathname} = new URL(err.request.responseURL);
|
|
45
|
+
if (pathname !== '/api/users/login' && code === 401) {
|
|
46
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
47
|
+
location.replace('/');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {components} from 'metronic-extension';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Custom DataTable class extending Metronic's Datatable component.
|
|
5
|
+
*/
|
|
6
|
+
export default class extends components.Datatable {
|
|
7
|
+
/**
|
|
8
|
+
* Initializes the DataTable with custom options.
|
|
9
|
+
* @param {string|HTMLTableElement|JQuery} table The table element selector, DOM element, or jQuery object.
|
|
10
|
+
* @param {object} options The DataTable options.
|
|
11
|
+
*/
|
|
12
|
+
constructor(table, options) {
|
|
13
|
+
// Initialize options with default values.
|
|
14
|
+
options = Object.assign({
|
|
15
|
+
// Option to show the column visibility toggle button.
|
|
16
|
+
columnVisibility: false,
|
|
17
|
+
|
|
18
|
+
// Selector for columns to be visible by default.
|
|
19
|
+
visibleColumns: undefined,
|
|
20
|
+
}, options);
|
|
21
|
+
|
|
22
|
+
if (options.columnVisibility) {
|
|
23
|
+
// If column visibility option is enabled.
|
|
24
|
+
// Place the column visibility toggle button in the DOM.
|
|
25
|
+
options.dom = `<'row align-items-center'<'col dataTables_pager'p><'col-auto'B>><'row'<'col-12'tr>><'row'<'col-12 dataTables_pager'p>>`;
|
|
26
|
+
|
|
27
|
+
// Add the column visibility toggle button.
|
|
28
|
+
options.buttons = {
|
|
29
|
+
dom: {
|
|
30
|
+
button: {
|
|
31
|
+
className: null,
|
|
32
|
+
},
|
|
33
|
+
buttonLiner: {
|
|
34
|
+
tag: null,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
buttons: [
|
|
38
|
+
{
|
|
39
|
+
extend: 'colvis',
|
|
40
|
+
columns: options.visibleColumns,
|
|
41
|
+
text: '<i class="ki-solid ki-gear fs-1"></i>',
|
|
42
|
+
// className: 'btn btn-sm btn-icon btn-color-primary btn-active-light-primary',
|
|
43
|
+
className: 'btn btn-icon btn-color-gray-500 btn-active-color-primary',
|
|
44
|
+
align: 'container',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Remove custom options as they are no longer needed.
|
|
50
|
+
delete options.columnVisibility;
|
|
51
|
+
delete options.visibleColumns;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Generates a unique state key for the DataTable.
|
|
56
|
+
* @param {object} settings DataTables settings object.
|
|
57
|
+
* @return {string} The generated state key.
|
|
58
|
+
*/
|
|
59
|
+
const getStateKey = (settings) => {
|
|
60
|
+
let stateKey = settings.sTableId;
|
|
61
|
+
stateKey += '_';
|
|
62
|
+
stateKey += location.pathname;
|
|
63
|
+
if (settings.nTable.getAttribute('data-ref')) {
|
|
64
|
+
stateKey += '/_';
|
|
65
|
+
stateKey += settings.nTable.getAttribute('data-ref');
|
|
66
|
+
}
|
|
67
|
+
return stateKey;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// // Set locale to Japanese.
|
|
72
|
+
// options.locale = 'ja';
|
|
73
|
+
|
|
74
|
+
// Save sorting criteria.
|
|
75
|
+
options.stateSave = true;
|
|
76
|
+
options.stateSaveCallback = (settings, data) => {
|
|
77
|
+
// Save state with a name that doesn't conflict with other tables.
|
|
78
|
+
localStorage.setItem(getStateKey(settings), JSON.stringify(data));
|
|
79
|
+
};
|
|
80
|
+
options.stateLoadCallback = (settings) => {
|
|
81
|
+
// Return the saved state.
|
|
82
|
+
return JSON.parse(localStorage.getItem(getStateKey(settings)));
|
|
83
|
+
};
|
|
84
|
+
options.stateSaveParams = (settings, data) => {
|
|
85
|
+
// Don't save search criteria and offset.
|
|
86
|
+
delete data.search;
|
|
87
|
+
delete data.start;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
super(table, options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Handles AJAX errors.
|
|
95
|
+
* @param {number} code The HTTP status code of the error.
|
|
96
|
+
* @return {void}
|
|
97
|
+
*/
|
|
98
|
+
ajaxErrorHook(code) {
|
|
99
|
+
if (code === 401) {
|
|
100
|
+
// Redirect to login page if authentication error occurs.
|
|
101
|
+
location.replace('/');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import '~/
|
|
1
|
+
import '~/users.css';
|
|
2
2
|
import hbs from 'handlebars-extd';
|
|
3
3
|
import {components} from 'metronic-extension';
|
|
4
|
+
import Datatable from '~/shared/Datatable';
|
|
4
5
|
import UserApi from '~/api/UserApi';
|
|
5
|
-
import UserModal from '~/
|
|
6
|
+
import UserModal from '~/modals/UserModal';
|
|
6
7
|
|
|
7
8
|
function initTable() {
|
|
8
|
-
userTable = new
|
|
9
|
+
userTable = new Datatable(ref.userTable, {
|
|
9
10
|
ajax: {
|
|
10
11
|
url: '/api/users',
|
|
11
12
|
data: d => {
|
|
@@ -15,9 +15,9 @@ module.exports = {
|
|
|
15
15
|
},
|
|
16
16
|
entry: {
|
|
17
17
|
app: './src/app.js',
|
|
18
|
-
login: './src/
|
|
19
|
-
users: './src/
|
|
20
|
-
editPersonal: './src/
|
|
18
|
+
login: './src/login.js',
|
|
19
|
+
users: './src/users.js',
|
|
20
|
+
editPersonal: './src/editPersonal.js'
|
|
21
21
|
},
|
|
22
22
|
output: {
|
|
23
23
|
path: path.resolve(__dirname, '../public/build'),
|
|
@@ -86,10 +86,62 @@ var __webpack_exports__ = {};
|
|
|
86
86
|
|
|
87
87
|
// EXTERNAL MODULE: ./node_modules/metronic-extension/dist/build.js
|
|
88
88
|
var build = __webpack_require__(236);
|
|
89
|
+
;// CONCATENATED MODULE: ./src/shared/Api.js
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Base API client class.
|
|
94
|
+
*/
|
|
95
|
+
/* harmony default export */ const Api = (class extends build.components.Api {
|
|
96
|
+
/**
|
|
97
|
+
* Initializes the API client.
|
|
98
|
+
* @param {string} path The base URL for requests.
|
|
99
|
+
*/
|
|
100
|
+
constructor(path) {
|
|
101
|
+
super(path, null, {
|
|
102
|
+
headers: {
|
|
103
|
+
// Indicate an AJAX request to the server.
|
|
104
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// /**
|
|
110
|
+
// * Initializes the API client.
|
|
111
|
+
// * @param {string} path The base URL for requests.
|
|
112
|
+
// * @param {string} [origin] The origin for requests.
|
|
113
|
+
// * @param {import('axios').AxiosRequestConfig} [options] Additional options for the Axios instance.
|
|
114
|
+
// */
|
|
115
|
+
// constructor(path, origin, options) {
|
|
116
|
+
// super(path, origin, Object.assign({}, {
|
|
117
|
+
// headers: {
|
|
118
|
+
// // Indicate an AJAX request to the server.
|
|
119
|
+
// 'X-Requested-With': 'XMLHttpRequest',
|
|
120
|
+
// },
|
|
121
|
+
// }, options));
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Handles API errors.
|
|
126
|
+
* @param {number} code The HTTP status code.
|
|
127
|
+
* @param {Error} err The error object.
|
|
128
|
+
* @return {void}
|
|
129
|
+
*/
|
|
130
|
+
errorHook(code, err) {
|
|
131
|
+
// Check if the error object and request properties exist to avoid runtime errors
|
|
132
|
+
if (err && err.request && err.request.responseURL) {
|
|
133
|
+
const {pathname} = new URL(err.request.responseURL);
|
|
134
|
+
if (pathname !== '/api/users/login' && code === 401) {
|
|
135
|
+
// Redirect to the login page if an authentication error occurs on a non-login request.
|
|
136
|
+
location.replace('/');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
89
141
|
;// CONCATENATED MODULE: ./src/api/UserApi.js
|
|
90
142
|
|
|
91
143
|
|
|
92
|
-
/* harmony default export */ const UserApi = (class extends
|
|
144
|
+
/* harmony default export */ const UserApi = (class extends components.Api {
|
|
93
145
|
constructor() {
|
|
94
146
|
super('/api/users');
|
|
95
147
|
}
|
|
@@ -122,7 +174,7 @@ var build = __webpack_require__(236);
|
|
|
122
174
|
return this.client.put('/profile', formData);
|
|
123
175
|
}
|
|
124
176
|
});
|
|
125
|
-
;// CONCATENATED MODULE: ./src/
|
|
177
|
+
;// CONCATENATED MODULE: ./src/editPersonal.js
|
|
126
178
|
|
|
127
179
|
|
|
128
180
|
|