@ibm-aspera/sdk 0.2.7 → 0.2.8
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/commonjs/app/core.d.ts +2 -1
- package/dist/commonjs/app/core.js +10 -3
- package/dist/commonjs/constants/messages.d.ts +1 -0
- package/dist/commonjs/constants/messages.js +1 -0
- package/dist/js/aspera-sdk.js +1 -1
- package/dist/js/aspera-sdk.js.LICENSE.txt +1 -1
- package/dist/js/aspera-sdk.js.map +1 -1
- package/package.json +3 -3
- package/.editorconfig +0 -13
- package/.eslintrc.js +0 -131
- package/.github/CODE_OF_CONDUCT.md +0 -128
- package/.github/CONTRIBUTING.md +0 -147
- package/.github/workflows/ci.yml +0 -36
- package/.github/workflows/documentation.yml +0 -43
- package/.github/workflows/npm_upload.yml +0 -30
- package/.husky/pre-commit +0 -4
- package/CHANGELOG.md +0 -165
- package/docs/DEVELOPMENT.md +0 -38
- package/example/README.md +0 -7
- package/example/index.html +0 -14
- package/example/package-lock.json +0 -2847
- package/example/package.json +0 -29
- package/example/public/404.html +0 -5
- package/example/public/sdk-code.js +0 -334
- package/example/src/App/App.scss +0 -40
- package/example/src/App/index.tsx +0 -174
- package/example/src/Views/AllTogether.tsx +0 -26
- package/example/src/Views/DragDrop.tsx +0 -23
- package/example/src/Views/Home.tsx +0 -10
- package/example/src/Views/Initialize.tsx +0 -21
- package/example/src/Views/Installer.tsx +0 -119
- package/example/src/Views/MonitorTransfers.tsx +0 -88
- package/example/src/Views/Other.tsx +0 -25
- package/example/src/Views/SelectItems.tsx +0 -46
- package/example/src/Views/StartTransfer.tsx +0 -32
- package/example/src/Views/Test.tsx +0 -20
- package/example/src/Views/Views.scss +0 -111
- package/example/src/helpers/index.ts +0 -19
- package/example/src/index.scss +0 -47
- package/example/src/main.tsx +0 -17
- package/example/src/vite-env.d.ts +0 -2
- package/example/tsconfig.json +0 -30
- package/example/vite.config.ts +0 -22
- package/jest.config.js +0 -15
- package/jest.setup.js +0 -0
- package/src/app/core.ts +0 -611
- package/src/app/installer.ts +0 -53
- package/src/constants/constants.ts +0 -19
- package/src/constants/messages.ts +0 -29
- package/src/helpers/client/client.ts +0 -11
- package/src/helpers/client/http-client.ts +0 -92
- package/src/helpers/client/safari-client.ts +0 -334
- package/src/helpers/helpers.ts +0 -214
- package/src/helpers/http.ts +0 -39
- package/src/helpers/ws.ts +0 -215
- package/src/index.ts +0 -78
- package/src/models/aspera-sdk.model.ts +0 -399
- package/src/models/models.ts +0 -676
- package/tests/client.spec.ts +0 -52
- package/tests/core.spec.ts +0 -13
- package/tests/helpers.spec.ts +0 -124
- package/tests/http.spec.ts +0 -14
- package/tests/installer.spec.ts +0 -135
- package/tests/mocks.ts +0 -11
- package/tsconfig.json +0 -13
- package/tsconfig.module.json +0 -16
- package/typedoc.js +0 -17
- package/webpack.config.js +0 -35
package/example/package.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aspera-sdk-js-test",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"start": "vite",
|
|
7
|
-
"build": "rm -rf dist && tsc -b && vite build --base /aspera-sdk-js/"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"@carbon/icons-react": "^11.57.0",
|
|
11
|
-
"@carbon/react": "^1.79.0",
|
|
12
|
-
"highlight.js": "^11.11.1",
|
|
13
|
-
"markdown-it": "^14.1.0",
|
|
14
|
-
"react": "^19.0.0",
|
|
15
|
-
"react-dom": "^19.0.0",
|
|
16
|
-
"react-router": "^7.4.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@types/markdown-it": "^14.1.2",
|
|
20
|
-
"@types/react": "^19.0.10",
|
|
21
|
-
"@types/react-dom": "^19.0.4",
|
|
22
|
-
"@vitejs/plugin-basic-ssl": "^2.0.0",
|
|
23
|
-
"@vitejs/plugin-react": "^4.3.4",
|
|
24
|
-
"globals": "^15.15.0",
|
|
25
|
-
"sass": "^1.86.2",
|
|
26
|
-
"typescript": "~5.7.2",
|
|
27
|
-
"vite": "^6.2.0"
|
|
28
|
-
}
|
|
29
|
-
}
|
package/example/public/404.html
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This JS file is used for code snippet examples.
|
|
3
|
-
* TypeScript file declrarations of toString
|
|
4
|
-
* do not maintain comments or newlines.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
window.selectedFiles = [];
|
|
8
|
-
|
|
9
|
-
function initializeAspera(supportMulti) {
|
|
10
|
-
/**
|
|
11
|
-
* An ID for your application. For multi user applications
|
|
12
|
-
* this can include the user ID or other identifier
|
|
13
|
-
*/
|
|
14
|
-
const appId = 'my-application-unique-id';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Indicate if machine runs the app with multiple user's at once
|
|
18
|
-
* like a virtual machine.
|
|
19
|
-
*/
|
|
20
|
-
const supportMultipleUsers = !!supportMulti;
|
|
21
|
-
|
|
22
|
-
asperaSdk.init({appId, supportMultipleUsers}).then(() => {
|
|
23
|
-
// The SDK started. Transfers and file picker can now be used.
|
|
24
|
-
alert('SDK started');
|
|
25
|
-
}).catch(error => {
|
|
26
|
-
// The SDK could not start. The app may not be running.
|
|
27
|
-
console.error('SDK could not start', error);
|
|
28
|
-
alert(`Init failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function testAspera() {
|
|
33
|
-
asperaSdk.testConnection().then(response => {
|
|
34
|
-
// The test was successful. The app is running
|
|
35
|
-
alert(`Test successful\n\n${JSON.stringify(response, undefined, 2)}`);
|
|
36
|
-
}).catch(error => {
|
|
37
|
-
// The test failed. The app is not running or cannot be reached.
|
|
38
|
-
console.error('Test failed', error);
|
|
39
|
-
alert(`Test failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function selectItemsAspera(selectFolders) {
|
|
44
|
-
/**
|
|
45
|
-
* showSelectFolderDialog will only allow picking folders.
|
|
46
|
-
* showSelectFileDialog will only allow picking files.
|
|
47
|
-
* They both return the same response type. So swapping
|
|
48
|
-
* out the function is safe.
|
|
49
|
-
*/
|
|
50
|
-
(selectFolders ? asperaSdk.showSelectFolderDialog() : asperaSdk.showSelectFileDialog()).then(response => {
|
|
51
|
-
/**
|
|
52
|
-
* File list for transferSpec is returned in `response.dataTransfer.files` array
|
|
53
|
-
* where name is the path to the selected item.
|
|
54
|
-
*/
|
|
55
|
-
alert(`Selected items:\n\n${JSON.stringify(response, undefined, 2)}`);
|
|
56
|
-
response.dataTransfer.files.forEach(item => window.selectedFiles.push(item));
|
|
57
|
-
}).catch(error => {
|
|
58
|
-
// If code -32002 then user canceled selecting. Otherwise another failure.
|
|
59
|
-
if (error.debugData?.code === -32002) {
|
|
60
|
-
alert('User canceled selecting items');
|
|
61
|
-
} else {
|
|
62
|
-
console.error('Selecting items failed', error);
|
|
63
|
-
alert(`Selecting items failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function startTransferAspera(transferSpec) {
|
|
69
|
-
/** The AsperaSpec defines rules on how the client app should work with transfers */
|
|
70
|
-
const asperaSpec = {use_absolute_destination_path: false};
|
|
71
|
-
|
|
72
|
-
asperaSdk.startTransfer(transferSpec, asperaSpec).then(response => {
|
|
73
|
-
// Transfer accepted and is starting
|
|
74
|
-
alert(`Transfer started:\n\n${JSON.stringify(response, undefined, 2)}`);
|
|
75
|
-
}).catch(error => {
|
|
76
|
-
// Transfer not accepted by the Aspera app
|
|
77
|
-
console.error('Start transfer failed', error);
|
|
78
|
-
alert(`Start transfer failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function setupDropAspera(dropZone) {
|
|
83
|
-
/**
|
|
84
|
-
* dropZone is a CSS style selector for an element that should be
|
|
85
|
-
* registered to watch for file drop events.
|
|
86
|
-
*
|
|
87
|
-
* You only need to init once and then can register each dropZone
|
|
88
|
-
* inidividually. Depending on how many drop zones may need to loop
|
|
89
|
-
* or split init and set dropzones.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
// For safety you can prevent at highest level drop default actions
|
|
93
|
-
// This is useful to avoid browser opening file if not dropped in the
|
|
94
|
-
// Dropzone
|
|
95
|
-
window.addEventListener('drop', event => {
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
});
|
|
98
|
-
window.addEventListener('dragover', event => {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
/** The callback for when files are dropped */
|
|
103
|
-
const dropCallback = response => {
|
|
104
|
-
response.event.stopPropagation();
|
|
105
|
-
/**
|
|
106
|
-
* File list for transferSpec is returned in `response.files.dataTransfer.files` array
|
|
107
|
-
* where name is the path to the selected item.
|
|
108
|
-
*/
|
|
109
|
-
alert(`Dropped items:\n\n${JSON.stringify(response.files, undefined, 2)}`);
|
|
110
|
-
response.files.dataTransfer.files.forEach(item => window.selectedFiles.push(item));
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* While not needed normally. You can also remove the dropdzone.
|
|
115
|
-
* This will remove the listener and no longer accept drops to that element.
|
|
116
|
-
*/
|
|
117
|
-
const cancelDropzone = () => {
|
|
118
|
-
asperaSdk.removeDropzone(dropZone);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
asperaSdk.initDragDrop().then(() => {
|
|
122
|
-
// Drag and drop can now be safely registered
|
|
123
|
-
// Register the dropZone
|
|
124
|
-
asperaSdk.createDropzone(dropCallback, dropZone);
|
|
125
|
-
}).catch(error => {
|
|
126
|
-
// Drag and drop init failed. This is rare.
|
|
127
|
-
console.error('Drag and drop could not start', error);
|
|
128
|
-
alert(`Drag and drop failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function monitorTransfersAspera() {
|
|
133
|
-
/**
|
|
134
|
-
* Setup all monitor callbacks and store transfers with latest
|
|
135
|
-
* data in the transferStore to render on a UI.
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
// Create local store to hold all transfers
|
|
139
|
-
/** @type {Map<string, AsperaSdkTransfer>} */
|
|
140
|
-
const transferStore = new Map();
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Create a function to parse transfers and place in map.
|
|
144
|
-
* Monitor and get all return similar responses.
|
|
145
|
-
* @param {AsperaSdkTransfer[]} transfers
|
|
146
|
-
*/
|
|
147
|
-
const parseTransfers = transfers => {
|
|
148
|
-
transfers.forEach(item => {
|
|
149
|
-
transferStore.set(item.uuid, item);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// On load get all transfers. This needs to be done after init.
|
|
154
|
-
asperaSdk.getAllTransfers().then(transfers => {
|
|
155
|
-
parseTransfers(transfers);
|
|
156
|
-
}).catch(error => {
|
|
157
|
-
console.error('Could not get all transfers on load', error);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// Register event listener for new transfers
|
|
161
|
-
asperaSdk.registerActivityCallback(response => {
|
|
162
|
-
parseTransfers(response.transfers);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Register event listener for transfers removed from app
|
|
166
|
-
asperaSdk.registerRemovedCallback(transfer => {
|
|
167
|
-
transferStore.delete(transfer.uuid);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// Used for demo. Normally use this store to render on the UI
|
|
171
|
-
return transferStore;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function removeTransferAspera(transferId) {
|
|
175
|
-
/** Remove a transfer from the monitor in app and from SDK responses */
|
|
176
|
-
asperaSdk.removeTransfer(transferId).then(response => {
|
|
177
|
-
// Transfer was removed. Remove it from local store
|
|
178
|
-
alert('Transfer removed');
|
|
179
|
-
console.info('Transfer removed', response);
|
|
180
|
-
}).catch(error => {
|
|
181
|
-
// Transfer could not be removed
|
|
182
|
-
console.error('Transfer removal failed', error);
|
|
183
|
-
alert(`Transfer removal failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function stopTransferAspera(transferId) {
|
|
188
|
-
/** Stop an active transfer. You can resume this transfer later. */
|
|
189
|
-
asperaSdk.stopTransfer(transferId).then(() => {
|
|
190
|
-
// Transfer was stopped. Next update from activity should indicate this.
|
|
191
|
-
alert('Transfer stopped');
|
|
192
|
-
console.info('Transfer stopped', response);
|
|
193
|
-
}).catch(error => {
|
|
194
|
-
// Transfer could not be stopped
|
|
195
|
-
console.error('Transfer stopping failed', error);
|
|
196
|
-
alert(`Transfer stopping failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function resumeTransferAspera(transferId) {
|
|
201
|
-
/** Resume a stopped transfer. */
|
|
202
|
-
asperaSdk.resumeTransfer(transferId).then(response => {
|
|
203
|
-
// Transfer was resumed. Next update from activity should indicate this.
|
|
204
|
-
alert('Transfer resumed');
|
|
205
|
-
console.info('Transfer resumed', response);
|
|
206
|
-
}).catch(error => {
|
|
207
|
-
// Transfer could not be resumed
|
|
208
|
-
console.error('Transfer resuming failed', error);
|
|
209
|
-
alert(`Transfer resuming failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function showDirectoryAspera(transferId) {
|
|
214
|
-
/** Open the local directory of the downloaded item. */
|
|
215
|
-
asperaSdk.showDirectory(transferId).then(response => {
|
|
216
|
-
console.info('Show directory', response);
|
|
217
|
-
}).catch(error => {
|
|
218
|
-
// Transfer info could not be retrieved
|
|
219
|
-
console.error('Show local directory failed', error);
|
|
220
|
-
alert(`Show local directory failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function transferInfoAspera(transferId) {
|
|
225
|
-
/** Get all details on a specific transfer. */
|
|
226
|
-
asperaSdk.getTransfer(transferId).then(response => {
|
|
227
|
-
alert('Transfer info retrieved. See console for object.');
|
|
228
|
-
console.info('Get transfer', response);
|
|
229
|
-
}).catch(error => {
|
|
230
|
-
// Transfer info could not be retrieved
|
|
231
|
-
console.error('Transfer info get failed', error);
|
|
232
|
-
alert(`Transfer info get failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function getInfoAspera() {
|
|
237
|
-
/** Get metadata about the IBM Aspera installation. */
|
|
238
|
-
asperaSdk.getInfo().then(response => {
|
|
239
|
-
alert(`Get info response\n\n${JSON.stringify(response, undefined, 2)}`);
|
|
240
|
-
console.info('Get info response', response);
|
|
241
|
-
}).catch(error => {
|
|
242
|
-
console.error('Get info failed', error);
|
|
243
|
-
alert(`Get info failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function showPreferencesAspera() {
|
|
248
|
-
/** Open preference window for IBM Aspera. */
|
|
249
|
-
asperaSdk.showPreferences().catch(error => {
|
|
250
|
-
console.error('Show preferences failed', error);
|
|
251
|
-
alert(`Show preferences failed\n\n${JSON.stringify(error, undefined, 2)}`);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function registerStatusCallbackAspera() {
|
|
256
|
-
/**
|
|
257
|
-
* Register status callback. This will monitor if the app is closed or reopens.
|
|
258
|
-
* This test currently just consoles all changes.
|
|
259
|
-
*/
|
|
260
|
-
alert('Registered app status changes. Monitor the console for events.');
|
|
261
|
-
|
|
262
|
-
asperaSdk.registerStatusCallback(status => {
|
|
263
|
-
console.info('Status changed', status);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function registerSafariExtensionStatusCallbackAspera() {
|
|
268
|
-
/**
|
|
269
|
-
* Register status callback for the Safari Extension.
|
|
270
|
-
* This will monitor if the extension has changes.
|
|
271
|
-
* `isSafari` is provided by the Aspera SDK.
|
|
272
|
-
*
|
|
273
|
-
* This test currently just consoles all changes.
|
|
274
|
-
*/
|
|
275
|
-
|
|
276
|
-
if (asperaSdk.isSafari()) {
|
|
277
|
-
alert('Registered safari extension changes. Monitor the console for events.');
|
|
278
|
-
|
|
279
|
-
asperaSdk.registerSafariExtensionStatusCallback(status => {
|
|
280
|
-
console.info('Status changed for Safari Extension', status);
|
|
281
|
-
});
|
|
282
|
-
} else {
|
|
283
|
-
alert('Register safari extension not set since not in Safari');
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function installerAspera() {
|
|
288
|
-
/**
|
|
289
|
-
* Basic JavaScript to get the installers and
|
|
290
|
-
* load it into the DOM.
|
|
291
|
-
* After successful init you should usually remove this.
|
|
292
|
-
*/
|
|
293
|
-
|
|
294
|
-
asperaSdk.getInstallerInfo().then(response => {
|
|
295
|
-
const header = document.createElement('h4');
|
|
296
|
-
header.innerText = 'IBM Aspera Installer';
|
|
297
|
-
header.style = 'margin-bottom: 20px; color: #fff;';
|
|
298
|
-
|
|
299
|
-
const launchButton = document.createElement('button');
|
|
300
|
-
launchButton.innerText = 'Launch'
|
|
301
|
-
launchButton.style = 'display: block; width: 100%; margin-bottom: 16px; padding: 8px';
|
|
302
|
-
launchButton.type = 'button';
|
|
303
|
-
launchButton.onclick = () => {
|
|
304
|
-
// Provide a way to launch the SDK if already installed
|
|
305
|
-
asperaSdk.launch();
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const buttons = response.entries.map(entry => {
|
|
309
|
-
// Loop over each entry and make a button to click it to open download
|
|
310
|
-
// Normally just one item. But some may have more. So iterate the entries
|
|
311
|
-
const button = document.createElement('button');
|
|
312
|
-
button.type = 'button';
|
|
313
|
-
button.style = 'display: block; width: 100%; margin-bottom: 16px; padding: 8px';
|
|
314
|
-
button.innerText = `Install (${entry.platform} - ${entry.type})`;
|
|
315
|
-
button.onclick = () => {
|
|
316
|
-
window.open(entry.url, '_blank', 'noopener,noreferrer');
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
return button;
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
buttons.unshift(launchButton);
|
|
323
|
-
|
|
324
|
-
// Create the wrapper element and add it to body as fixed element
|
|
325
|
-
const wrapper = document.createElement('div');
|
|
326
|
-
wrapper.id = 'aspera-installer-test';
|
|
327
|
-
wrapper.style = 'position: fixed; bottom: 0px; right: 32px; height: 260px; width: 280px; background-color: #444; padding: 16px 20px;';
|
|
328
|
-
wrapper.append(header, ...buttons);
|
|
329
|
-
|
|
330
|
-
document.body.append(wrapper);
|
|
331
|
-
}).catch(error => {
|
|
332
|
-
console.error('Installer info get failed', error);
|
|
333
|
-
});
|
|
334
|
-
}
|
package/example/src/App/App.scss
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.aspera-root {
|
|
2
|
-
height: 100vh;
|
|
3
|
-
|
|
4
|
-
.content-root {
|
|
5
|
-
position: absolute;
|
|
6
|
-
top: 3rem;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
right: 0;
|
|
9
|
-
left: 0;
|
|
10
|
-
overflow-y: auto;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.content-header {
|
|
14
|
-
.cds--tabs {
|
|
15
|
-
border-top: 1px solid var(--cds-border-subtle);
|
|
16
|
-
border-bottom: 1px solid var(--cds-border-subtle);
|
|
17
|
-
padding: 0 3rem;
|
|
18
|
-
|
|
19
|
-
.cds--tabs__nav-item {
|
|
20
|
-
min-width: 7rem;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
h1 {
|
|
25
|
-
padding: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&-title {
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
align-items: end;
|
|
32
|
-
padding: 2rem 3rem 1rem 3rem;
|
|
33
|
-
flex-wrap: wrap;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.route-root {
|
|
38
|
-
padding: 2rem 3rem;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import './App.scss';
|
|
2
|
-
import { init, launch, testConnection } from '@ibm-aspera/sdk';
|
|
3
|
-
import { Header, HeaderGlobalAction, HeaderGlobalBar, HeaderName, Theme, Tab, TabList, Tabs, Button } from '@carbon/react';
|
|
4
|
-
import { LogoGithub, Notification, NotificationOff, Sdk } from '@carbon/icons-react';
|
|
5
|
-
import { Route, Routes, useLocation, useNavigate } from 'react-router';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
7
|
-
import hljs from 'highlight.js/lib/core';
|
|
8
|
-
import javascript from 'highlight.js/lib/languages/javascript';
|
|
9
|
-
import Initialize from '../Views/Initialize';
|
|
10
|
-
import Test from '../Views/Test';
|
|
11
|
-
import StartTransfer from '../Views/StartTransfer';
|
|
12
|
-
import MonitorTransfers from '../Views/MonitorTransfers';
|
|
13
|
-
import SelectItems from '../Views/SelectItems';
|
|
14
|
-
import Installer from '../Views/Installer';
|
|
15
|
-
import DragDrop from '../Views/DragDrop';
|
|
16
|
-
import Other from '../Views/Other';
|
|
17
|
-
import Home from '../Views/Home';
|
|
18
|
-
import AllTogether from '../Views/AllTogether';
|
|
19
|
-
|
|
20
|
-
export const tabItems = [
|
|
21
|
-
{route: '/', name: 'Home', component: <Home />},
|
|
22
|
-
{route: '/init', name: 'Initialize', component: <Initialize />, row: 1},
|
|
23
|
-
{route: '/test', name: 'Test', component: <Test />, row: 1},
|
|
24
|
-
{route: '/installer', name: 'Installing', component: <Installer />, row: 4},
|
|
25
|
-
{route: '/select-items', name: 'Select items', component: <SelectItems />, row: 3},
|
|
26
|
-
{route: '/start-transfer', name: 'Start transfer', component: <StartTransfer />, row: 2},
|
|
27
|
-
{route: '/manage-transfer', name: 'Manage transfers', component: <MonitorTransfers />, row: 2},
|
|
28
|
-
{route: '/drag-drop', name: 'Drag & drop', component: <DragDrop />, row: 3},
|
|
29
|
-
{route: '/other', name: 'Other', component: <Other />, row: 1},
|
|
30
|
-
{route: '/all', name: 'All together', component: <AllTogether />},
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
export default function App() {
|
|
34
|
-
const [disableAlert, setDisableAlert] = useState(false);
|
|
35
|
-
const navigate = useNavigate();
|
|
36
|
-
const location = useLocation();
|
|
37
|
-
hljs.registerLanguage('javascript', javascript);
|
|
38
|
-
let initialized = false;
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
// Prevent drag and drop testing from reloading page
|
|
42
|
-
window.addEventListener('drop', event => {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
});
|
|
45
|
-
window.addEventListener('dragover', event => {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
window.addEventListener('keyup', event => {
|
|
50
|
-
// If ESCAPE is pressed remove the installer window if set. Hidden option for power users.
|
|
51
|
-
if (event.key === 'Escape') {
|
|
52
|
-
document.querySelector('#aspera-installer-test')?.remove();
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const path = localStorage.getItem('path');
|
|
57
|
-
|
|
58
|
-
if (path) {
|
|
59
|
-
localStorage.removeItem('path');
|
|
60
|
-
navigate(path);
|
|
61
|
-
}
|
|
62
|
-
}, []);
|
|
63
|
-
|
|
64
|
-
const openGithub = (): void => {
|
|
65
|
-
window.open('https://github.com/IBM/aspera-sdk-js', '_blank', 'noopener,noreferrer');
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const openSDKdocs = (): void => {
|
|
69
|
-
window.open('docs', '_blank', 'noopener,noreferrer');
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const toggleAlert = (): void => {
|
|
73
|
-
const newValue = !disableAlert;
|
|
74
|
-
|
|
75
|
-
if (newValue) {
|
|
76
|
-
window.alert = (data) => {
|
|
77
|
-
console.info(data);
|
|
78
|
-
};
|
|
79
|
-
} else {
|
|
80
|
-
window.location.reload();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setDisableAlert(newValue);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const openPath = (path: string): void => {
|
|
87
|
-
navigate(path);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const header = (
|
|
91
|
-
<Header aria-label="Carbon Tutorial">
|
|
92
|
-
<HeaderName prefix="IBM Aspera">JavaScript SDK Test Application</HeaderName>
|
|
93
|
-
<HeaderGlobalBar>
|
|
94
|
-
<HeaderGlobalAction aria-label={disableAlert ? 'Enable alerts (needs reload)' : 'Disable alerts'} tooltipAlignment="end" className="action-icons" onClick={toggleAlert}>
|
|
95
|
-
{disableAlert ? <Notification size={20} /> : <NotificationOff size={20} />}
|
|
96
|
-
</HeaderGlobalAction>
|
|
97
|
-
<HeaderGlobalAction aria-label="Github" tooltipAlignment="end" className="action-icons" onClick={openGithub}>
|
|
98
|
-
<LogoGithub size={20} />
|
|
99
|
-
</HeaderGlobalAction>
|
|
100
|
-
<HeaderGlobalAction aria-label="SDK Docs" tooltipAlignment="end" className="action-icons" onClick={openSDKdocs}>
|
|
101
|
-
<Sdk size={20} />
|
|
102
|
-
</HeaderGlobalAction>
|
|
103
|
-
</HeaderGlobalBar>
|
|
104
|
-
</Header>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const startApp = (): void => {
|
|
108
|
-
let testResolved = false;
|
|
109
|
-
|
|
110
|
-
const initCallback = (): void => {
|
|
111
|
-
if (initialized) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Seeing issue in Safari where calling init doesn't catch or then...
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
init({appId: 'my-application-unique-id'}).then(() => {
|
|
118
|
-
initialized = true;
|
|
119
|
-
}).catch((error: unknown) => {
|
|
120
|
-
console.error('SDK could not start from quick launch', error);
|
|
121
|
-
})
|
|
122
|
-
}, 3000);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
testConnection().then(() => {
|
|
126
|
-
testResolved = true;
|
|
127
|
-
initCallback();
|
|
128
|
-
}).catch(() => {
|
|
129
|
-
testResolved = true;
|
|
130
|
-
launch();
|
|
131
|
-
initCallback();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
setTimeout(() => {
|
|
135
|
-
// Test never resolved. Launch
|
|
136
|
-
if (!testResolved) {
|
|
137
|
-
launch();
|
|
138
|
-
initCallback();
|
|
139
|
-
}
|
|
140
|
-
}, 2000);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const currentTabIndex = tabItems.findIndex(item => item.route === location.pathname);
|
|
144
|
-
|
|
145
|
-
const tabs = (
|
|
146
|
-
<Tabs selectedIndex={currentTabIndex}>
|
|
147
|
-
<TabList contained>
|
|
148
|
-
{tabItems.map(item => <Tab key={item.route} onClick={() => openPath(item.route)}>{item.name}</Tab>)}
|
|
149
|
-
</TabList>
|
|
150
|
-
</Tabs>
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<Theme theme="g100" className="aspera-root">
|
|
155
|
-
{header}
|
|
156
|
-
<div className="content-root">
|
|
157
|
-
<div className="content-header">
|
|
158
|
-
<div className="content-header-title">
|
|
159
|
-
<h1>{tabItems[currentTabIndex]?.name || '404'}</h1>
|
|
160
|
-
<div className="content-header-title--actions">
|
|
161
|
-
<Button kind="ghost" type="button" onClick={startApp}>Launch and start</Button>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
{tabs}
|
|
165
|
-
</div>
|
|
166
|
-
<div className="route-root">
|
|
167
|
-
<Routes>
|
|
168
|
-
{tabItems.map(item => <Route index={item.route === '/'} key={item.route} path={item.route === '/' ? undefined : item.route} element={item.component} />)}
|
|
169
|
-
</Routes>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
</Theme>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import './Views.scss';
|
|
2
|
-
import { tabItems } from '../App';
|
|
3
|
-
|
|
4
|
-
export default function AllTogether() {
|
|
5
|
-
const getItem = (item: {route: string; name: string; component: React.ReactNode}): React.ReactNode => {
|
|
6
|
-
return (
|
|
7
|
-
<div className="item-area" key={item.route}>
|
|
8
|
-
{item.component}
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const rows = tabItems.filter(item => !!item.row).map(item => item.row).sort();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div className="example-pages all-together">
|
|
17
|
-
{[...new Set(rows)].map(row => {
|
|
18
|
-
return (
|
|
19
|
-
<div className={`item-row ${row === 1 ? 'flat-space' : ''}`} key={row}>
|
|
20
|
-
{tabItems.filter(item => item.row === row).map(item => getItem(item))}
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
})}
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import './Views.scss';
|
|
2
|
-
import { Button, CodeSnippet } from '@carbon/react';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
import hljs from 'highlight.js';
|
|
5
|
-
|
|
6
|
-
export default function DragDrop() {
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
document.querySelector('.cds--snippet-container > pre > code')?.classList.add('language-javascript');
|
|
9
|
-
hljs.highlightAll();
|
|
10
|
-
}, []);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div className="example-pages">
|
|
14
|
-
<h2>Code example</h2>
|
|
15
|
-
<CodeSnippet type="multi" feedback="Copied to clipboard" maxCollapsedNumberOfRows={25}>{window.setupDropAspera.toString()}</CodeSnippet>
|
|
16
|
-
<h2>Try it out</h2>
|
|
17
|
-
<Button onClick={() => window.setupDropAspera('#drop-zone')}>Setup Drag & drop</Button>
|
|
18
|
-
<div className="drop-zone" id="drop-zone">
|
|
19
|
-
Drag and drop files here
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import './Views.scss';
|
|
2
|
-
import readme from '../../../README.md?raw';
|
|
3
|
-
import MarkdownIt from 'markdown-it';
|
|
4
|
-
|
|
5
|
-
export default function Home() {
|
|
6
|
-
const converter = new MarkdownIt();
|
|
7
|
-
let htmlData = converter.render(readme);
|
|
8
|
-
|
|
9
|
-
return <div className="markdown-render" dangerouslySetInnerHTML={{__html: htmlData}} />;
|
|
10
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import './Views.scss';
|
|
2
|
-
import { Button, CodeSnippet } from '@carbon/react';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
import hljs from 'highlight.js';
|
|
5
|
-
|
|
6
|
-
export default function Initialize() {
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
document.querySelector('.cds--snippet-container > pre > code')?.classList.add('language-javascript');
|
|
9
|
-
hljs.highlightAll();
|
|
10
|
-
}, []);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div className="example-pages">
|
|
14
|
-
<h2>Code example</h2>
|
|
15
|
-
<CodeSnippet type="multi" feedback="Copied to clipboard" maxCollapsedNumberOfRows={25}>{window.initializeAspera.toString()}</CodeSnippet>
|
|
16
|
-
<h2>Try it out</h2>
|
|
17
|
-
<Button onClick={() => window.initializeAspera(false)}>Initialize SDK</Button>
|
|
18
|
-
<Button onClick={() => window.initializeAspera(true)}>Initialize SDK (multi user)</Button>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
};
|