@@ -41,9 +41,9 @@ import { Helmet } from 'react-helmet';
41
41
import generatePath from 'lib/generatePath' ;
42
42
import { withRouter } from 'lib/withRouter' ;
43
43
import { get } from 'lib/AJAX' ;
44
+ import BrowserFooter from './BrowserFooter.react' ;
44
45
45
46
// The initial and max amount of rows fetched by lazy loading
46
- const MAX_ROWS_FETCHED = 200 ;
47
47
const BROWSER_LAST_LOCATION = 'brower_last_location' ;
48
48
49
49
@subscribeTo ( 'Schema' , 'schema' )
@@ -54,6 +54,7 @@ class Browser extends DashboardView {
54
54
this . section = 'Core' ;
55
55
this . subsection = 'Browser' ;
56
56
this . noteTimeout = null ;
57
+ const limit = window . localStorage ?. getItem ( 'browserLimit' ) ;
57
58
58
59
this . state = {
59
60
showCreateClassDialog : false ,
@@ -75,6 +76,8 @@ class Browser extends DashboardView {
75
76
clp : { } ,
76
77
filters : new List ( ) ,
77
78
ordering : '-createdAt' ,
79
+ skip : 0 ,
80
+ limit : limit ? parseInt ( limit ) : 100 ,
78
81
selection : { } ,
79
82
exporting : false ,
80
83
exportingCount : 0 ,
@@ -894,7 +897,7 @@ class Browser extends DashboardView {
894
897
}
895
898
896
899
async fetchParseData ( source , filters ) {
897
- const { useMasterKey } = this . state ;
900
+ const { useMasterKey, skip , limit } = this . state ;
898
901
const query = await queryFromFilters ( source , filters ) ;
899
902
const sortDir = this . state . ordering [ 0 ] === '-' ? '-' : '+' ;
900
903
const field = this . state . ordering . substr ( sortDir === '-' ? 1 : 0 ) ;
@@ -904,8 +907,11 @@ class Browser extends DashboardView {
904
907
} else {
905
908
query . ascending ( field ) ;
906
909
}
910
+ query . skip ( skip ) ;
911
+ query . limit ( limit ) ;
912
+
913
+ localStorage ?. setItem ( 'browserLimit' , limit ) ;
907
914
908
- query . limit ( MAX_ROWS_FETCHED ) ;
909
915
this . excludeFields ( query , source ) ;
910
916
let promise = query . find ( { useMasterKey } ) ;
911
917
let isUnique = false ;
@@ -957,7 +963,7 @@ class Browser extends DashboardView {
957
963
this . setState ( {
958
964
data : data ,
959
965
filters,
960
- lastMax : MAX_ROWS_FETCHED ,
966
+ lastMax : this . state . limit ,
961
967
filteredCounts : filteredCounts ,
962
968
} ) ;
963
969
}
@@ -971,7 +977,7 @@ class Browser extends DashboardView {
971
977
selection : { } ,
972
978
data,
973
979
filters,
974
- lastMax : MAX_ROWS_FETCHED ,
980
+ lastMax : this . state . limit ,
975
981
} ) ;
976
982
}
977
983
@@ -1024,7 +1030,7 @@ class Browser extends DashboardView {
1024
1030
query . lessThan ( 'createdAt' , this . state . data [ this . state . data . length - 1 ] . get ( 'createdAt' ) ) ;
1025
1031
query . addDescending ( 'createdAt' ) ;
1026
1032
}
1027
- query . limit ( MAX_ROWS_FETCHED ) ;
1033
+ query . limit ( this . state . limit ) ;
1028
1034
this . excludeFields ( query , source ) ;
1029
1035
1030
1036
const { useMasterKey } = this . state ;
@@ -1035,7 +1041,7 @@ class Browser extends DashboardView {
1035
1041
} ) ) ;
1036
1042
}
1037
1043
} ) ;
1038
- this . setState ( { lastMax : this . state . lastMax + MAX_ROWS_FETCHED } ) ;
1044
+ this . setState ( { lastMax : this . state . lastMax + this . state . limit } ) ;
1039
1045
}
1040
1046
1041
1047
updateFilters ( filters ) {
@@ -1051,6 +1057,10 @@ class Browser extends DashboardView {
1051
1057
// filters param change is making the fetch call
1052
1058
this . props . navigate ( generatePath ( this . context , url ) ) ;
1053
1059
}
1060
+
1061
+ this . setState ( {
1062
+ skip : 0 ,
1063
+ } ) ;
1054
1064
}
1055
1065
1056
1066
saveFilters ( filters , name ) {
@@ -1302,7 +1312,7 @@ class Browser extends DashboardView {
1302
1312
this . state . counts [ className ] = 0 ;
1303
1313
this . setState ( {
1304
1314
data : [ ] ,
1305
- lastMax : MAX_ROWS_FETCHED ,
1315
+ lastMax : this . state . limit ,
1306
1316
selection : { } ,
1307
1317
} ) ;
1308
1318
}
@@ -1362,7 +1372,7 @@ class Browser extends DashboardView {
1362
1372
1363
1373
// If after deletion, the remaining elements on the table is lesser than the maximum allowed elements
1364
1374
// we fetch more data to fill the table
1365
- if ( this . state . data . length < MAX_ROWS_FETCHED ) {
1375
+ if ( this . state . data . length < this . state . limit ) {
1366
1376
this . prefetchData ( this . props , this . context ) ;
1367
1377
} else {
1368
1378
this . forceUpdate ( ) ;
@@ -2005,80 +2015,96 @@ class Browser extends DashboardView {
2005
2015
}
2006
2016
}
2007
2017
browser = (
2008
- < DataBrowser
2009
- app = { this . context }
2010
- ref = { this . dataBrowserRef }
2011
- isUnique = { this . state . isUnique }
2012
- uniqueField = { this . state . uniqueField }
2013
- count = { count }
2014
- perms = { this . state . clp [ className ] }
2015
- schema = { this . props . schema }
2016
- filters = { this . state . filters }
2017
- onFilterChange = { this . updateFilters }
2018
- onFilterSave = { ( ...args ) => this . saveFilters ( ...args ) }
2019
- onRemoveColumn = { this . showRemoveColumn }
2020
- onDeleteRows = { this . showDeleteRows }
2021
- onDropClass = { this . showDropClass }
2022
- onExport = { this . showExport }
2023
- onChangeCLP = { this . handleCLPChange }
2024
- onRefresh = { this . refresh }
2025
- onAttachRows = { this . showAttachRowsDialog }
2026
- onAttachSelectedRows = { this . showAttachSelectedRowsDialog }
2027
- onExecuteScriptRows = { this . showExecuteScriptRowsDialog }
2028
- onCloneSelectedRows = { this . showCloneSelectedRowsDialog }
2029
- onEditSelectedRow = { this . showEditRowDialog }
2030
- onEditPermissions = { this . onDialogToggle }
2031
- onExportSelectedRows = { this . showExportSelectedRowsDialog }
2032
- onExportSchema = { this . showExportSchemaDialog }
2033
- onSaveNewRow = { this . saveNewRow }
2034
- onShowPointerKey = { this . showPointerKeyDialog }
2035
- onAbortAddRow = { this . abortAddRow }
2036
- onSaveEditCloneRow = { this . saveEditCloneRow }
2037
- onAbortEditCloneRow = { this . abortEditCloneRow }
2038
- onCancelPendingEditRows = { this . cancelPendingEditRows }
2039
- currentUser = { this . state . currentUser }
2040
- useMasterKey = { this . state . useMasterKey }
2041
- login = { this . login }
2042
- logout = { this . logout }
2043
- toggleMasterKeyUsage = { this . toggleMasterKeyUsage }
2044
- markRequiredFieldRow = { this . state . markRequiredFieldRow }
2045
- requiredColumnFields = { this . state . requiredColumnFields }
2046
- columns = { columns }
2047
- className = { className }
2048
- fetchNextPage = { this . fetchNextPage }
2049
- maxFetched = { this . state . lastMax }
2050
- selectRow = { this . selectRow }
2051
- selection = { this . state . selection }
2052
- data = { this . state . data }
2053
- ordering = { this . state . ordering }
2054
- newObject = { this . state . newObject }
2055
- editCloneRows = { this . state . editCloneRows }
2056
- relation = { this . state . relation }
2057
- disableKeyControls = { this . hasExtras ( ) }
2058
- updateRow = { this . updateRow }
2059
- updateOrdering = { this . updateOrdering }
2060
- onPointerClick = { this . handlePointerClick }
2061
- onPointerCmdClick = { this . handlePointerCmdClick }
2062
- setRelation = { this . setRelation }
2063
- onAddColumn = { this . showAddColumn }
2064
- onAddRow = { this . addRow }
2065
- onAddRowWithModal = { this . addRowWithModal }
2066
- onAddClass = { this . showCreateClass }
2067
- showNote = { this . showNote }
2068
- onMouseDownRowCheckBox = { this . onMouseDownRowCheckBox }
2069
- onMouseUpRowCheckBox = { this . onMouseUpRowCheckBox }
2070
- onMouseOverRowCheckBox = { this . onMouseOverRowCheckBox }
2071
- classes = { this . classes }
2072
- classwiseCloudFunctions = { this . state . classwiseCloudFunctions }
2073
- callCloudFunction = { this . fetchAggregationPanelData }
2074
- isLoadingCloudFunction = { this . state . isLoading }
2075
- setLoading = { this . setLoading }
2076
- AggregationPanelData = { this . state . AggregationPanelData }
2077
- setAggregationPanelData = { this . setAggregationPanelData }
2078
- setErrorAggregatedData = { this . setErrorAggregatedData }
2079
- errorAggregatedData = { this . state . errorAggregatedData }
2080
- appName = { this . props . params . appId }
2081
- />
2018
+ < >
2019
+ < DataBrowser
2020
+ app = { this . context }
2021
+ ref = { this . dataBrowserRef }
2022
+ isUnique = { this . state . isUnique }
2023
+ uniqueField = { this . state . uniqueField }
2024
+ count = { count }
2025
+ perms = { this . state . clp [ className ] }
2026
+ schema = { this . props . schema }
2027
+ filters = { this . state . filters }
2028
+ onFilterChange = { this . updateFilters }
2029
+ onFilterSave = { ( ...args ) => this . saveFilters ( ...args ) }
2030
+ onRemoveColumn = { this . showRemoveColumn }
2031
+ onDeleteRows = { this . showDeleteRows }
2032
+ onDropClass = { this . showDropClass }
2033
+ onExport = { this . showExport }
2034
+ onChangeCLP = { this . handleCLPChange }
2035
+ onRefresh = { this . refresh }
2036
+ onAttachRows = { this . showAttachRowsDialog }
2037
+ onAttachSelectedRows = { this . showAttachSelectedRowsDialog }
2038
+ onExecuteScriptRows = { this . showExecuteScriptRowsDialog }
2039
+ onCloneSelectedRows = { this . showCloneSelectedRowsDialog }
2040
+ onEditSelectedRow = { this . showEditRowDialog }
2041
+ onEditPermissions = { this . onDialogToggle }
2042
+ onExportSelectedRows = { this . showExportSelectedRowsDialog }
2043
+ onExportSchema = { this . showExportSchemaDialog }
2044
+ onSaveNewRow = { this . saveNewRow }
2045
+ onShowPointerKey = { this . showPointerKeyDialog }
2046
+ onAbortAddRow = { this . abortAddRow }
2047
+ onSaveEditCloneRow = { this . saveEditCloneRow }
2048
+ onAbortEditCloneRow = { this . abortEditCloneRow }
2049
+ onCancelPendingEditRows = { this . cancelPendingEditRows }
2050
+ currentUser = { this . state . currentUser }
2051
+ useMasterKey = { this . state . useMasterKey }
2052
+ login = { this . login }
2053
+ logout = { this . logout }
2054
+ toggleMasterKeyUsage = { this . toggleMasterKeyUsage }
2055
+ markRequiredFieldRow = { this . state . markRequiredFieldRow }
2056
+ requiredColumnFields = { this . state . requiredColumnFields }
2057
+ columns = { columns }
2058
+ className = { className }
2059
+ fetchNextPage = { this . fetchNextPage }
2060
+ maxFetched = { this . state . lastMax }
2061
+ selectRow = { this . selectRow }
2062
+ selection = { this . state . selection }
2063
+ data = { this . state . data }
2064
+ ordering = { this . state . ordering }
2065
+ newObject = { this . state . newObject }
2066
+ editCloneRows = { this . state . editCloneRows }
2067
+ relation = { this . state . relation }
2068
+ disableKeyControls = { this . hasExtras ( ) }
2069
+ updateRow = { this . updateRow }
2070
+ updateOrdering = { this . updateOrdering }
2071
+ onPointerClick = { this . handlePointerClick }
2072
+ onPointerCmdClick = { this . handlePointerCmdClick }
2073
+ setRelation = { this . setRelation }
2074
+ onAddColumn = { this . showAddColumn }
2075
+ onAddRow = { this . addRow }
2076
+ onAddRowWithModal = { this . addRowWithModal }
2077
+ onAddClass = { this . showCreateClass }
2078
+ showNote = { this . showNote }
2079
+ onMouseDownRowCheckBox = { this . onMouseDownRowCheckBox }
2080
+ onMouseUpRowCheckBox = { this . onMouseUpRowCheckBox }
2081
+ onMouseOverRowCheckBox = { this . onMouseOverRowCheckBox }
2082
+ classes = { this . classes }
2083
+ classwiseCloudFunctions = { this . state . classwiseCloudFunctions }
2084
+ callCloudFunction = { this . fetchAggregationPanelData }
2085
+ isLoadingCloudFunction = { this . state . isLoading }
2086
+ setLoading = { this . setLoading }
2087
+ AggregationPanelData = { this . state . AggregationPanelData }
2088
+ setAggregationPanelData = { this . setAggregationPanelData }
2089
+ setErrorAggregatedData = { this . setErrorAggregatedData }
2090
+ errorAggregatedData = { this . state . errorAggregatedData }
2091
+ appName = { this . props . params . appId }
2092
+ limit = { this . state . limit }
2093
+ />
2094
+ < BrowserFooter
2095
+ skip = { this . state . skip }
2096
+ setSkip = { skip => {
2097
+ this . setState ( { skip } ) ;
2098
+ this . updateOrdering ( this . state . ordering ) ;
2099
+ } }
2100
+ count = { count }
2101
+ limit = { this . state . limit }
2102
+ setLimit = { limit => {
2103
+ this . setState ( { limit } ) ;
2104
+ this . updateOrdering ( this . state . ordering ) ;
2105
+ } }
2106
+ />
2107
+ </ >
2082
2108
) ;
2083
2109
}
2084
2110
}
@@ -2268,6 +2294,7 @@ class Browser extends DashboardView {
2268
2294
confirmAttachSelectedRows = { this . confirmAttachSelectedRows }
2269
2295
schema = { this . props . schema }
2270
2296
useMasterKey = { this . state . useMasterKey }
2297
+ limit = { this . state . limit }
2271
2298
/>
2272
2299
) ;
2273
2300
} else if ( this . state . rowsToExport ) {
0 commit comments