aws-s3-explorer icon indicating copy to clipboard operation
aws-s3-explorer copied to clipboard

Enable sorting S3 objects by date

Open melnur opened this issue 3 years ago • 5 comments

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

melnur avatar Dec 13 '21 15:12 melnur

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?

wparad avatar Dec 13 '21 16:12 wparad

Thanks @wparad . Either would work. I am current running the fork but any help would be appreciated. Thanks

melnur avatar Dec 14 '21 17:12 melnur

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.

wparad avatar Dec 14 '21 17:12 wparad

Hi! Will this feature be applied in the code? It's something I would like.

Tks!

roening avatar Jun 29 '22 18:06 roening

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.

wparad avatar Jun 29 '22 18:06 wparad