5htp-core 0.2.1 → 0.2.2
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/package.json +10 -3
- package/src/client/app/index.ts +2 -2
- package/src/client/assets/css/components/card.less +0 -3
- package/src/client/assets/css/components/other.less +2 -4
- package/src/client/assets/css/components/table.less +1 -2
- package/src/client/assets/css/components.less +4 -0
- package/src/client/assets/css/core.less +0 -1
- package/src/client/assets/css/theme.less +2 -2
- package/src/client/assets/css/utils/medias.less +21 -0
- package/src/client/components/Card/index.tsx +8 -5
- package/src/client/components/Dialog/index.less +3 -3
- package/src/client/components/Row/index.less +2 -0
- package/src/client/components/Row/index.tsx +44 -10
- package/src/client/components/Video/index.less +39 -0
- package/src/client/components/Video/index.tsx +69 -0
- package/src/client/components/containers/Popover/index.tsx +2 -2
- package/src/client/components/data/Time.tsx +1 -1
- package/src/client/components/data/progressbar/circular/index.tsx +1 -1
- package/src/client/components/index.ts +24 -8
- package/src/client/components/input/BaseV2/index.tsx +0 -1
- package/src/client/components/{input/BaseV2/index.less → inputv3/base.less} +1 -1
- package/src/client/components/inputv3/base.tsx +73 -0
- package/src/client/components/{input/UploadImage → inputv3/file}/Bouton.tsx +0 -0
- package/src/client/components/inputv3/file/FileToUpload.ts +34 -0
- package/src/client/components/inputv3/file/index.less +59 -0
- package/src/client/components/inputv3/file/index.tsx +157 -0
- package/src/client/components/{input → inputv3/string}/index.tsx +41 -27
- package/src/client/pages/bug.tsx +3 -4
- package/src/client/services/router/index.tsx +0 -1
- package/src/client/services/router/request/api.ts +20 -12
- package/src/client/services/router/request/multipart.ts +27 -0
- package/src/common/data/chaines/greetings.ts +1 -1
- package/src/common/data/dates.ts +1 -1
- package/src/common/data/input/validate.ts +0 -9
- package/src/common/data/markdown.ts +1 -1
- package/src/common/errors/index.ts +16 -12
- package/src/common/router/request/api.ts +11 -3
- package/src/common/validation/schema.ts +21 -20
- package/src/common/validation/validators.ts +3 -6
- package/src/server/app/commands.ts +149 -0
- package/src/server/app/index.ts +23 -4
- package/src/server/app/service.ts +4 -0
- package/src/server/services/cache/commands.ts +41 -0
- package/src/server/services/cache/index.ts +102 -34
- package/src/server/services/console/index.ts +1 -1
- package/src/server/services/database/connection.ts +38 -22
- package/src/server/services/database/datatypes.ts +51 -12
- package/src/server/services/database/index.ts +133 -40
- package/src/server/services/database/metas.ts +63 -37
- package/src/server/services/database/repository.ts +26 -0
- package/src/server/services/email/index.ts +102 -42
- package/src/server/services/fetch/index.ts +110 -0
- package/src/server/services/router/http/multipart.ts +70 -41
- package/src/server/services/router/index.ts +35 -4
- package/src/server/services/router/request/index.ts +8 -6
- package/src/server/services/schema/index.ts +4 -11
- package/src/server/services/schema/request.ts +16 -7
- package/src/server/services/schema/router.ts +6 -2
- package/src/server/{services_old → services/security/encrypt}/aes.ts +33 -14
- package/src/server/services/users/index.ts +3 -3
- package/src/server/services/users/router/index.ts +0 -2
- package/src/types/global/utils.d.ts +11 -1
- package/tsconfig.common.json +3 -0
- package/src/client/components/input/Textarea.tsx +0 -57
- package/src/client/components/input/Upload.tsx +0 -5
- package/src/client/components/input/UploadImage/index.less +0 -93
- package/src/client/components/input/UploadImage/index.tsx +0 -220
- package/src/common/data/file.ts +0 -25
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
.uploadImg {
|
|
2
|
-
position: relative;
|
|
3
|
-
overflow: hidden;
|
|
4
|
-
border-radius: @radius;
|
|
5
|
-
border: dashed 3px var(--cLine);
|
|
6
|
-
min-height: 200px;
|
|
7
|
-
background: @cBgPage + #090909;
|
|
8
|
-
|
|
9
|
-
&:not(.enCours):hover {
|
|
10
|
-
border-color: var(--cAccent);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Encadré
|
|
14
|
-
&.contain {
|
|
15
|
-
width: 100%;
|
|
16
|
-
height: 14.15rem;
|
|
17
|
-
padding: @spacing;
|
|
18
|
-
|
|
19
|
-
> img {
|
|
20
|
-
border-radius: @radius;
|
|
21
|
-
max-width: 100%;
|
|
22
|
-
height: 100%;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.cover {
|
|
27
|
-
width: 15rem;
|
|
28
|
-
height: 14.15rem;
|
|
29
|
-
|
|
30
|
-
> img {
|
|
31
|
-
object-fit: cover;
|
|
32
|
-
width: 100%;
|
|
33
|
-
height: 100%;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.contChamp & {
|
|
37
|
-
width: 100%;
|
|
38
|
-
height: 15rem;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&.imageChoisie {
|
|
42
|
-
border: none;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
> img {
|
|
47
|
-
display: block;
|
|
48
|
-
margin: 0 auto;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.indicateur,
|
|
52
|
-
input[type="file"] {
|
|
53
|
-
position: absolute;
|
|
54
|
-
top: 0; left: 0;
|
|
55
|
-
width: 100%;
|
|
56
|
-
height: 100%;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.indicateur {
|
|
60
|
-
|
|
61
|
-
transition: all .1s linear;
|
|
62
|
-
background: inherit;
|
|
63
|
-
|
|
64
|
-
input[type="file"] {
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
opacity: 0;
|
|
67
|
-
z-index: 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.bouton {
|
|
71
|
-
position: absolute;
|
|
72
|
-
bottom: 5px;
|
|
73
|
-
right: 5px;
|
|
74
|
-
z-index: 2;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Rend l'indicateur semi-transparent
|
|
79
|
-
&.imageChoisie .indicateur {
|
|
80
|
-
opacity: 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&.enCours {
|
|
84
|
-
cursor: wait;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&:hover,
|
|
88
|
-
&.enCours {
|
|
89
|
-
.indicateur {
|
|
90
|
-
opacity: 0.8;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
// Npm
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { ComponentChild } from 'preact';
|
|
7
|
-
|
|
8
|
-
// Composants généraux
|
|
9
|
-
import Bouton from '@client/components/button';
|
|
10
|
-
|
|
11
|
-
// Libs
|
|
12
|
-
import useContext, { useState } from '@/client/context';
|
|
13
|
-
import NormalisedFile from '@common/data/file';
|
|
14
|
-
|
|
15
|
-
// Ressources
|
|
16
|
-
import './index.less';
|
|
17
|
-
|
|
18
|
-
/*----------------------------------
|
|
19
|
-
- OUTILS
|
|
20
|
-
----------------------------------*/
|
|
21
|
-
export const getBase64 = (fichier: Blob) => new Promise((resolve, reject) => {
|
|
22
|
-
|
|
23
|
-
// Conversion de l'image en base24 pour l'afficher
|
|
24
|
-
const reader = new FileReader();
|
|
25
|
-
let imageBase64: string | null = null;
|
|
26
|
-
reader.addEventListener('load', () => {
|
|
27
|
-
|
|
28
|
-
var enc = new TextDecoder("utf-8");
|
|
29
|
-
|
|
30
|
-
// reader.result pout être une chaine ou un arraybuffer
|
|
31
|
-
imageBase64 = reader.result instanceof ArrayBuffer
|
|
32
|
-
? enc.decode(reader.result) // ArrayBuffer => Chaine
|
|
33
|
-
: reader.result;
|
|
34
|
-
|
|
35
|
-
// Affichage
|
|
36
|
-
resolve(imageBase64);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
reader.readAsDataURL(fichier);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const normalizeFile = (file: File) => new NormalisedFile({
|
|
43
|
-
name: file.name,
|
|
44
|
-
type: file.type,
|
|
45
|
-
size: file.size,
|
|
46
|
-
data: undefined,
|
|
47
|
-
original: file
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
/*----------------------------------
|
|
51
|
-
- COMPOSANT
|
|
52
|
-
----------------------------------*/
|
|
53
|
-
/*export default Champ<Props, TValeurDefaut, TValeurOut>('image', { valeurDefaut, saisieManuelle: false }, ({
|
|
54
|
-
nom,
|
|
55
|
-
className,
|
|
56
|
-
render,
|
|
57
|
-
api,
|
|
58
|
-
indication,
|
|
59
|
-
format = 'contain',
|
|
60
|
-
opt,
|
|
61
|
-
remove
|
|
62
|
-
},{ value, state, setState } , rendre) => {*/
|
|
63
|
-
|
|
64
|
-
export default ({
|
|
65
|
-
value: initialValue, render, indication, uploadUrl, className, format = 'contain', remove,
|
|
66
|
-
onSelect
|
|
67
|
-
}: {
|
|
68
|
-
|
|
69
|
-
value?: string,
|
|
70
|
-
render?: (urlImg: string) => ComponentChild,
|
|
71
|
-
indication?: ComponentChild,
|
|
72
|
-
uploadUrl?: string, // Si spécifié, l'envoi se fera juste après la sélection d'un fichier
|
|
73
|
-
className?: string,
|
|
74
|
-
format?: 'contain' | 'cover',
|
|
75
|
-
remove?: () => Promise<void>,
|
|
76
|
-
|
|
77
|
-
onSelect?: (imageUrl: string) => void
|
|
78
|
-
}) => {
|
|
79
|
-
|
|
80
|
-
/*----------------------------------
|
|
81
|
-
- STATE
|
|
82
|
-
----------------------------------*/
|
|
83
|
-
|
|
84
|
-
const { api } = useContext();
|
|
85
|
-
|
|
86
|
-
const [{ urlApercu, progress, value }, setState] = useState({
|
|
87
|
-
value: initialValue,
|
|
88
|
-
urlApercu: undefined as string | undefined,
|
|
89
|
-
progress: false as false | number
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
className = 'uploadImg ' + format + (className === undefined ? '' : ' ' + className)
|
|
93
|
-
|
|
94
|
-
if (!render) {
|
|
95
|
-
className += ' miniature';
|
|
96
|
-
render = (urlImg: string) => (
|
|
97
|
-
<img src={urlImg} />
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (progress !== false)
|
|
102
|
-
className += ' enCours';
|
|
103
|
-
|
|
104
|
-
if (urlApercu !== undefined)
|
|
105
|
-
className += ' imageChoisie';
|
|
106
|
-
|
|
107
|
-
/*----------------------------------
|
|
108
|
-
- ACTIONS
|
|
109
|
-
----------------------------------*/
|
|
110
|
-
|
|
111
|
-
const envoyer = (fichier: File) => {
|
|
112
|
-
|
|
113
|
-
if (!uploadUrl) return;
|
|
114
|
-
|
|
115
|
-
const data = new FormData();
|
|
116
|
-
data.append('image', fichier);
|
|
117
|
-
|
|
118
|
-
return api.post( uploadUrl, data, {
|
|
119
|
-
onProgress: (progress: number) => setState({ progress })
|
|
120
|
-
}).then(( url ) => {
|
|
121
|
-
|
|
122
|
-
if (onSelect !== undefined)
|
|
123
|
-
onSelect(url);
|
|
124
|
-
else
|
|
125
|
-
setState({
|
|
126
|
-
progress: false,
|
|
127
|
-
// Rechargement url image intiale, sans cache
|
|
128
|
-
urlApercu: url + '?' + (new Date().getTime())
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
}).catch(e => {
|
|
132
|
-
|
|
133
|
-
setState({
|
|
134
|
-
progress: false,
|
|
135
|
-
urlApercu: undefined,
|
|
136
|
-
});
|
|
137
|
-
throw e;
|
|
138
|
-
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/*----------------------------------
|
|
143
|
-
- RENDER
|
|
144
|
-
----------------------------------*/
|
|
145
|
-
return (
|
|
146
|
-
<div class={className}>
|
|
147
|
-
|
|
148
|
-
{urlApercu !== undefined && render( urlApercu )}
|
|
149
|
-
|
|
150
|
-
<div class="indicateur row">
|
|
151
|
-
{progress === false ? <>
|
|
152
|
-
|
|
153
|
-
{indication ? (
|
|
154
|
-
|
|
155
|
-
<span>{indication}</span>
|
|
156
|
-
|
|
157
|
-
) : <>
|
|
158
|
-
|
|
159
|
-
<span>Click here to select a File</span>
|
|
160
|
-
|
|
161
|
-
{(value !== undefined && remove !== undefined) && (
|
|
162
|
-
<Bouton icon="trash" async onClick={() => remove().then(() => {
|
|
163
|
-
setState({
|
|
164
|
-
value: undefined,
|
|
165
|
-
progress: false,
|
|
166
|
-
urlApercu: undefined
|
|
167
|
-
});
|
|
168
|
-
})} />
|
|
169
|
-
)}
|
|
170
|
-
|
|
171
|
-
</>}
|
|
172
|
-
|
|
173
|
-
<input type="file" onChange={(c: any) => {
|
|
174
|
-
|
|
175
|
-
const fichier = c.target.files[0] as File;
|
|
176
|
-
if (fichier) {
|
|
177
|
-
|
|
178
|
-
// Indicateur chargement le temps de convertir l'image en base64
|
|
179
|
-
setState({ progress: 0 })
|
|
180
|
-
|
|
181
|
-
// Récup apercu via fichier sélectionné
|
|
182
|
-
getBase64(fichier).then((urlApercu: string) => {
|
|
183
|
-
|
|
184
|
-
// Injection de l'url d'apercu dans le fichier pour pouvoir y accéder en dehors du composant
|
|
185
|
-
//fichier.urlApercu = urlApercu;
|
|
186
|
-
|
|
187
|
-
// Affichage apercu et réinit progressbar
|
|
188
|
-
setState({
|
|
189
|
-
value: normalizeFile(fichier),
|
|
190
|
-
urlApercu,
|
|
191
|
-
progress: uploadUrl ? 0 : false
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// Envoi direct sur endpoint api
|
|
195
|
-
if (uploadUrl)
|
|
196
|
-
envoyer(fichier);
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
}} />
|
|
202
|
-
</> : (
|
|
203
|
-
<div class="col al-center">
|
|
204
|
-
<i src="spin" />
|
|
205
|
-
|
|
206
|
-
<span>
|
|
207
|
-
{progress === 0 ? (
|
|
208
|
-
"Preparing ..."
|
|
209
|
-
) : progress !== 100 ? (
|
|
210
|
-
"Uploading your image ... " + progress + "%"
|
|
211
|
-
) : (
|
|
212
|
-
"Processing your image ..."
|
|
213
|
-
)}
|
|
214
|
-
</span>
|
|
215
|
-
</div>
|
|
216
|
-
)}
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
);
|
|
220
|
-
}
|
package/src/common/data/file.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type Sharp from 'sharp';
|
|
2
|
-
|
|
3
|
-
export default class NormalisedFile {
|
|
4
|
-
|
|
5
|
-
public name: string;
|
|
6
|
-
public size: number;
|
|
7
|
-
public type: string;
|
|
8
|
-
public data: Buffer;
|
|
9
|
-
|
|
10
|
-
public image?: Sharp;
|
|
11
|
-
|
|
12
|
-
public constructor(opts: {
|
|
13
|
-
name: string,
|
|
14
|
-
size: number,
|
|
15
|
-
type: string,
|
|
16
|
-
data: Buffer,
|
|
17
|
-
}) {
|
|
18
|
-
|
|
19
|
-
this.name = opts.name;
|
|
20
|
-
this.size = opts.size;
|
|
21
|
-
this.type = opts.type;
|
|
22
|
-
this.data = opts.data;
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|