@xuda.io/xuda-widget-plugin-xuda-drive 1.0.113 → 1.0.115

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/src/runtime.mjs CHANGED
@@ -1,39 +1,39 @@
1
- import * as FilePond from "filepond";
2
- import "filepond/dist/filepond.min.css";
1
+ import * as FilePond from 'filepond';
2
+ import 'filepond/dist/filepond.min.css';
3
3
 
4
4
  window.FilePond = FilePond;
5
5
 
6
- import FilePondPluginFilePoster from "filepond-plugin-file-poster";
7
- import "filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css";
6
+ import FilePondPluginFilePoster from 'filepond-plugin-file-poster';
7
+ import 'filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css';
8
8
 
9
- import FilePondPluginMediaPreview from "filepond-plugin-media-preview";
10
- import "filepond-plugin-media-preview/dist/filepond-plugin-media-preview.css";
9
+ import FilePondPluginMediaPreview from 'filepond-plugin-media-preview';
10
+ import 'filepond-plugin-media-preview/dist/filepond-plugin-media-preview.css';
11
11
 
12
- import FilePondPluginFileValidateType from "filepond-plugin-file-validate-type";
12
+ import FilePondPluginFileValidateType from 'filepond-plugin-file-validate-type';
13
13
 
14
- import * as pintura from "./vendors/pintura/pintura/pintura.js";
15
- import "./vendors/pintura/pintura/pintura.css";
14
+ import * as pintura from './vendors/pintura/pintura/pintura.js';
15
+ import './vendors/pintura/pintura/pintura.css';
16
16
 
17
- import FilePondPluginImageEditor from "./vendors/pintura/filepond-plugin-image-editor";
17
+ import FilePondPluginImageEditor from './vendors/pintura/filepond-plugin-image-editor';
18
18
 
19
- import moment from "moment";
20
- import { createApp } from "vue/dist/vue.esm-bundler";
21
- import "./vendors/tailwind.cdn.js";
22
- import Swiper from "swiper/bundle";
23
- import "swiper/css/bundle";
19
+ import moment from 'moment';
20
+ import { createApp } from 'vue/dist/vue.esm-bundler';
21
+ import './vendors/tailwind.cdn.js';
22
+ import Swiper from 'swiper/bundle';
23
+ import 'swiper/css/bundle';
24
24
 
25
- import "swiper/css/navigation";
26
- import "swiper/css";
25
+ import 'swiper/css/navigation';
26
+ import 'swiper/css';
27
27
 
28
- import FloatingVue from "floating-vue";
29
- import "floating-vue/dist/style.css";
30
- import * as fs from "./vendors/fs-lightbox.js";
28
+ import FloatingVue from 'floating-vue';
29
+ import 'floating-vue/dist/style.css';
30
+ import * as fs from './vendors/fs-lightbox.js';
31
31
 
32
- import { useDropZone, useDebounceFn } from "@vueuse/core";
32
+ import { useDropZone, useDebounceFn } from '@vueuse/core';
33
33
 
34
34
  export async function upload(fields, e) {
35
35
  return new Promise(async (resolve, reject) => {
36
- var overrideAction = "replace";
36
+ var overrideAction = 'replace';
37
37
  var existingFiles = {};
38
38
  fields.method = e.method;
39
39
 
@@ -53,7 +53,7 @@ export async function upload(fields, e) {
53
53
  init_files.push({
54
54
  source: val,
55
55
  options: {
56
- type: "local",
56
+ type: 'local',
57
57
  },
58
58
  });
59
59
  });
@@ -61,10 +61,8 @@ export async function upload(fields, e) {
61
61
 
62
62
  // init files from predefined array
63
63
  if (!_.isEmpty(fields.file_upload_init_file_array)) {
64
- if (typeof fields.file_upload_init_file_array === "string") {
65
- fields.file_upload_init_file_array = eval(
66
- fields.file_upload_init_file_array
67
- );
64
+ if (typeof fields.file_upload_init_file_array === 'string') {
65
+ fields.file_upload_init_file_array = eval(fields.file_upload_init_file_array);
68
66
  }
69
67
  if (fields.file_upload_init_file_array?.length) {
70
68
  init_files_fn(fields.file_upload_init_file_array);
@@ -74,11 +72,11 @@ export async function upload(fields, e) {
74
72
  // init files from bind
75
73
  var initialBindValue;
76
74
 
77
- if (!_.isEmpty(fields["xu-bind"])) {
78
- initialBindValue = await e.api_utils.get_field_value(fields["xu-bind"]);
75
+ if (!_.isEmpty(fields['xu-bind'])) {
76
+ initialBindValue = await e.api_utils.get_field_value(fields['xu-bind']);
79
77
  let value = initialBindValue;
80
- if (typeof value === "string") {
81
- value = value.split(",").filter((e) => e);
78
+ if (typeof value === 'string') {
79
+ value = value.split(',').filter((e) => e);
82
80
  }
83
81
  if (value?.length) {
84
82
  init_files_fn(value);
@@ -105,41 +103,32 @@ export async function upload(fields, e) {
105
103
  // }
106
104
  });
107
105
 
108
- if (!_.isEmpty(fields["xu-bind"])) {
106
+ if (!_.isEmpty(fields['xu-bind'])) {
109
107
  var ret = ret_obj.app_files;
110
- if (typeof initialBindValue === "string")
111
- ret = ret_obj.app_files.map((f) => f.server_fileName).join(",");
108
+ if (typeof initialBindValue === 'string') ret = ret_obj.app_files.map((f) => f.server_fileName).join(',');
112
109
 
113
- await e.api_utils.set_field_value(fields["xu-bind"], ret);
110
+ await e.api_utils.set_field_value(fields['xu-bind'], ret);
114
111
  }
115
112
 
116
113
  if (is_remove && fields.event_name_for_successful_remove_callback) {
117
- await e.api_utils.invoke_event(
118
- fields.event_name_for_successful_remove_callback
119
- );
114
+ await e.api_utils.invoke_event(fields.event_name_for_successful_remove_callback);
120
115
  }
121
116
 
122
117
  if (!is_remove && fields.event_name_for_successful_callback) {
123
- await e.api_utils.invoke_event(
124
- fields.event_name_for_successful_callback
125
- );
118
+ await e.api_utils.invoke_event(fields.event_name_for_successful_callback);
126
119
  }
127
120
 
128
121
  if (fields.clear_on_file_upload) {
129
122
  pond.removeFiles();
130
- e.api_utils.set_field_value(fields["xu-bind"], []);
123
+ e.api_utils.set_field_value(fields['xu-bind'], []);
131
124
  }
132
125
  }, 100);
133
126
  };
134
127
 
135
- var $pallet_wrapper = $(
136
- `<div class="image_wrapper" style="border: none !important;">`
137
- );
128
+ var $pallet_wrapper = $(`<div class="image_wrapper" style="border: none !important;">`);
138
129
 
139
130
  var input_id = new Date().valueOf();
140
- var $imgInp = $(
141
- `<input class="filepond ${widget_cssClass}" id="${input_id}" />`
142
- ).appendTo($pallet_wrapper);
131
+ var $imgInp = $(`<input class="filepond ${widget_cssClass}" id="${input_id}" />`).appendTo($pallet_wrapper);
143
132
 
144
133
  e.$containerP.html($pallet_wrapper);
145
134
 
@@ -158,7 +147,7 @@ export async function upload(fields, e) {
158
147
  </mask>
159
148
  <rect fill="rgba(255,255,255,.3125)" x="0" y="0" width="100%" height="100%" mask="url(#my-mask)"/>
160
149
  <circle cx="50%" cy="50%" r="50%" fill="transparent" stroke-width="1" stroke="#fff"/>
161
- `
150
+ `,
162
151
  );
163
152
  };
164
153
 
@@ -170,10 +159,10 @@ export async function upload(fields, e) {
170
159
  });
171
160
 
172
161
  fetch(url, {
173
- method: "POST",
162
+ method: 'POST',
174
163
  body: e,
175
164
  }).then((res) => {
176
- console.log("Request complete! response:", res);
165
+ console.log('Request complete! response:', res);
177
166
  });
178
167
  };
179
168
 
@@ -191,12 +180,7 @@ export async function upload(fields, e) {
191
180
  imageEditorSupportImage: (file) => {
192
181
  // return /^image/.test(file);
193
182
 
194
- return (
195
- file.type !== "image/svg+xml" &&
196
- file.type !== "image/gif" &&
197
- !file.type.includes("audio") &&
198
- !file.type.includes("video")
199
- );
183
+ return file.type !== 'image/svg+xml' && file.type !== 'image/gif' && !file.type.includes('audio') && !file.type.includes('video');
200
184
  },
201
185
 
202
186
  imageEditor: {
@@ -219,7 +203,7 @@ export async function upload(fields, e) {
219
203
  .then(function (response) {
220
204
  try {
221
205
  if (response.ok) return response.blob();
222
- throw new Error("bad image");
206
+ throw new Error('bad image');
223
207
  } catch (err) {
224
208
  error({});
225
209
  }
@@ -238,41 +222,28 @@ export async function upload(fields, e) {
238
222
  },
239
223
  };
240
224
  },
241
- process: (
242
- fieldName,
243
- file,
244
- metadata,
245
- load,
246
- error,
247
- progress,
248
- abort,
249
- transfer,
250
- options
251
- ) => {
225
+ process: (fieldName, file, metadata, load, error, progress, abort, transfer, options) => {
252
226
  let formData = new FormData();
253
- formData.append("file", file, file.name);
254
- const { app_id, gtp_token, app_token } = e._session;
255
-
256
- formData.append(
257
- "app_id_reference",
258
- APP_OBJ?.[app_id]?.app_id_reference
259
- );
260
- formData.append("app_id", app_id);
261
- formData.append("gtp_token", gtp_token);
262
- formData.append("app_token", app_token);
263
- formData.append("drive_type", "workspace");
264
- if (fields.file_upload_folder)
265
- formData.append("folder", fields.file_upload_folder);
266
- if (fields.public_file)
267
- formData.append("make_public", fields.public_file);
227
+ formData.append('file', file, file.name);
228
+ const { app_id, gtp_token, app_token, api_key } = e._session;
229
+
230
+ formData.append('app_id_reference', APP_OBJ?.[app_id]?.app_id_reference);
231
+ formData.append('app_id', app_id);
232
+ formData.append('gtp_token', gtp_token);
233
+ formData.append('app_token', app_token);
234
+ formData.append('drive_type', 'workspace');
235
+ formData.append('api_key', api_key);
236
+
237
+ if (fields.file_upload_folder) formData.append('folder', fields.file_upload_folder);
238
+ if (fields.public_file) formData.append('make_public', fields.public_file);
268
239
 
269
240
  let tags = fields.assign_file_tags || [];
270
241
 
271
242
  let file_tags = [];
272
243
  if (fields.auto_tag_generator) {
273
- let identifier = fields.auto_tag_identifier || " ";
244
+ let identifier = fields.auto_tag_identifier || ' ';
274
245
 
275
- const filename = file.name.split(".").slice(0, -1).join(".");
246
+ const filename = file.name.split('.').slice(0, -1).join('.');
276
247
  file_tags = filename.split(identifier);
277
248
  if (fields.auto_tag_translation) {
278
249
  for (let tag of file_tags) {
@@ -282,34 +253,25 @@ export async function upload(fields, e) {
282
253
  }
283
254
  }
284
255
  }
285
- formData.append("tags", [...tags, ...file_tags]);
256
+ formData.append('tags', [...tags, ...file_tags]);
286
257
 
287
258
  const request = new XMLHttpRequest();
288
259
 
289
260
  let _domain = e._session.domain;
290
261
  if (e._session.is_deployment) {
291
- _domain =
292
- e._session.opt.regional_server === "dev.xuda.io"
293
- ? "dev.xuda.io"
294
- : "xuda.io";
262
+ _domain = e._session.opt.regional_server === 'dev.xuda.io' ? 'dev.xuda.io' : 'xuda.io';
295
263
  }
296
264
 
297
- if (overrideAction === "replace" && file.name in existingFiles) {
298
- formData.append("file_path", "/" + file.name);
299
- formData.append("file_name", file.name);
300
- request.open(
301
- "POST",
302
- `https://${_domain}/cpi/update_drive_file_workspace`
303
- );
265
+ if (overrideAction === 'replace' && file.name in existingFiles) {
266
+ formData.append('file_path', '/' + file.name);
267
+ formData.append('file_name', file.name);
268
+ request.open('POST', `https://${_domain}/cpi/update_drive_file_workspace`);
304
269
  } else {
305
- request.open(
306
- "POST",
307
- `https://${_domain}/cpi/upload_drive_file_workspace`
308
- );
270
+ request.open('POST', `https://${_domain}/cpi/upload_drive_file_workspace`);
309
271
  }
310
272
 
311
- request.setRequestHeader("xu-gtp-token", gtp_token);
312
- request.setRequestHeader("xu-app-token", app_token);
273
+ request.setRequestHeader('xu-gtp-token', gtp_token);
274
+ request.setRequestHeader('xu-app-token', app_token);
313
275
 
314
276
  // request.open("POST", `https://${_domain}/rpi/runtime_upload_file`);
315
277
 
@@ -345,7 +307,7 @@ export async function upload(fields, e) {
345
307
  var res = JSON.parse(request.responseText);
346
308
 
347
309
  error(res.data);
348
- this.$emit("error", error);
310
+ this.$emit('error', error);
349
311
  };
350
312
 
351
313
  request.send(formData);
@@ -376,36 +338,27 @@ export async function upload(fields, e) {
376
338
  let app_id = e._session.app_id;
377
339
  let app_id_reference = APP_OBJ[app_id].app_id_reference;
378
340
 
379
- axios_ajax(
380
- func.common.get_url(
381
- e.SESSION_ID,
382
- "rpi",
383
- "runtime_delete_file_bulk"
384
- ),
385
- {
386
- app_id,
387
- server_files: ret_obj.deletedArr,
388
- app_id_reference: app_id_reference,
389
- gtp_token: e._session.gtp_token,
390
- }
391
- );
341
+ axios_ajax(func.common.get_url(e.SESSION_ID, 'rpi', 'runtime_delete_file_bulk'), {
342
+ app_id,
343
+ server_files: ret_obj.deletedArr,
344
+ app_id_reference: app_id_reference,
345
+ gtp_token: e._session.gtp_token,
346
+ api_key,
347
+ });
392
348
  load();
393
349
  },
394
350
  remove: (source, load, error) => {
395
- var source_clean = source.split("/").pop();
351
+ var source_clean = source.split('/').pop();
396
352
 
397
353
  ret_obj.deletedArr.push(source_clean);
398
354
 
399
- var myIndex = ret_obj.app_files.indexOf(
400
- (file) => file.server_fileName === source
401
- );
355
+ var myIndex = ret_obj.app_files.indexOf((file) => file.server_fileName === source);
402
356
  if (myIndex !== -1) {
403
357
  ret_obj.app_files.splice(myIndex, 1);
404
358
  }
405
359
 
406
360
  ////////////// CALLBACK
407
- if (fields.instant_file_upload === "N" ? false : true)
408
- do_callback(true);
361
+ if (fields.instant_file_upload === 'N' ? false : true) do_callback(true);
409
362
  // Can call the error method if something is wrong, should exit after
410
363
  // error('oh my goodness');
411
364
 
@@ -426,45 +379,45 @@ export async function upload(fields, e) {
426
379
  opt.files = init_files;
427
380
  }
428
381
 
429
- opt.instantUpload = fields.instant_file_upload === "N" ? false : true;
382
+ opt.instantUpload = fields.instant_file_upload === 'N' ? false : true;
430
383
 
431
384
  if (fields.file_upload_mime_type_preset) {
432
385
  switch (fields.file_upload_mime_type_preset) {
433
- case "image":
434
- opt.acceptedFileTypes = ["image/*"];
386
+ case 'image':
387
+ opt.acceptedFileTypes = ['image/*'];
435
388
  break;
436
- case "video":
437
- opt.acceptedFileTypes = ["video/*"];
389
+ case 'video':
390
+ opt.acceptedFileTypes = ['video/*'];
438
391
  break;
439
- case "audio":
440
- opt.acceptedFileTypes = ["audio/*"];
392
+ case 'audio':
393
+ opt.acceptedFileTypes = ['audio/*'];
441
394
  break;
442
395
  default:
443
- opt.acceptedFileTypes = ["image/*"];
396
+ opt.acceptedFileTypes = ['image/*'];
444
397
  }
445
398
  } else {
446
399
  if (fields.file_upload_custom_mime_types) {
447
- opt.acceptedFileTypes = fields.file_upload_custom_mime_types.split(",");
400
+ opt.acceptedFileTypes = fields.file_upload_custom_mime_types.split(',');
448
401
  } else {
449
402
  opt.allowFileTypeValidation = false;
450
403
  }
451
404
  }
452
405
 
453
- if (fields.file_upload_mask === "circle") {
406
+ if (fields.file_upload_mask === 'circle') {
454
407
  opt.imagePreviewHeight = 170;
455
- opt.imageCropAspectRatio = "1:1";
408
+ opt.imageCropAspectRatio = '1:1';
456
409
  opt.imageResizeTargetWidth = 200;
457
410
  opt.imageResizeTargetHeight = 200;
458
- opt.stylePanelLayout = "compact circle";
459
- opt.styleLoadIndicatorPosition = "center bottom";
460
- opt.styleProgressIndicatorPosition = "right bottom";
461
- opt.styleButtonRemoveItemPosition = "left bottom";
462
- opt.styleButtonProcessItemPosition = "right bottom";
411
+ opt.stylePanelLayout = 'compact circle';
412
+ opt.styleLoadIndicatorPosition = 'center bottom';
413
+ opt.styleProgressIndicatorPosition = 'right bottom';
414
+ opt.styleButtonRemoveItemPosition = 'left bottom';
415
+ opt.styleButtonProcessItemPosition = 'right bottom';
463
416
  }
464
417
 
465
418
  pond = FilePond.create($imgInp[0], opt);
466
419
 
467
- pond.on("processfiles", (e) => {
420
+ pond.on('processfiles', (e) => {
468
421
  do_callback();
469
422
  });
470
423
 
@@ -487,7 +440,7 @@ export async function upload(fields, e) {
487
440
  }
488
441
 
489
442
  export async function viewer(fields, e) {
490
- const { app_id, gtp_token, app_token } = e._session;
443
+ const { app_id, gtp_token, app_token, api_key } = e._session;
491
444
 
492
445
  var sepcialLoader = {
493
446
  template: `
@@ -531,7 +484,7 @@ export async function viewer(fields, e) {
531
484
  };
532
485
 
533
486
  var segmentComponent = {
534
- props: ["options", "modelValue"],
487
+ props: ['options', 'modelValue'],
535
488
  computed: {
536
489
  model: {
537
490
  get() {
@@ -540,7 +493,7 @@ export async function viewer(fields, e) {
540
493
  return value;
541
494
  },
542
495
  set(v) {
543
- this.$emit("update:modelValue", v);
496
+ this.$emit('update:modelValue', v);
544
497
  },
545
498
  },
546
499
  segmentActive() {
@@ -568,7 +521,7 @@ export async function viewer(fields, e) {
568
521
  };
569
522
 
570
523
  var imagePreview = {
571
- props: ["file", "size"],
524
+ props: ['file', 'size'],
572
525
  template: `
573
526
 
574
527
 
@@ -733,7 +686,9 @@ export async function viewer(fields, e) {
733
686
  <div class="mt-2 block truncate font-medium text-sm text-gray-900" v-text="file.name"></div>
734
687
  <div class="flex items-center justify-between text-xs text-gray-500">
735
688
  <div class="truncate" v-text="file.size"></div>
736
- <div class="truncate" v-text="moment(file.date_created).format('lll')"></div>
689
+ <div v-tooltip="{content: (file.date_modified ? '<div> Date modified: '+ moment(file.date_modified).format('lll') + '</div>' : '') +'<div> Date created: '+ moment(file.date_created).format('lll') +'</div>', html: true}" class="truncate">
690
+ {{ file.date_modified ? moment(file.date_modified).format('lll') : moment(file.date_created).format('lll') }}
691
+ </div>
737
692
  </div>
738
693
  </div>
739
694
  <div v-if="view === 'list'" class="flex group items-center justify-between py-2 px-4 hover:bg-neutral-100 transition-all">
@@ -900,14 +855,15 @@ export async function viewer(fields, e) {
900
855
  // }
901
856
 
902
857
  opt.app_id = app_id;
858
+ opt.api_key = api_key;
903
859
 
904
860
  const response = await fetch(`https://${_domain}/cpi/${service}`, {
905
- method: "POST",
861
+ method: 'POST',
906
862
  headers: {
907
- Accept: "application/json",
908
- "Content-Type": "application/json",
909
- "xu-gtp-token": gtp_token,
910
- "xu-app-token": app_token,
863
+ Accept: 'application/json',
864
+ 'Content-Type': 'application/json',
865
+ 'xu-gtp-token': gtp_token,
866
+ 'xu-app-token': app_token,
911
867
  },
912
868
  body: JSON.stringify(opt),
913
869
  });
@@ -923,18 +879,18 @@ export async function viewer(fields, e) {
923
879
 
924
880
  const formatBytes = function (bytes) {
925
881
  if (bytes < 1024) {
926
- return bytes + " Bytes"; // Less than 1 KB
882
+ return bytes + ' Bytes'; // Less than 1 KB
927
883
  } else if (bytes < 1024 * 1024) {
928
- return (bytes / 1024).toFixed(2) + " KB"; // Less than 1 MB
884
+ return (bytes / 1024).toFixed(2) + ' KB'; // Less than 1 MB
929
885
  } else if (bytes < 1024 * 1024 * 1024) {
930
- return (bytes / (1024 * 1024)).toFixed(2) + " MB"; // Less than 1 GB
886
+ return (bytes / (1024 * 1024)).toFixed(2) + ' MB'; // Less than 1 GB
931
887
  } else {
932
- return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB"; // 1 GB or more
888
+ return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB'; // 1 GB or more
933
889
  }
934
890
  };
935
891
 
936
892
  var containerId = crypto.randomUUID();
937
- e.$containerP.attr("widget-id", containerId);
893
+ e.$containerP.attr('widget-id', containerId);
938
894
 
939
895
  var app = createApp({
940
896
  template: html,
@@ -946,27 +902,27 @@ export async function viewer(fields, e) {
946
902
  data() {
947
903
  return {
948
904
  replaceOptions: [
949
- { label: "Replace existing items", value: "replace" },
950
- { label: "Keep all items", value: "keep" },
905
+ { label: 'Replace existing items', value: 'replace' },
906
+ { label: 'Keep all items', value: 'keep' },
951
907
  ],
952
908
  sortDirOptions: [
953
909
  {
954
- label: "Ascending",
955
- value: "asc",
910
+ label: 'Ascending',
911
+ value: 'asc',
956
912
  },
957
913
  {
958
- label: "Descending",
959
- value: "desc",
914
+ label: 'Descending',
915
+ value: 'desc',
960
916
  },
961
917
  ],
962
918
  sortOptions: [
963
919
  {
964
- label: "Date",
965
- value: "date",
920
+ label: 'Date',
921
+ value: 'date',
966
922
  },
967
923
  {
968
- label: "Name",
969
- value: "name",
924
+ label: 'Name',
925
+ value: 'name',
970
926
  },
971
927
  ],
972
928
  viewOptions: [
@@ -978,8 +934,8 @@ export async function viewer(fields, e) {
978
934
  clip-rule="evenodd"
979
935
  ></path>
980
936
  </svg>`,
981
- label: "",
982
- value: "gallery",
937
+ label: '',
938
+ value: 'gallery',
983
939
  },
984
940
  {
985
941
  icon: ` <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@@ -989,22 +945,22 @@ export async function viewer(fields, e) {
989
945
  clip-rule="evenodd"
990
946
  ></path>
991
947
  </svg>`,
992
- label: "",
993
- value: "list",
948
+ label: '',
949
+ value: 'list',
994
950
  },
995
951
  {
996
952
  icon: ` <svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256">
997
953
  <path d="M200,64V192a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H192A8,8,0,0,1,200,64Z" opacity="0.2"></path>
998
954
  <path d="M192,48H64A16,16,0,0,0,48,64V192a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64A16,16,0,0,0,192,48Zm0,144H64V64H192V192ZM240,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0ZM32,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0Z"></path>
999
955
  </svg>`,
1000
- label: "",
1001
- value: "slider",
956
+ label: '',
957
+ value: 'slider',
1002
958
  },
1003
959
  ],
1004
960
  options: fields,
1005
961
  folders: [],
1006
962
  files: [],
1007
- view: fields.default_view_type || "gallery",
963
+ view: fields.default_view_type || 'gallery',
1008
964
  uploadModal: false,
1009
965
  uploaderLoading: false,
1010
966
  loadingSearch: false,
@@ -1012,33 +968,33 @@ export async function viewer(fields, e) {
1012
968
  formatBytes,
1013
969
  initUploader: upload,
1014
970
  swiper: null,
1015
- existingTags: "",
971
+ existingTags: '',
1016
972
  showSearchPopper: false,
1017
973
  isOverDropZone: false,
1018
974
  removeChipCount: 0,
1019
975
  searchOptions: [
1020
976
  {
1021
- label: "Filename",
1022
- tag: "name",
1023
- modifier: "contains",
977
+ label: 'Filename',
978
+ tag: 'name',
979
+ modifier: 'contains',
1024
980
  },
1025
981
  {
1026
- label: "Tag",
1027
- tag: "tag",
1028
- modifier: "equals",
982
+ label: 'Tag',
983
+ tag: 'tag',
984
+ modifier: 'equals',
1029
985
  },
1030
986
  {
1031
- label: "Content",
1032
- tag: "any",
1033
- modifier: "contains",
987
+ label: 'Content',
988
+ tag: 'any',
989
+ modifier: 'contains',
1034
990
  },
1035
991
  ],
1036
992
  opts: {
1037
993
  app_id,
1038
- path: "/",
1039
- search_string: "",
1040
- sort_by: fields.sort_by || "date",
1041
- sort_dir: fields.sort_dir || "asc",
994
+ path: '/',
995
+ search_string: '',
996
+ sort_by: fields.sort_by || 'date',
997
+ sort_dir: fields.sort_dir || 'asc',
1042
998
  ...(fields.filter_tags?.length ? { tags: fields.filter_tags } : {}),
1043
999
  // ...filter_tags
1044
1000
  },
@@ -1047,14 +1003,14 @@ export async function viewer(fields, e) {
1047
1003
  existingFiles: {},
1048
1004
  allLoading: false,
1049
1005
  showExistModal: false,
1050
- overrideAction: "replace",
1006
+ overrideAction: 'replace',
1051
1007
  pond: null,
1052
1008
  processFiles: null,
1053
1009
  };
1054
1010
  },
1055
1011
  methods: {
1056
1012
  async refreshDirectory(all, bypassFolders = false) {
1057
- if (this.view === "slider") bypassFolders = true;
1013
+ if (this.view === 'slider') bypassFolders = true;
1058
1014
 
1059
1015
  this.loadingSearch = true;
1060
1016
 
@@ -1065,17 +1021,17 @@ export async function viewer(fields, e) {
1065
1021
  }
1066
1022
 
1067
1023
  if (!bypassFolders) {
1068
- const folders = await this.fetcher("get_drive_files_workspace", {
1024
+ const folders = await this.fetcher('get_drive_files_workspace', {
1069
1025
  ...this.opts,
1070
- type: "directory",
1026
+ type: 'directory',
1071
1027
  });
1072
1028
  this.folders = folders.data.children || [];
1073
1029
  }
1074
1030
 
1075
- const files = await this.fetcher("get_drive_files_workspace", {
1031
+ const files = await this.fetcher('get_drive_files_workspace', {
1076
1032
  ...this.opts,
1077
1033
  ...(all ? {} : { from: 0, to: this.limit }),
1078
- type: "file",
1034
+ type: 'file',
1079
1035
  });
1080
1036
 
1081
1037
  this.files = files.data.children || [];
@@ -1118,17 +1074,15 @@ export async function viewer(fields, e) {
1118
1074
  let promises = [];
1119
1075
  this.existingFiles = {};
1120
1076
 
1121
- var filesMapped = this.pond
1122
- .getFiles()
1123
- .map((e) => ({ id: e.id, filename: e.file.name }));
1077
+ var filesMapped = this.pond.getFiles().map((e) => ({ id: e.id, filename: e.file.name }));
1124
1078
 
1125
1079
  filesMapped.forEach(({ filename }) => {
1126
1080
  promises.push(
1127
1081
  new Promise((resolve, reject) => {
1128
1082
  this.fetcher(`check_drive_file_workspace`, {
1129
- file_path: "/" + filename,
1083
+ file_path: '/' + filename,
1130
1084
  file_name: filename,
1131
- type: "file",
1085
+ type: 'file',
1132
1086
  })
1133
1087
  .then((e) => {
1134
1088
  resolve(e);
@@ -1144,7 +1098,7 @@ export async function viewer(fields, e) {
1144
1098
 
1145
1099
  reject(err);
1146
1100
  });
1147
- })
1101
+ }),
1148
1102
  );
1149
1103
  });
1150
1104
 
@@ -1156,9 +1110,7 @@ export async function viewer(fields, e) {
1156
1110
  }
1157
1111
 
1158
1112
  filesMapped
1159
- .filter(
1160
- (e) => !Object.keys(this.existingFiles).includes(e.filename)
1161
- )
1113
+ .filter((e) => !Object.keys(this.existingFiles).includes(e.filename))
1162
1114
  .forEach((e) => {
1163
1115
  this.processFiles(e.id);
1164
1116
  });
@@ -1177,10 +1129,10 @@ export async function viewer(fields, e) {
1177
1129
  this.opts.search_string = this.opts.search_string
1178
1130
  .replaceAll(
1179
1131
  this.opts.search_string
1180
- .split(" ")
1181
- .filter((e) => e.includes(":"))
1132
+ .split(' ')
1133
+ .filter((e) => e.includes(':'))
1182
1134
  .at(-1),
1183
- ""
1135
+ '',
1184
1136
  )
1185
1137
  .trim();
1186
1138
  this.removeChipCount = 0;
@@ -1189,12 +1141,11 @@ export async function viewer(fields, e) {
1189
1141
  }
1190
1142
  }
1191
1143
  },
1192
- // hideSearchPopper() {
1193
- // debugger;
1194
- // setTimeout(() => {
1195
- // this.showSearchPopper = false;
1196
- // }, 100);
1197
- // },
1144
+ hideSearchPopper() {
1145
+ setTimeout(() => {
1146
+ this.showSearchPopper = false;
1147
+ }, 100);
1148
+ },
1198
1149
  searchDebounce: _.debounce(async function ($event) {
1199
1150
  await this.refreshDirectory();
1200
1151
  }, 400),
@@ -1202,7 +1153,7 @@ export async function viewer(fields, e) {
1202
1153
  },
1203
1154
  mounted() {
1204
1155
  var onDrop = (files) => {
1205
- if (this.view === "slider") return;
1156
+ if (this.view === 'slider') return;
1206
1157
  this.uploadModal = true;
1207
1158
  this.pond.addFiles(files);
1208
1159
  };
@@ -1215,31 +1166,23 @@ export async function viewer(fields, e) {
1215
1166
  },
1216
1167
  computed: {
1217
1168
  searchTags() {
1218
- return this.opts.search_string
1219
- .split(" ")
1220
- .filter((e) => e.includes(":"));
1169
+ return this.opts.search_string.split(' ').filter((e) => e.includes(':'));
1221
1170
  },
1222
1171
  search: {
1223
1172
  get() {
1224
1173
  return this.opts.search_string
1225
- .split(" ")
1226
- .filter((e) => !e.includes(":"))
1174
+ .split(' ')
1175
+ .filter((e) => !e.includes(':'))
1227
1176
  .filter((e) => e)
1228
- .join(" ")
1177
+ .join(' ')
1229
1178
  .trim();
1230
1179
  },
1231
1180
 
1232
1181
  set(value) {
1233
1182
  // debugger;
1234
- var existingTags = this.opts.search_string
1235
- .split(" ")
1236
- .filter((e) => e.includes(":"));
1183
+ var existingTags = this.opts.search_string.split(' ').filter((e) => e.includes(':'));
1237
1184
 
1238
- this.opts.search_string = (
1239
- existingTags.join(" ") +
1240
- " " +
1241
- value
1242
- ).trim();
1185
+ this.opts.search_string = (existingTags.join(' ') + ' ' + value).trim();
1243
1186
 
1244
1187
  console.log(value);
1245
1188
 
@@ -1247,7 +1190,7 @@ export async function viewer(fields, e) {
1247
1190
  this.showSearchPopper = true;
1248
1191
  }
1249
1192
 
1250
- if (value.includes(":")) {
1193
+ if (value.includes(':')) {
1251
1194
  setTimeout(() => {
1252
1195
  this.showSearchPopper = false;
1253
1196
  }, 50);
@@ -1264,10 +1207,10 @@ export async function viewer(fields, e) {
1264
1207
  },
1265
1208
  view: {
1266
1209
  handler(val) {
1267
- if (val === "slider") {
1210
+ if (val === 'slider') {
1268
1211
  this.$nextTick(() => {
1269
1212
  // setTimeout(() => {
1270
- this.swiper = new Swiper(this.$refs["swiper-container"], {
1213
+ this.swiper = new Swiper(this.$refs['swiper-container'], {
1271
1214
  loop: true,
1272
1215
  slidesPerView: 1,
1273
1216
  spaceBetween: 20,
@@ -1277,13 +1220,8 @@ export async function viewer(fields, e) {
1277
1220
  // ...(fields?.direction === "rtl" ? { reverseDirection: true } : {})
1278
1221
  });
1279
1222
 
1280
- this.swiper.on("slideChange", (event) => {
1281
- if (
1282
- event.activeIndex >= 5 &&
1283
- !this.isEndOfList &&
1284
- !this.loadingSearch &&
1285
- !this.allLoading
1286
- ) {
1223
+ this.swiper.on('slideChange', (event) => {
1224
+ if (event.activeIndex >= 5 && !this.isEndOfList && !this.loadingSearch && !this.allLoading) {
1287
1225
  this.refreshDirectory(true);
1288
1226
  }
1289
1227
  });
@@ -1309,10 +1247,7 @@ export async function viewer(fields, e) {
1309
1247
 
1310
1248
  this.$nextTick(async () => {
1311
1249
  // debugger;
1312
- var { pond, processFiles } = await this.initUploader(
1313
- { ...fields, instant_file_upload: "N" },
1314
- { ...e, $containerP: $("#imageUploaderComponent") }
1315
- );
1250
+ var { pond, processFiles } = await this.initUploader({ ...fields, instant_file_upload: 'N' }, { ...e, $containerP: $('#imageUploaderComponent') });
1316
1251
 
1317
1252
  this.pond = pond;
1318
1253
  this.processFiles = processFiles;
@@ -1321,8 +1256,8 @@ export async function viewer(fields, e) {
1321
1256
  this.refreshDirectory(false, true);
1322
1257
  }, 2500);
1323
1258
 
1324
- this.pond.on("processfile", (e, { id }) => {
1325
- if (!e?.type !== "error") {
1259
+ this.pond.on('processfile', (e, { id }) => {
1260
+ if (!e?.type !== 'error') {
1326
1261
  this.pond.removeFiles(id);
1327
1262
  }
1328
1263
 
@@ -1335,12 +1270,12 @@ export async function viewer(fields, e) {
1335
1270
  refreshThrottled();
1336
1271
  });
1337
1272
 
1338
- this.pond.on("processfiles", (a, b) => {
1339
- console.log("Finished all");
1273
+ this.pond.on('processfiles', (a, b) => {
1274
+ console.log('Finished all');
1340
1275
  });
1341
1276
  });
1342
1277
 
1343
- this.$watch("opts", (value) => {
1278
+ this.$watch('opts', (value) => {
1344
1279
  this.refreshDirectory();
1345
1280
  });
1346
1281
  },