Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable sorting S3 objects by date #8

Open
melnur opened this issue Dec 13, 2021 · 5 comments
Open

Enable sorting S3 objects by date #8

melnur opened this issue Dec 13, 2021 · 5 comments

Comments

@melnur
Copy link

melnur commented Dec 13, 2021

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

@wparad
Copy link
Member

wparad commented Dec 13, 2021

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?

@melnur
Copy link
Author

melnur commented Dec 14, 2021

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

@wparad
Copy link
Member

wparad commented Dec 14, 2021

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 wparad changed the title Sorting by date Enable sorting S3 objects by date header Dec 14, 2021
@wparad wparad changed the title Enable sorting S3 objects by date header Enable sorting S3 objects by date Dec 14, 2021
@roening
Copy link

roening commented Jun 29, 2022

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

Tks!

@wparad
Copy link
Member

wparad commented Jun 29, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants