diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index 8a3c0c17..c72bf289 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -78,6 +78,25 @@ export class DataService { return repoData; } + async loadRepoDataDetailView(config: { + search?: string; + sort?: string; + direction?: 'ASC' | 'DESC'; + page?: string; + count?: string; + includeForks?: string; + }) { + const repoData = await this.http + .get<{ + repositories: Repository[]; + total: number; + }>(`${environment.api}institutionRepositories`, { + params: config, + }) + .toPromise(); + return repoData; + } + async loadUserData(config: { search: string; sort: string; diff --git a/frontend/src/app/institution-detail-view/institution-detail-view.component.ts b/frontend/src/app/institution-detail-view/institution-detail-view.component.ts index ffc18a58..a5db7314 100644 --- a/frontend/src/app/institution-detail-view/institution-detail-view.component.ts +++ b/frontend/src/app/institution-detail-view/institution-detail-view.component.ts @@ -259,7 +259,7 @@ export class InstitutionDetailViewComponent implements OnInit { reloadData() { this.dataService - .loadRepoData({ + .loadRepoDataDetailView({ sort: this.activeSort, direction: this.sortDirection, page: this.page.toString(), diff --git a/oss-api/src/api/api.controller.ts b/oss-api/src/api/api.controller.ts index fd90d24b..fe25e747 100644 --- a/oss-api/src/api/api.controller.ts +++ b/oss-api/src/api/api.controller.ts @@ -73,7 +73,7 @@ export class ApiController { @Query() queryDto: RepositoryQueryDto, ): Promise { const queryConfig = queryDto; - return await this.handleRepositories(queryConfig); + return await this.handleRepositories(queryConfig, false); } @Get('paginatedUsers') @@ -83,6 +83,15 @@ export class ApiController { return await this.handleUsers(queryConfig); } + @Get('institutionRepositories') + @UsePipes(new RepositoryQueryPipe(), new ValidationPipe({ transform: true })) + async findRepositoriesDetailView( + @Query() queryDto: RepositoryQueryDto, + ): Promise { + const queryConfig = queryDto; + return await this.handleRepositories(queryConfig, true); + } + @Get('latestUpdate') async findLatestUpdate() { return (await this.mongoDbService.latestUpdate())[0]; @@ -139,6 +148,7 @@ export class ApiController { */ private async handleRepositories( queryConfig: RepositoryQueryConfig, + detailedView: boolean, ): Promise { const includeForks = queryConfig.includeForks ? [false, true] : [false]; let condition: Object[] = [ @@ -146,10 +156,14 @@ export class ApiController { fork: { $in: includeForks }, }, ]; - if (queryConfig.search.length > 0) { + if (queryConfig.search.length > 0 && !detailedView) { condition.push({ $text: { $search: queryConfig.search }, }); + } else if (detailedView) { + condition.push({ + institution: queryConfig.search, + }); } let repositories = await this.mongoDbService.findRepositoryWithConditions( queryConfig.sort,