@@ -265,50 +265,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
265265 } ) ;
266266 } ,
267267
268- __reloadStudiesFiltered : function ( text ) {
269- if ( this . _loadingResourcesBtn . isFetching ( ) ) {
270- return ;
271- }
272- this . __resetStudiesList ( ) ;
273- this . _loadingResourcesBtn . setFetching ( true ) ;
274- this . _loadingResourcesBtn . setVisibility ( "visible" ) ;
275- const request = this . __getTextFilteredNextRequest ( text ) ;
276- request
277- . then ( resp => {
278- const filteredStudies = resp [ "data" ] ;
279- this . _resourcesContainer . getFlatList ( ) . nextRequest = resp [ "_links" ] [ "next" ] ;
280- this . __addStudiesToList ( filteredStudies ) ;
281- } )
282- . catch ( err => console . error ( err ) )
283- . finally ( ( ) => {
284- this . _loadingResourcesBtn . setFetching ( false ) ;
285- this . _loadingResourcesBtn . setVisibility ( this . _resourcesContainer . getFlatList ( ) . nextRequest === null ? "excluded" : "visible" ) ;
286- this . _moreResourcesRequired ( ) ;
287- } ) ;
288- } ,
289-
290- __reloadSortedByStudies : function ( ) {
291- if ( this . _loadingResourcesBtn . isFetching ( ) ) {
292- return ;
293- }
294- this . __resetStudiesList ( ) ;
295- this . _loadingResourcesBtn . setFetching ( true ) ;
296- this . _loadingResourcesBtn . setVisibility ( "visible" ) ;
297- const request = this . __getSortedByNextRequest ( ) ;
298- request
299- . then ( resp => {
300- const sortedStudies = resp [ "data" ] ;
301- this . _resourcesContainer . getFlatList ( ) . nextRequest = resp [ "_links" ] [ "next" ] ;
302- this . __addStudiesToList ( sortedStudies ) ;
303- } )
304- . catch ( err => console . error ( err ) )
305- . finally ( ( ) => {
306- this . _loadingResourcesBtn . setFetching ( false ) ;
307- this . _loadingResourcesBtn . setVisibility ( this . _resourcesContainer . getFlatList ( ) . nextRequest === null ? "excluded" : "visible" ) ;
308- this . _moreResourcesRequired ( ) ;
309- } ) ;
310- } ,
311-
312268 __resetStudiesList : function ( ) {
313269 this . _resourcesList = [ ] ;
314270 this . _reloadCards ( ) ;
@@ -458,6 +414,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
458414
459415 if ( workspaceId === - 1 ) {
460416 this . __reloadWorkspaces ( ) ;
417+ } else if ( workspaceId === - 2 ) {
418+ this . __reloadStudies ( ) ;
461419 } else {
462420 this . __reloadFolders ( ) ;
463421 this . __reloadStudies ( ) ;
@@ -681,33 +639,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
681639 orderBy : JSON . stringify ( this . getOrderBy ( ) ) ,
682640 }
683641 } ;
684- const nextRequestParams = this . __getNextRequestParams ( ) ;
685- if ( nextRequestParams ) {
686- params . url . offset = nextRequestParams . offset ;
687- params . url . limit = nextRequestParams . limit ;
642+ const filterData = this . _searchBarFilter . getFilterData ( ) ;
643+ if ( filterData . text ) {
644+ params . url [ "text" ] = filterData . text ; // name, description and uuid
688645 }
689- const options = {
690- resolveWResponse : true
691- } ;
692-
693- params . url . workspaceId = this . getCurrentWorkspaceId ( ) ;
694- params . url . folderId = this . getCurrentFolderId ( ) ;
695- if ( params . url . orderBy ) {
696- return osparc . data . Resources . fetch ( "studies" , "getPageSortBy" , params , undefined , options ) ;
697- }
698- return osparc . data . Resources . fetch ( "studies" , "getPage" , params , undefined , options ) ;
699- } ,
700646
701- __getTextFilteredNextRequest : function ( text ) {
702- const params = {
703- url : {
704- offset : 0 ,
705- limit : osparc . dashboard . ResourceBrowserBase . PAGINATED_STUDIES ,
706- // MD todo. orderBy: JSON.stringify(this.getOrderBy()),
707- text, // name, description and uuid
708- // MD todo. tags,
709- }
710- } ;
711647 const nextRequestParams = this . __getNextRequestParams ( ) ;
712648 if ( nextRequestParams ) {
713649 params . url . offset = nextRequestParams . offset ;
@@ -719,29 +655,12 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
719655
720656 params . url . workspaceId = this . getCurrentWorkspaceId ( ) ;
721657 params . url . folderId = this . getCurrentFolderId ( ) ;
722- return osparc . data . Resources . fetch ( "studies" , "getPageSearch" , params , undefined , options ) ;
723- } ,
724-
725- __getSortedByNextRequest : function ( ) {
726- const params = {
727- url : {
728- offset : 0 ,
729- limit : osparc . dashboard . ResourceBrowserBase . PAGINATED_STUDIES ,
730- orderBy : JSON . stringify ( this . getOrderBy ( ) )
731- }
732- } ;
733- const nextRequestParams = this . __getNextRequestParams ( ) ;
734- if ( nextRequestParams ) {
735- params . url . offset = nextRequestParams . offset ;
736- params . url . limit = nextRequestParams . limit ;
658+ if ( params . url . text ) {
659+ return osparc . data . Resources . fetch ( "studies" , "getPageSearch" , params , undefined , options ) ;
660+ } else if ( params . url . orderBy ) {
661+ return osparc . data . Resources . fetch ( "studies" , "getPageSortBy" , params , undefined , options ) ;
737662 }
738- const options = {
739- resolveWResponse : true
740- } ;
741-
742- params . url . workspaceId = this . getCurrentWorkspaceId ( ) ;
743- params . url . folderId = this . getCurrentFolderId ( ) ;
744- return osparc . data . Resources . fetch ( "studies" , "getPageSortBy" , params , undefined , options ) ;
663+ return osparc . data . Resources . fetch ( "studies" , "getPage" , params , undefined , options ) ;
745664 } ,
746665
747666 invalidateStudies : function ( ) {
@@ -873,7 +792,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
873792 const filterData = e . getData ( ) ;
874793 if ( filterData . text ) {
875794 this . _changeContext ( - 2 , null ) ;
876- this . __reloadStudiesFiltered ( filterData . text ) ;
877795 } else {
878796 this . __reloadFolders ( ) ;
879797 this . __reloadStudies ( ) ;
@@ -972,7 +890,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
972890 osparc . utils . Utils . setIdToWidget ( sortByButton , "sortByButton" ) ;
973891 sortByButton . addListener ( "sortByChanged" , e => {
974892 this . setOrderBy ( e . getData ( ) )
975- this . __reloadSortedByStudies ( ) ;
893+ this . __resetStudiesList ( ) ;
894+ this . __reloadStudies ( ) ;
976895 } , this ) ;
977896 this . _toolbar . add ( sortByButton ) ;
978897 } ,
0 commit comments