Skip to content

Upgrade to use searchv2 #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VITE_WC_PROJECT_ID=8e39af16af0819871be6f2da61a3a038

VITE_URL=https://panel.fs.neo.org/
VITE_RESTGW=https://rest.fs.neo.org/v1
VITE_RESTGW=https://rest.fs.neo.org

# Mainnet NeoFS contract
VITE_NETWORK=mainnet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
tests:
name: npm tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18.x]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ You can easily run the node locally in a docker container using [@nspcc-dev/neof
You need to update the parameters in the `.env` file to make it work:

```env
VITE_RESTGW=http://localhost:8090/v1
VITE_RESTGW=http://localhost:8090
```

# Make instructions
Expand Down
1 change: 1 addition & 0 deletions public/img/icons/list_view.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/img/icons/tree_view.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const App = () => {
});

const [params] = useState({
rest_gw: import.meta.env.VITE_RESTGW ? import.meta.env.VITE_RESTGW : 'https://rest.t5.fs.neo.org/v1',
rest_gw: import.meta.env.VITE_RESTGW ? import.meta.env.VITE_RESTGW : 'https://rest.t5.fs.neo.org',
});

const [objectLinkLifetime, setObjectLinkLifetime] = useState(new Date().toLocaleDateString("sv"));
Expand Down Expand Up @@ -210,7 +210,7 @@ export const App = () => {
onPopup('success', 'Wallet connected');
onModal();

api('GET', '/network-info').then((e) => {
api('GET', '/v1/network-info').then((e) => {
if (!e.message) {
setNetworkInfo(e);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ export const App = () => {
}]
}

api('POST', '/auth', body, {
api('POST', '/v1/auth', body, {
"X-Bearer-Owner-Id": walletData.account.address,
"X-Bearer-Lifetime": params.objectId ? formatDateToHours(objectLinkLifetime) : 2,
"X-Bearer-For-All-Users": true,
Expand Down Expand Up @@ -389,7 +389,7 @@ export const App = () => {
}

if (type === 'object') {
api('GET', '/auth/bearer?walletConnect=true', {}, {
api('GET', '/v1/auth/bearer?walletConnect=true', {}, {
"Authorization": `Bearer ${msg}`,
"X-Bearer-Signature": response.data + response.salt,
"X-Bearer-Signature-Key": response.publicKey,
Expand All @@ -412,7 +412,7 @@ export const App = () => {
if (containerForm.containerName.length >= 3) {
setError({ active: false, type: [], text: '' });
setLoadingForm(true);
api('PUT', '/containers?walletConnect=true&name-scope-global=true', {
api('PUT', '/v1/containers?walletConnect=true&name-scope-global=true', {
"containerName": containerForm.containerName,
"placementPolicy": containerForm.placementPolicy,
"basicAcl": containerForm.basicAcl,
Expand Down Expand Up @@ -440,7 +440,7 @@ export const App = () => {
setError({ active: true, type: [], text: e.message });
} else {
if (containerForm.eACLParams.length > 0) {
api('PUT', `/containers/${e.containerId}/eacl?walletConnect=true`, {
api('PUT', `/v1/containers/${e.containerId}/eacl?walletConnect=true`, {
"records": containerForm.eACLParams.filter((item) => delete item.isOpen),
}, {
"Authorization": `Bearer ${walletData.tokens.container.SETEACL.token}`,
Expand Down Expand Up @@ -492,7 +492,7 @@ export const App = () => {
const onDeleteContainer = (containerName) => {
setLoadingForm(true);
setError({ active: false, type: [], text: '' });
api('DELETE', `/containers/${containerName}?walletConnect=true`, {}, {
api('DELETE', `/v1/containers/${containerName}?walletConnect=true`, {}, {
"Authorization": `Bearer ${walletData.tokens.container.DELETE.token}`,
"X-Bearer-Owner-Id": walletData.account.address,
"X-Bearer-Signature": walletData.tokens.container.DELETE.signature,
Expand Down Expand Up @@ -535,7 +535,7 @@ export const App = () => {

const attributesHeaders = {};
attributes.map((attribute) => attributesHeaders[attribute.key] = attribute.value);
api('POST', `/objects/${containerId}`, objectForm.file, {
api('POST', `/v1/objects/${containerId}`, objectForm.file, {
'Content-Type': objectForm.file.type,
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
'X-Attributes': JSON.stringify({
Expand Down Expand Up @@ -572,7 +572,7 @@ export const App = () => {
const onDeleteObject = (containerId, objectId) => {
setError({ active: false, type: [], text: '' });
setLoadingForm(true);
api('DELETE', `/objects/${containerId}/${objectId}`, {}, {
api('DELETE', `/v1/objects/${containerId}/${objectId}`, {}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((e) => {
setLoadingForm(false);
Expand Down Expand Up @@ -1485,6 +1485,7 @@ export const App = () => {
</Form.Field>
<Form.Field>
<Form.Label>Attributes</Form.Label>
<Heading className="input_caption">Attributes are key value pairs (string:string) that are attached to the metadata of objects. You can specify anything as an attribute.<br/><br/>If you set the FileName attribute, you can also see the file name in the object list. The FilePath attribute allows you to present the list of objects as a tree in the panel interface.</Heading>
<div style={attributes.length >= 3 ? { overflow: 'scroll', maxHeight: 180 } : {}}>
{attributes.map((attribute, index) => (
<Form.Field kind="group" key={index}>
Expand Down
96 changes: 66 additions & 30 deletions src/Components/ContainerItem/ContainerItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default function ContainerItem({
const ObjectsPerPage = 40;
const [isOpen, setIsOpen] = useState(false);
const [pagination, setPagination] = useState({
page: 0,
objects: 0,
history: [],
cursor: '',
});
const [filters, setFilters] = useState([{
key: '',
Expand All @@ -42,10 +42,11 @@ export default function ContainerItem({
const [isLoadingEACL, setLoadingEACL] = useState(false);
const [eACLParams, setEACLParams] = useState([]);
const [activePanel, setActivePanel] = useState('');
const [isTreeViewObjects, setTreeViewObjects] = useState(false);

useEffect(() => {
if (isLoadContainers === containerItem.containerId) {
onGetObjects(isLoadContainers);
onGetObjects(isLoadContainers, '', { history: [], cursor: '' });
setLoadContainers(false);
onModal();
}
Expand All @@ -54,7 +55,7 @@ export default function ContainerItem({
useEffect(() => {
if (walletData.tokens.object && walletData.tokens.object.containerId === containerItem.containerId) {
setActivePanel('objects');
onGetObjects(containerItem.containerId);
onGetObjects(containerItem.containerId, '', { history: [], cursor: '' });
onModal();
setWalletData({
...walletData,
Expand Down Expand Up @@ -86,27 +87,39 @@ export default function ContainerItem({
}
}, [walletData]); // eslint-disable-line react-hooks/exhaustive-deps

const onGetObjects = (containerId, pageTemp = pagination.page) => {
setPagination({ ...pagination, page: pageTemp});
const onGetObjects = (containerId, cursor = '', paginationTemp = pagination, isTreeViewObjectsTemp = isTreeViewObjects) => {
setLoadingObjects(true);
api('POST', `/objects/${containerId}/search?limit=${ObjectsPerPage}&offset=${pageTemp * ObjectsPerPage}`, {
filters: filters.every((item) => item.key !== '' && item.value !== '') ? filters : [],
let filtersApplied = filters.filter(item => item.key !== '' && item.value !== '');
if (isTreeViewObjectsTemp) {
const hasFilePath = filtersApplied.some(item => item.key === 'FilePath');
filtersApplied = hasFilePath ? filtersApplied : [{ key: "FilePath", match: "MatchCommonPrefix", value: "" }, ...filtersApplied];
}

api('POST', `/v2/objects/${containerId}/search?limit=${ObjectsPerPage}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`, {
attributes: [...new Set(filtersApplied.map(item => item.key))],
filters: filtersApplied,
}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((e) => {
setLoadingObjects(false);
if (e.message) {
onPopup('failed', e.message);
} else {
setPagination({ objects: e.objects ? e.objects.length : 0, page: pageTemp});
setObjects(e.objects ? formatForTreeView(e.objects) : []);
const pos = paginationTemp.history.indexOf(e.cursor);
if (pos !== -1) {
paginationTemp.history.splice(pos, 1);
} else if (paginationTemp.cursor !== '') {
paginationTemp.history.push(paginationTemp.cursor);
}
setPagination({ history: paginationTemp.history, cursor: e.cursor });
setObjects(e.objects && e.objects.length > 0 ? formatForTreeView(e.objects) : []);
}
});
};

const onGetEACL = (containerId) => {
setLoadingEACL(true);
api('GET', `/containers/${containerId}/eacl`, {}, {
api('GET', `/v1/containers/${containerId}/eacl`, {}, {
"X-Bearer-Owner-Id": walletData.account.address,
}).then((e) => {
setLoadingEACL(false);
Expand Down Expand Up @@ -282,7 +295,7 @@ export default function ContainerItem({
} else if (activePanel === 'objects') {
setActivePanel('');
} else {
onGetObjects(containerItem.containerId, 0);
onGetObjects(containerItem.containerId, '', { history: [], cursor: '' });
setActivePanel('objects');
}
}}
Expand All @@ -299,17 +312,40 @@ export default function ContainerItem({
Objects
</div>
{activePanel === 'objects' && (
<Button
renderAs="button"
size="small"
color="primary"
onClick={(e) => {
onModal('createObject', { containerId: containerItem.containerId })
e.stopPropagation();
}}
>
New object
</Button>
<div>
<Button
renderAs="button"
size="small"
color="primary"
style={{ marginRight: 10 }}
onClick={(e) => {
setTreeViewObjects(!isTreeViewObjects);
onGetObjects(containerItem.containerId, '', { history: [], cursor: '' }, !isTreeViewObjects);
e.stopPropagation();
}}
disabled={!isTreeViewObjects && objects?.length === 0 || isLoadingObjects}
>
<img
src={`/img/icons/${isTreeViewObjects ? 'tree' : 'list'}_view.svg`}
height={12}
width={12}
style={{ marginRight: 5 }}
alt="view"
/>
{isTreeViewObjects ? 'Tree view' : 'List view'}
</Button>
<Button
renderAs="button"
size="small"
color="primary"
onClick={(e) => {
onModal('createObject', { containerId: containerItem.containerId })
e.stopPropagation();
}}
>
New object
</Button>
</div>
)}
</Heading>
{activePanel === 'objects' && (
Expand Down Expand Up @@ -430,7 +466,7 @@ export default function ContainerItem({
color="primary"
size="small"
style={{ marginTop: 8 }}
onClick={() => onGetObjects(containerItem.containerId, 0)}
onClick={() => onGetObjects(containerItem.containerId, '', { history: [], cursor: '' })}
disabled={isLoadingObjects || filters.some((item) => item.key === '' || item.value === '')}
>
Search
Expand All @@ -449,18 +485,18 @@ export default function ContainerItem({
containerItem={containerItem}
objects={objects}
/>
{!(pagination.page === 0 && pagination.objects === 0) && (
{objects.length !== 0 && (
<div className="pagination">
<div
className="pagination-previous"
onClick={() => onGetObjects(containerItem.containerId, pagination.page - 1)}
style={pagination.page === 0 ? { pointerEvents: 'none', borderColor: '#e9e9e9' } : {}}
onClick={() => onGetObjects(containerItem.containerId, pagination.history.length > 1 ? pagination.history[pagination.history.length - 2] : '')}
style={pagination.history.length === 0 ? { pointerEvents: 'none', borderColor: '#e9e9e9', color: '#9f9f9f' } : {}}
>{`<`}</div>
<div className="pagination-text">{pagination.page + 1}</div>
<div className="pagination-text">{pagination.history.length + 1}</div>
<div
className="pagination-next"
onClick={() => onGetObjects(containerItem.containerId, pagination.page + 1)}
style={pagination.objects < ObjectsPerPage ? { pointerEvents: 'none', borderColor: '#e9e9e9' } : {}}
onClick={() => onGetObjects(containerItem.containerId, pagination.cursor)}
style={pagination.cursor === '' ? { pointerEvents: 'none', borderColor: '#e9e9e9', color: '#9f9f9f' } : {}}
>{`>`}</div>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/EACLPanel/EACLPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function EACLPanel({
if (eACLParams.every((eACLItem) => eACLItem.operation !== '' && eACLItem.action !== '' && eACLItem.targets[0].role !== '' && eACLItem.filters.every((filterItem) => filterItem.headerType !== '' && filterItem.matchType !== '' && filterItem.key !== '' && filterItem.value !== ''))) {
setError({ active: false, type: [], text: '' });
setLoadingForm(true);
api('PUT', `/containers/${containerId}/eacl?walletConnect=true`, {
api('PUT', `/v1/containers/${containerId}/eacl?walletConnect=true`, {
"records": eACLParams.filter((item) => delete item.isOpen),
}, {
"Authorization": `Bearer ${walletData.tokens.container.SETEACL.token}`,
Expand Down
14 changes: 7 additions & 7 deletions src/Components/TreeView/TreeView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const File = ({
const handleToggle = e => {
setIsOpen(!isOpen);
if (!isOpen) {
api('HEAD', `/objects/${containerItem.containerId}/by_id/${objectItem.address.objectId}`, {}, {
api('HEAD', `/v1/objects/${containerItem.containerId}/by_id/${objectItem.objectId}`, {}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((e) => {
setObjectDate(e);
Expand Down Expand Up @@ -129,7 +129,7 @@ const File = ({
<Heading size={5} weight="bolder" style={{ color: '#00e599' }}>Information</Heading>
<Heading size={6} weight="light">
<span>{`Object id: `}</span>
{objectItem.address.objectId}
{objectItem.objectId}
</Heading>
<Heading size={6} weight="light">
<span>{`Owner id: `}</span>
Expand Down Expand Up @@ -166,7 +166,7 @@ const File = ({
className="manage_icon"
onClick={() => {
onModal('loading');
api('GET', `/objects/${containerItem.containerId}/by_id/${objectItem.address.objectId}`, {}, {
api('GET', `/v1/objects/${containerItem.containerId}/by_id/${objectItem.objectId}`, {}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((data) => {
if (data.message) {
Expand Down Expand Up @@ -201,7 +201,7 @@ const File = ({
className="manage_icon"
onClick={() => {
onModal('loading');
api('GET', `/objects/${containerItem.containerId}/by_id/${objectItem.address.objectId}`, {}, {
api('GET', `/v1/objects/${containerItem.containerId}/by_id/${objectItem.objectId}`, {}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((data) => {
if (data.message) {
Expand Down Expand Up @@ -234,13 +234,13 @@ const File = ({
className="manage_icon"
onClick={() => {
onModal('loading');
api('HEAD', `/objects/${containerItem.containerId}/by_id/${objectItem.address.objectId}`, {}, {
api('HEAD', `/v1/objects/${containerItem.containerId}/by_id/${objectItem.objectId}`, {}, {
"Authorization": `Bearer ${walletData.tokens.object.bearer}`,
}).then((e) => {
onModal('shareObjectLink', {
type: e === 200 ? 'public' : 'private',
containerId: containerItem.containerId,
objectId: objectItem.address.objectId,
objectId: objectItem.objectId,
});
});
}}
Expand All @@ -253,7 +253,7 @@ const File = ({
src="/img/icons/manage/delete.png"
className="manage_icon"
onClick={(e) => {
onModal('deleteObject', { containerId: containerItem.containerId, objectId: objectItem.address.objectId });
onModal('deleteObject', { containerId: containerItem.containerId, objectId: objectItem.objectId });
e.stopPropagation();
}}
width={40}
Expand Down
Loading