Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit 3d63767

Browse files
authored
pagination support for more than 100 filesystems #165 (#166)
1 parent aad601e commit 3d63767

File tree

2 files changed

+69
-16
lines changed

2 files changed

+69
-16
lines changed

source/api/app.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,28 @@ def list_filesystems():
256256
:returns: Object containing filesystems
257257
:raises ChaliceViewError
258258
"""
259+
260+
261+
query_params = app.current_request.query_params
262+
263+
cursor = None
264+
265+
if query_params is not None:
266+
try:
267+
cursor = query_params['cursor']
268+
except KeyError:
269+
pass
270+
259271
try:
260-
response = EFS.describe_file_systems()
272+
if cursor:
273+
response = EFS.describe_file_systems(
274+
MaxItems=10,
275+
Marker=cursor
276+
)
277+
else:
278+
response = EFS.describe_file_systems(
279+
MaxItems=10
280+
)
261281
except botocore.exceptions.ClientError as error:
262282
app.log.error(error)
263283
raise ChaliceViewError("Check API logs")
@@ -272,7 +292,12 @@ def list_filesystems():
272292
raise ChaliceViewError("Check API logs")
273293
else:
274294
formatted_filesystems.append(formatted)
275-
return formatted_filesystems
295+
if 'NextMarker' in response:
296+
pagination_token = response['NextMarker']
297+
return {"filesystems": formatted_filesystems, "paginationToken": pagination_token}
298+
299+
else:
300+
return {"filesystems": formatted_filesystems}
276301

277302

278303
@app.route('/filesystems/{filesystem_id}', methods=['GET'], cors=True, authorizer=AUTHORIZER)

source/web/src/components/filesystems.vue

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div>
3+
<b-row>
34
<b-table striped hover :items="filesystems">
45
<template v-slot:cell(file_system_id)="data">
56
<div v-if="data.item.managed === true">
@@ -24,12 +25,16 @@
2425
</div>
2526
</template>
2627
</b-table>
27-
<div v-if="noFileSystemsFound">
28-
<p>No Amazon EFS file systems found.
29-
Please create an EFS filesystem in the
30-
<a href="https://console.aws.amazon.com/efs/home/file-systems">AWS console</a>
31-
</p>
32-
</div>
28+
</b-row>
29+
<div v-if="noFileSystemsFound">
30+
<p>No Amazon EFS file systems found.
31+
Please create an EFS filesystem in the
32+
<a href="https://console.aws.amazon.com/efs/home/file-systems">AWS console</a>
33+
</p>
34+
</div>
35+
<div id="moreFilesystemsBtn" v-if="paginationToken != null">
36+
<b-button @click=listFilesystems()>More</b-button>
37+
</div>
3338
</div>
3439
</template>
3540

@@ -41,22 +46,41 @@ export default {
4146
data() {
4247
return {
4348
filesystems: [],
44-
noFileSystemsFound: false
49+
noFileSystemsFound: false,
50+
paginationToken: null
4551
}
4652
},
4753
mounted: function () {
4854
this.listFilesystems()
4955
},
5056
methods: {
5157
async listFilesystems() {
52-
try {
53-
let response = await API.get('fileManagerApi', '/api/filesystems/')
54-
if(response.length == 0){
55-
this.noFileSystemsFound = true
56-
}else{
57-
this.filesystems = response
58-
}
58+
let apiPath = ''
59+
if (this.paginationToken == null) {
60+
apiPath = '/api/filesystems/'
61+
}
62+
else {
63+
apiPath = '/api/filesystems/?cursor=' + this.paginationToken
64+
}
65+
66+
try {
67+
let response = await API.get('fileManagerApi', apiPath)
68+
let filesystems = response.filesystems
69+
if (filesystems.length == 0) {
70+
this.noFileSystemsFound = true
71+
}
72+
else {
73+
filesystems.forEach(filesystem => this.filesystems.push(filesystem))
74+
}
75+
76+
if ("paginationToken" in response) {
77+
this.paginationToken = response.paginationToken
78+
}
79+
else {
80+
this.paginationToken = null
81+
}
5982
}
83+
6084
catch (error) {
6185
alert('Unable to list filesystems, check api logs')
6286
console.log(error)
@@ -73,5 +97,9 @@ export default {
7397
<!-- Add "scoped" attribute to limit CSS to this component only -->
7498
<style scoped>
7599
100+
#moreFilesystemsBtn {
101+
float: right;
102+
103+
}
76104
77105
</style>

0 commit comments

Comments
 (0)