@@ -33,6 +33,47 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
3333
3434 this . _showLoadingPage ( this . tr ( "Starting" ) + " " + osparc . store . StaticInfo . getInstance ( ) . getDisplayName ( ) ) ;
3535
36+ const padding = osparc . dashboard . Dashboard . PADDING ;
37+ const leftColumnWidth = this . self ( ) . SIDE_SPACER_WIDTH ;
38+ const emptyColumnMinWidth = 50 ;
39+ const spacing = 20 ;
40+ const mainLayoutsScroll = 8 ;
41+
42+ const mainLayoutWithSideSpacers = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( spacing ) )
43+ this . _addToMainLayout ( mainLayoutWithSideSpacers ) ;
44+
45+ this . __leftLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 10 ) ) . set ( {
46+ width : leftColumnWidth
47+ } ) ;
48+ mainLayoutWithSideSpacers . add ( this . __leftLayout ) ;
49+
50+ this . __centerLayout = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 10 ) ) ;
51+ mainLayoutWithSideSpacers . add ( this . __centerLayout ) ;
52+
53+ const rightColum = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 10 ) ) ;
54+ mainLayoutWithSideSpacers . add ( rightColum , {
55+ flex : 1
56+ } ) ;
57+
58+ const itemWidth = osparc . dashboard . GridButtonBase . ITEM_WIDTH + osparc . dashboard . GridButtonBase . SPACING ;
59+ this . __centerLayout . setMinWidth ( this . self ( ) . MIN_GRID_CARDS_PER_ROW * itemWidth + mainLayoutsScroll ) ;
60+ const fitResourceCards = ( ) => {
61+ const w = document . documentElement . clientWidth ;
62+ const nStudies = Math . floor ( ( w - 2 * padding - 2 * spacing - leftColumnWidth - emptyColumnMinWidth ) / itemWidth ) ;
63+ const newWidth = nStudies * itemWidth + 8 ;
64+ if ( newWidth > this . __centerLayout . getMinWidth ( ) ) {
65+ this . __centerLayout . setWidth ( newWidth ) ;
66+ } else {
67+ this . __centerLayout . setWidth ( this . __centerLayout . getMinWidth ( ) ) ;
68+ }
69+
70+ const compactVersion = w < this . __centerLayout . getMinWidth ( ) + leftColumnWidth + emptyColumnMinWidth ;
71+ this . __leftLayout . setVisibility ( compactVersion ? "excluded" : "visible" ) ;
72+ rightColum . setVisibility ( compactVersion ? "excluded" : "visible" ) ;
73+ } ;
74+ fitResourceCards ( ) ;
75+ window . addEventListener ( "resize" , ( ) => fitResourceCards ( ) ) ;
76+
3677 this . addListener ( "appear" , ( ) => this . _moreResourcesRequired ( ) ) ;
3778 } ,
3879
@@ -42,6 +83,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
4283
4384 statics : {
4485 PAGINATED_STUDIES : 10 ,
86+ MIN_GRID_CARDS_PER_ROW : 4 ,
87+ SIDE_SPACER_WIDTH : 180 ,
4588
4689 checkLoggedIn : function ( ) {
4790 const isLogged = osparc . auth . Manager . getInstance ( ) . isLoggedIn ( ) ;
@@ -165,6 +208,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
165208 } ,
166209
167210 members : {
211+ __leftLayout : null ,
212+ __centerLayout : null ,
168213 _resourceType : null ,
169214 _resourcesList : null ,
170215 _topBar : null ,
@@ -182,7 +227,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
182227 scroll . getChildControl ( "pane" ) . addListener ( "scrollY" , ( ) => this . _moreResourcesRequired ( ) , this ) ;
183228 control = this . _createLayout ( ) ;
184229 scroll . add ( control ) ;
185- this . _addToMainLayout ( scroll , {
230+ this . _addToLayout ( scroll , {
186231 flex : 1
187232 } ) ;
188233 break ;
@@ -191,6 +236,10 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
191236 return control || this . base ( arguments , id ) ;
192237 } ,
193238
239+ _addToLayout : function ( widget , props = { } ) {
240+ this . __centerLayout . add ( widget , props )
241+ } ,
242+
194243 initResources : function ( ) {
195244 throw new Error ( "Abstract method called!" ) ;
196245 } ,
@@ -205,15 +254,15 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
205254
206255 _createResourcesLayout : function ( ) {
207256 const topBar = this . __createTopBar ( ) ;
208- this . _addToMainLayout ( topBar ) ;
257+ this . _addToLayout ( topBar ) ;
209258
210259 const toolbar = this . _toolbar = new qx . ui . toolbar . ToolBar ( ) . set ( {
211260 backgroundColor : "transparent" ,
212261 spacing : 10 ,
213262 paddingRight : 8 ,
214263 alignY : "middle"
215264 } ) ;
216- this . _addToMainLayout ( toolbar ) ;
265+ this . _addToLayout ( toolbar ) ;
217266
218267 this . __viewModeLayout = new qx . ui . toolbar . Part ( ) ;
219268
@@ -224,7 +273,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
224273 resourcesContainer . addListener ( "publishTemplate" , e => this . fireDataEvent ( "publishTemplate" , e . getData ( ) ) ) ;
225274 resourcesContainer . addListener ( "tagClicked" , e => this . _searchBarFilter . addTagActiveFilter ( e . getData ( ) ) ) ;
226275 resourcesContainer . addListener ( "emptyStudyClicked" , e => this . _deleteResourceRequested ( e . getData ( ) ) ) ;
227- this . _addToMainLayout ( resourcesContainer ) ;
276+ this . _addToLayout ( resourcesContainer ) ;
228277 } ,
229278
230279 __createTopBar : function ( ) {
@@ -321,8 +370,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
321370 _addResourceFilter : function ( ) {
322371 const resourceFilter = new osparc . dashboard . ResourceFilter ( this . _resourceType ) . set ( {
323372 marginTop : osparc . dashboard . SearchBarFilter . HEIGHT + 10 , // aligned with toolbar buttons: search bar + spacing
324- maxWidth : osparc . ui . basic . LoadingPageHandler . SIDE_SPACER_WIDTH ,
325- width : osparc . ui . basic . LoadingPageHandler . SIDE_SPACER_WIDTH
373+ maxWidth : this . self ( ) . SIDE_SPACER_WIDTH ,
374+ width : this . self ( ) . SIDE_SPACER_WIDTH
326375 } ) ;
327376
328377 resourceFilter . addListener ( "changeSharedWith" , e => {
@@ -340,7 +389,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
340389 resourceFilter . filterChanged ( filterData ) ;
341390 } ) ;
342391
343- this . _addToLeftColumn ( resourceFilter ) ;
392+ this . __leftLayout . add ( resourceFilter ) ;
344393 } ,
345394
346395 /**
0 commit comments