Skip to content

Commit 513b96b

Browse files
egorenvisionblockchainEgorkirill-tolochko
authored
fix: add topicId filter for the tokens page [4784] (#4851)
Signed-off-by: egorenvisionblockchain <[email protected]> Co-authored-by: Egor <[email protected]> Co-authored-by: kirill-tolochko <[email protected]>
1 parent 2b0d2de commit 513b96b

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

indexer-api-gateway/src/api/services/entities.ts

+8
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ export class EntityApi extends ApiClient {
685685
example: '0.0.1960',
686686
required: false,
687687
})
688+
@ApiQuery({
689+
name: 'topicId',
690+
description: 'Topic identifier',
691+
example: '0.0.1960',
692+
required: false,
693+
})
688694
@HttpCode(HttpStatus.OK)
689695
async getTokens(
690696
@Query('pageIndex') pageIndex?: number,
@@ -693,6 +699,7 @@ export class EntityApi extends ApiClient {
693699
@Query('orderDir') orderDir?: string,
694700
@Query('tokenId') tokenId?: string,
695701
@Query('treasury') treasury?: string,
702+
@Query('topicId') topicId?: string,
696703
) {
697704
return await this.send(IndexerMessageAPI.GET_TOKENS, {
698705
pageIndex,
@@ -701,6 +708,7 @@ export class EntityApi extends ApiClient {
701708
orderDir,
702709
tokenId,
703710
treasury,
711+
topicId,
704712
});
705713
}
706714

indexer-frontend/src/app/views/collections/tokens/tokens.component.ts

+5
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ export class TokensComponent extends BaseGridComponent {
158158
field: 'tokenId',
159159
label: 'grid.token_id'
160160
}))
161+
this.filters.push(new Filter({
162+
type: 'input',
163+
field: 'topicId',
164+
label: 'grid.topic_id'
165+
}))
161166
this.filters.push(new Filter({
162167
type: 'input',
163168
field: 'treasury',

indexer-frontend/src/app/views/details/topic-details/topic-details.component.ts

+8
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ export class TopicDetailsComponent extends BaseDetailsComponent {
207207
});
208208
}
209209

210+
public override onOpenTokens() {
211+
this.router.navigate(['/tokens'], {
212+
queryParams: {
213+
'topicId': this.id,
214+
},
215+
});
216+
}
217+
210218
public override onOpenRoles() {
211219
this.router.navigate(['/roles'], {
212220
queryParams: {

indexer-service/src/api/entities.service.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -1122,9 +1122,31 @@ export class EntityService {
11221122
@Payload() msg: PageFilters
11231123
): Promise<AnyResponse<Page<Token>>> {
11241124
try {
1125-
const options = parsePageParams(msg);
1126-
const filters = parsePageFilters(msg);
1125+
const { topicId, ...params } = msg;
1126+
const options = parsePageParams(params);
1127+
const filters = parsePageFilters(params);
11271128
const em = DataBaseHelper.getEntityManager();
1129+
1130+
if (topicId) {
1131+
const tokens = await em.find(Message, {
1132+
type: MessageType.TOKEN,
1133+
topicId,
1134+
} as any, {
1135+
...options,
1136+
fields: ["options"],
1137+
});
1138+
1139+
filters.tokenId = {
1140+
$in: tokens.reduce((res, { options }) => {
1141+
if (options?.tokenId) {
1142+
res.push(options.tokenId);
1143+
}
1144+
1145+
return res;
1146+
}, [])
1147+
}
1148+
}
1149+
11281150
const [rows, count] = await em.findAndCount(
11291151
TokenCache,
11301152
filters,

swagger-indexer.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,13 @@ paths:
886886
schema:
887887
example: 0.0.1960
888888
type: string
889+
- name: topicId
890+
required: false
891+
in: query
892+
description: Topic identifier
893+
schema:
894+
example: 0.0.1960
895+
type: string
889896
responses:
890897
'200':
891898
description: Tokens

0 commit comments

Comments
 (0)