My views improved. Own screenshots view added

This commit is contained in:
Christoph Haas 2021-03-09 22:43:50 +01:00
parent 15b58548cc
commit 0207d6b392
7 changed files with 93 additions and 39 deletions

View file

@ -5,19 +5,24 @@ class MyController < ApplicationController
# Show audit logs # Show audit logs
def logs def logs
@logs = Log.paginate(page: params[:page], per_page: 20) @logs = Log.paginate(page: params[:page], per_page: 20)
render :logs
end end
# Show the user's own uploaded screenshots
def screenshots
@screenshots = current_user.screenshots.paginate(page: params[:page], per_page: 10)
end
# def profile # def profile
# end # end
def uploads # def uploads
# @current_users_screenshots gets filled in ApplicationController # # @current_users_screenshots gets filled in ApplicationController
# # #
# Get packages that the uploaded screenshots belong to. # # Get packages that the uploaded screenshots belong to.
@packages = Package.joins(:screenshots).where( # @packages = Package.joins(:screenshots).where(
'screenshots.id' => @current_users_screenshots) # 'screenshots.id' => @current_users_screenshots)
end # end
def moderate_list def moderate_list
# First package with pending screenshots # First package with pending screenshots

View file

@ -3,6 +3,9 @@
li class=('active' if action_name=='profile') li class=('active' if action_name=='profile')
= link_to my_profile_path = link_to my_profile_path
= fa_icon 'user-o 2x', text: 'Myself' = fa_icon 'user-o 2x', text: 'Myself'
li class=('active' if action_name=='screenshots')
= link_to my_screenshots_path
= fa_icon 'camera 2x', text: 'Screenshots'
li class=('active' if action_name=='moderate_list') li class=('active' if action_name=='moderate_list')
= link_to moderate_list_path = link_to moderate_list_path
= fa_icon 'check 2x', text: 'Moderate' = fa_icon 'check 2x', text: 'Moderate'

View file

@ -6,16 +6,17 @@
// Paginator // Paginator
= render(partial: 'packages/paginator', locals: {items: @logs}) = render(partial: 'packages/paginator', locals: {items: @logs})
.small-6.medium-4.large-3.cell / .small-6.medium-4.large-3.cell
// Search form / // Search form
= render 'packages/searchfield' / = render 'packages/searchfield'
- if @logs - if @logs
table table
thead thead
tr tr
th Time
th Message th Message
th Level / th Level
th Section th Section
th Package th Package
th Screenshot th Screenshot
@ -24,8 +25,9 @@
tbody tbody
- @logs.each do |log| - @logs.each do |log|
tr tr
td #{log.created_at}
td #{log.message} td #{log.message}
td #{log.level} / td #{log.level}
td #{log.section} td #{log.section}
td td
- if log.package - if log.package

View file

@ -2,9 +2,13 @@
= render partial: 'menu' = render partial: 'menu'
h1 These packages have new screenshots h1 Packages that require moderation
- if @packages.any? - if @packages.any?
p
i Note the red bar at the top also listing packages that need moderation.
ul ul
- @packages.each do |pkg| - @packages.each do |pkg|
li li

View file

@ -1,34 +1,45 @@
.grid-container
= render partial: 'menu' = render partial: 'menu'
h1 As far as we know… h1 Your data
- unless current_user.name.blank?
h2 Your name h2 Your name
= current_user.name
= text_field_tag 'name', current_user.name - unless current_user.email.blank?
h2 Your email address
p = current_user.email
p.help-text p.help-text
' Your name will be shown to others along with the images you upload. ' This web site recognizes you by your email address.
' Feel free to change it. ' Don't worry - it will not be shown or given to anyone.
/ TODO: submit - save - unless current_user.provider.blank?
h2 Account provider
p You logged in using #{current_user.pretty_provider}.
- unless current_user.email.blank? h2 Number of screenshots you uploaded
h2 Your email address p = current_user.screenshots.count
p = current_user.email
p.help-text
' This web site recognizes you by your email address.
' Don't worry - it will not be shown or given to anyone.
- unless current_user.provider.blank? h2 Your permissions
h2 Single-sign-on provider ul
p You logged in using #{current_user.pretty_provider}. - if can? :approve, Screenshot
li
h2 Number of screenshots you uploaded => fa_icon 'thumbs-up'
p = current_user.screenshots.count 'approve uploaded screenshots
- if can? :destroy, Screenshot
/ - if current_user.is_admin? li
/ h2 Admin => fa_icon 'trash'
/ p Apparently you are an administrator. Be careful with that thing! 'delete screenshots
/ - you can moderate - if can? :hide, Screenshot
/ - you can … li
=> fa_icon 'eye-slash'
'hide screenshots from the public
- if can? :unhide, Screenshot
li
=> fa_icon 'eye'
'restore (unhide) screenshots to the public
- if can? :view, Log
li
=> fa_icon 'book'
'view logs

View file

@ -0,0 +1,28 @@
= render partial: 'menu'
h1 Screenshots uploaded by you
= render(partial: 'packages/paginator', locals: {items: @screenshots})
- if @screenshots
table
thead
tr
th Uploaded
th Package
th Screenshot
tbody
- @screenshots.each do |ss|
tr
td #{time_ago_in_words ss.created_at} ago
td
= link_to ss.package.name, ss.package
td
- if ss.package
.image
/ This leads to an N+1 SQL query for each image. Ideas for optimization welcome.
img src=ss.simage_url(:thumb)
/ = link_to ss.id, package_path(ss.package, highlight: ss.id)
- else
p You haven't uploaded any screenshots yet.

View file

@ -23,6 +23,7 @@ Rails.application.routes.draw do
get 'my/profile' get 'my/profile'
get 'my/uploads' get 'my/uploads'
get 'my/welcome' get 'my/welcome'
get 'my/screenshots'
get 'my/moderate_list', as: :moderate_list get 'my/moderate_list', as: :moderate_list
get 'my/logs', as: :logs get 'my/logs', as: :logs
get 'package/:name' => 'packages#details', as: :package, name: /[^\/]+/ get 'package/:name' => 'packages#details', as: :package, name: /[^\/]+/