@galadrim/galadmin 0.1.2 → 0.1.7
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 +21 -0
- package/dist/api.d.ts +1 -1
- package/dist/api.js +48 -7
- package/dist/api.js.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/config.d.ts +25 -10
- package/package.json +4 -2
- package/src/api.ts +82 -43
- package/src/front/build/asset-manifest.json +7 -7
- package/src/front/build/index.html +1 -1
- package/src/front/build/static/js/{2.f7eb6c73.chunk.js → 2.778cdac1.chunk.js} +3 -3
- package/src/front/build/static/js/{2.f7eb6c73.chunk.js.LICENSE.txt → 2.778cdac1.chunk.js.LICENSE.txt} +0 -0
- package/src/front/build/static/js/2.778cdac1.chunk.js.map +1 -0
- package/src/front/build/static/js/main.906f8841.chunk.js +2 -0
- package/src/front/build/static/js/main.906f8841.chunk.js.map +1 -0
- package/src/front/node_modules/.cache/.eslintcache +1 -1
- package/src/front/node_modules/.cache/babel-loader/0568c20044caccc1c4bd148d4199ec33.json +1 -0
- package/src/front/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/a0/a5/02eb7c3686fc0b8b368d7571ac99d9057923ade02523769a0104df72645454c3abb5e1abd7959435a4592ccfc6f625105898092e038cb444bea039289fc9 +1 -0
- package/src/front/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/b0/07/00882278b9090f96b45cc0bfb7f173180669ecfe7e504f30ca9124259e5487022ce69cb10ae73fb72db53540ae644e6cb7c1307c0cb6072963cb97f4e27f +1 -0
- package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/87/08/421190bfe6e50816e059da6c33526c9943732ef856ebd2752d0cbfb4a852 +1 -1
- package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/bc/60/45a8cd3b5ff1c55a654323e4532eaa0218e186e53786ef1acf429ff046a5 +1 -1
- package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/ca/6b/9043d892787bfe3013fe0b053e83a97c9ac666f000bbc21783bbd242c158 +2 -0
- package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/e8/a0/0d48cce4b946fe50c4b6bf34f7e1a52058d2d785e0ff7d6f841b115a2f4a +1 -1
- package/src/front/node_modules/.cache/terser-webpack-plugin/index-v5/f3/67/591e18ebf4c0bef454dd26c51b3a6caca691338ed27811d59ddef26e7031 +2 -0
- package/src/front/src/components/inputs/FileInput.js +6 -3
- package/src/index.ts +22 -5
- package/src/types/config.ts +23 -6
- package/src/front/build/static/js/2.f7eb6c73.chunk.js.map +0 -1
- package/src/front/build/static/js/main.8f781ead.chunk.js +0 -2
- package/src/front/build/static/js/main.8f781ead.chunk.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
3cf466b77b04157d0c4a742d842fd63cacac6073 {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002Fruntime-main.2084140f.js\",\"contentHash\":\"21b0955fafaa36835c2c\"}","integrity":"sha512-EIHWkk+Hu8omZttNSZyf/dcQREufSs8WYrDS8rrnA4aKRWlIARB00JVPiR1DRsuEMh2l+YSkkh+tpa2nXovJ6g==","time":1662453475907,"size":17514}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
5ac8a4e618f2381797609557ce7d4fcb1404faed {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002Fmain.8f781ead.chunk.js\",\"contentHash\":\"b6bbf16acbe634c19888\"}","integrity":"sha512-vfJhxTZF+VrDrRrOcy5KAR41kN1MJXzJ8KiM71J96JiyyAZRLgZaJVJyMvMKxc03pvFMBnigYcrToO2DnNNGGA==","time":1662453475863,"size":370622}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
|
|
2
|
+
65f9891ddd137e1a988359cd9e8161563d54a34f {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002Fmain.906f8841.chunk.js\",\"contentHash\":\"3e4e461c09912379545b\"}","integrity":"sha512-sAcAiCJ4uQkPlrRcwL+38XMYBmns/n5QTzDKkSQlnlSHAizmnLEK5z+3LbU1QK5kTmy3wTB8DLYHKWPLl/Tifw==","time":1662921997975,"size":370622}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
3aa3d3e8b0a2526fe7c3430937895bba40e4e7c6 {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002F2.f7eb6c73.chunk.js\",\"contentHash\":\"2c2bb42462c6cd9cd87b\"}","integrity":"sha512-uLHlengKn8K3XBnif8rWyTch1O+HnExDpM3jMpuAp7WZAOkOJ+Ku7tSEKVN6o/OptJM8OG7zQYQgVWOAtYcwbA==","time":1662453479306,"size":1866754}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
|
|
2
|
+
afb23abf226961013282618eba74c0fc117b2fac {"key":"{\"terser\":\"5.7.1\",\"terser-webpack-plugin\":\"4.2.3\",\"terser-webpack-plugin-options\":{\"test\":new RegExp(\"\\\\.[cm]?js(\\\\?.*)?$\", \"i\"),\"extractComments\":true,\"sourceMap\":true,\"cache\":true,\"cacheKeys\":defaultCacheKeys => defaultCacheKeys,\"parallel\":true,\"include\":undefined,\"exclude\":undefined,\"minify\":undefined,\"terserOptions\":{\"parse\":{\"ecma\":8},\"compress\":{\"ecma\":5,\"warnings\":false,\"comparisons\":false,\"inline\":2},\"mangle\":{\"safari10\":true},\"keep_classnames\":false,\"keep_fnames\":false,\"output\":{\"ecma\":5,\"comments\":false,\"ascii_only\":true},\"ecma\":5}},\"name\":\"static\\u002Fjs\\u002F2.778cdac1.chunk.js\",\"contentHash\":\"ce4b87f45f8664279b8c\"}","integrity":"sha512-oKUC63w2hvwLizaNdXGsmdkFeSOt4CUjdpoBBN9yZFRUw6u14avXlZQ1pFksz8b2JRBYmAkuA4y0RL6gOSifyQ==","time":1662922001500,"size":1867086}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useRef, useState } from "react";
|
|
2
2
|
import axios from "axios";
|
|
3
|
+
import {
|
|
4
|
+
useParams
|
|
5
|
+
} from "react-router-dom";
|
|
3
6
|
|
|
4
7
|
export default ({ column, onChange, initialData }) => {
|
|
5
8
|
const form = useRef(null);
|
|
9
|
+
const { viewIndex } = useParams();
|
|
6
10
|
const [isLoading, setIsLoading] = useState(false)
|
|
7
11
|
const [path, setPath] = useState(initialData?.[column.name])
|
|
8
12
|
|
|
@@ -15,9 +19,8 @@ export default ({ column, onChange, initialData }) => {
|
|
|
15
19
|
url: `/uploadFile`,
|
|
16
20
|
data: f,
|
|
17
21
|
params: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
s3Config: column.s3Config
|
|
22
|
+
viewIndex,
|
|
23
|
+
columnId: column.__id__
|
|
21
24
|
},
|
|
22
25
|
headers: { "Content-Type": "multipart/form-data" }
|
|
23
26
|
})
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as session from "express-session";
|
|
|
3
3
|
import * as SessionStore from "express-mysql-session";
|
|
4
4
|
import * as mysql2 from 'mysql2/promise';
|
|
5
5
|
import dbManager from "./utils/dbManager";
|
|
6
|
+
import * as bcrypt from "bcryptjs";
|
|
6
7
|
|
|
7
8
|
import * as fs from "fs";
|
|
8
9
|
import * as path from "path";
|
|
@@ -51,10 +52,21 @@ export default (config: Config): any => {
|
|
|
51
52
|
name: 'galadmin.sid'
|
|
52
53
|
}));
|
|
53
54
|
|
|
54
|
-
app.post('/api/login', (req, res) => {
|
|
55
|
+
app.post('/api/login', async (req, res) => {
|
|
55
56
|
if (req.body.username === config.auth.username && req.body.password === config.auth.password) {
|
|
56
|
-
req.session.
|
|
57
|
+
req.session.user = { role: "root" }
|
|
57
58
|
res.send({ success: true })
|
|
59
|
+
} else if (config.authRoles) {
|
|
60
|
+
for (const authRole of config.authRoles) {
|
|
61
|
+
const { rows } = await db.query("SELECT * FROM ?? WHERE ?? = ?", [authRole.table, authRole.usernameField, req.body.username]);
|
|
62
|
+
const user = rows.find(x => bcrypt.compareSync(req.body.password, x[authRole.passwordField]))
|
|
63
|
+
if (!user) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
req.session.user = { role: authRole.role, userId: user[authRole.idField] }
|
|
67
|
+
return res.send({ success: true })
|
|
68
|
+
}
|
|
69
|
+
res.send({ success: false })
|
|
58
70
|
} else {
|
|
59
71
|
res.send({ success: false })
|
|
60
72
|
}
|
|
@@ -63,19 +75,24 @@ export default (config: Config): any => {
|
|
|
63
75
|
|
|
64
76
|
app.get('/api/isAuthenticated', (req, res) => {
|
|
65
77
|
res.send({
|
|
66
|
-
isAuthenticated: !!req.session.
|
|
78
|
+
isAuthenticated: !!req.session.user
|
|
67
79
|
})
|
|
68
80
|
})
|
|
69
81
|
|
|
70
82
|
app.use("/api", (req, res, next) => {
|
|
71
|
-
if (req.method === "OPTIONS" || req.session.
|
|
83
|
+
if (req.method === "OPTIONS" || req.session.user) {
|
|
72
84
|
next()
|
|
73
85
|
} else {
|
|
74
86
|
res.sendStatus(401)
|
|
75
87
|
}
|
|
76
88
|
})
|
|
77
89
|
|
|
78
|
-
app.use("/api",
|
|
90
|
+
app.use("/api", (req, res, next) => {
|
|
91
|
+
return api(db, {
|
|
92
|
+
...config,
|
|
93
|
+
views: config.views.filter(x => !x.roles || (req.session.user && x.roles.includes(req.session.user.role)))
|
|
94
|
+
}, req.session.user)(req, res, next)
|
|
95
|
+
})
|
|
79
96
|
|
|
80
97
|
// Serve static files
|
|
81
98
|
app.get("*", (req, res) => {
|
package/src/types/config.ts
CHANGED
|
@@ -107,6 +107,11 @@ export type FileColumn = {
|
|
|
107
107
|
subfolder?: string
|
|
108
108
|
signedUrlNeeded?: boolean,
|
|
109
109
|
region?: string,
|
|
110
|
+
},
|
|
111
|
+
sftpConfig?: {
|
|
112
|
+
host: string,
|
|
113
|
+
user: string,
|
|
114
|
+
password: string
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
|
|
@@ -152,6 +157,7 @@ export type TableView = {
|
|
|
152
157
|
isDesc?: boolean,
|
|
153
158
|
limit?: number,
|
|
154
159
|
filters?: string,
|
|
160
|
+
filtersFromUser?: (userId: number) => string,
|
|
155
161
|
notClickable?: boolean,
|
|
156
162
|
clickToEdit?: boolean,
|
|
157
163
|
customActions?: CustomAction[],
|
|
@@ -161,11 +167,11 @@ export type TableView = {
|
|
|
161
167
|
/** Rendre possible à l'utilisateur de modifier des enregistrements */
|
|
162
168
|
canEdit?: boolean,
|
|
163
169
|
createCallback?: string,
|
|
164
|
-
createCallbackFunction?: ({ id: number, data: any }) => void,
|
|
170
|
+
createCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
|
|
165
171
|
editCallback?: string,
|
|
166
|
-
editCallbackFunction?: ({ id: number, data: any }) => void,
|
|
172
|
+
editCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
|
|
167
173
|
deleteCallback?: string,
|
|
168
|
-
deleteCallbackFunction?: ({ id: number }) => void,
|
|
174
|
+
deleteCallbackFunction?: ({ id }: { id: number }) => void,
|
|
169
175
|
columns: Column[],
|
|
170
176
|
subviews?: Subview[],
|
|
171
177
|
recordViewPanels?: ViewPanel[]
|
|
@@ -204,9 +210,9 @@ export type TablePanel = {
|
|
|
204
210
|
},
|
|
205
211
|
formattedValues?: { [key: string]: string },
|
|
206
212
|
createCallback?: string,
|
|
207
|
-
createCallbackFunction?: ({ id: number, data: any }) => void,
|
|
213
|
+
createCallbackFunction?: ({ id, data }: { id: number, data: any }) => void,
|
|
208
214
|
deleteCallback?: string,
|
|
209
|
-
deleteCallbackFunction?: ({ id: number }) => void,
|
|
215
|
+
deleteCallbackFunction?: ({ id }: { id: number }) => void,
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
export type MapPanel = {
|
|
@@ -255,11 +261,20 @@ export type CustomView = {
|
|
|
255
261
|
|
|
256
262
|
export type BaseTypeView = {
|
|
257
263
|
/** Cache la vue dans le menu latéral */
|
|
258
|
-
hidden?: boolean
|
|
264
|
+
hidden?: boolean,
|
|
265
|
+
roles?: string[]
|
|
259
266
|
}
|
|
260
267
|
|
|
261
268
|
export type View = BaseTypeView & (TableView | IframeView | LinkView | CustomView)
|
|
262
269
|
|
|
270
|
+
export type AuthRole = {
|
|
271
|
+
role: string,
|
|
272
|
+
table: string,
|
|
273
|
+
usernameField: string,
|
|
274
|
+
passwordField: string,
|
|
275
|
+
idField: string,
|
|
276
|
+
}
|
|
277
|
+
|
|
263
278
|
export type Config = {
|
|
264
279
|
/** Nom du projet */
|
|
265
280
|
name: string,
|
|
@@ -278,6 +293,8 @@ export type Config = {
|
|
|
278
293
|
password: string
|
|
279
294
|
},
|
|
280
295
|
|
|
296
|
+
authRoles?: AuthRole[],
|
|
297
|
+
|
|
281
298
|
/** Identifiants de connexion à la base de données */
|
|
282
299
|
mysql: {
|
|
283
300
|
host: string,
|