express-sweet-generator 2.0.3 → 2.0.5
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/screencaps/404-error.jpeg +0 -0
- package/screencaps/500-error.jpeg +0 -0
- package/templates/cjs/config/config.js +10 -5
- 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/cjs/routes/api/users.js +2 -0
- package/templates/cjs/routes/login.js +2 -0
- package/templates/cjs/routes/users.js +2 -0
- package/templates/cjs/views/errors/404.hbs +44 -0
- package/templates/cjs/views/errors/500.hbs +44 -0
- package/templates/cjs/views/layout/default.hbs +2 -2
- 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/config/config.js +10 -5
- 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/esm/routes/api/users.js +2 -0
- package/templates/esm/routes/login.js +2 -0
- package/templates/esm/routes/users.js +2 -0
- package/templates/esm/views/errors/404.hbs +44 -0
- package/templates/esm/views/errors/500.hbs +44 -0
- package/templates/esm/views/layout/default.hbs +2 -2
- 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
|
@@ -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'),
|
|
@@ -70,12 +70,17 @@ export default {
|
|
|
70
70
|
* @example
|
|
71
71
|
* hook_handle_error: (err, req, res, next) => {
|
|
72
72
|
* if (err.status === 404)
|
|
73
|
-
* // If the URL cannot be found, a 404 error screen (views/
|
|
74
|
-
* res.render('
|
|
73
|
+
* // If the URL cannot be found, a 404 error screen (views/errors/404.hbs) is displayed.
|
|
74
|
+
* res.render('errors/404');
|
|
75
75
|
* else
|
|
76
|
-
* // For other errors, unknown error screen (views/error
|
|
77
|
-
* res.render('error
|
|
76
|
+
* // For other errors, unknown error screen (views/error/500.hbs) is displayed.
|
|
77
|
+
* res.render('error/500');
|
|
78
78
|
* },
|
|
79
79
|
*/
|
|
80
|
-
hook_handle_error:
|
|
80
|
+
hook_handle_error: (err, req, res, next) => {
|
|
81
|
+
if (err.status === 404)
|
|
82
|
+
res.status(404).render('errors/404', {isErrorPage: true});
|
|
83
|
+
else
|
|
84
|
+
res.status(500).render('errors/500', {isErrorPage: true});
|
|
85
|
+
},
|
|
81
86
|
}
|
|
@@ -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 => {
|
|
@@ -6,6 +6,7 @@ import UserNotFound from '../../exceptions/UserNotFound.js';
|
|
|
6
6
|
import * as CustomValidation from '../../shared/CustomValidation.js';
|
|
7
7
|
|
|
8
8
|
const router = Router();
|
|
9
|
+
|
|
9
10
|
router.post('/login', [
|
|
10
11
|
body('email').trim().not().isEmpty().isEmail(),
|
|
11
12
|
body('password').trim().not().isEmpty()
|
|
@@ -111,4 +112,5 @@ router.put('/profile', [
|
|
|
111
112
|
next(err);
|
|
112
113
|
}
|
|
113
114
|
});
|
|
115
|
+
|
|
114
116
|
export default router;
|
|
@@ -2,6 +2,7 @@ import {Router} from 'express';
|
|
|
2
2
|
import UserModel from '../models/UserModel.js';
|
|
3
3
|
|
|
4
4
|
const router = Router();
|
|
5
|
+
|
|
5
6
|
router.get('/', (req, res) => {
|
|
6
7
|
res.render('users');
|
|
7
8
|
});
|
|
@@ -15,4 +16,5 @@ router.get('/edit-personal', async (req, res) => {
|
|
|
15
16
|
const user = await UserModel.getUser(req.user.id);
|
|
16
17
|
res.render('edit-personal', {user: user.toJSON()});
|
|
17
18
|
});
|
|
19
|
+
|
|
18
20
|
export default router;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{{!< default}}
|
|
2
|
+
{{#contentFor 'title'}}404 Error: Page Not Found{{/contentFor}}
|
|
3
|
+
{{#contentFor 'style'}}
|
|
4
|
+
<style>
|
|
5
|
+
body {
|
|
6
|
+
background-image: url('/build/theme/media/auth/bg6.jpg');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[data-bs-theme="dark"] body {
|
|
10
|
+
background-image: url('/build/theme/media/auth/bg6-dark.jpg');
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
{{/contentFor}}
|
|
14
|
+
<!--begin::Authentication - Signup Welcome Message -->
|
|
15
|
+
<div class="d-flex flex-column flex-center flex-column-fluid">
|
|
16
|
+
<!--begin::Content-->
|
|
17
|
+
<div class="d-flex flex-column flex-center text-center p-10">
|
|
18
|
+
<!--begin::Wrapper-->
|
|
19
|
+
<div class="card card-flush w-lg-650px py-5">
|
|
20
|
+
<div class="card-body py-15 py-lg-20">
|
|
21
|
+
<!--begin::Title-->
|
|
22
|
+
<h1 class="fw-bolder fs-2hx mb-4">404 Error: Page Not Found</h1>
|
|
23
|
+
<!--end::Title-->
|
|
24
|
+
<!--begin::Text-->
|
|
25
|
+
<div class="fw-semibold fs-6 mb-7">The page you requested could not be found. Please check the URL and try again. If the problem persists, please contact us.</div>
|
|
26
|
+
<!--end::Text-->
|
|
27
|
+
<!--begin::Illustration-->
|
|
28
|
+
<div class="mb-3">
|
|
29
|
+
<img src="/build/theme/media/auth/404-error.png" class="mw-100 mh-300px theme-light-show" alt="" />
|
|
30
|
+
<img src="/build/theme/media/auth/404-error-dark.png" class="mw-100 mh-300px theme-dark-show" alt="" />
|
|
31
|
+
</div>
|
|
32
|
+
<!--end::Illustration-->
|
|
33
|
+
<!--begin::Link-->
|
|
34
|
+
<div class="mb-0">
|
|
35
|
+
<a href="/" class="btn btn-sm btn-primary">Back to Home</a>
|
|
36
|
+
</div>
|
|
37
|
+
<!--end::Link-->
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<!--end::Wrapper-->
|
|
41
|
+
</div>
|
|
42
|
+
<!--end::Content-->
|
|
43
|
+
</div>
|
|
44
|
+
<!--end::Authentication - Signup Welcome Message-->
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{{!< default}}
|
|
2
|
+
{{#contentFor 'title'}}500 Error: Server Error{{/contentFor}}
|
|
3
|
+
{{#contentFor 'style'}}
|
|
4
|
+
<style>
|
|
5
|
+
body {
|
|
6
|
+
background-image: url('/build/theme/media/auth/bg6.jpg');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[data-bs-theme="dark"] body {
|
|
10
|
+
background-image: url('/build/theme/media/auth/bg6-dark.jpg');
|
|
11
|
+
}
|
|
12
|
+
</style>
|
|
13
|
+
{{/contentFor}}
|
|
14
|
+
<!--begin::Authentication - Signup Welcome Message -->
|
|
15
|
+
<div class="d-flex flex-column flex-center flex-column-fluid">
|
|
16
|
+
<!--begin::Content-->
|
|
17
|
+
<div class="d-flex flex-column flex-center text-center p-10">
|
|
18
|
+
<!--begin::Wrapper-->
|
|
19
|
+
<div class="card card-flush w-lg-650px py-5">
|
|
20
|
+
<div class="card-body py-15 py-lg-20">
|
|
21
|
+
<!--begin::Title-->
|
|
22
|
+
<h1 class="fw-bolder fs-2hx mb-4">500 Error: Server Error</h1>
|
|
23
|
+
<!--end::Title-->
|
|
24
|
+
<!--begin::Text-->
|
|
25
|
+
<div class="fw-semibold fs-6 mb-7">We're sorry, a server error has occurred. Please try again later. If the problem persists, please contact us.</div>
|
|
26
|
+
<!--end::Text-->
|
|
27
|
+
<!--begin::Illustration-->
|
|
28
|
+
<div class="mb-3">
|
|
29
|
+
<img src="/build/theme/media/auth/500-error.png" class="mw-100 mh-300px theme-light-show" alt="" />
|
|
30
|
+
<img src="/build/theme/media/auth/500-error-dark.png" class="mw-100 mh-300px theme-dark-show" alt="" />
|
|
31
|
+
</div>
|
|
32
|
+
<!--end::Illustration-->
|
|
33
|
+
<!--begin::Link-->
|
|
34
|
+
<div class="mb-0">
|
|
35
|
+
<a href="/" class="btn btn-sm btn-primary">Back to Home</a>
|
|
36
|
+
</div>
|
|
37
|
+
<!--end::Link-->
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<!--end::Wrapper-->
|
|
41
|
+
</div>
|
|
42
|
+
<!--end::Content-->
|
|
43
|
+
</div>
|
|
44
|
+
<!--end::Authentication - Signup Welcome Message-->
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<!--begin::Body-->
|
|
24
24
|
<body
|
|
25
25
|
id="kt_app_body"
|
|
26
|
-
{{#if session}}
|
|
26
|
+
{{#if (and (notEmpty session) (neq isErrorPage true))}}
|
|
27
27
|
data-kt-app-layout="light-sidebar"
|
|
28
28
|
data-kt-app-header-fixed="true"
|
|
29
29
|
data-kt-app-sidebar-enabled="true"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
</script>
|
|
57
57
|
<!--end::Theme mode setup on page load-->
|
|
58
|
-
{{#if session}}
|
|
58
|
+
{{#if (and (notEmpty session) (neq isErrorPage true))}}
|
|
59
59
|
<!--begin::App-->
|
|
60
60
|
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
|
|
61
61
|
<!--begin::Page-->
|