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

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,26 @@ 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);
227
+ formData.append('file', file, file.name);
254
228
  const { app_id, gtp_token, app_token } = e._session;
255
229
 
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);
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
+ if (fields.file_upload_folder) formData.append('folder', fields.file_upload_folder);
236
+ if (fields.public_file) formData.append('make_public', fields.public_file);
268
237
 
269
238
  let tags = fields.assign_file_tags || [];
270
239
 
271
240
  let file_tags = [];
272
241
  if (fields.auto_tag_generator) {
273
- let identifier = fields.auto_tag_identifier || " ";
242
+ let identifier = fields.auto_tag_identifier || ' ';
274
243
 
275
- const filename = file.name.split(".").slice(0, -1).join(".");
244
+ const filename = file.name.split('.').slice(0, -1).join('.');
276
245
  file_tags = filename.split(identifier);
277
246
  if (fields.auto_tag_translation) {
278
247
  for (let tag of file_tags) {
@@ -282,34 +251,25 @@ export async function upload(fields, e) {
282
251
  }
283
252
  }
284
253
  }
285
- formData.append("tags", [...tags, ...file_tags]);
254
+ formData.append('tags', [...tags, ...file_tags]);
286
255
 
287
256
  const request = new XMLHttpRequest();
288
257
 
289
258
  let _domain = e._session.domain;
290
259
  if (e._session.is_deployment) {
291
- _domain =
292
- e._session.opt.regional_server === "dev.xuda.io"
293
- ? "dev.xuda.io"
294
- : "xuda.io";
260
+ _domain = e._session.opt.regional_server === 'dev.xuda.io' ? 'dev.xuda.io' : 'xuda.io';
295
261
  }
296
262
 
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
- );
263
+ if (overrideAction === 'replace' && file.name in existingFiles) {
264
+ formData.append('file_path', '/' + file.name);
265
+ formData.append('file_name', file.name);
266
+ request.open('POST', `https://${_domain}/cpi/update_drive_file_workspace`);
304
267
  } else {
305
- request.open(
306
- "POST",
307
- `https://${_domain}/cpi/upload_drive_file_workspace`
308
- );
268
+ request.open('POST', `https://${_domain}/cpi/upload_drive_file_workspace`);
309
269
  }
310
270
 
311
- request.setRequestHeader("xu-gtp-token", gtp_token);
312
- request.setRequestHeader("xu-app-token", app_token);
271
+ request.setRequestHeader('xu-gtp-token', gtp_token);
272
+ request.setRequestHeader('xu-app-token', app_token);
313
273
 
314
274
  // request.open("POST", `https://${_domain}/rpi/runtime_upload_file`);
315
275
 
@@ -345,7 +305,7 @@ export async function upload(fields, e) {
345
305
  var res = JSON.parse(request.responseText);
346
306
 
347
307
  error(res.data);
348
- this.$emit("error", error);
308
+ this.$emit('error', error);
349
309
  };
350
310
 
351
311
  request.send(formData);
@@ -376,36 +336,26 @@ export async function upload(fields, e) {
376
336
  let app_id = e._session.app_id;
377
337
  let app_id_reference = APP_OBJ[app_id].app_id_reference;
378
338
 
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
- );
339
+ axios_ajax(func.common.get_url(e.SESSION_ID, 'rpi', 'runtime_delete_file_bulk'), {
340
+ app_id,
341
+ server_files: ret_obj.deletedArr,
342
+ app_id_reference: app_id_reference,
343
+ gtp_token: e._session.gtp_token,
344
+ });
392
345
  load();
393
346
  },
394
347
  remove: (source, load, error) => {
395
- var source_clean = source.split("/").pop();
348
+ var source_clean = source.split('/').pop();
396
349
 
397
350
  ret_obj.deletedArr.push(source_clean);
398
351
 
399
- var myIndex = ret_obj.app_files.indexOf(
400
- (file) => file.server_fileName === source
401
- );
352
+ var myIndex = ret_obj.app_files.indexOf((file) => file.server_fileName === source);
402
353
  if (myIndex !== -1) {
403
354
  ret_obj.app_files.splice(myIndex, 1);
404
355
  }
405
356
 
406
357
  ////////////// CALLBACK
407
- if (fields.instant_file_upload === "N" ? false : true)
408
- do_callback(true);
358
+ if (fields.instant_file_upload === 'N' ? false : true) do_callback(true);
409
359
  // Can call the error method if something is wrong, should exit after
410
360
  // error('oh my goodness');
411
361
 
@@ -426,45 +376,45 @@ export async function upload(fields, e) {
426
376
  opt.files = init_files;
427
377
  }
428
378
 
429
- opt.instantUpload = fields.instant_file_upload === "N" ? false : true;
379
+ opt.instantUpload = fields.instant_file_upload === 'N' ? false : true;
430
380
 
431
381
  if (fields.file_upload_mime_type_preset) {
432
382
  switch (fields.file_upload_mime_type_preset) {
433
- case "image":
434
- opt.acceptedFileTypes = ["image/*"];
383
+ case 'image':
384
+ opt.acceptedFileTypes = ['image/*'];
435
385
  break;
436
- case "video":
437
- opt.acceptedFileTypes = ["video/*"];
386
+ case 'video':
387
+ opt.acceptedFileTypes = ['video/*'];
438
388
  break;
439
- case "audio":
440
- opt.acceptedFileTypes = ["audio/*"];
389
+ case 'audio':
390
+ opt.acceptedFileTypes = ['audio/*'];
441
391
  break;
442
392
  default:
443
- opt.acceptedFileTypes = ["image/*"];
393
+ opt.acceptedFileTypes = ['image/*'];
444
394
  }
445
395
  } else {
446
396
  if (fields.file_upload_custom_mime_types) {
447
- opt.acceptedFileTypes = fields.file_upload_custom_mime_types.split(",");
397
+ opt.acceptedFileTypes = fields.file_upload_custom_mime_types.split(',');
448
398
  } else {
449
399
  opt.allowFileTypeValidation = false;
450
400
  }
451
401
  }
452
402
 
453
- if (fields.file_upload_mask === "circle") {
403
+ if (fields.file_upload_mask === 'circle') {
454
404
  opt.imagePreviewHeight = 170;
455
- opt.imageCropAspectRatio = "1:1";
405
+ opt.imageCropAspectRatio = '1:1';
456
406
  opt.imageResizeTargetWidth = 200;
457
407
  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";
408
+ opt.stylePanelLayout = 'compact circle';
409
+ opt.styleLoadIndicatorPosition = 'center bottom';
410
+ opt.styleProgressIndicatorPosition = 'right bottom';
411
+ opt.styleButtonRemoveItemPosition = 'left bottom';
412
+ opt.styleButtonProcessItemPosition = 'right bottom';
463
413
  }
464
414
 
465
415
  pond = FilePond.create($imgInp[0], opt);
466
416
 
467
- pond.on("processfiles", (e) => {
417
+ pond.on('processfiles', (e) => {
468
418
  do_callback();
469
419
  });
470
420
 
@@ -531,7 +481,7 @@ export async function viewer(fields, e) {
531
481
  };
532
482
 
533
483
  var segmentComponent = {
534
- props: ["options", "modelValue"],
484
+ props: ['options', 'modelValue'],
535
485
  computed: {
536
486
  model: {
537
487
  get() {
@@ -540,7 +490,7 @@ export async function viewer(fields, e) {
540
490
  return value;
541
491
  },
542
492
  set(v) {
543
- this.$emit("update:modelValue", v);
493
+ this.$emit('update:modelValue', v);
544
494
  },
545
495
  },
546
496
  segmentActive() {
@@ -568,7 +518,7 @@ export async function viewer(fields, e) {
568
518
  };
569
519
 
570
520
  var imagePreview = {
571
- props: ["file", "size"],
521
+ props: ['file', 'size'],
572
522
  template: `
573
523
 
574
524
 
@@ -902,12 +852,12 @@ export async function viewer(fields, e) {
902
852
  opt.app_id = app_id;
903
853
 
904
854
  const response = await fetch(`https://${_domain}/cpi/${service}`, {
905
- method: "POST",
855
+ method: 'POST',
906
856
  headers: {
907
- Accept: "application/json",
908
- "Content-Type": "application/json",
909
- "xu-gtp-token": gtp_token,
910
- "xu-app-token": app_token,
857
+ Accept: 'application/json',
858
+ 'Content-Type': 'application/json',
859
+ 'xu-gtp-token': gtp_token,
860
+ 'xu-app-token': app_token,
911
861
  },
912
862
  body: JSON.stringify(opt),
913
863
  });
@@ -923,18 +873,18 @@ export async function viewer(fields, e) {
923
873
 
924
874
  const formatBytes = function (bytes) {
925
875
  if (bytes < 1024) {
926
- return bytes + " Bytes"; // Less than 1 KB
876
+ return bytes + ' Bytes'; // Less than 1 KB
927
877
  } else if (bytes < 1024 * 1024) {
928
- return (bytes / 1024).toFixed(2) + " KB"; // Less than 1 MB
878
+ return (bytes / 1024).toFixed(2) + ' KB'; // Less than 1 MB
929
879
  } else if (bytes < 1024 * 1024 * 1024) {
930
- return (bytes / (1024 * 1024)).toFixed(2) + " MB"; // Less than 1 GB
880
+ return (bytes / (1024 * 1024)).toFixed(2) + ' MB'; // Less than 1 GB
931
881
  } else {
932
- return (bytes / (1024 * 1024 * 1024)).toFixed(2) + " GB"; // 1 GB or more
882
+ return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB'; // 1 GB or more
933
883
  }
934
884
  };
935
885
 
936
886
  var containerId = crypto.randomUUID();
937
- e.$containerP.attr("widget-id", containerId);
887
+ e.$containerP.attr('widget-id', containerId);
938
888
 
939
889
  var app = createApp({
940
890
  template: html,
@@ -946,27 +896,27 @@ export async function viewer(fields, e) {
946
896
  data() {
947
897
  return {
948
898
  replaceOptions: [
949
- { label: "Replace existing items", value: "replace" },
950
- { label: "Keep all items", value: "keep" },
899
+ { label: 'Replace existing items', value: 'replace' },
900
+ { label: 'Keep all items', value: 'keep' },
951
901
  ],
952
902
  sortDirOptions: [
953
903
  {
954
- label: "Ascending",
955
- value: "asc",
904
+ label: 'Ascending',
905
+ value: 'asc',
956
906
  },
957
907
  {
958
- label: "Descending",
959
- value: "desc",
908
+ label: 'Descending',
909
+ value: 'desc',
960
910
  },
961
911
  ],
962
912
  sortOptions: [
963
913
  {
964
- label: "Date",
965
- value: "date",
914
+ label: 'Date',
915
+ value: 'date',
966
916
  },
967
917
  {
968
- label: "Name",
969
- value: "name",
918
+ label: 'Name',
919
+ value: 'name',
970
920
  },
971
921
  ],
972
922
  viewOptions: [
@@ -978,8 +928,8 @@ export async function viewer(fields, e) {
978
928
  clip-rule="evenodd"
979
929
  ></path>
980
930
  </svg>`,
981
- label: "",
982
- value: "gallery",
931
+ label: '',
932
+ value: 'gallery',
983
933
  },
984
934
  {
985
935
  icon: ` <svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
@@ -989,22 +939,22 @@ export async function viewer(fields, e) {
989
939
  clip-rule="evenodd"
990
940
  ></path>
991
941
  </svg>`,
992
- label: "",
993
- value: "list",
942
+ label: '',
943
+ value: 'list',
994
944
  },
995
945
  {
996
946
  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
947
  <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
948
  <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
949
  </svg>`,
1000
- label: "",
1001
- value: "slider",
950
+ label: '',
951
+ value: 'slider',
1002
952
  },
1003
953
  ],
1004
954
  options: fields,
1005
955
  folders: [],
1006
956
  files: [],
1007
- view: fields.default_view_type || "gallery",
957
+ view: fields.default_view_type || 'gallery',
1008
958
  uploadModal: false,
1009
959
  uploaderLoading: false,
1010
960
  loadingSearch: false,
@@ -1012,33 +962,33 @@ export async function viewer(fields, e) {
1012
962
  formatBytes,
1013
963
  initUploader: upload,
1014
964
  swiper: null,
1015
- existingTags: "",
965
+ existingTags: '',
1016
966
  showSearchPopper: false,
1017
967
  isOverDropZone: false,
1018
968
  removeChipCount: 0,
1019
969
  searchOptions: [
1020
970
  {
1021
- label: "Filename",
1022
- tag: "name",
1023
- modifier: "contains",
971
+ label: 'Filename',
972
+ tag: 'name',
973
+ modifier: 'contains',
1024
974
  },
1025
975
  {
1026
- label: "Tag",
1027
- tag: "tag",
1028
- modifier: "equals",
976
+ label: 'Tag',
977
+ tag: 'tag',
978
+ modifier: 'equals',
1029
979
  },
1030
980
  {
1031
- label: "Content",
1032
- tag: "any",
1033
- modifier: "contains",
981
+ label: 'Content',
982
+ tag: 'any',
983
+ modifier: 'contains',
1034
984
  },
1035
985
  ],
1036
986
  opts: {
1037
987
  app_id,
1038
- path: "/",
1039
- search_string: "",
1040
- sort_by: fields.sort_by || "date",
1041
- sort_dir: fields.sort_dir || "asc",
988
+ path: '/',
989
+ search_string: '',
990
+ sort_by: fields.sort_by || 'date',
991
+ sort_dir: fields.sort_dir || 'asc',
1042
992
  ...(fields.filter_tags?.length ? { tags: fields.filter_tags } : {}),
1043
993
  // ...filter_tags
1044
994
  },
@@ -1047,14 +997,14 @@ export async function viewer(fields, e) {
1047
997
  existingFiles: {},
1048
998
  allLoading: false,
1049
999
  showExistModal: false,
1050
- overrideAction: "replace",
1000
+ overrideAction: 'replace',
1051
1001
  pond: null,
1052
1002
  processFiles: null,
1053
1003
  };
1054
1004
  },
1055
1005
  methods: {
1056
1006
  async refreshDirectory(all, bypassFolders = false) {
1057
- if (this.view === "slider") bypassFolders = true;
1007
+ if (this.view === 'slider') bypassFolders = true;
1058
1008
 
1059
1009
  this.loadingSearch = true;
1060
1010
 
@@ -1065,17 +1015,17 @@ export async function viewer(fields, e) {
1065
1015
  }
1066
1016
 
1067
1017
  if (!bypassFolders) {
1068
- const folders = await this.fetcher("get_drive_files_workspace", {
1018
+ const folders = await this.fetcher('get_drive_files_workspace', {
1069
1019
  ...this.opts,
1070
- type: "directory",
1020
+ type: 'directory',
1071
1021
  });
1072
1022
  this.folders = folders.data.children || [];
1073
1023
  }
1074
1024
 
1075
- const files = await this.fetcher("get_drive_files_workspace", {
1025
+ const files = await this.fetcher('get_drive_files_workspace', {
1076
1026
  ...this.opts,
1077
1027
  ...(all ? {} : { from: 0, to: this.limit }),
1078
- type: "file",
1028
+ type: 'file',
1079
1029
  });
1080
1030
 
1081
1031
  this.files = files.data.children || [];
@@ -1118,17 +1068,15 @@ export async function viewer(fields, e) {
1118
1068
  let promises = [];
1119
1069
  this.existingFiles = {};
1120
1070
 
1121
- var filesMapped = this.pond
1122
- .getFiles()
1123
- .map((e) => ({ id: e.id, filename: e.file.name }));
1071
+ var filesMapped = this.pond.getFiles().map((e) => ({ id: e.id, filename: e.file.name }));
1124
1072
 
1125
1073
  filesMapped.forEach(({ filename }) => {
1126
1074
  promises.push(
1127
1075
  new Promise((resolve, reject) => {
1128
1076
  this.fetcher(`check_drive_file_workspace`, {
1129
- file_path: "/" + filename,
1077
+ file_path: '/' + filename,
1130
1078
  file_name: filename,
1131
- type: "file",
1079
+ type: 'file',
1132
1080
  })
1133
1081
  .then((e) => {
1134
1082
  resolve(e);
@@ -1144,7 +1092,7 @@ export async function viewer(fields, e) {
1144
1092
 
1145
1093
  reject(err);
1146
1094
  });
1147
- })
1095
+ }),
1148
1096
  );
1149
1097
  });
1150
1098
 
@@ -1156,9 +1104,7 @@ export async function viewer(fields, e) {
1156
1104
  }
1157
1105
 
1158
1106
  filesMapped
1159
- .filter(
1160
- (e) => !Object.keys(this.existingFiles).includes(e.filename)
1161
- )
1107
+ .filter((e) => !Object.keys(this.existingFiles).includes(e.filename))
1162
1108
  .forEach((e) => {
1163
1109
  this.processFiles(e.id);
1164
1110
  });
@@ -1177,10 +1123,10 @@ export async function viewer(fields, e) {
1177
1123
  this.opts.search_string = this.opts.search_string
1178
1124
  .replaceAll(
1179
1125
  this.opts.search_string
1180
- .split(" ")
1181
- .filter((e) => e.includes(":"))
1126
+ .split(' ')
1127
+ .filter((e) => e.includes(':'))
1182
1128
  .at(-1),
1183
- ""
1129
+ '',
1184
1130
  )
1185
1131
  .trim();
1186
1132
  this.removeChipCount = 0;
@@ -1189,12 +1135,11 @@ export async function viewer(fields, e) {
1189
1135
  }
1190
1136
  }
1191
1137
  },
1192
- // hideSearchPopper() {
1193
- // debugger;
1194
- // setTimeout(() => {
1195
- // this.showSearchPopper = false;
1196
- // }, 100);
1197
- // },
1138
+ hideSearchPopper() {
1139
+ setTimeout(() => {
1140
+ this.showSearchPopper = false;
1141
+ }, 100);
1142
+ },
1198
1143
  searchDebounce: _.debounce(async function ($event) {
1199
1144
  await this.refreshDirectory();
1200
1145
  }, 400),
@@ -1202,7 +1147,7 @@ export async function viewer(fields, e) {
1202
1147
  },
1203
1148
  mounted() {
1204
1149
  var onDrop = (files) => {
1205
- if (this.view === "slider") return;
1150
+ if (this.view === 'slider') return;
1206
1151
  this.uploadModal = true;
1207
1152
  this.pond.addFiles(files);
1208
1153
  };
@@ -1215,31 +1160,23 @@ export async function viewer(fields, e) {
1215
1160
  },
1216
1161
  computed: {
1217
1162
  searchTags() {
1218
- return this.opts.search_string
1219
- .split(" ")
1220
- .filter((e) => e.includes(":"));
1163
+ return this.opts.search_string.split(' ').filter((e) => e.includes(':'));
1221
1164
  },
1222
1165
  search: {
1223
1166
  get() {
1224
1167
  return this.opts.search_string
1225
- .split(" ")
1226
- .filter((e) => !e.includes(":"))
1168
+ .split(' ')
1169
+ .filter((e) => !e.includes(':'))
1227
1170
  .filter((e) => e)
1228
- .join(" ")
1171
+ .join(' ')
1229
1172
  .trim();
1230
1173
  },
1231
1174
 
1232
1175
  set(value) {
1233
1176
  // debugger;
1234
- var existingTags = this.opts.search_string
1235
- .split(" ")
1236
- .filter((e) => e.includes(":"));
1177
+ var existingTags = this.opts.search_string.split(' ').filter((e) => e.includes(':'));
1237
1178
 
1238
- this.opts.search_string = (
1239
- existingTags.join(" ") +
1240
- " " +
1241
- value
1242
- ).trim();
1179
+ this.opts.search_string = (existingTags.join(' ') + ' ' + value).trim();
1243
1180
 
1244
1181
  console.log(value);
1245
1182
 
@@ -1247,7 +1184,7 @@ export async function viewer(fields, e) {
1247
1184
  this.showSearchPopper = true;
1248
1185
  }
1249
1186
 
1250
- if (value.includes(":")) {
1187
+ if (value.includes(':')) {
1251
1188
  setTimeout(() => {
1252
1189
  this.showSearchPopper = false;
1253
1190
  }, 50);
@@ -1264,10 +1201,10 @@ export async function viewer(fields, e) {
1264
1201
  },
1265
1202
  view: {
1266
1203
  handler(val) {
1267
- if (val === "slider") {
1204
+ if (val === 'slider') {
1268
1205
  this.$nextTick(() => {
1269
1206
  // setTimeout(() => {
1270
- this.swiper = new Swiper(this.$refs["swiper-container"], {
1207
+ this.swiper = new Swiper(this.$refs['swiper-container'], {
1271
1208
  loop: true,
1272
1209
  slidesPerView: 1,
1273
1210
  spaceBetween: 20,
@@ -1277,13 +1214,8 @@ export async function viewer(fields, e) {
1277
1214
  // ...(fields?.direction === "rtl" ? { reverseDirection: true } : {})
1278
1215
  });
1279
1216
 
1280
- this.swiper.on("slideChange", (event) => {
1281
- if (
1282
- event.activeIndex >= 5 &&
1283
- !this.isEndOfList &&
1284
- !this.loadingSearch &&
1285
- !this.allLoading
1286
- ) {
1217
+ this.swiper.on('slideChange', (event) => {
1218
+ if (event.activeIndex >= 5 && !this.isEndOfList && !this.loadingSearch && !this.allLoading) {
1287
1219
  this.refreshDirectory(true);
1288
1220
  }
1289
1221
  });
@@ -1309,10 +1241,7 @@ export async function viewer(fields, e) {
1309
1241
 
1310
1242
  this.$nextTick(async () => {
1311
1243
  // debugger;
1312
- var { pond, processFiles } = await this.initUploader(
1313
- { ...fields, instant_file_upload: "N" },
1314
- { ...e, $containerP: $("#imageUploaderComponent") }
1315
- );
1244
+ var { pond, processFiles } = await this.initUploader({ ...fields, instant_file_upload: 'N' }, { ...e, $containerP: $('#imageUploaderComponent') });
1316
1245
 
1317
1246
  this.pond = pond;
1318
1247
  this.processFiles = processFiles;
@@ -1321,8 +1250,8 @@ export async function viewer(fields, e) {
1321
1250
  this.refreshDirectory(false, true);
1322
1251
  }, 2500);
1323
1252
 
1324
- this.pond.on("processfile", (e, { id }) => {
1325
- if (!e?.type !== "error") {
1253
+ this.pond.on('processfile', (e, { id }) => {
1254
+ if (!e?.type !== 'error') {
1326
1255
  this.pond.removeFiles(id);
1327
1256
  }
1328
1257
 
@@ -1335,12 +1264,12 @@ export async function viewer(fields, e) {
1335
1264
  refreshThrottled();
1336
1265
  });
1337
1266
 
1338
- this.pond.on("processfiles", (a, b) => {
1339
- console.log("Finished all");
1267
+ this.pond.on('processfiles', (a, b) => {
1268
+ console.log('Finished all');
1340
1269
  });
1341
1270
  });
1342
1271
 
1343
- this.$watch("opts", (value) => {
1272
+ this.$watch('opts', (value) => {
1344
1273
  this.refreshDirectory();
1345
1274
  });
1346
1275
  },