@widgetic/editor 3.10.49 → 3.10.50
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/editor",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.50",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "webpack --config webpack.config.js --watch --progress",
|
|
6
6
|
"build": "webpack --config webpack.config.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"version": "grunt release && git add -A lib",
|
|
10
10
|
"postversion": "git push && npm publish",
|
|
11
11
|
"genssl": "openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout key.pem -out cert.pem -subj /CN=localhost",
|
|
12
|
-
"server": "http-server -S -p 8083"
|
|
12
|
+
"server": "http-server -S -p 8083",
|
|
13
|
+
"deploy": "cd ./lib && rsync * root@zeus.widgetic.com:/opt/widgetic_editor/lib"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@widgetic/spine": "^2.0.3",
|
|
@@ -81,44 +81,57 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
upload(uploadFile) {
|
|
84
|
-
// console.log("upload file:", uploadFile);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
84
|
+
// console.log("on upload file:", uploadFile);
|
|
85
|
+
|
|
86
|
+
// create a new File instance from the uploadFile
|
|
87
|
+
let file = new File({
|
|
88
|
+
state: 'new',
|
|
89
|
+
size: uploadFile.size,
|
|
90
|
+
name: uploadFile.name,
|
|
91
|
+
type: parseType(uploadFile.type),
|
|
92
|
+
lastModified: Date.now(),
|
|
93
|
+
uploadFile,
|
|
94
|
+
});
|
|
95
|
+
console.log("on upload file:", file);
|
|
96
|
+
|
|
97
|
+
// push it to the files array
|
|
98
|
+
this.files.push(file);
|
|
99
|
+
|
|
100
|
+
// increase used quota
|
|
96
101
|
this.used += uploadFile.size;
|
|
102
|
+
|
|
103
|
+
// broadcast the update of the files array
|
|
97
104
|
this._broadcast.update();
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
uploadComplete(uploadFile, instanceId) {
|
|
101
108
|
// console.log("uploadComplete file:", uploadFile);
|
|
109
|
+
|
|
102
110
|
if (uploadFile.status === 'error') return;
|
|
103
111
|
|
|
104
|
-
// read metadata
|
|
112
|
+
// read metadata from the file that's on the server
|
|
105
113
|
const response = JSON.parse(uploadFile.xhr.response);
|
|
106
|
-
// console.log("uploadComplete
|
|
107
|
-
|
|
114
|
+
// console.log("uploadComplete server response:", response);
|
|
115
|
+
|
|
116
|
+
// read file from the response
|
|
117
|
+
let serverFile = response.files.data[0];
|
|
118
|
+
// console.log("uploadComplete file on the server:", serverFile);
|
|
108
119
|
|
|
109
120
|
// read quota from response
|
|
110
121
|
// this.quota = response.quota.max;
|
|
111
122
|
this.used = response.quota.used;
|
|
112
123
|
|
|
124
|
+
// update the file in the files array with the data from the server
|
|
113
125
|
this._update(uploadFile, f => {
|
|
114
126
|
f.state = 'complete';
|
|
115
|
-
f.id = id;
|
|
116
|
-
f.path =
|
|
127
|
+
f.id = serverFile.id;
|
|
128
|
+
f.path = serverFile.path;
|
|
117
129
|
f.url = response.hostUrl + f.path;
|
|
118
|
-
|
|
130
|
+
f.lastModified = serverFile.lastModified;
|
|
119
131
|
});
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
// broadcast the completion of the upload based on the fileId and instanceId
|
|
134
|
+
this._broadcast.complete([this.get(serverFile.id), instanceId]);
|
|
122
135
|
}
|
|
123
136
|
|
|
124
137
|
accept(file, done) {
|
|
@@ -162,10 +175,13 @@ export default class UploadService extends EventsMixin(Service) {
|
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
_update(file, transform) {
|
|
178
|
+
// apply the transform function to the file in the array
|
|
165
179
|
this.files = this.files.map(f => {
|
|
166
180
|
if (f.uploadFile === file) transform(f);
|
|
167
181
|
return f;
|
|
168
182
|
});
|
|
183
|
+
|
|
184
|
+
// broadcast the update of the files array
|
|
169
185
|
this._broadcast.update();
|
|
170
186
|
}
|
|
171
187
|
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
import Dropzone from './dropzone.html';
|
|
183
183
|
import ScrollPane from './scroll-pane.html';
|
|
184
184
|
import File from './file.html';
|
|
185
|
-
import Service from './service.html';
|
|
185
|
+
import Service from './service.html'; // actually imports services/uploads.js
|
|
186
186
|
|
|
187
187
|
let instanceId = 0;
|
|
188
188
|
|
|
@@ -233,7 +233,7 @@ export default {
|
|
|
233
233
|
|
|
234
234
|
// on selecting a file square
|
|
235
235
|
toggle(file) {
|
|
236
|
-
console.log("on toggle file:", file);
|
|
236
|
+
// console.log("on toggle file:", file);
|
|
237
237
|
|
|
238
238
|
if (file.error) {
|
|
239
239
|
this.Uploads.remove(file);
|
|
@@ -251,7 +251,7 @@ export default {
|
|
|
251
251
|
},
|
|
252
252
|
|
|
253
253
|
refresh(ev) {
|
|
254
|
-
console.log("refreshing...");
|
|
254
|
+
// console.log("refreshing...");
|
|
255
255
|
if (ev) ev.preventDefault();
|
|
256
256
|
|
|
257
257
|
return this.Uploads.getFiles(this.get('filetypes'))
|
|
@@ -264,20 +264,37 @@ export default {
|
|
|
264
264
|
// if(!a.id.indexOf) return -1;
|
|
265
265
|
// let noIdA = a.id.substr(a.id.indexOf('_t')+2, 4);
|
|
266
266
|
// let noIdB = b.id.substr(a.id.indexOf('_t')+2, 4);
|
|
267
|
-
// // console.log("noIdA & noIdB: ", noIdA, noIdB, (noIdA
|
|
267
|
+
// // console.log("noIdA & noIdB: ", noIdA, noIdB, (noIdA - noIdB));
|
|
268
268
|
// return noIdA - noIdB;
|
|
269
269
|
// });
|
|
270
270
|
// console.log("uploadedFiles after sort: ", files);
|
|
271
271
|
|
|
272
|
-
// sort files by last modified date
|
|
272
|
+
// sort files by last modified(uploadTime) date
|
|
273
273
|
files = files.sort((a, b) => {
|
|
274
|
+
|
|
275
|
+
// read a lastModified timestamp
|
|
274
276
|
let x = a.lastModified;
|
|
277
|
+
|
|
278
|
+
// read the lastModified date from the id
|
|
279
|
+
if(!x) x = a.id.substring(a.id.indexOf('_u')+3);
|
|
280
|
+
|
|
281
|
+
// if still not available then set it to 0
|
|
275
282
|
if(!x) x = 0;
|
|
283
|
+
// a.lastModified = x;
|
|
284
|
+
|
|
276
285
|
|
|
286
|
+
// read b lastModified timestamp
|
|
277
287
|
let y = b.lastModified;
|
|
288
|
+
|
|
289
|
+
// read the lastModified date from the id
|
|
290
|
+
if(!y) y = b.id.substring(b.id.indexOf('_u')+3);
|
|
291
|
+
|
|
292
|
+
// if still not available then set it to 0
|
|
278
293
|
if(!y) y = 0;
|
|
294
|
+
// b.lastModified = y;
|
|
295
|
+
|
|
279
296
|
|
|
280
|
-
// console.log("x & y: ", x, y);
|
|
297
|
+
// console.log("x & y: ", a.lastModified, x, b.lastModified, y);
|
|
281
298
|
|
|
282
299
|
return x - y;
|
|
283
300
|
});
|
|
@@ -342,12 +359,12 @@ export default {
|
|
|
342
359
|
*/
|
|
343
360
|
|
|
344
361
|
_onDropZoneNewUpload(event) {
|
|
345
|
-
console.log("on DropZone New Upload:", event);
|
|
362
|
+
// console.log("on DropZone New Upload:", event);
|
|
346
363
|
this.refs.scrollPane && this.refs.scrollPane.scrollBottom();
|
|
347
364
|
},
|
|
348
365
|
|
|
349
366
|
_onDropZoneUpload(event) {
|
|
350
|
-
console.log("on DropZone Upload:", event);
|
|
367
|
+
// console.log("on DropZone Upload:", event);
|
|
351
368
|
this.toggle( event );
|
|
352
369
|
},
|
|
353
370
|
|