uploads: add thumbnail view to /uploads listing.

Add a thumbnail view to the /uploads listing. You can click on images to
resume the upload, or go to the post if it's already been posted.
This commit is contained in:
evazion
2022-02-02 01:35:20 -06:00
parent 92a4d045e2
commit 054b0b4d0a
5 changed files with 133 additions and 70 deletions

View File

@@ -29,10 +29,19 @@ class UploadsController < ApplicationController
end
def index
@uploads = authorize Upload.visible(CurrentUser.user).paginated_search(params, count_pages: true)
@uploads = @uploads.includes(:uploader, :media_assets) if request.format.html?
@mode = params.fetch(:mode, "table")
respond_with(@uploads)
case @mode
when "table"
@uploads = authorize Upload.visible(CurrentUser.user).paginated_search(params, count_pages: true)
@uploads = @uploads.includes(:uploader, media_assets: [:post]) if request.format.html?
respond_with(@uploads)
when "gallery"
@media_assets = authorize MediaAsset.distinct.visible(CurrentUser.user).joins(:uploads).where(uploads: { uploader: CurrentUser.user }).paginated_search(params, count_pages: true)
respond_with(@media_assets)
else
raise "Invalid mode '#{mode}'"
end
end
def show