@griddo/ax 1.55.13 → 1.56.1
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 +2 -2
- package/src/GlobalStore.tsx +3 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +6 -0
- package/src/components/Fields/Wysiwyg/config.tsx +0 -1
- package/src/components/Fields/Wysiwyg/index.tsx +16 -5
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +110 -99
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +75 -55
- package/src/components/Gallery/GalleryPanel/index.tsx +14 -8
- package/src/components/Gallery/index.tsx +113 -151
- package/src/components/Gallery/style.tsx +40 -10
- package/src/components/MainWrapper/AppBar/index.tsx +1 -0
- package/src/components/Toast/index.tsx +15 -9
- package/src/components/Toast/style.tsx +2 -2
- package/src/containers/Gallery/actions.tsx +171 -0
- package/src/containers/Gallery/constants.tsx +18 -0
- package/src/containers/Gallery/index.tsx +7 -0
- package/src/containers/Gallery/interfaces.tsx +41 -0
- package/src/containers/Gallery/reducer.tsx +78 -0
- package/src/containers/PageEditor/actions.tsx +15 -5
- package/src/containers/StructuredData/actions.tsx +4 -21
- package/src/forms/fields.tsx +19 -6
- package/src/guards/error/index.tsx +3 -1
- package/src/modules/Content/HeaderMenus/Live/index.tsx +6 -5
- package/src/modules/Sites/SitesList/index.tsx +1 -1
- package/src/modules/StructuredData/Form/ConnectedField/index.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +10 -4
- package/src/modules/StructuredData/StructuredDataList/HeaderMenus/Live/index.tsx +1 -1
- package/src/types/index.tsx +20 -0
- package/src/components/Gallery/store.tsx +0 -186
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { isReqOk, compressImage } from "@ax/helpers";
|
|
2
|
-
import { images, sites } from "@ax/api";
|
|
3
|
-
|
|
4
|
-
const SET_DROP_DEPTH = "SET_DROP_DEPTH";
|
|
5
|
-
const SET_IN_DROP_ZONE = "SET_IN_DROP_ZONE";
|
|
6
|
-
const SET_IS_UPLOADING = "SET_IS_UPLOADING";
|
|
7
|
-
const SET_UPLOAD_SUCCESS = "SET_UPLOAD_SUCCESS";
|
|
8
|
-
const SET_UPLOAD_ERROR = "SET_UPLOAD_ERROR";
|
|
9
|
-
const SET_INIT_FORM = "SET_INIT_FORM";
|
|
10
|
-
const SET_FORM_FIELD = "SET_FORM_FIELD";
|
|
11
|
-
const THUMB_WIDTH = 128;
|
|
12
|
-
const THUMB_HEIGHT = 96;
|
|
13
|
-
const MAX_SIZE = 10; // MB
|
|
14
|
-
|
|
15
|
-
export const ITEMS_PER_PAGE = 50;
|
|
16
|
-
|
|
17
|
-
export const reducer = (prevState: IGalleryStore, action: any): IGalleryStore => {
|
|
18
|
-
switch (action.type) {
|
|
19
|
-
case SET_DROP_DEPTH:
|
|
20
|
-
return { ...prevState, dropDepth: action.payload.dropDepth };
|
|
21
|
-
case SET_IN_DROP_ZONE:
|
|
22
|
-
return {
|
|
23
|
-
...prevState,
|
|
24
|
-
inDropZone: action.payload.inDropZone,
|
|
25
|
-
isUploading: false,
|
|
26
|
-
isError: false,
|
|
27
|
-
isSuccess: false,
|
|
28
|
-
errorMsg: "",
|
|
29
|
-
};
|
|
30
|
-
case SET_IS_UPLOADING:
|
|
31
|
-
return { ...prevState, inDropZone: false, isUploading: true };
|
|
32
|
-
case SET_UPLOAD_SUCCESS:
|
|
33
|
-
return { ...prevState, isUploading: false, isSuccess: true };
|
|
34
|
-
case SET_UPLOAD_ERROR:
|
|
35
|
-
return { ...prevState, inDropZone: false, isUploading: false, isError: true, errorMsg: action.payload.msg };
|
|
36
|
-
case SET_INIT_FORM:
|
|
37
|
-
return {
|
|
38
|
-
...prevState,
|
|
39
|
-
imageForm: {
|
|
40
|
-
id: action.payload.id,
|
|
41
|
-
alt: action.payload.alt,
|
|
42
|
-
title: action.payload.title,
|
|
43
|
-
description: action.payload.description,
|
|
44
|
-
tags: action.payload.tags,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
case SET_FORM_FIELD:
|
|
48
|
-
return { ...prevState, imageForm: { ...prevState.imageForm, [action.payload.field]: action.payload.value } };
|
|
49
|
-
default:
|
|
50
|
-
return prevState;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export function setDropDepth(dropDepth: number) {
|
|
55
|
-
return { type: SET_DROP_DEPTH, payload: { dropDepth } };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function setInDropZone(inDropZone: boolean) {
|
|
59
|
-
return { type: SET_IN_DROP_ZONE, payload: { inDropZone } };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function setIsUploading() {
|
|
63
|
-
return { type: SET_IS_UPLOADING };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function setUploadSuccess() {
|
|
67
|
-
return { type: SET_UPLOAD_SUCCESS };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function setUploadError(errorMsg = "") {
|
|
71
|
-
return { type: SET_UPLOAD_ERROR, payload: { errorMsg } };
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function setInitForm(imageData: IImageForm) {
|
|
75
|
-
return {
|
|
76
|
-
type: SET_INIT_FORM,
|
|
77
|
-
payload: {
|
|
78
|
-
id: imageData.id,
|
|
79
|
-
title: imageData.title ? imageData.title : "",
|
|
80
|
-
alt: imageData.alt ? imageData.alt : "",
|
|
81
|
-
description: imageData.description ? imageData.description : "",
|
|
82
|
-
tags: imageData.tags ? imageData.tags : [],
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function setFormField(field: string, value: string) {
|
|
88
|
-
return { type: SET_FORM_FIELD, payload: { field, value } };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const getSiteImages = async (props: IGetSiteImages): Promise<any> => {
|
|
92
|
-
const { site, page = 1, items = null, query, search } = props
|
|
93
|
-
try {
|
|
94
|
-
const result = await sites.getSiteImages(site, page, items, THUMB_WIDTH, THUMB_HEIGHT, query, search);
|
|
95
|
-
if (isReqOk(result.status)) {
|
|
96
|
-
return result.data.items;
|
|
97
|
-
}
|
|
98
|
-
} catch (e) {
|
|
99
|
-
console.log(e);
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const uploadImage = async (imageFile: File, site: number | string) => {
|
|
105
|
-
try {
|
|
106
|
-
const imageSize = imageFile.size / (1024 * 1024);
|
|
107
|
-
const image = imageSize >= MAX_SIZE ? await compressImage(imageFile, 9999, 9999, MAX_SIZE, false) : imageFile;
|
|
108
|
-
|
|
109
|
-
const form = new FormData();
|
|
110
|
-
form.append("file", image);
|
|
111
|
-
site && form.append("site", JSON.stringify(site));
|
|
112
|
-
const result = await images.createImage(form);
|
|
113
|
-
if (isReqOk(result.status)) {
|
|
114
|
-
return result.data;
|
|
115
|
-
}
|
|
116
|
-
} catch (e) {
|
|
117
|
-
console.log(e);
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const saveImageData = async (imageID: number, imageData: IImageForm) => {
|
|
123
|
-
try {
|
|
124
|
-
const result = await images.updateImage(imageID, imageData);
|
|
125
|
-
if (isReqOk(result.status)) {
|
|
126
|
-
return result.data;
|
|
127
|
-
}
|
|
128
|
-
} catch (e) {
|
|
129
|
-
console.log(e);
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const deleteImageData = async (imageID: number) => {
|
|
135
|
-
try {
|
|
136
|
-
const result = await images.deleteImage(imageID);
|
|
137
|
-
if (isReqOk(result.status)) {
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
} catch (e) {
|
|
141
|
-
console.log(e);
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export const initialState: IGalleryStore = {
|
|
147
|
-
dropDepth: 0,
|
|
148
|
-
inDropZone: false,
|
|
149
|
-
isUploading: false,
|
|
150
|
-
isSuccess: false,
|
|
151
|
-
isError: false,
|
|
152
|
-
errorMsg: "",
|
|
153
|
-
imageForm: {
|
|
154
|
-
id: undefined,
|
|
155
|
-
alt: "",
|
|
156
|
-
title: "",
|
|
157
|
-
description: "",
|
|
158
|
-
tags: [],
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
interface IImageForm {
|
|
163
|
-
id?: number;
|
|
164
|
-
alt: string;
|
|
165
|
-
title: string;
|
|
166
|
-
description: string;
|
|
167
|
-
tags: string[];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
interface IGalleryStore {
|
|
171
|
-
dropDepth: number;
|
|
172
|
-
inDropZone: boolean;
|
|
173
|
-
isUploading: boolean;
|
|
174
|
-
isSuccess: boolean;
|
|
175
|
-
isError: boolean;
|
|
176
|
-
errorMsg: string;
|
|
177
|
-
imageForm: IImageForm;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
interface IGetSiteImages {
|
|
181
|
-
site: number | string;
|
|
182
|
-
page?: number;
|
|
183
|
-
items: number | null;
|
|
184
|
-
query?: string;
|
|
185
|
-
search?: string;
|
|
186
|
-
}
|