Skip to content

Commit

Permalink
Merge pull request #141 from IDEA-Research/feature/dataset_random_query2
Browse files Browse the repository at this point in the history
Feature/dataset random query2
  • Loading branch information
xifanii authored Mar 27, 2024
2 parents 54be034 + ebb6887 commit 0686b0e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion deepdataspace/server/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</head>
<body>
<div id="root"></div>
<script src="/static/umi.ddf0a1b5.js"></script>
<script src="/static/umi.d5355c89.js"></script>

</body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deepdataspace/server/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</head>
<body>
<div id="root"></div>
<script src="/static/umi.ddf0a1b5.js"></script>
<script src="/static/umi.d5355c89.js"></script>

</body></html>
7 changes: 5 additions & 2 deletions packages/app/src/models/dataset/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default () => {
);

const { loading: loadingImgList, run: loadImgList } = useRequest(
(isSlient = false) => {
(isSlient = false, withouOffset = false) => {
// when to load slient
if (!pageState.datasetId || !pageState.filterValues.categoryId) {
throw null;
Expand All @@ -160,7 +160,7 @@ export default () => {
};
if (pageState.queryMode === QueryMode.random) {
Object.assign(params, {
offset: -1,
offset: withouOffset ? -1 : pageState.offset,
pageSize: DEFAULT_PAGE_SIZE,
});
}
Expand Down Expand Up @@ -197,6 +197,9 @@ export default () => {
s.imgList = result.imageList;
s.total = result.total;
});
setPageState((s) => {
s.offset = isNumber(result.offset) ? result.offset : -1;
});
},
onError: () => {},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/models/dataset/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface PageState {
datasetId: string;
datasetName: string;
queryMode: QueryMode;
offset: number;
page: number;
pageSize: number;
// config
Expand Down Expand Up @@ -69,6 +70,7 @@ export const DEFAULT_PAGE_STATE = {
datasetId: '',
datasetName: '',
queryMode: QueryMode.pagination,
offset: -1,
page: 1,
pageSize: DEFAULT_PAGE_SIZE,
cloumnCount: 5,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/Dataset/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Header: React.FC = () => {
type="text"
icon={<RandomIcon />}
className={styles.randomBtn}
onClick={() => loadImgList()}
onClick={() => loadImgList(false, true)}
>
{localeText('dataset.detail.randomQuery')}
</Button>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export namespace NsApiDataset {

export interface FetchImgListRsp {
imageList: Array<NsDataSet.DataSetImg>;
offset: number;
total: number;
}

Expand Down

0 comments on commit 0686b0e

Please sign in to comment.