Skip to content

Commit 3e00ea9

Browse files
authored
Merge pull request #45 from NFDI4Chem/development
Development
2 parents 14334f3 + f4ecbb1 commit 3e00ea9

8 files changed

Lines changed: 1843 additions & 1938 deletions

File tree

package-lock.json

Lines changed: 1252 additions & 1294 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
},
1515
"dependencies": {
1616
"@emotion/react": "^11.10.4",
17-
"nmr-load-save": "^0.2.1",
18-
"nmrium": "^0.31.0",
19-
"react-router-dom": "^6.4.1"
17+
"filelist-utils": "^0.12.0",
18+
"nmr-load-save": "^0.3.0",
19+
"nmrium": "^0.32.0",
20+
"react-router-dom": "^6.4.2"
2021
},
2122
"scripts": {
2223
"start": "vite --host localhost --port 3000 --open",
@@ -37,32 +38,32 @@
3738
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
3839
"@babel/preset-react": "^7.18.6",
3940
"@babel/preset-typescript": "^7.18.6",
40-
"@playwright/test": "^1.26.0",
41+
"@playwright/test": "^1.27.1",
4142
"@simbathesailor/use-what-changed": "^2.0.0",
42-
"@types/jest": "^29.0.3",
43-
"@types/node": "^18.7.21",
43+
"@types/jest": "^29.1.2",
44+
"@types/node": "^18.8.5",
4445
"@types/react": "^18.0.21",
4546
"@types/react-dom": "^18.0.6",
4647
"@types/react-router-dom": "^5.3.3",
47-
"@typescript-eslint/eslint-plugin": "^5.38.0",
48-
"@typescript-eslint/parser": "^5.38.0",
48+
"@typescript-eslint/eslint-plugin": "^5.40.0",
49+
"@typescript-eslint/parser": "^5.40.0",
4950
"@vitejs/plugin-react": "^2.1.0",
5051
"cross-env": "^7.0.3",
51-
"eslint": "^8.24.0",
52+
"eslint": "^8.25.0",
5253
"eslint-config-airbnb": "^19.0.4",
5354
"eslint-config-prettier": "^8.5.0",
5455
"eslint-import-resolver-typescript": "^3.5.1",
5556
"eslint-plugin-import": "^2.26.0",
5657
"eslint-plugin-jsx-a11y": "^6.6.1",
5758
"eslint-plugin-prettier": "^4.2.1",
58-
"eslint-plugin-react": "^7.31.8",
59+
"eslint-plugin-react": "^7.31.10",
5960
"eslint-plugin-react-hooks": "^4.6.0",
60-
"jest": "^29.0.3",
61+
"jest": "^29.1.2",
6162
"prettier": "2.7.1",
6263
"react": "^18.2.0",
6364
"react-dom": "^18.2.0",
6465
"serve": "^14.0.1",
65-
"typescript": "^4.8.3",
66-
"vite": "^3.1.3"
66+
"typescript": "^4.8.4",
67+
"vite": "^3.1.8"
6768
}
68-
}
69+
}

src/events/event.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import { EventType, EventData } from './types';
2+
import { isIPAddress } from '../utilities/isIPAddress';
23

34
const ALLOWED_ORIGINS: string[] = [
45
'https://nmrxiv.org',
56
'http://nmrxiv.org',
67
'http://localhost',
78
'http://localhost:3000',
9+
'http://127.0.0.1:',
10+
'http://127.0.0.1:3000',
811
'http://test.nmrxiv.org',
912
'http://193.196.39.168',
1013
'http://193.196.39.168:3000',
14+
'https://nodejsdev.nmrxiv.org',
1115
];
1216

1317
const namespace = 'nmr-wrapper';
1418

1519
function parseOrigin(origin: string) {
20+
let url: string | null = '';
1621
const urlSegments = origin.split('://');
17-
const hostSegments = urlSegments[1].split('.');
18-
const startIndex = hostSegments.length > 2 ? 1 : 0;
19-
20-
const url = `${urlSegments[0]}://${hostSegments
21-
.slice(hostSegments.length > 1 ? startIndex : 0)
22-
.join('.')}`;
22+
if (isIPAddress(origin)) {
23+
url = origin;
24+
} else {
25+
const hostSegments = urlSegments[1].split('.');
26+
const startIndex = hostSegments.length > 2 ? 1 : 0;
27+
url = `${urlSegments[0]}://${hostSegments
28+
.slice(hostSegments.length > 1 ? startIndex : 0)
29+
.join('.')}`;
30+
}
2331

2432
return url;
2533
}

src/hooks/useLoadSpectra.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
// import { addBruker, addJcamp, addJDF } from 'nmrium/lib/data/SpectraManager';
31
import { useCallback, useMemo, useState } from 'react';
42
import { read } from 'nmr-load-save';
3+
import { fileCollectionFromFiles } from 'filelist-utils';
54
import { Spectrum } from 'nmr-load-save/lib/types/Spectra/Spectrum';
65
import events from '../events';
76
import { isArrayOfString } from '../utilities/isArrayOfString';
@@ -30,7 +29,9 @@ export function useLoadSpectra() {
3029
inputFiles = options.files;
3130
}
3231

33-
const { spectra, molecules } = await read(inputFiles);
32+
const fileCollection = await fileCollectionFromFiles(inputFiles);
33+
34+
const { spectra, molecules } = await read(fileCollection);
3435
setData({ spectra, molecules });
3536
} catch (error: any) {
3637
events.trigger('error', error);

src/utilities/isIPAddress.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function isIPAddress(ip: string) {
2+
return /(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.test(ip);
3+
}

test-e2e/core.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ test('should load NMRium from external Urls', async ({ page }) => {
2626
// if loaded successfully, there should be a 1H and 13C tabs
2727
await test.step('spectra should be loaded', async () => {
2828
await expect(
29-
nmrium.page.locator('_react=InternalTab[tabid = "1H"]'),
29+
nmrium.page.locator('.tab-list-item >> text=1H'),
3030
).toBeVisible();
3131
await expect(
32-
nmrium.page.locator('_react=InternalTab[tabid = "13C"]'),
32+
nmrium.page.locator('.tab-list-item >> text=13C'),
3333
).toBeVisible();
3434
});
3535

@@ -45,7 +45,7 @@ test('should load NMRium from Files', async ({ page }) => {
4545
// if loaded successfully, there should be a 1H and 13C tabs
4646
await test.step('spectra should be loaded', async () => {
4747
await expect(
48-
nmrium.page.locator('_react=InternalTab[tabid = "13C"]'),
48+
nmrium.page.locator('.tab-list-item >> text=13C'),
4949
).toBeVisible();
5050
});
5151

@@ -60,7 +60,5 @@ test('should load NMRium from json', async ({ page }) => {
6060
await nmrium.page.click('text=Test load from json');
6161

6262
// if loaded successfully, there should be a 1H and 13C tabs
63-
await expect(
64-
nmrium.page.locator('_react=InternalTab[tabid = "13C"]'),
65-
).toBeVisible();
63+
await expect(nmrium.page.locator('.tab-list-item >> text=13C')).toBeVisible();
6664
});

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default () => {
66
base: './',
77
esbuild: {
88
jsx: 'automatic',
9-
sourcemap: false,
9+
sourcemap: true,
1010
},
1111
build: {
1212
sourcemap: true,

0 commit comments

Comments
 (0)