Add admin attachments panel
This commit is contained in:
parent
15683f583d
commit
bd839a8abc
8 changed files with 82 additions and 0 deletions
18
app/controllers/admin/media_attachments_controller.rb
Normal file
18
app/controllers/admin/media_attachments_controller.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class MediaAttachmentsController < BaseController
|
||||
def index
|
||||
authorize :account, :index?
|
||||
|
||||
@media_attachments = filtered_attachments.page(params[:page])
|
||||
@form = Form::MediaAttachmentsBatch.new
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def filtered_attachments
|
||||
MediaAttachment.recently_attachments
|
||||
end
|
||||
end
|
||||
end
|
13
app/models/form/media_attachments_batch.rb
Normal file
13
app/models/form/media_attachments_batch.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Form::MediaAttachmentsBatch
|
||||
include ActiveModel::Model
|
||||
include Authorization
|
||||
include AccountableConcern
|
||||
include Payloadable
|
||||
|
||||
attr_accessor :query
|
||||
|
||||
def save
|
||||
end
|
||||
end
|
|
@ -33,6 +33,7 @@ class MediaAttachment < ApplicationRecord
|
|||
self.inheritance_column = nil
|
||||
|
||||
include Attachmentable
|
||||
include RoutingHelper
|
||||
|
||||
enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
|
||||
enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
|
||||
|
@ -208,6 +209,7 @@ class MediaAttachment < ApplicationRecord
|
|||
scope :local, -> { where(remote_url: '') }
|
||||
scope :remote, -> { where.not(remote_url: '') }
|
||||
scope :cached, -> { remote.where.not(file_file_name: nil) }
|
||||
scope :recently_attachments, -> { attached.order(status_id: 'DESC') }
|
||||
|
||||
default_scope { order(id: :asc) }
|
||||
|
||||
|
@ -271,6 +273,10 @@ class MediaAttachment < ApplicationRecord
|
|||
delay_processing? && attachment_name == :file
|
||||
end
|
||||
|
||||
def url
|
||||
full_asset_url(file.url(:original))
|
||||
end
|
||||
|
||||
after_commit :enqueue_processing, on: :create
|
||||
after_commit :reset_parent_cache, on: :update
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
.batch-table__row{ class: ['batch-table__row--attention'] }
|
||||
.batch-table__row__content.batch-table__row__content--unpadded
|
||||
%table.accounts-table
|
||||
%tbody
|
||||
%tr
|
||||
%td
|
||||
%img{ src: media_attachment.url }
|
||||
%div
|
||||
= media_attachment.status.uri
|
||||
%div
|
||||
= media_attachment.status.visibility
|
30
app/views/admin/media_attachments/index.html.haml
Normal file
30
app/views/admin/media_attachments/index.html.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- content_for :page_title do
|
||||
= t('admin.accounts.title')
|
||||
|
||||
- content_for :header_tags do
|
||||
= javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous'
|
||||
|
||||
= form_for(@form, url: admin_media_attachments_path) do |f|
|
||||
= hidden_field_tag :page, params[:page] || 1
|
||||
= hidden_field_tag :select_all_matching, '0'
|
||||
|
||||
- AccountFilter::KEYS.each do |key|
|
||||
= hidden_field_tag key, params[key] if params[key].present?
|
||||
|
||||
.batch-table
|
||||
.batch-table__toolbar
|
||||
- if @media_attachments.total_count > @media_attachments.size
|
||||
.batch-table__select-all
|
||||
.not-selected.active
|
||||
%span= t('generic.all_items_on_page_selected_html', count: @media_attachments.size)
|
||||
%button{ type: 'button' }= t('generic.select_all_matching_items', count: @media_attachments.total_count)
|
||||
.selected
|
||||
%span= t('generic.all_matching_items_selected_html', count: @media_attachments.total_count)
|
||||
%button{ type: 'button' }= t('generic.deselect')
|
||||
.batch-table__body
|
||||
- if @media_attachments.empty?
|
||||
= nothing_here 'nothing-here--under-tabs'
|
||||
- else
|
||||
= render partial: 'media_attachment', collection: @media_attachments, locals: { f: f }
|
||||
|
||||
= paginate @media_attachments
|
|
@ -97,6 +97,7 @@ Doorkeeper.configure do
|
|||
:push,
|
||||
:'admin:read',
|
||||
:'admin:read:accounts',
|
||||
:'admin:read:media_attachments',
|
||||
:'admin:read:reports',
|
||||
:'admin:read:domain_allows',
|
||||
:'admin:read:domain_blocks',
|
||||
|
@ -105,6 +106,7 @@ Doorkeeper.configure do
|
|||
:'admin:read:canonical_email_blocks',
|
||||
:'admin:write',
|
||||
:'admin:write:accounts',
|
||||
:'admin:write:media_attachments',
|
||||
:'admin:write:reports',
|
||||
:'admin:write:domain_allows',
|
||||
:'admin:write:domain_blocks',
|
||||
|
|
|
@ -42,6 +42,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
|||
n.item :moderation, safe_join([fa_icon('gavel fw'), t('moderation.title')]), nil, if: -> { current_user.can?(:manage_reports, :view_audit_log, :manage_users, :manage_invites, :manage_taxonomies, :manage_federation, :manage_blocks) } do |s|
|
||||
s.item :reports, safe_join([fa_icon('flag fw'), t('admin.reports.title')]), admin_reports_path, highlights_on: %r{/admin/reports}, if: -> { current_user.can?(:manage_reports) }
|
||||
s.item :accounts, safe_join([fa_icon('users fw'), t('admin.accounts.title')]), admin_accounts_path(origin: 'local'), highlights_on: %r{/admin/accounts|/admin/pending_accounts|/admin/disputes|/admin/users}, if: -> { current_user.can?(:manage_users) }
|
||||
s.item :media_attachments, safe_join([fa_icon('users fw'), t('admin.accounts.title')]), admin_media_attachments_path, highlights_on: %r{/admin/media_attachments}, if: -> { current_user.can?(:manage_users) }
|
||||
s.item :invites, safe_join([fa_icon('user-plus fw'), t('admin.invites.title')]), admin_invites_path, if: -> { current_user.can?(:manage_invites) }
|
||||
s.item :follow_recommendations, safe_join([fa_icon('user-plus fw'), t('admin.follow_recommendations.title')]), admin_follow_recommendations_path, highlights_on: %r{/admin/follow_recommendations}, if: -> { current_user.can?(:manage_taxonomies) }
|
||||
s.item :instances, safe_join([fa_icon('cloud fw'), t('admin.instances.title')]), admin_instances_path(limited: whitelist_mode? ? nil : '1'), highlights_on: %r{/admin/instances|/admin/domain_blocks|/admin/domain_allows}, if: -> { current_user.can?(:manage_federation) }
|
||||
|
|
|
@ -257,6 +257,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :action_logs, only: [:index]
|
||||
resources :warning_presets, except: [:new]
|
||||
resources :media_attachments, only: [:index]
|
||||
|
||||
resources :announcements, except: [:show] do
|
||||
member do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue