datajunction-ui 0.0.1-a82 → 0.0.1-a84
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 +1 -1
- package/src/app/components/Search.jsx +26 -31
package/package.json
CHANGED
|
@@ -17,42 +17,37 @@ export default function Search() {
|
|
|
17
17
|
}
|
|
18
18
|
return str.length > 100 ? str.substring(0, 90) + '...' : str;
|
|
19
19
|
};
|
|
20
|
+
|
|
20
21
|
useEffect(() => {
|
|
21
22
|
const fetchNodes = async () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
weight
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
name: '
|
|
39
|
-
weight:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
name: 'tag_type',
|
|
47
|
-
weight: 5,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
});
|
|
51
|
-
setFuse(fuse);
|
|
23
|
+
try {
|
|
24
|
+
const [data, tags] = await Promise.all([
|
|
25
|
+
djClient.nodeDetails(),
|
|
26
|
+
djClient.listTags(),
|
|
27
|
+
]);
|
|
28
|
+
const allEntities = data.concat(
|
|
29
|
+
(tags || []).map(tag => {
|
|
30
|
+
tag.type = 'tag';
|
|
31
|
+
return tag;
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
const fuse = new Fuse(allEntities || [], {
|
|
35
|
+
keys: [
|
|
36
|
+
'name', // will be assigned a `weight` of 1
|
|
37
|
+
{ name: 'description', weight: 2 },
|
|
38
|
+
{ name: 'display_name', weight: 3 },
|
|
39
|
+
{ name: 'type', weight: 4 },
|
|
40
|
+
{ name: 'tag_type', weight: 5 },
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
setFuse(fuse);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error fetching nodes or tags:', error);
|
|
46
|
+
}
|
|
52
47
|
};
|
|
53
48
|
fetchNodes();
|
|
54
49
|
}, []);
|
|
55
|
-
|
|
50
|
+
|
|
56
51
|
const handleChange = e => {
|
|
57
52
|
setSearchValue(e.target.value);
|
|
58
53
|
if (fuse) {
|