@deephaven/file-explorer 0.5.1 → 0.5.2-allpackages.16
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/dist/FileExistsError.js +7 -35
- package/dist/FileExistsError.js.map +1 -1
- package/dist/FileExplorer.js +62 -139
- package/dist/FileExplorer.js.map +1 -1
- package/dist/FileExplorerShortcuts.js +1 -1
- package/dist/FileExplorerShortcuts.js.map +1 -1
- package/dist/FileExplorerToolbar.js +7 -6
- package/dist/FileExplorerToolbar.js.map +1 -1
- package/dist/FileList.js +103 -172
- package/dist/FileList.js.map +1 -1
- package/dist/FileListContainer.js +38 -68
- package/dist/FileListContainer.js.map +1 -1
- package/dist/FileListItemEditor.js +28 -58
- package/dist/FileListItemEditor.js.map +1 -1
- package/dist/FileNotFoundError.js +5 -40
- package/dist/FileNotFoundError.js.map +1 -1
- package/dist/FileUtils.js +208 -258
- package/dist/FileUtils.js.map +1 -1
- package/dist/NewItemModal.js +397 -464
- package/dist/NewItemModal.js.map +1 -1
- package/dist/WebdavFileStorage.js +97 -250
- package/dist/WebdavFileStorage.js.map +1 -1
- package/dist/WebdavFileStorageTable.js +196 -346
- package/dist/WebdavFileStorageTable.js.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
|
@@ -2,28 +2,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
2
2
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
4
|
|
|
5
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
|
|
7
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
11
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
12
|
-
|
|
13
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
-
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
-
|
|
17
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
18
6
|
|
|
19
7
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
20
8
|
|
|
21
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
|
-
|
|
23
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
24
|
-
|
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
-
|
|
27
9
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
10
|
|
|
29
11
|
import Log from '@deephaven/log';
|
|
@@ -34,7 +16,7 @@ var log = Log.module('WebdavFileStorageTable');
|
|
|
34
16
|
* Takes a path to specify what root this table should start at.
|
|
35
17
|
*/
|
|
36
18
|
|
|
37
|
-
export
|
|
19
|
+
export class WebdavFileStorageTable {
|
|
38
20
|
/**
|
|
39
21
|
* Map of expanded directory paths to the tables that manage that path.
|
|
40
22
|
* We use a tree of tables to query the server so we just get the directories that are expanded.
|
|
@@ -45,11 +27,9 @@ export var WebdavFileStorageTable = /*#__PURE__*/function () {
|
|
|
45
27
|
* @param client The WebDAV client instance to use
|
|
46
28
|
* @param root The root path for this storage table
|
|
47
29
|
*/
|
|
48
|
-
|
|
30
|
+
constructor(client) {
|
|
49
31
|
var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
|
|
50
32
|
|
|
51
|
-
_classCallCheck(this, WebdavFileStorageTable);
|
|
52
|
-
|
|
53
33
|
_defineProperty(this, "client", void 0);
|
|
54
34
|
|
|
55
35
|
_defineProperty(this, "root", void 0);
|
|
@@ -70,349 +50,219 @@ export var WebdavFileStorageTable = /*#__PURE__*/function () {
|
|
|
70
50
|
this.root = root;
|
|
71
51
|
}
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
value: function getViewportData() {
|
|
76
|
-
var _this$viewportUpdateP;
|
|
53
|
+
getViewportData() {
|
|
54
|
+
var _this$viewportUpdateP;
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
56
|
+
if (!this.viewportUpdatePromise) {
|
|
57
|
+
this.refreshInternal();
|
|
58
|
+
}
|
|
81
59
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
60
|
+
return (_this$viewportUpdateP = this.viewportUpdatePromise) !== null && _this$viewportUpdateP !== void 0 ? _this$viewportUpdateP : Promise.resolve({
|
|
61
|
+
items: [],
|
|
62
|
+
offset: 0
|
|
63
|
+
});
|
|
64
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
87
65
|
|
|
88
|
-
}, {
|
|
89
|
-
key: "getSnapshot",
|
|
90
|
-
value: function getSnapshot(sortedRanges) {
|
|
91
|
-
throw new Error('Method not implemented.');
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "size",
|
|
95
|
-
get: function get() {
|
|
96
|
-
return this.currentSize;
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "setExpanded",
|
|
100
|
-
value: function () {
|
|
101
|
-
var _setExpanded = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(path, expanded) {
|
|
102
|
-
var paths, nextPath, remainingPath, childTable, _childTable, _childTable2;
|
|
103
|
-
|
|
104
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
105
|
-
while (1) {
|
|
106
|
-
switch (_context.prev = _context.next) {
|
|
107
|
-
case 0:
|
|
108
|
-
paths = path.split('/');
|
|
109
|
-
nextPath = paths.shift();
|
|
110
|
-
|
|
111
|
-
if (!nextPath) {
|
|
112
|
-
nextPath = paths.shift();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (nextPath) {
|
|
116
|
-
_context.next = 5;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
throw new Error("Invalid path: ".concat(path));
|
|
121
|
-
|
|
122
|
-
case 5:
|
|
123
|
-
remainingPath = paths.join('/');
|
|
124
|
-
|
|
125
|
-
if (expanded) {
|
|
126
|
-
if (!this.childTables.has(nextPath)) {
|
|
127
|
-
childTable = new WebdavFileStorageTable(this.client, "".concat(this.root).concat(nextPath, "/"));
|
|
128
|
-
this.childTables.set(nextPath, childTable);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (remainingPath) {
|
|
132
|
-
_childTable = this.childTables.get(nextPath);
|
|
133
|
-
_childTable === null || _childTable === void 0 ? void 0 : _childTable.setExpanded(remainingPath, expanded);
|
|
134
|
-
}
|
|
135
|
-
} else if (this.childTables.has(nextPath)) {
|
|
136
|
-
if (remainingPath) {
|
|
137
|
-
_childTable2 = this.childTables.get(nextPath);
|
|
138
|
-
_childTable2 === null || _childTable2 === void 0 ? void 0 : _childTable2.setExpanded(remainingPath, expanded);
|
|
139
|
-
} else {
|
|
140
|
-
this.childTables["delete"](nextPath);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!this.currentViewport) {
|
|
145
|
-
_context.next = 10;
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
_context.next = 10;
|
|
150
|
-
return this.refreshInternal();
|
|
151
|
-
|
|
152
|
-
case 10:
|
|
153
|
-
case "end":
|
|
154
|
-
return _context.stop();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, _callee, this);
|
|
158
|
-
}));
|
|
159
66
|
|
|
160
|
-
|
|
161
|
-
|
|
67
|
+
getSnapshot(sortedRanges) {
|
|
68
|
+
throw new Error('Method not implemented.');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get size() {
|
|
72
|
+
return this.currentSize;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setExpanded(path, expanded) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
|
|
78
|
+
return _asyncToGenerator(function* () {
|
|
79
|
+
var paths = path.split('/');
|
|
80
|
+
var nextPath = paths.shift();
|
|
81
|
+
|
|
82
|
+
if (!nextPath) {
|
|
83
|
+
nextPath = paths.shift();
|
|
162
84
|
}
|
|
163
85
|
|
|
164
|
-
|
|
165
|
-
|
|
86
|
+
if (!nextPath) {
|
|
87
|
+
throw new Error("Invalid path: ".concat(path));
|
|
88
|
+
}
|
|
166
89
|
|
|
167
|
-
|
|
168
|
-
key: "setSearch",
|
|
169
|
-
value: function setSearch(search) {
|
|
170
|
-
throw new Error('Method not implemented.');
|
|
171
|
-
}
|
|
172
|
-
}, {
|
|
173
|
-
key: "setViewport",
|
|
174
|
-
value: function setViewport(viewport) {
|
|
175
|
-
this.currentViewport = viewport;
|
|
176
|
-
this.refreshInternal();
|
|
177
|
-
} // eslint-disable-next-line class-methods-use-this
|
|
178
|
-
|
|
179
|
-
}, {
|
|
180
|
-
key: "setFilters",
|
|
181
|
-
value: function setFilters() {
|
|
182
|
-
throw new Error('Method not implemented.');
|
|
183
|
-
} // eslint-disable-next-line class-methods-use-this
|
|
184
|
-
|
|
185
|
-
}, {
|
|
186
|
-
key: "setSorts",
|
|
187
|
-
value: function setSorts() {
|
|
188
|
-
throw new Error('Method not implemented.');
|
|
189
|
-
} // eslint-disable-next-line class-methods-use-this
|
|
190
|
-
|
|
191
|
-
}, {
|
|
192
|
-
key: "setReversed",
|
|
193
|
-
value: function setReversed() {
|
|
194
|
-
throw new Error('Method not implemented.');
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "close",
|
|
198
|
-
value: function close() {
|
|
199
|
-
this.listeners = [];
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "onUpdate",
|
|
203
|
-
value: function onUpdate(callback) {
|
|
204
|
-
var _this = this;
|
|
205
|
-
|
|
206
|
-
this.listeners = [].concat(_toConsumableArray(this.listeners), [callback]);
|
|
207
|
-
return function () {
|
|
208
|
-
_this.listeners = _this.listeners.filter(function (other) {
|
|
209
|
-
return other !== callback;
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}, {
|
|
214
|
-
key: "refresh",
|
|
215
|
-
value: function () {
|
|
216
|
-
var _refresh = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
217
|
-
var _this$viewportUpdateP2;
|
|
218
|
-
|
|
219
|
-
var viewportData;
|
|
220
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
221
|
-
while (1) {
|
|
222
|
-
switch (_context2.prev = _context2.next) {
|
|
223
|
-
case 0:
|
|
224
|
-
log.debug2(this.root, 'refreshData');
|
|
225
|
-
(_this$viewportUpdateP2 = this.viewportUpdatePromise) === null || _this$viewportUpdateP2 === void 0 ? void 0 : _this$viewportUpdateP2.cancel();
|
|
226
|
-
this.viewportUpdatePromise = PromiseUtils.makeCancelable(this.fetchData());
|
|
227
|
-
_context2.next = 5;
|
|
228
|
-
return this.viewportUpdatePromise;
|
|
229
|
-
|
|
230
|
-
case 5:
|
|
231
|
-
viewportData = _context2.sent;
|
|
232
|
-
this.currentViewportData = viewportData;
|
|
233
|
-
this.sendUpdate();
|
|
234
|
-
return _context2.abrupt("return", viewportData);
|
|
235
|
-
|
|
236
|
-
case 9:
|
|
237
|
-
case "end":
|
|
238
|
-
return _context2.stop();
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}, _callee2, this);
|
|
242
|
-
}));
|
|
90
|
+
var remainingPath = paths.join('/');
|
|
243
91
|
|
|
244
|
-
|
|
245
|
-
|
|
92
|
+
if (expanded) {
|
|
93
|
+
if (!_this.childTables.has(nextPath)) {
|
|
94
|
+
var childTable = new WebdavFileStorageTable(_this.client, "".concat(_this.root).concat(nextPath, "/"));
|
|
95
|
+
|
|
96
|
+
_this.childTables.set(nextPath, childTable);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (remainingPath) {
|
|
100
|
+
var _childTable = _this.childTables.get(nextPath);
|
|
101
|
+
|
|
102
|
+
_childTable === null || _childTable === void 0 ? void 0 : _childTable.setExpanded(remainingPath, expanded);
|
|
103
|
+
}
|
|
104
|
+
} else if (_this.childTables.has(nextPath)) {
|
|
105
|
+
if (remainingPath) {
|
|
106
|
+
var _childTable2 = _this.childTables.get(nextPath);
|
|
107
|
+
|
|
108
|
+
_childTable2 === null || _childTable2 === void 0 ? void 0 : _childTable2.setExpanded(remainingPath, expanded);
|
|
109
|
+
} else {
|
|
110
|
+
_this.childTables.delete(nextPath);
|
|
111
|
+
}
|
|
246
112
|
}
|
|
247
113
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
259
|
-
while (1) {
|
|
260
|
-
switch (_context3.prev = _context3.next) {
|
|
261
|
-
case 0:
|
|
262
|
-
_context3.prev = 0;
|
|
263
|
-
_context3.next = 3;
|
|
264
|
-
return this.refresh();
|
|
265
|
-
|
|
266
|
-
case 3:
|
|
267
|
-
_context3.next = 8;
|
|
268
|
-
break;
|
|
269
|
-
|
|
270
|
-
case 5:
|
|
271
|
-
_context3.prev = 5;
|
|
272
|
-
_context3.t0 = _context3["catch"](0);
|
|
273
|
-
|
|
274
|
-
if (!PromiseUtils.isCanceled(_context3.t0)) {
|
|
275
|
-
log.error('Unable to refresh data', _context3.t0);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
case 8:
|
|
279
|
-
case "end":
|
|
280
|
-
return _context3.stop();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}, _callee3, this, [[0, 5]]);
|
|
284
|
-
}));
|
|
114
|
+
if (_this.currentViewport) {
|
|
115
|
+
yield _this.refreshInternal();
|
|
116
|
+
}
|
|
117
|
+
})();
|
|
118
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
setSearch(search) {
|
|
122
|
+
throw new Error('Method not implemented.');
|
|
123
|
+
}
|
|
285
124
|
|
|
286
|
-
|
|
287
|
-
|
|
125
|
+
setViewport(viewport) {
|
|
126
|
+
this.currentViewport = viewport;
|
|
127
|
+
this.refreshInternal();
|
|
128
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
setFilters() {
|
|
132
|
+
throw new Error('Method not implemented.');
|
|
133
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
setSorts() {
|
|
137
|
+
throw new Error('Method not implemented.');
|
|
138
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
setReversed() {
|
|
142
|
+
throw new Error('Method not implemented.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
close() {
|
|
146
|
+
this.listeners = [];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onUpdate(callback) {
|
|
150
|
+
this.listeners = [...this.listeners, callback];
|
|
151
|
+
return () => {
|
|
152
|
+
this.listeners = this.listeners.filter(other => other !== callback);
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
refresh() {
|
|
157
|
+
var _this2 = this;
|
|
158
|
+
|
|
159
|
+
return _asyncToGenerator(function* () {
|
|
160
|
+
var _this2$viewportUpdate;
|
|
161
|
+
|
|
162
|
+
log.debug2(_this2.root, 'refreshData');
|
|
163
|
+
(_this2$viewportUpdate = _this2.viewportUpdatePromise) === null || _this2$viewportUpdate === void 0 ? void 0 : _this2$viewportUpdate.cancel();
|
|
164
|
+
_this2.viewportUpdatePromise = PromiseUtils.makeCancelable(_this2.fetchData());
|
|
165
|
+
var viewportData = yield _this2.viewportUpdatePromise;
|
|
166
|
+
_this2.currentViewportData = viewportData;
|
|
167
|
+
|
|
168
|
+
_this2.sendUpdate();
|
|
169
|
+
|
|
170
|
+
return viewportData;
|
|
171
|
+
})();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Refreshes data, but catches any errors and logs them
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
refreshInternal() {
|
|
179
|
+
var _this3 = this;
|
|
180
|
+
|
|
181
|
+
return _asyncToGenerator(function* () {
|
|
182
|
+
try {
|
|
183
|
+
yield _this3.refresh();
|
|
184
|
+
} catch (e) {
|
|
185
|
+
if (!PromiseUtils.isCanceled(e)) {
|
|
186
|
+
log.error('Unable to refresh data', e);
|
|
187
|
+
}
|
|
288
188
|
}
|
|
189
|
+
})();
|
|
190
|
+
}
|
|
289
191
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
});
|
|
321
|
-
}).sort(function (a, b) {
|
|
322
|
-
if (a.type !== b.type) {
|
|
323
|
-
return a.type === 'directory' ? -1 : 1;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return a.basename.localeCompare(b.basename);
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
case 5:
|
|
331
|
-
items = _context4.sent;
|
|
332
|
-
i = 0;
|
|
333
|
-
|
|
334
|
-
case 7:
|
|
335
|
-
if (!(i < items.length)) {
|
|
336
|
-
_context4.next = 21;
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
item = items[i];
|
|
341
|
-
basename = item.basename, filename = item.filename;
|
|
342
|
-
|
|
343
|
-
if (!(filename === "".concat(this.root).concat(basename) && item.type === 'directory')) {
|
|
344
|
-
_context4.next = 18;
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
childTable = this.childTables.get(basename);
|
|
349
|
-
|
|
350
|
-
if (!(childTable != null)) {
|
|
351
|
-
_context4.next = 18;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
childTable.setViewport({
|
|
356
|
-
top: 0,
|
|
357
|
-
bottom: viewport.bottom - i
|
|
358
|
-
}); // eslint-disable-next-line no-await-in-loop
|
|
359
|
-
|
|
360
|
-
_context4.next = 16;
|
|
361
|
-
return childTable.getViewportData();
|
|
362
|
-
|
|
363
|
-
case 16:
|
|
364
|
-
childViewportData = _context4.sent;
|
|
365
|
-
|
|
366
|
-
(_items = items).splice.apply(_items, [i + 1, 0].concat(_toConsumableArray(childViewportData.items)));
|
|
367
|
-
|
|
368
|
-
case 18:
|
|
369
|
-
i += 1;
|
|
370
|
-
_context4.next = 7;
|
|
371
|
-
break;
|
|
372
|
-
|
|
373
|
-
case 21:
|
|
374
|
-
this.currentSize = items.length;
|
|
375
|
-
log.debug2(this.root, 'items', items, viewport); // Slice it to the correct viewport
|
|
376
|
-
|
|
377
|
-
items = items.slice(viewport.top, viewport.bottom);
|
|
378
|
-
return _context4.abrupt("return", {
|
|
379
|
-
items: items,
|
|
380
|
-
offset: viewport.top
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
case 25:
|
|
384
|
-
case "end":
|
|
385
|
-
return _context4.stop();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}, _callee4, this);
|
|
389
|
-
}));
|
|
192
|
+
fetchData() {
|
|
193
|
+
var _this4 = this;
|
|
194
|
+
|
|
195
|
+
return _asyncToGenerator(function* () {
|
|
196
|
+
var {
|
|
197
|
+
currentViewport: viewport
|
|
198
|
+
} = _this4;
|
|
199
|
+
|
|
200
|
+
if (!viewport) {
|
|
201
|
+
throw new Error('No viewport set');
|
|
202
|
+
} // First get the root directory contents
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
var items = yield _this4.client.getDirectoryContents(_this4.root).then(dirContents => dirContents.map(file => _objectSpread(_objectSpread({}, file), {}, {
|
|
206
|
+
id: file.filename,
|
|
207
|
+
isExpanded: file.type === 'directory' ? _this4.childTables.has(file.basename) : undefined
|
|
208
|
+
})).sort((a, b) => {
|
|
209
|
+
if (a.type !== b.type) {
|
|
210
|
+
return a.type === 'directory' ? -1 : 1;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return a.basename.localeCompare(b.basename);
|
|
214
|
+
})); // Get the data from all expanded directories
|
|
215
|
+
|
|
216
|
+
for (var i = 0; i < items.length; i += 1) {
|
|
217
|
+
var item = items[i];
|
|
218
|
+
var {
|
|
219
|
+
basename,
|
|
220
|
+
filename
|
|
221
|
+
} = item;
|
|
390
222
|
|
|
391
|
-
|
|
392
|
-
|
|
223
|
+
if (filename === "".concat(_this4.root).concat(basename) && item.type === 'directory') {
|
|
224
|
+
var childTable = _this4.childTables.get(basename);
|
|
225
|
+
|
|
226
|
+
if (childTable != null) {
|
|
227
|
+
childTable.setViewport({
|
|
228
|
+
top: 0,
|
|
229
|
+
bottom: viewport.bottom - i
|
|
230
|
+
}); // eslint-disable-next-line no-await-in-loop
|
|
231
|
+
|
|
232
|
+
var childViewportData = yield childTable.getViewportData();
|
|
233
|
+
items.splice(i + 1, 0, ...childViewportData.items);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
393
236
|
}
|
|
394
237
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
// Retain a reference to it in case a listener gets removed while sending an update
|
|
403
|
-
var listeners = this.listeners;
|
|
404
|
-
var data = (_this$currentViewport = this.currentViewportData) !== null && _this$currentViewport !== void 0 ? _this$currentViewport : {
|
|
405
|
-
items: [],
|
|
406
|
-
offset: 0
|
|
238
|
+
_this4.currentSize = items.length;
|
|
239
|
+
log.debug2(_this4.root, 'items', items, viewport); // Slice it to the correct viewport
|
|
240
|
+
|
|
241
|
+
items = items.slice(viewport.top, viewport.bottom);
|
|
242
|
+
return {
|
|
243
|
+
items,
|
|
244
|
+
offset: viewport.top
|
|
407
245
|
};
|
|
246
|
+
})();
|
|
247
|
+
}
|
|
408
248
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
249
|
+
sendUpdate() {
|
|
250
|
+
var _this$currentViewport;
|
|
251
|
+
|
|
252
|
+
// Retain a reference to it in case a listener gets removed while sending an update
|
|
253
|
+
var {
|
|
254
|
+
listeners
|
|
255
|
+
} = this;
|
|
256
|
+
var data = (_this$currentViewport = this.currentViewportData) !== null && _this$currentViewport !== void 0 ? _this$currentViewport : {
|
|
257
|
+
items: [],
|
|
258
|
+
offset: 0
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
for (var i = 0; i < listeners.length; i += 1) {
|
|
262
|
+
listeners[i](data);
|
|
412
263
|
}
|
|
413
|
-
}
|
|
264
|
+
}
|
|
414
265
|
|
|
415
|
-
|
|
416
|
-
}();
|
|
266
|
+
}
|
|
417
267
|
export default WebdavFileStorageTable;
|
|
418
268
|
//# sourceMappingURL=WebdavFileStorageTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/WebdavFileStorageTable.ts"],"names":["Log","PromiseUtils","log","module","WebdavFileStorageTable","client","root","Map","viewportUpdatePromise","refreshInternal","Promise","resolve","items","offset","sortedRanges","Error","currentSize","path","expanded","paths","split","nextPath","shift","remainingPath","join","childTables","has","childTable","set","get","setExpanded","currentViewport","search","viewport","listeners","callback","filter","other","debug2","cancel","makeCancelable","fetchData","viewportData","currentViewportData","sendUpdate","refresh","isCanceled","error","getDirectoryContents","then","dirContents","map","file","id","filename","isExpanded","type","basename","undefined","sort","a","b","localeCompare","i","length","item","setViewport","top","bottom","getViewportData","childViewportData","splice","sl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K,CAACoD,MAAzB;AAEA9D,gBAAAA,GAAG,CAACoC,MAAJ,CAAW,KAAKhC,IAAhB,EAAsB,OAAtB,EAA+BM,KAA/B,EAAsCqB,QAAtC,EA3CF,CA6CE;;AACArB,gBAAAA,KAAK,GAAGA,KAAK,CAAC4D,KAAN,CAAYvC,QAAQ,CAACkC,GAArB,EAA0BlC,QAAQ,CAACmC,MAAnC,CAAR;AA9CF,kDAgDS;AAAExD,kBAAAA,KAAK,EAALA,KAAF;AAASC,kBAAAA,MAAM,EAAEoB,QAAQ,CAACkC;AAA1B,iBAhDT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OA5JF;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,WA+ME,sBAAqB;AAAA;;AACnB;AACA,UAAQjC,SAAR,GAAsB,IAAtB,CAAQA,SAAR;AACA,UAAMuC,IAAI,4BAAG,KAAK9B,mBAAR,yEAA+B;AAAE/B,QAAAA,KAAK,EAAE,EAAT;AAAaC,QAAAA,MAAM,EAAE;AAArB,OAAzC;;AACA,WAAK,IAAIkD,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG7B,SAAS,CAAC8B,MAA9B,EAAsCD,CAAC,IAAI,CAA3C,EAA8C;AAC5C7B,QAAAA,SAAS,CAAC6B,CAAD,CAAT,CAAaU,IAAb;AACD;AACF;AAtNH;;AAAA;AAAA;AAyNA,eAAerE,sBAAf","sourcesContent":["import { FileStat, WebDAVClient } from 'webdav/web';\nimport Log from '@deephaven/log';\nimport {\n StorageTableViewport,\n StorageListenerRemover,\n ViewportUpdateCallback,\n ViewportData,\n IndexRange,\n StorageSnapshot,\n} from '@deephaven/storage';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\nimport { FileStorageTable, FileStorageItem } from './FileStorage';\n\nconst log = Log.module('WebdavFileStorageTable');\n\n/**\n * Implementation of FileStorageTable for WebDAV.\n * Takes a path to specify what root this table should start at.\n */\nexport class WebdavFileStorageTable implements FileStorageTable {\n readonly client: WebDAVClient;\n\n readonly root: string;\n\n private currentSize = 0;\n\n private currentViewport?: StorageTableViewport;\n\n private listeners: ViewportUpdateCallback<FileStorageItem>[] = [];\n\n private viewportUpdatePromise?: CancelablePromise<\n ViewportData<FileStorageItem>\n >;\n\n private currentViewportData?: ViewportData<FileStorageItem>;\n\n /**\n * Map of expanded directory paths to the tables that manage that path.\n * We use a tree of tables to query the server so we just get the directories that are expanded.\n * Also the nginx module we are using does not support a depth of infinity: https://github.com/arut/nginx-dav-ext-module/blob/f5e30888a256136d9c550bf1ada77d6ea78a48af/ngx_http_dav_ext_module.c#L757\n */\n private childTables: Map<string, WebdavFileStorageTable> = new Map();\n\n /**\n * @param client The WebDAV client instance to use\n * @param root The root path for this storage table\n */\n constructor(client: WebDAVClient, root = '/') {\n this.client = client;\n this.root = root;\n }\n\n getViewportData(): Promise<ViewportData<FileStorageItem>> {\n if (!this.viewportUpdatePromise) {\n this.refreshInternal();\n }\n return (\n this.viewportUpdatePromise ?? Promise.resolve({ items: [], offset: 0 })\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n getSnapshot(\n sortedRanges: IndexRange[]\n ): Promise<StorageSnapshot<FileStorageItem>> {\n throw new Error('Method not implemented.');\n }\n\n get size(): number {\n return this.currentSize;\n }\n\n async setExpanded(path: string, expanded: boolean): Promise<void> {\n const paths = path.split('/');\n let nextPath = paths.shift();\n if (!nextPath) {\n nextPath = paths.shift();\n }\n if (!nextPath) {\n throw new Error(`Invalid path: ${path}`);\n }\n const remainingPath = paths.join('/');\n if (expanded) {\n if (!this.childTables.has(nextPath)) {\n const childTable = new WebdavFileStorageTable(\n this.client,\n `${this.root}${nextPath}/`\n );\n this.childTables.set(nextPath, childTable);\n }\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n }\n } else if (this.childTables.has(nextPath)) {\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n } else {\n this.childTables.delete(nextPath);\n }\n }\n if (this.currentViewport) {\n await this.refreshInternal();\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSearch(search: string): void {\n throw new Error('Method not implemented.');\n }\n\n setViewport(viewport: StorageTableViewport): void {\n this.currentViewport = viewport;\n\n this.refreshInternal();\n }\n\n // eslint-disable-next-line class-methods-use-this\n setFilters(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSorts(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setReversed(): void {\n throw new Error('Method not implemented.');\n }\n\n close(): void {\n this.listeners = [];\n }\n\n onUpdate(\n callback: ViewportUpdateCallback<FileStorageItem>\n ): StorageListenerRemover {\n this.listeners = [...this.listeners, callback];\n return () => {\n this.listeners = this.listeners.filter(other => other !== callback);\n };\n }\n\n async refresh(): Promise<ViewportData<FileStorageItem>> {\n log.debug2(this.root, 'refreshData');\n\n this.viewportUpdatePromise?.cancel();\n\n this.viewportUpdatePromise = PromiseUtils.makeCancelable(this.fetchData());\n\n const viewportData = await this.viewportUpdatePromise;\n\n this.currentViewportData = viewportData;\n\n this.sendUpdate();\n\n return viewportData;\n }\n\n /**\n * Refreshes data, but catches any errors and logs them\n */\n private async refreshInternal(): Promise<void> {\n try {\n await this.refresh();\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to refresh data', e);\n }\n }\n }\n\n private async fetchData(): Promise<ViewportData<FileStorageItem>> {\n const { currentViewport: viewport } = this;\n if (!viewport) {\n throw new Error('No viewport set');\n }\n\n // First get the root directory contents\n let items = await this.client.getDirectoryContents(this.root).then(\n dirContents =>\n (dirContents as FileStat[])\n .map(file => ({\n ...file,\n id: file.filename,\n isExpanded:\n file.type === 'directory'\n ? this.childTables.has(file.basename)\n : undefined,\n }))\n .sort((a, b) => {\n if (a.type !== b.type) {\n return a.type === 'directory' ? -1 : 1;\n }\n return a.basename.localeCompare(b.basename);\n }) as FileStorageItem[]\n );\n\n // Get the data from all expanded directories\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n const { basename, filename } = item;\n if (filename === `${this.root}${basename}` && item.type === 'directory') {\n const childTable = this.childTables.get(basename);\n if (childTable != null) {\n childTable.setViewport({ top: 0, bottom: viewport.bottom - i });\n // eslint-disable-next-line no-await-in-loop\n const childViewportData = await childTable.getViewportData();\n items.splice(i + 1, 0, ...childViewportData.items);\n }\n }\n }\n\n this.currentSize = items.length;\n\n log.debug2(this.root, 'items', items, viewport);\n\n // Slice it to the correct viewport\n items = items.slice(viewport.top, viewport.bottom);\n\n return { items, offset: viewport.top };\n }\n\n private sendUpdate() {\n // Retain a reference to it in case a listener gets removed while sending an update\n const { listeners } = this;\n const data = this.currentViewportData ?? { items: [], offset: 0 };\n for (let i = 0; i < listeners.length; i += 1) {\n listeners[i](data);\n }\n }\n}\n\nexport default WebdavFileStorageTable;\n"],"file":"WebdavFileStorageTable.js"}
|
|
1
|
+
{"version":3,"sources":["../src/WebdavFileStorageTable.ts"],"names":["Log","PromiseUtils","log","module","WebdavFileStorageTable","constructor","client","root","Map","getViewportData","viewportUpdatePromise","refreshInternal","Promise","resolve","items","offset","getSnapshot","sortedRanges","Error","size","currentSize","setExpanded","path","expanded","paths","split","nextPath","shift","remainingPath","join","childTables","has","childTable","set","get","delete","currentViewport","setSearch","search","setViewport","viewport","setFilters","setSorts","setReversed","close","listeners","onUpdate","callback","filter","other","refresh","debug2","cancel","makeCancelable","fetchData","viewportData","currentViewportData","sendUpdate","e","isCanceled","error","getDirectoryContents","then","dirContents","map","file","id","filename","isExpanded","type","basename","undefined","sort","a","b","localeCompare","i","length","item","top","bottom","childViewportData","splice","slice","data"],"mappings":";;;;;;;;;;AACA,OAAOA,GAAP,MAAgB,gBAAhB;AASA,SAA4BC,YAA5B,QAAgD,kBAAhD;AAGA,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,wBAAX,CAAZ;AAEA;AACA;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IAAI,CAA3C,EAA8C;AAC5C/B,MAAAA,SAAS,CAAC+B,CAAD,CAAT,CAAaQ,IAAb;AACD;AACF;;AAtN6D;AAyNhE,eAAehF,sBAAf","sourcesContent":["import { FileStat, WebDAVClient } from 'webdav/web';\nimport Log from '@deephaven/log';\nimport {\n StorageTableViewport,\n StorageListenerRemover,\n ViewportUpdateCallback,\n ViewportData,\n IndexRange,\n StorageSnapshot,\n} from '@deephaven/storage';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\nimport { FileStorageTable, FileStorageItem } from './FileStorage';\n\nconst log = Log.module('WebdavFileStorageTable');\n\n/**\n * Implementation of FileStorageTable for WebDAV.\n * Takes a path to specify what root this table should start at.\n */\nexport class WebdavFileStorageTable implements FileStorageTable {\n readonly client: WebDAVClient;\n\n readonly root: string;\n\n private currentSize = 0;\n\n private currentViewport?: StorageTableViewport;\n\n private listeners: ViewportUpdateCallback<FileStorageItem>[] = [];\n\n private viewportUpdatePromise?: CancelablePromise<\n ViewportData<FileStorageItem>\n >;\n\n private currentViewportData?: ViewportData<FileStorageItem>;\n\n /**\n * Map of expanded directory paths to the tables that manage that path.\n * We use a tree of tables to query the server so we just get the directories that are expanded.\n * Also the nginx module we are using does not support a depth of infinity: https://github.com/arut/nginx-dav-ext-module/blob/f5e30888a256136d9c550bf1ada77d6ea78a48af/ngx_http_dav_ext_module.c#L757\n */\n private childTables: Map<string, WebdavFileStorageTable> = new Map();\n\n /**\n * @param client The WebDAV client instance to use\n * @param root The root path for this storage table\n */\n constructor(client: WebDAVClient, root = '/') {\n this.client = client;\n this.root = root;\n }\n\n getViewportData(): Promise<ViewportData<FileStorageItem>> {\n if (!this.viewportUpdatePromise) {\n this.refreshInternal();\n }\n return (\n this.viewportUpdatePromise ?? Promise.resolve({ items: [], offset: 0 })\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n getSnapshot(\n sortedRanges: IndexRange[]\n ): Promise<StorageSnapshot<FileStorageItem>> {\n throw new Error('Method not implemented.');\n }\n\n get size(): number {\n return this.currentSize;\n }\n\n async setExpanded(path: string, expanded: boolean): Promise<void> {\n const paths = path.split('/');\n let nextPath = paths.shift();\n if (!nextPath) {\n nextPath = paths.shift();\n }\n if (!nextPath) {\n throw new Error(`Invalid path: ${path}`);\n }\n const remainingPath = paths.join('/');\n if (expanded) {\n if (!this.childTables.has(nextPath)) {\n const childTable = new WebdavFileStorageTable(\n this.client,\n `${this.root}${nextPath}/`\n );\n this.childTables.set(nextPath, childTable);\n }\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n }\n } else if (this.childTables.has(nextPath)) {\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n } else {\n this.childTables.delete(nextPath);\n }\n }\n if (this.currentViewport) {\n await this.refreshInternal();\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSearch(search: string): void {\n throw new Error('Method not implemented.');\n }\n\n setViewport(viewport: StorageTableViewport): void {\n this.currentViewport = viewport;\n\n this.refreshInternal();\n }\n\n // eslint-disable-next-line class-methods-use-this\n setFilters(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSorts(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setReversed(): void {\n throw new Error('Method not implemented.');\n }\n\n close(): void {\n this.listeners = [];\n }\n\n onUpdate(\n callback: ViewportUpdateCallback<FileStorageItem>\n ): StorageListenerRemover {\n this.listeners = [...this.listeners, callback];\n return () => {\n this.listeners = this.listeners.filter(other => other !== callback);\n };\n }\n\n async refresh(): Promise<ViewportData<FileStorageItem>> {\n log.debug2(this.root, 'refreshData');\n\n this.viewportUpdatePromise?.cancel();\n\n this.viewportUpdatePromise = PromiseUtils.makeCancelable(this.fetchData());\n\n const viewportData = await this.viewportUpdatePromise;\n\n this.currentViewportData = viewportData;\n\n this.sendUpdate();\n\n return viewportData;\n }\n\n /**\n * Refreshes data, but catches any errors and logs them\n */\n private async refreshInternal(): Promise<void> {\n try {\n await this.refresh();\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to refresh data', e);\n }\n }\n }\n\n private async fetchData(): Promise<ViewportData<FileStorageItem>> {\n const { currentViewport: viewport } = this;\n if (!viewport) {\n throw new Error('No viewport set');\n }\n\n // First get the root directory contents\n let items = await this.client.getDirectoryContents(this.root).then(\n dirContents =>\n (dirContents as FileStat[])\n .map(file => ({\n ...file,\n id: file.filename,\n isExpanded:\n file.type === 'directory'\n ? this.childTables.has(file.basename)\n : undefined,\n }))\n .sort((a, b) => {\n if (a.type !== b.type) {\n return a.type === 'directory' ? -1 : 1;\n }\n return a.basename.localeCompare(b.basename);\n }) as FileStorageItem[]\n );\n\n // Get the data from all expanded directories\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n const { basename, filename } = item;\n if (filename === `${this.root}${basename}` && item.type === 'directory') {\n const childTable = this.childTables.get(basename);\n if (childTable != null) {\n childTable.setViewport({ top: 0, bottom: viewport.bottom - i });\n // eslint-disable-next-line no-await-in-loop\n const childViewportData = await childTable.getViewportData();\n items.splice(i + 1, 0, ...childViewportData.items);\n }\n }\n }\n\n this.currentSize = items.length;\n\n log.debug2(this.root, 'items', items, viewport);\n\n // Slice it to the correct viewport\n items = items.slice(viewport.top, viewport.bottom);\n\n return { items, offset: viewport.top };\n }\n\n private sendUpdate() {\n // Retain a reference to it in case a listener gets removed while sending an update\n const { listeners } = this;\n const data = this.currentViewportData ?? { items: [], offset: 0 };\n for (let i = 0; i < listeners.length; i += 1) {\n listeners[i](data);\n }\n }\n}\n\nexport default WebdavFileStorageTable;\n"],"file":"WebdavFileStorageTable.js"}
|