@adminforth/upload 1.1.1-next.2 → 1.1.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/build.log CHANGED
@@ -11,5 +11,5 @@ custom/preview.vue
11
11
  custom/tsconfig.json
12
12
  custom/uploader.vue
13
13
 
14
- sent 37,773 bytes received 134 bytes 75,814.00 bytes/sec
15
- total size is 37,291 speedup is 0.98
14
+ sent 37,887 bytes received 134 bytes 76,042.00 bytes/sec
15
+ total size is 37,398 speedup is 0.98
@@ -39,7 +39,11 @@
39
39
  background: rgba(0, 0, 0, 0.8);
40
40
  }
41
41
  .medium-zoom-overlay {
42
- background: rgba(255, 255, 255, 0.8) !important
42
+ z-index: 99;
43
+ background: rgba(255, 255, 255, 0.8) !important;
44
+ }
45
+ html.dark .medium-zoom-overlay {
46
+ background: rgba(17, 24, 39, 0.7) !important;
43
47
  }
44
48
  body.medium-zoom--opened aside {
45
49
  filter: grayscale(1)
@@ -39,7 +39,11 @@
39
39
  background: rgba(0, 0, 0, 0.8);
40
40
  }
41
41
  .medium-zoom-overlay {
42
- background: rgba(255, 255, 255, 0.8) !important
42
+ z-index: 99;
43
+ background: rgba(255, 255, 255, 0.8) !important;
44
+ }
45
+ html.dark .medium-zoom-overlay {
46
+ background: rgba(17, 24, 39, 0.7) !important;
43
47
  }
44
48
  body.medium-zoom--opened aside {
45
49
  filter: grayscale(1)
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
99
99
  modifyResourceConfig: { get: () => super.modifyResourceConfig }
100
100
  });
101
101
  return __awaiter(this, void 0, void 0, function* () {
102
- var _a, _b, _c, _d;
102
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
103
103
  _super.modifyResourceConfig.call(this, adminforth, resourceConfig);
104
104
  // after column to store the path of the uploaded file, add new VirtualColumn,
105
105
  // show only in edit and create views
@@ -149,34 +149,33 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
149
149
  list: false,
150
150
  show: false,
151
151
  filter: false,
152
- },
152
+ }
153
153
  };
154
154
  if (!resourceConfig.columns[pathColumnIndex].components) {
155
155
  resourceConfig.columns[pathColumnIndex].components = {};
156
156
  }
157
- const pathColumn = resourceConfig.columns[pathColumnIndex];
158
- // add preview column to list
159
- resourceConfig.columns[pathColumnIndex].components.list = {
160
- file: this.componentPath('preview.vue'),
161
- meta: pluginFrontendOptions,
162
- };
163
- resourceConfig.columns[pathColumnIndex].components.show = {
164
- file: this.componentPath('preview.vue'),
165
- meta: pluginFrontendOptions,
166
- };
157
+ if (((_e = this.options.preview) === null || _e === void 0 ? void 0 : _e.showInList) || ((_f = this.options.preview) === null || _f === void 0 ? void 0 : _f.showInList) === undefined) {
158
+ // add preview column to list
159
+ resourceConfig.columns[pathColumnIndex].components.list = {
160
+ file: this.componentPath('preview.vue'),
161
+ meta: pluginFrontendOptions,
162
+ };
163
+ }
164
+ if (((_g = this.options.preview) === null || _g === void 0 ? void 0 : _g.showInShow) || ((_h = this.options.preview) === null || _h === void 0 ? void 0 : _h.showInShow) === undefined) {
165
+ resourceConfig.columns[pathColumnIndex].components.show = {
166
+ file: this.componentPath('preview.vue'),
167
+ meta: pluginFrontendOptions,
168
+ };
169
+ }
167
170
  // insert virtual column after path column if it is not already there
168
171
  const virtualColumnIndex = resourceConfig.columns.findIndex((column) => column.name === virtualColumn.name);
169
172
  if (virtualColumnIndex === -1) {
170
173
  resourceConfig.columns.splice(pathColumnIndex + 1, 0, virtualColumn);
171
174
  }
172
- // if showIn of path column has 'create' or 'edit' remove it but use it for virtual column
173
- if (pathColumn.showIn && (pathColumn.showIn.create !== undefined)) {
174
- virtualColumn.showIn = Object.assign(Object.assign({}, virtualColumn.showIn), { create: pathColumn.showIn.create });
175
- pathColumn.showIn = Object.assign(Object.assign({}, pathColumn.showIn), { create: false });
176
- }
177
- if (pathColumn.showIn && (pathColumn.showIn.edit !== undefined)) {
178
- virtualColumn.showIn = Object.assign(Object.assign({}, virtualColumn.showIn), { edit: pathColumn.showIn.edit });
179
- pathColumn.showIn = Object.assign(Object.assign({}, pathColumn.showIn), { edit: false });
175
+ // if showIn of path column has 'create' or 'edit' remove it
176
+ const pathColumn = resourceConfig.columns[pathColumnIndex];
177
+ if (pathColumn.showIn && (pathColumn.showIn.create || pathColumn.showIn.edit)) {
178
+ pathColumn.showIn = Object.assign(Object.assign({}, pathColumn.showIn), { create: false, edit: false });
180
179
  }
181
180
  virtualColumn.required = pathColumn.required;
182
181
  virtualColumn.label = pathColumn.label;
@@ -215,27 +214,25 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
215
214
  }));
216
215
  // ** HOOKS FOR SHOW **//
217
216
  // add show hook to get presigned URL
218
- if (pathColumn.showIn.show) {
219
- resourceConfig.hooks.show.afterDatasourceResponse.push((_a) => __awaiter(this, [_a], void 0, function* ({ response }) {
220
- const record = response[0];
221
- if (!record) {
222
- return { ok: true };
223
- }
224
- if (record[pathColumnName]) {
225
- const s3 = new S3({
226
- credentials: {
227
- accessKeyId: this.options.s3AccessKeyId,
228
- secretAccessKey: this.options.s3SecretAccessKey,
229
- },
230
- region: this.options.s3Region,
231
- });
232
- yield this.genPreviewUrl(record, s3);
233
- }
217
+ resourceConfig.hooks.show.afterDatasourceResponse.push((_a) => __awaiter(this, [_a], void 0, function* ({ response }) {
218
+ const record = response[0];
219
+ if (!record) {
234
220
  return { ok: true };
235
- }));
236
- }
221
+ }
222
+ if (record[pathColumnName]) {
223
+ const s3 = new S3({
224
+ credentials: {
225
+ accessKeyId: this.options.s3AccessKeyId,
226
+ secretAccessKey: this.options.s3SecretAccessKey,
227
+ },
228
+ region: this.options.s3Region,
229
+ });
230
+ yield this.genPreviewUrl(record, s3);
231
+ }
232
+ return { ok: true };
233
+ }));
237
234
  // ** HOOKS FOR LIST **//
238
- if (pathColumn.showIn.list) {
235
+ if (((_j = this.options.preview) === null || _j === void 0 ? void 0 : _j.showInList) || ((_k = this.options.preview) === null || _k === void 0 ? void 0 : _k.showInList) === undefined) {
239
236
  resourceConfig.hooks.list.afterDatasourceResponse.push((_a) => __awaiter(this, [_a], void 0, function* ({ response }) {
240
237
  const s3 = new S3({
241
238
  credentials: {
package/index.ts CHANGED
@@ -150,24 +150,27 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
150
150
  list: false,
151
151
  show: false,
152
152
  filter: false,
153
- },
153
+ }
154
154
  };
155
155
 
156
156
  if (!resourceConfig.columns[pathColumnIndex].components) {
157
157
  resourceConfig.columns[pathColumnIndex].components = {};
158
158
  }
159
- const pathColumn = resourceConfig.columns[pathColumnIndex];
160
159
 
161
- // add preview column to list
162
- resourceConfig.columns[pathColumnIndex].components.list = {
163
- file: this.componentPath('preview.vue'),
164
- meta: pluginFrontendOptions,
165
- };
160
+ if (this.options.preview?.showInList || this.options.preview?.showInList === undefined) {
161
+ // add preview column to list
162
+ resourceConfig.columns[pathColumnIndex].components.list = {
163
+ file: this.componentPath('preview.vue'),
164
+ meta: pluginFrontendOptions,
165
+ };
166
+ }
166
167
 
167
- resourceConfig.columns[pathColumnIndex].components.show = {
168
- file: this.componentPath('preview.vue'),
169
- meta: pluginFrontendOptions,
170
- };
168
+ if (this.options.preview?.showInShow || this.options.preview?.showInShow === undefined) {
169
+ resourceConfig.columns[pathColumnIndex].components.show = {
170
+ file: this.componentPath('preview.vue'),
171
+ meta: pluginFrontendOptions,
172
+ };
173
+ }
171
174
 
172
175
  // insert virtual column after path column if it is not already there
173
176
  const virtualColumnIndex = resourceConfig.columns.findIndex((column: any) => column.name === virtualColumn.name);
@@ -175,16 +178,10 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
175
178
  resourceConfig.columns.splice(pathColumnIndex + 1, 0, virtualColumn);
176
179
  }
177
180
 
178
-
179
- // if showIn of path column has 'create' or 'edit' remove it but use it for virtual column
180
- if (pathColumn.showIn && (pathColumn.showIn.create !== undefined)) {
181
- virtualColumn.showIn = { ...virtualColumn.showIn, create: pathColumn.showIn.create };
182
- pathColumn.showIn = { ...pathColumn.showIn, create: false };
183
- }
184
-
185
- if (pathColumn.showIn && (pathColumn.showIn.edit !== undefined)) {
186
- virtualColumn.showIn = { ...virtualColumn.showIn, edit: pathColumn.showIn.edit };
187
- pathColumn.showIn = { ...pathColumn.showIn, edit: false };
181
+ // if showIn of path column has 'create' or 'edit' remove it
182
+ const pathColumn = resourceConfig.columns[pathColumnIndex];
183
+ if (pathColumn.showIn && (pathColumn.showIn.create || pathColumn.showIn.edit)) {
184
+ pathColumn.showIn = { ...pathColumn.showIn, create: false, edit: false };
188
185
  }
189
186
 
190
187
  virtualColumn.required = pathColumn.required;
@@ -232,33 +229,30 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
232
229
 
233
230
 
234
231
  // add show hook to get presigned URL
235
- if (pathColumn.showIn.show) {
232
+ resourceConfig.hooks.show.afterDatasourceResponse.push(async ({ response }: { response: any }) => {
233
+ const record = response[0];
234
+ if (!record) {
235
+ return { ok: true };
236
+ }
237
+ if (record[pathColumnName]) {
238
+ const s3 = new S3({
239
+ credentials: {
240
+ accessKeyId: this.options.s3AccessKeyId,
241
+ secretAccessKey: this.options.s3SecretAccessKey,
242
+ },
236
243
 
237
- resourceConfig.hooks.show.afterDatasourceResponse.push(async ({ response }: { response: any }) => {
238
- const record = response[0];
239
- if (!record) {
240
- return { ok: true };
241
- }
242
- if (record[pathColumnName]) {
243
- const s3 = new S3({
244
- credentials: {
245
- accessKeyId: this.options.s3AccessKeyId,
246
- secretAccessKey: this.options.s3SecretAccessKey,
247
- },
248
-
249
- region: this.options.s3Region,
250
- });
244
+ region: this.options.s3Region,
245
+ });
251
246
 
252
- await this.genPreviewUrl(record, s3);
253
- }
254
- return { ok: true };
255
- });
256
- }
247
+ await this.genPreviewUrl(record, s3);
248
+ }
249
+ return { ok: true };
250
+ });
257
251
 
258
252
  // ** HOOKS FOR LIST **//
259
253
 
260
254
 
261
- if (pathColumn.showIn.list) {
255
+ if (this.options.preview?.showInList || this.options.preview?.showInList === undefined) {
262
256
  resourceConfig.hooks.list.afterDatasourceResponse.push(async ({ response }: { response: any }) => {
263
257
  const s3 = new S3({
264
258
  credentials: {
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "1.1.1-next.2",
3
+ "version": "1.1.1",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "homepage": "https://adminforth.dev/docs/tutorial/Plugins/upload/",
8
7
  "repository": {
9
8
  "type": "git",
10
9
  "url": "https://github.com/devforth/adminforth-upload.git"
@@ -20,13 +19,6 @@
20
19
  "@aws-sdk/client-s3": "^3.629.0",
21
20
  "@aws-sdk/s3-request-presigner": "^3.629.0"
22
21
  },
23
- "keywords": [
24
- "adminforth",
25
- "upload",
26
- "plugin",
27
- "s3-upload",
28
- "aws-s3"
29
- ],
30
22
  "release": {
31
23
  "plugins": [
32
24
  "@semantic-release/commit-analyzer",
package/types.ts CHANGED
@@ -64,6 +64,18 @@ export type PluginOptions = {
64
64
 
65
65
  preview: {
66
66
 
67
+ /**
68
+ * Whether to show preview of image instead of path in list field
69
+ * By default true
70
+ */
71
+ showInList?: boolean,
72
+
73
+ /**
74
+ * Whether to show preview of image instead of path in list field
75
+ * By default true
76
+ */
77
+ showInShow?: boolean,
78
+
67
79
  /**
68
80
  * Maximum width of the preview image
69
81
  */
package/README.md DELETED
@@ -1,2 +0,0 @@
1
-
2
- Ussage guide and documentation: https://adminforth.dev/docs/tutorial/Plugins/upload/