Add admin views to mobile, use partials for common code with desktop

This commit is contained in:
SansPseudoFix 2017-01-25 18:17:57 +01:00 committed by Benjamin Neff
parent df1139234f
commit 276b640418
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
13 changed files with 285 additions and 5 deletions

View file

@ -0,0 +1,14 @@
#app {
.btn-block,
input {
margin-bottom: 5px;
margin-top: 5px;
}
}
#admin-nav li a {
&:hover,
&:focus {
background-color: $gray-light;
}
}

View file

@ -16,6 +16,7 @@
@import "mobile/stream_element"; @import "mobile/stream_element";
@import "mobile/comments"; @import "mobile/comments";
@import 'mobile/openid_connect_error_page'; @import 'mobile/openid_connect_error_page';
@import 'mobile/admins';
@import 'typography'; @import 'typography';

View file

@ -1,7 +1,7 @@
module Admin module Admin
class PodsController < AdminController class PodsController < AdminController
respond_to :html, :json respond_to :html, :json, :mobile
def index def index
pods_json = PodPresenter.as_collection(Pod.all) pods_json = PodPresenter.as_collection(Pod.all)
@ -15,6 +15,7 @@ module Admin
render "admins/pods" render "admins/pods"
end end
format.mobile { render "admins/pods" }
format.json { render json: pods_json } format.json { render json: pods_json }
end end
end end
@ -26,6 +27,7 @@ module Admin
respond_with do |format| respond_with do |format|
format.html { redirect_to admin_pods_path } format.html { redirect_to admin_pods_path }
format.json { render json: PodPresenter.new(pod).as_json } format.json { render json: PodPresenter.new(pod).as_json }
format.mobile { redirect_to admin_pods_path }
end end
end end
end end

View file

@ -1,9 +1,7 @@
- content_for :head do - content_for :head do
= stylesheet_link_tag :admin = stylesheet_link_tag :admin
%h2= t(".pages") %ul.nav.nav-pills.nav-stacked#admin-nav
%ul#admin_nav.nav.nav-pills.nav-stacked
%li{role: "presentation", class: current_page?(admin_dashboard_path) && "active"} %li{role: "presentation", class: current_page?(admin_dashboard_path) && "active"}
= link_to t(".dashboard"), admin_dashboard_path = link_to t(".dashboard"), admin_dashboard_path
%li{role: "presentation", class: current_page?(user_search_path) && "active"} %li{role: "presentation", class: current_page?(user_search_path) && "active"}
@ -22,4 +20,3 @@
= link_to t(".pod_network"), admin_pods_path = link_to t(".pod_network"), admin_pods_path
%li{role: "presentation", class: current_page?(sidekiq_path) && "active"} %li{role: "presentation", class: current_page?(sidekiq_path) && "active"}
= link_to t(".sidekiq_monitor"), sidekiq_path = link_to t(".sidekiq_monitor"), sidekiq_path

View file

@ -0,0 +1,76 @@
%li.user.media
.pull-left
- if user.person
%span.media-object
= person_image_tag(user.person, size: :thumb_small)
.media-body.row
%span.label.label-default
= t(".id")
= user.id
%span.label.label-info
= t(".guid")
= user.person.guid if user.person
%h4.media-heading
= user.person.name if user.person
%div
.unstyled.text-right.actions
= link_to t("admins.user_search.view_profile"), person_path(user.person), class: "btn btn-default btn-block"
= link_to t("admins.user_search.add_invites"), add_invites_path(user.invitation_code),
class: "btn btn-info btn-block"
- unless user.person.closed_account
= link_to t("admins.user_search.close_account"), admin_close_account_path(user),
method: :post, data: {confirm: t("admins.user_search.are_you_sure")},
class: "btn btn-danger btn-block"
- unless user.closed_account?
- if !user.access_locked?
= link_to t("admins.user_search.lock_account"), admin_lock_account_path(user), method: :post,
data: {confirm: t("admins.user_search.are_you_sure_lock_account")},
class: "btn btn-danger btn-block"
- else
= link_to t("admins.user_search.unlock_account"), admin_unlock_account_path(user), method: :post,
data: {confirm: t("admins.user_search.are_you_sure_unlock_account")},
class: "btn btn-danger btn-block"
.row
.col-md-5
%dl.dl-horizontal
%dt= t("username")
%dd= user.username
%dt= t(".email")
%dd= user.email
%dt= t(".diaspora_handle")
%dd= user.person.diaspora_handle
%dt= t(".last_seen")
%dd= user.last_seen || t(".unknown")
- if user.invited_by.present?
%dt= t(".invite_token")
%dd= invite_code_url(user.invited_by.invitation_code)
%dt= t(".account_closed")
%dd
- if user.person.closed_account
%span.label.label-warning= t(".yes")
- else
%span.label.label-success= t(".no")
%dt= t(".nsfw")
%dd
- if user.person.profile.nsfw
%span.label.label-warning= t(".yes")
- else
%span.label.label-success= t(".no")
%h4= t("layouts.header.profile")
%dl.dl-horizontal
%dt= t("people.profile_sidebar.born")
%dd= user.person.profile.birthday
%dt= t("people.profile_sidebar.gender")
%dd= user.person.profile.gender
%dt= t("people.profile_sidebar.location")
%dd= user.person.profile.location
%dt= t("people.profile_sidebar.bio")
%dd= user.person.profile.bio

View file

@ -0,0 +1,9 @@
.col-md-9
#pod-status
%h2
= t(".pod_status")
.alert.alert-info.pod-version{role: "alert"}
= t(".fetching_diaspora_version")
- if unreviewed_reports_count > 0
.alert.alert-warning.reports-warning{role: "alert"}
= t("report.unreviewed_reports", count: unreviewed_reports_count)

View file

@ -0,0 +1,9 @@
.container
.row
.col-md-9
%h2
= t(".pod_network")
.alert.alert-warning
= t(".pod_desktop_view")
= link_to t(".pod_desktop_link"), toggle_mobile_path

View file

@ -0,0 +1,56 @@
.col-md-9
%h1= t(".usage_statistic")
%div
= form_tag("/admins/stats", method: "get", class: "form-inline") do
%select.form-control{name: "range"}
%option{value: "daily", selected: ("selected" if params[:range] == "daily")}
= t(".daily")
%option{value: "week", selected: ("selected" if params[:range] == "week")}
= t(".week")
%option{value: "2weeks", selected: ("selected" if params[:range] == "2weeks")}
= t(".2weeks")
%option{value: "month", selected: ("selected" if params[:range] == "month")}
= t(".month")
= submit_tag t(".go"), class: "btn btn-primary btn-block"
%h3
!= t("admins.stats.display_results", segment: content_tag(:strong, @segment))
.row
- %i(posts comments aspect_memberships users).each do |name|
- model = instance_variable_get("@#{name}")
- if name == :aspect_memberships
- name = t(".shares", count: model[:yesterday])
- if name == :posts
- name = t(".posts", count: model[:yesterday])
- if name == :comments
- name = t(".comments", count: model[:yesterday])
- if name == :users
- name = t(".users", count: model[:yesterday])
.col-md-3
%h2{style: "font-weight:bold;"}
= name.to_s
%h4
= model[:day_before]
%span.percent_change{class: (model[:change] > 0 ? "green" : "red")}
= "(#{model[:change]}%)"
.row
.col-md-12
%p.alert.alert-info.text-center{role: "alert"}
!= t("admins.stats.current_segment",
post_yest: content_tag(:strong, @posts[:yesterday] / @user_count.to_f),
post_day: content_tag(:strong, @posts[:day_before] / @user_count.to_f))
.row
.col-md-12
%h3= t(".50_most")
%ul
- @popular_tags.each do |name, count|
%li
!= t("admins.stats.tag_name",
name_tag: content_tag(:strong, name),
count_tag: content_tag(:strong, count))

View file

@ -0,0 +1,56 @@
.col-md-9
.row
.user_search.col-md-8
%h3= t("admins.admin_bar.user_search")
= form_for @search, url: {action: "user_search"}, html: {method: :get, class: "form-horizontal"} do |f|
.form-group
= f.label :username, t("username"), class: "col-sm-2 control-label"
.col-sm-10
= f.text_field :username, class: "form-control"
.form-group
= f.label :email, t("email"), class: "col-sm-2 control-label"
.col-sm-10
= f.text_field :email, class: "form-control"
.form-group
= f.label :guid, t("admins.user_entry.guid"), class: "col-sm-2 control-label"
.col-sm-10
= f.text_field :guid, class: "form-control"
.form-group
.col-sm-offset-2.col-sm-10
= f.label :under13 do
= f.check_box :under13
= t(".under_13")
.form-group
.clearfix.col-sm-12
= submit_tag t("admins.stats.go"), class: "btn btn-primary btn-block"
.more_invites.col-md-4
%h3= t("shared.invitations.invites")
.clearfix#add-invites-section
!= t(".you_currently", count: current_user.invitation_code.count,
link: link_to(t(".add_invites"), add_invites_path(current_user.invitation_code),
class: "btn btn-link pull-right"))
= form_tag "admin_inviter", method: :get, class: "form-horizontal" do
.form-group
%label.col-sm-4.control-label
= t(".email_to")
.col-sm-8
= text_field_tag "identifier", nil, class: "form-control"
.form-group
.clearfix.col-md-12
= submit_tag t(".invite"), class: "btn btn-default btn-block"
.row
.col-md-12
.alert.alert-info.text-center{role: "alert"}
= t(".users", count: @users.count)
.row
.users.col-md-12
%ul.media-list
- @users.each do |user|
= render partial: "user_entry", locals: {user: user}

View file

@ -0,0 +1,17 @@
.col-md-9
%h2
= t(".current_server", date: Time.zone.now.to_date)
%div
= form_tag("/admins/weekly_user_stats", method: "get", class: "form-inline") do
= select_tag(:week,
options_for_select(@created_users_by_week.keys.reverse,
@selected_week),
class: "form-control")
= submit_tag t("admins.stats.go"), class: "btn btn-primary btn-block"
= t(".amount_of", count: @counter)
%br
- @created_users_by_week[@selected_week].each do |m|
= link_to m, "/u/#{m}"
%br

View file

@ -35,5 +35,7 @@
= person_image_tag(current_user, size: :thumb_small) = person_image_tag(current_user, size: :thumb_small)
%li= link_to t("_contacts"), contacts_path %li= link_to t("_contacts"), contacts_path
%li= link_to t("layouts.header.settings"), edit_user_path %li= link_to t("layouts.header.settings"), edit_user_path
- if current_user.admin?
= render partial: "admins/admin_bar"
%li= link_to t("layouts.application.toggle"), toggle_mobile_path %li= link_to t("layouts.application.toggle"), toggle_mobile_path
%li= link_to t("layouts.header.logout"), destroy_user_session_path, method: :delete %li= link_to t("layouts.header.logout"), destroy_user_session_path, method: :delete

View file

@ -0,0 +1,39 @@
.col-md-9
#reports
%h1
= t("report.title")
- @reports.each do |report|
- if report.item
.panel.panel-default
- username = report.user.username
.panel-heading
.reporter.pull-right
= raw t("report.reported_label", person: link_to(username, user_profile_path(username)))
.reason
%span.reason-label
= t("report.reason_label")
%span
= report.text
.panel-body
.content
= report_content(report)
= button_to t("report.reported_user_details"),
user_search_path(admins_controller_user_search: {guid: report.reported_author.guid}),
class: "btn pull-left btn-info btn-small", method: :post
= button_to t("report.review_link"), report_path(report.id, type: report.item_type),
class: "btn pull-left btn-info btn-small", method: :put
= button_to t("report.delete_link"), report_path(report.id, type: report.item_type),
data: {confirm: t("report.confirm_deletion")},
class: "btn pull-right btn-danger btn-small", method: :delete
- else
.panel.panel-default
- username = report.user.username
.panel-heading
.reporter.pull-right
= raw t("report.reported_label", person: link_to(username, user_profile_path(username)))
.title
= report_content(report)
.panel-body
= button_to t("report.review_link"), report_path(report.id, type: report.item_type),
class: "btn pull-left btn-info btn-small", method: :put

View file

@ -160,6 +160,8 @@ en:
tag_name: "Tag name: %{name_tag} Count: %{count_tag}" tag_name: "Tag name: %{name_tag} Count: %{count_tag}"
pods: pods:
pod_network: "Pod network" pod_network: "Pod network"
pod_desktop_view: "This page is not available on mobile view, please switch to"
pod_desktop_link: "desktop view."
aspects: aspects:
edit: edit:
confirm_remove_aspect: "Are you sure you want to delete this aspect?" confirm_remove_aspect: "Are you sure you want to delete this aspect?"