Skip to content

Commit 80865f7

Browse files
Feature : add 'trigger optimizers' button to collection info (#210)
1 parent 9a53edb commit 80865f7

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

src/components/Collections/CollectionInfo.jsx

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { memo, useEffect } from 'react';
22
import PropTypes from 'prop-types';
3-
import { Box, Card, CardContent, CardHeader, Typography } from '@mui/material';
3+
import { Box, Button, Card, CardContent, CardHeader, Typography } from '@mui/material';
44
import { useClient } from '../../context/client-context';
55
import { DataGridList } from '../Points/DataGridList';
66
import { CopyButton } from '../Common/CopyButton';
@@ -17,6 +17,21 @@ export const CollectionInfo = ({ collectionName }) => {
1717
const [clusterInfo, setClusterInfo] = React.useState(null);
1818

1919
useEffect(() => {
20+
fetchCollection();
21+
qdrantClient
22+
.api('cluster')
23+
.collectionClusterInfo({ collection_name: collectionName })
24+
.then((res) => {
25+
setClusterInfo(() => {
26+
return { ...res.data };
27+
});
28+
})
29+
.catch((err) => {
30+
enqueueSnackbar(err.message, getSnackbarOptions('error', closeSnackbar));
31+
});
32+
}, [collectionName]);
33+
34+
const fetchCollection = () => {
2035
qdrantClient
2136
.getCollection(collectionName)
2237
.then((res) => {
@@ -27,19 +42,21 @@ export const CollectionInfo = ({ collectionName }) => {
2742
.catch((err) => {
2843
enqueueSnackbar(err.message, getSnackbarOptions('error', closeSnackbar));
2944
});
45+
};
3046

47+
const triggerOptimizers = () => {
3148
qdrantClient
32-
.api('cluster')
33-
.collectionClusterInfo({ collection_name: collectionName })
34-
.then((res) => {
35-
setClusterInfo(() => {
36-
return { ...res.data };
37-
});
49+
.updateCollection(collectionName, {
50+
optimizers_config: {},
51+
})
52+
.then(() => {
53+
enqueueSnackbar('Optimizers triggered', getSnackbarOptions('success', closeSnackbar));
54+
fetchCollection();
3855
})
3956
.catch((err) => {
4057
enqueueSnackbar(err.message, getSnackbarOptions('error', closeSnackbar));
4158
});
42-
}, [collectionName]);
59+
};
4360

4461
return (
4562
<Box pt={2}>
@@ -57,9 +74,17 @@ export const CollectionInfo = ({ collectionName }) => {
5774
data={collection}
5875
specialCases={{
5976
status: (
60-
<Typography variant="subtitle1" color="text.secondary">
61-
{collection.status} <Dot color={collection.status} />
62-
</Typography>
77+
<Box display="flex" alignItems="center" justifyContent={'space-between'}>
78+
<Typography variant="subtitle1" color="text.secondary">
79+
{collection.status} <Dot color={collection.status} />
80+
</Typography>
81+
{(collection.status === 'grey' ||
82+
collection.optimizer_status?.error === `optimizations pending, awaiting update operation`) && (
83+
<Button variant="outlined" size="small" onClick={triggerOptimizers}>
84+
Trigger optimizers
85+
</Button>
86+
)}
87+
</Box>
6388
),
6489
}}
6590
/>

0 commit comments

Comments
 (0)