File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -40,4 +40,11 @@ export class InstrumentsController {
4040 ) : Promise < InstrumentInfo [ ] > {
4141 return this . instrumentsService . findInfo ( { kind, subjectId } , { ability } ) ;
4242 }
43+
44+ @ApiOperation ( { summary : 'List Instruments' } )
45+ @Get ( 'list' )
46+ @RouteAccess ( { action : 'read' , subject : 'Instrument' } )
47+ async list ( @CurrentUser ( 'ability' ) ability : AppAbility , @Query ( 'kind' ) kind ?: InstrumentKind ) {
48+ return this . instrumentsService . list ( { kind } , ability ) ;
49+ }
4350}
Original file line number Diff line number Diff line change 55 LoggingService ,
66 VirtualizationService
77} from '@douglasneuroinformatics/libnest' ;
8- import type { Model } from '@douglasneuroinformatics/libnest' ;
8+ import type { AppAbility , Model } from '@douglasneuroinformatics/libnest' ;
99import { Injectable } from '@nestjs/common' ;
1010import {
1111 ConflictException ,
@@ -234,6 +234,16 @@ export class InstrumentsService {
234234 return instance ;
235235 }
236236
237+ async list < TKind extends InstrumentKind > ( query : InstrumentQuery < TKind > = { } , ability : AppAbility ) {
238+ return this . find ( query , { ability } ) . then ( ( arr ) => {
239+ return arr . map ( ( instrument ) => ( {
240+ id : instrument . id ,
241+ internal : instrument . internal ,
242+ title : instrument . details . title
243+ } ) ) ;
244+ } ) ;
245+ }
246+
237247 private async instantiate ( instruments : Pick < InstrumentBundleContainer , 'bundle' | 'id' > [ ] ) {
238248 return Promise . all (
239249 instruments . map ( ( instrument ) => {
You can’t perform that action at this time.
0 commit comments