66 InferOutputsType ,
77 PlDataTableState ,
88 isPColumn ,
9- isPColumnSpec ,
9+ isPColumnSpec
1010} from '@platforma-sdk/model' ;
11+ import { parseResourceMap } from './helpers' ;
1112
1213/**
1314 * Block arguments coming from the user interface
@@ -18,29 +19,35 @@ export type BlockArgs = {
1819} ;
1920
2021export type TreeSelection = {
21- donor ?: string ,
22- treeId ?: number
23- }
22+ donor ?: string ;
23+ treeId ?: number ;
24+ } ;
25+
26+ export type ReportSelection = {
27+ donor ?: string ;
28+ type : 'alleles' | 'shmTrees' ;
29+ } ;
2430
2531export type UiState = {
2632 treeTableState ?: PlDataTableState ;
27- treeSelectionForTreeNodesTable : TreeSelection
33+ treeSelectionForTreeNodesTable : TreeSelection ;
34+ reportSelection : ReportSelection ;
2835} ;
2936
3037export type ColumnOption = {
31- ref : Ref ,
32- label : string ,
33- spec : PColumnSpec
34- }
38+ ref : Ref ;
39+ label : string ;
40+ spec : PColumnSpec ;
41+ } ;
3542
3643export const platforma = BlockModel . create < BlockArgs , UiState > ( 'Heavy' )
3744
3845 . initialArgs ( {
3946 datasetColumns : [ null ]
4047 } )
4148
42- . output ( 'donorColumnOptions' , ( ctx ) => {
43- return ctx . resultPool
49+ . output ( 'donorColumnOptions' , ( ctx ) =>
50+ ctx . resultPool
4451 . getSpecsFromResultPool ( )
4552 . entries . filter ( ( v ) => isPColumnSpec ( v . obj ) )
4653 . filter ( ( v ) => {
@@ -55,8 +62,8 @@ export const platforma = BlockModel.create<BlockArgs, UiState>('Heavy')
5562 v . obj . annotations ?. [ 'pl7.app/label' ] ?? `unlabelled`
5663 } `
5764 } satisfies Option )
58- ) ;
59- } )
65+ )
66+ )
6067
6168 . output ( 'datasetColumnOptions' , ( ctx ) => {
6269 if ( ctx . args . donorColumn === undefined ) {
@@ -117,20 +124,27 @@ export const platforma = BlockModel.create<BlockArgs, UiState>('Heavy')
117124 . output ( 'treeNodes' , ( ctx ) => {
118125 const pCols = ctx . outputs ?. resolve ( 'treeNodes' ) ?. getPColumns ( ) ;
119126 if ( pCols === undefined ) return undefined ;
120-
127+
121128 return ctx . createPFrame ( pCols ) ;
122129 } )
123130
124- . output ( 'allelesLog' , ( ctx ) => {
125- return ctx . outputs ?. resolve ( 'allelesLog' ) ?. listInputFields ( ) ;
126- } )
131+ . output ( 'allelesReports' , ( ctx ) =>
132+ parseResourceMap (
133+ ctx . outputs ?. resolve ( { field : 'allelesReports' , assertFieldType : 'Input' } ) ,
134+ ( acc ) => acc . getFileContentAsString ( )
135+ )
136+ )
127137
128- . output ( 'treesLog' , ( ctx ) => {
129- return ctx . outputs ?. resolve ( 'treesLog' ) ?. listInputFields ( ) ;
130- } )
138+ . output ( 'treesReports' , ( ctx ) =>
139+ parseResourceMap (
140+ ctx . outputs ?. resolve ( { field : 'treesReports' , assertFieldType : 'Input' } ) ,
141+ ( acc ) => acc . getFileContentAsString ( )
142+ )
143+ )
131144
132145 . sections ( [
133146 { type : 'link' , href : '/' , label : 'Settings' } ,
147+ { type : 'link' , href : '/reports' , label : 'Reports' } ,
134148 { type : 'link' , href : '/trees' , label : 'Trees Table' } ,
135149 { type : 'link' , href : '/treeNodes' , label : 'Tree Nodes Table' }
136150 ] )
0 commit comments