aws-s3-explorer
aws-s3-explorer copied to clipboard
Enable sorting S3 objects by date
Hi @wparad . How easy is to sort objects by last modified date (or perhaps toggle sorting ascending - descending on column headers click)? I have tried to change
const sortedObjects = computed(() => store.objects.sort((a, b) => a.key.localeCompare(b.key)));
to
const sortedObjects = computed(() => store.objects.sort((a, b) => new Date(a.date) - new Date(b.date)));
and
<tr v-for="path in sortedObjects.filter(o => o.type === 'PATH' && o.key.split(store.delimiter).slice(-1)[0])"
:key="path.key">
to
<tr v-for="path in sortedObjects.filter(o => o.type === 'PATH' && o.key.split(store.delimiter).slice(-1)[0])"
:key="path.lastModified">
something like that. Vue and JS are not really area of my specialty so I might have done something completely wrong hence it didn't work. Please, let me know if that can be implemented by changing lines above? Thanks
Are you running this in a fork of this repo and you just want the code, or is the request to support sorting in the repo's default UI?
Thanks @wparad . Either would work. I am current running the fork but any help would be appreciated. Thanks
You definitely want to leave this alone, the key is html magic, it tells the virtual DOM these are unique objects.
<tr v-for="path in sortedObjects.filter(o => o.type === 'PATH' && o.key.split(store.delimiter).slice(-1)[0])"
:key="path.key">
This looks fine-ish:
const sortedObjects = computed(() => store.objects.sort((a, b) => new Date(a.date) - new Date(b.date)));
If a.date is a thing, but it isn't. I don't think date is defined anywhere. So you've got a few problems there. If it's something present in the response from AWS you can update the bucketManager.fetchBucketObjectsExplicit with the date property and then it would work.
Hi! Will this feature be applied in the code? It's something I would like.
Tks!
We think it is something that makes sense. Having a PR that sets up most of the designed functionality goes a long way to having it implemented. Obviously, if there is a driving use case that increases value of the feature, sharing that here, helps us to better prioritize.