sort.ts 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { SORTABLE_COLUMNS } from '../../initializers/constants'
  2. import { checkSort, createSortableColumns } from './utils'
  3. // Initialize constants here for better performances
  4. const SORTABLE_USERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USERS)
  5. const SORTABLE_ACCOUNTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.ACCOUNTS)
  6. const SORTABLE_JOBS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.JOBS)
  7. const SORTABLE_VIDEO_ABUSES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_ABUSES)
  8. const SORTABLE_VIDEOS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS)
  9. const SORTABLE_VIDEOS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEOS_SEARCH)
  10. const SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS_SEARCH)
  11. const SORTABLE_VIDEO_IMPORTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_IMPORTS)
  12. const SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_COMMENT_THREADS)
  13. const SORTABLE_VIDEO_RATES_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_RATES)
  14. const SORTABLE_BLACKLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.BLACKLISTS)
  15. const SORTABLE_VIDEO_CHANNELS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_CHANNELS)
  16. const SORTABLE_FOLLOWERS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWERS)
  17. const SORTABLE_FOLLOWING_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.FOLLOWING)
  18. const SORTABLE_USER_SUBSCRIPTIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_SUBSCRIPTIONS)
  19. const SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.ACCOUNTS_BLOCKLIST)
  20. const SORTABLE_SERVERS_BLOCKLIST_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.SERVERS_BLOCKLIST)
  21. const SORTABLE_USER_NOTIFICATIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_NOTIFICATIONS)
  22. const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS)
  23. const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS)
  24. const accountsSortValidator = checkSort(SORTABLE_ACCOUNTS_COLUMNS)
  25. const jobsSortValidator = checkSort(SORTABLE_JOBS_COLUMNS)
  26. const videoAbusesSortValidator = checkSort(SORTABLE_VIDEO_ABUSES_COLUMNS)
  27. const videosSortValidator = checkSort(SORTABLE_VIDEOS_COLUMNS)
  28. const videoImportsSortValidator = checkSort(SORTABLE_VIDEO_IMPORTS_COLUMNS)
  29. const videosSearchSortValidator = checkSort(SORTABLE_VIDEOS_SEARCH_COLUMNS)
  30. const videoChannelsSearchSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_SEARCH_COLUMNS)
  31. const videoCommentThreadsSortValidator = checkSort(SORTABLE_VIDEO_COMMENT_THREADS_COLUMNS)
  32. const videoRatesSortValidator = checkSort(SORTABLE_VIDEO_RATES_COLUMNS)
  33. const blacklistSortValidator = checkSort(SORTABLE_BLACKLISTS_COLUMNS)
  34. const videoChannelsSortValidator = checkSort(SORTABLE_VIDEO_CHANNELS_COLUMNS)
  35. const followersSortValidator = checkSort(SORTABLE_FOLLOWERS_COLUMNS)
  36. const followingSortValidator = checkSort(SORTABLE_FOLLOWING_COLUMNS)
  37. const userSubscriptionsSortValidator = checkSort(SORTABLE_USER_SUBSCRIPTIONS_COLUMNS)
  38. const accountsBlocklistSortValidator = checkSort(SORTABLE_ACCOUNTS_BLOCKLIST_COLUMNS)
  39. const serversBlocklistSortValidator = checkSort(SORTABLE_SERVERS_BLOCKLIST_COLUMNS)
  40. const userNotificationsSortValidator = checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS)
  41. const videoPlaylistsSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS)
  42. // ---------------------------------------------------------------------------
  43. export {
  44. usersSortValidator,
  45. videoAbusesSortValidator,
  46. videoChannelsSortValidator,
  47. videoImportsSortValidator,
  48. videosSearchSortValidator,
  49. videosSortValidator,
  50. blacklistSortValidator,
  51. accountsSortValidator,
  52. followersSortValidator,
  53. followingSortValidator,
  54. jobsSortValidator,
  55. videoCommentThreadsSortValidator,
  56. videoRatesSortValidator,
  57. userSubscriptionsSortValidator,
  58. videoChannelsSearchSortValidator,
  59. accountsBlocklistSortValidator,
  60. serversBlocklistSortValidator,
  61. userNotificationsSortValidator,
  62. videoPlaylistsSortValidator
  63. }