mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 21:36:44 +08:00
Added statistics block in users profile [SCI-566]
This commit is contained in:
parent
24cdbedd05
commit
d28edfb488
4 changed files with 204 additions and 150 deletions
|
@ -744,6 +744,17 @@ a[data-toggle="tooltip"] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-statistics {
|
||||||
|
li {
|
||||||
|
height: 100px;
|
||||||
|
margin: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Protocols management */
|
/** Protocols management */
|
||||||
.breadcrumb-protocols-manager {
|
.breadcrumb-protocols-manager {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
|
|
@ -263,6 +263,20 @@ class User < ActiveRecord::Base
|
||||||
organizations.pluck(:id)
|
organizations.pluck(:id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a hash with user statistics
|
||||||
|
def statistics
|
||||||
|
statistics = {}
|
||||||
|
statistics[:number_of_teams] = organizations.count
|
||||||
|
statistics[:number_of_projects] = projects.count
|
||||||
|
number_of_experiments = 0
|
||||||
|
projects.find_each do |pr|
|
||||||
|
number_of_experiments += pr.experiments.count
|
||||||
|
end
|
||||||
|
statistics[:number_of_experiments] = number_of_experiments
|
||||||
|
statistics[:number_of_protocols] = added_protocols.count
|
||||||
|
statistics
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def time_zone_check
|
def time_zone_check
|
||||||
|
|
|
@ -1,169 +1,192 @@
|
||||||
<% provide(:head_title, t("users.registrations.edit.head_title")) %>
|
<% provide(:head_title, t("users.registrations.edit.head_title")) %>
|
||||||
|
|
||||||
<div class="center-block center-block-narrow">
|
<div class="row">
|
||||||
<h2><%=t "users.registrations.edit.title" %></h2>
|
<div class="col-md-4">
|
||||||
|
<h2><%=t "users.registrations.edit.title" %></h2>
|
||||||
|
|
||||||
<% if not resource.errors.empty? %>
|
<% if not resource.errors.empty? %>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, "data-for" => "avatar" }) do |f| %>
|
|
||||||
<%= hidden_field_tag "user[change_avatar]", "true" %>
|
|
||||||
<div data-part="view">
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label t("users.registrations.edit.avatar_label") %><br />
|
|
||||||
<% @user_avatar_url ||= avatar_path(current_user, :thumb) %>
|
|
||||||
<%= image_tag @user_avatar_url %><br /><br />
|
|
||||||
<a href="#" class="btn btn-default" data-action="edit"><%=t "users.registrations.edit.avatar_btn" %></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div data-part="edit" style="display: none;">
|
<% end %>
|
||||||
<div class="well">
|
|
||||||
<h4><%=t "users.registrations.edit.avatar_title" %></h4>
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, "data-for" => "avatar" }) do |f| %>
|
||||||
|
<%= hidden_field_tag "user[change_avatar]", "true" %>
|
||||||
|
<div data-part="view">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :avatar, t("users.registrations.edit.avatar_edit_label") %>
|
<%= f.label t("users.registrations.edit.avatar_label") %><br />
|
||||||
<%= f.file_field :avatar, class: "btn btn-default" %>
|
<% @user_avatar_url ||= avatar_path(current_user, :thumb) %>
|
||||||
</div>
|
<%= image_tag @user_avatar_url %><br /><br />
|
||||||
<div>
|
<a href="#" class="btn btn-default" data-action="edit"><%=t "users.registrations.edit.avatar_btn" %></a>
|
||||||
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
|
||||||
<%= f.submit t("users.registrations.edit.avatar_submit"), class: 'btn btn-primary', onclick: "processFile(event, #{@direct_upload});" %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div data-part="edit" style="display: none;">
|
||||||
<% end %>
|
<div class="well">
|
||||||
|
<h4><%=t "users.registrations.edit.avatar_title" %></h4>
|
||||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "full_name" }) do |f| %>
|
<div class="form-group">
|
||||||
<div data-part="view">
|
<%= f.label :avatar, t("users.registrations.edit.avatar_edit_label") %>
|
||||||
<div class="form-group">
|
<%= f.file_field :avatar, class: "btn btn-default" %>
|
||||||
<%= f.label t("users.registrations.edit.name_label") %>
|
</div>
|
||||||
<div class="input-group">
|
<div>
|
||||||
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.full_name %>" name="fake_user[full_name]" id="fake_user_full_name">
|
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
||||||
<span class="input-group-btn">
|
<%= f.submit t("users.registrations.edit.avatar_submit"), class: 'btn btn-primary', onclick: "processFile(event, #{@direct_upload});" %>
|
||||||
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div data-part="edit" style="display: none;">
|
|
||||||
<div class="well">
|
|
||||||
<h4><%=t "users.registrations.edit.name_title" %></h4>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label :full_name, t("users.registrations.edit.name_label") %>
|
|
||||||
<%= f.text_field :full_name, class: "form-control", "data-role" => "edit" %>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
|
||||||
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "initials" }) do |f| %>
|
|
||||||
<div data-part="view">
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label t("users.registrations.edit.initials_label") %>
|
|
||||||
<div class="input-group">
|
|
||||||
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.initials %>" name="fake_user[initials]" id="fake_user_initials">
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div data-part="edit" style="display: none;">
|
|
||||||
<div class="well">
|
|
||||||
<h4><%=t "users.registrations.edit.initials_title" %></h4>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label :initials, t("users.registrations.edit.initials_label") %>
|
|
||||||
<%= f.text_field :initials, class: "form-control", "data-role" => "edit" %>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
|
||||||
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "email" }) do |f| %>
|
|
||||||
<div data-part="view">
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label t("users.registrations.edit.email_label") %>
|
|
||||||
<div class="input-group">
|
|
||||||
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.email %>" name="fake_user[email]" id="fake_user_email">
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
|
||||||
<div class="alert alert-info" style="margin-top: 15px;" role="alert">
|
|
||||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
|
||||||
<%=t "users.registrations.edit.waiting_for_confirm", email: resource.unconfirmed_email %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div data-part="edit" style="display: none;">
|
|
||||||
<div class="well">
|
|
||||||
<h4><%=t "users.registrations.edit.email_title" %></h4>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label :email, t("users.registrations.edit.new_email_label") %>
|
|
||||||
<%= f.email_field :email, class: "form-control", "data-role" => "edit" %>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label :current_password, t("users.registrations.edit.current_password_label") %> <i><%=t "users.registrations.edit.password_explanation" %></i>
|
|
||||||
<%= f.password_field :current_password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
|
||||||
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "password" }) do |f| %>
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "full_name" }) do |f| %>
|
||||||
<%= hidden_field_tag "user[change_password]", "true" %>
|
<div data-part="view">
|
||||||
<div data-part="view">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<%= f.label t("users.registrations.edit.name_label") %>
|
||||||
<%= f.label t("users.registrations.edit.password_label") %>
|
<div class="input-group">
|
||||||
<div class="input-group">
|
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.full_name %>" name="fake_user[full_name]" id="fake_user_full_name">
|
||||||
<input class="form-control" disabled="disabled" autocomplete="off" type="password" value="aaaaaaaaaa" name="fake_user[current_password]" id="fake_user_current_password">
|
<span class="input-group-btn">
|
||||||
<span class="input-group-btn">
|
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
||||||
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div data-part="edit" style="display: none;">
|
||||||
<div data-part="edit" style="display: none;">
|
<div class="well">
|
||||||
<div class="well">
|
<h4><%=t "users.registrations.edit.name_title" %></h4>
|
||||||
<h4><%=t "users.registrations.edit.password_title" %></h4>
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<%= f.label :full_name, t("users.registrations.edit.name_label") %>
|
||||||
<%= f.label :current_password, t("users.registrations.edit.current_password_label") %> <i><%=t "users.registrations.edit.password_explanation" %></i>
|
<%= f.text_field :full_name, class: "form-control", "data-role" => "edit" %>
|
||||||
<%= f.password_field :current_password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
</div>
|
||||||
</div>
|
<div>
|
||||||
|
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
||||||
<div class="form-group">
|
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
||||||
<%= f.label :password, t("users.registrations.edit.new_password_label") %>
|
</div>
|
||||||
<%= f.password_field :password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label :password_confirmation, t("users.registrations.edit.new_password_2_label") %>
|
|
||||||
<%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
|
||||||
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "initials" }) do |f| %>
|
||||||
|
<div data-part="view">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t("users.registrations.edit.initials_label") %>
|
||||||
|
<div class="input-group">
|
||||||
|
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.initials %>" name="fake_user[initials]" id="fake_user_initials">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div data-part="edit" style="display: none;">
|
||||||
|
<div class="well">
|
||||||
|
<h4><%=t "users.registrations.edit.initials_title" %></h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :initials, t("users.registrations.edit.initials_label") %>
|
||||||
|
<%= f.text_field :initials, class: "form-control", "data-role" => "edit" %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
||||||
|
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "email" }) do |f| %>
|
||||||
|
<div data-part="view">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t("users.registrations.edit.email_label") %>
|
||||||
|
<div class="input-group">
|
||||||
|
<input data-role="src" class="form-control" disabled="disabled" type="text" value="<%= @user.email %>" name="fake_user[email]" id="fake_user_email">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
||||||
|
<div class="alert alert-info" style="margin-top: 15px;" role="alert">
|
||||||
|
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
|
||||||
|
<%=t "users.registrations.edit.waiting_for_confirm", email: resource.unconfirmed_email %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div data-part="edit" style="display: none;">
|
||||||
|
<div class="well">
|
||||||
|
<h4><%=t "users.registrations.edit.email_title" %></h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :email, t("users.registrations.edit.new_email_label") %>
|
||||||
|
<%= f.email_field :email, class: "form-control", "data-role" => "edit" %>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :current_password, t("users.registrations.edit.current_password_label") %> <i><%=t "users.registrations.edit.password_explanation" %></i>
|
||||||
|
<%= f.password_field :current_password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
||||||
|
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name, format: :json), remote: true, html: { method: :put, "data-for" => "password" }) do |f| %>
|
||||||
|
<%= hidden_field_tag "user[change_password]", "true" %>
|
||||||
|
<div data-part="view">
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label t("users.registrations.edit.password_label") %>
|
||||||
|
<div class="input-group">
|
||||||
|
<input class="form-control" disabled="disabled" autocomplete="off" type="password" value="aaaaaaaaaa" name="fake_user[current_password]" id="fake_user_current_password">
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<a href="#" class="btn btn-default" data-action="edit"><%=t "general.edit" %></a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div data-part="edit" style="display: none;">
|
||||||
|
<div class="well">
|
||||||
|
<h4><%=t "users.registrations.edit.password_title" %></h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :current_password, t("users.registrations.edit.current_password_label") %> <i><%=t "users.registrations.edit.password_explanation" %></i>
|
||||||
|
<%= f.password_field :current_password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password, t("users.registrations.edit.new_password_label") %>
|
||||||
|
<%= f.password_field :password, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :password_confirmation, t("users.registrations.edit.new_password_2_label") %>
|
||||||
|
<%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control", "data-role" => "clear" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a href="#" class="btn btn-default" data-action="cancel"><%=t "general.cancel" %></a>
|
||||||
|
<%= f.submit t("general.update"), class: "btn btn-primary" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7 col-md-offset-1">
|
||||||
|
<h2><%=t "users.statistics.title" %></h2>
|
||||||
|
<ul class="list-inline user-statistics">
|
||||||
|
<li class="label label-primary">
|
||||||
|
<h2><%= @user.statistics[:number_of_teams]%></h2>
|
||||||
|
<%= t("users.statistics.team").pluralize(@user.statistics[:number_of_teams]) %>
|
||||||
|
</li>
|
||||||
|
<li class="label label-primary">
|
||||||
|
<h2><%= @user.statistics[:number_of_projects] %></h2>
|
||||||
|
<%= t("users.statistics.project").pluralize(@user.statistics[:number_of_projects]) %>
|
||||||
|
</li>
|
||||||
|
<li class="label label-primary">
|
||||||
|
<h2><%= @user.statistics[:number_of_experiments] %></h2>
|
||||||
|
<%= t("users.statistics.experiment").pluralize(@user.statistics[:number_of_experiments]) %>
|
||||||
|
</li>
|
||||||
|
<li class="label label-primary">
|
||||||
|
<h2><%= @user.statistics[:number_of_protocols] %></h2>
|
||||||
|
<%= t("users.statistics.protocol").pluralize(@user.statistics[:number_of_protocols]) %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= javascript_include_tag("canvas-to-blob.min") %>
|
<%= javascript_include_tag("canvas-to-blob.min") %>
|
||||||
|
|
|
@ -1117,6 +1117,12 @@ en:
|
||||||
head_title: "Sign up"
|
head_title: "Sign up"
|
||||||
team_name_label: "Team name"
|
team_name_label: "Team name"
|
||||||
team_name_help: "Team name is required in order to create your own team."
|
team_name_help: "Team name is required in order to create your own team."
|
||||||
|
statistics:
|
||||||
|
title: "Statistics"
|
||||||
|
team: "Team"
|
||||||
|
project: "Project"
|
||||||
|
experiment: "Experiment"
|
||||||
|
protocol: "Protocol"
|
||||||
settings:
|
settings:
|
||||||
changed_org_flash: "You are working on %{team} now!"
|
changed_org_flash: "You are working on %{team} now!"
|
||||||
changed_org_error_flash: "Something went wrong! Try again later."
|
changed_org_error_flash: "Something went wrong! Try again later."
|
||||||
|
|
Loading…
Add table
Reference in a new issue