Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeuroHub - component categorical grid #1359

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions BrainPortal/app/assets/stylesheets/neurohub.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3421,3 +3421,61 @@ $DASHBOARD_CARD_MIN_WIDTH: 25;
}
}
}

/*
=============================================================
| component/projects categories
=============================================================
/* Subprojects, components of Neurohub grid */

.neurohub-tool {
height: $BAR_HEIGHT + rem; // patch that sets height for link_to element that does not return a link
display: flex;
padding: 10px;
padding-right: 15px;
justify-content: center;

width: 90%;
object-fit: contain;
flex-direction: column;

a {
object-fit: contain;
@extend .btn-text;

@extend .external;
@include text("xs");
padding: 0;
height: 100%;
text-decoration: none;
padding: 3px;
}

img {
object-fit: contain;
}

.mini-logo {
height: 3.5em;
}
}

.card_category_description {
@include p(5);
padding: 5px;
/*flex: 1 1 5rem;*/
overflow: hidden;
position: relative;
&::after {
// overflow gradient
content: "";
background: linear-gradient(rgba(255, 255, 255, 0), $DEFAULT_BG);
width: 100%;
height: 0.1rem;
position: absolute;
bottom: 0;
left: 0;
}
}


9 changes: 7 additions & 2 deletions BrainPortal/app/controllers/neurohub_portal_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# NeuroHub Project
#
# Copyright (C) 2020
# Copyright (C) 2020-2023
# The Royal Institution for the Advancement of Learning
# McGill University
#
Expand All @@ -28,7 +28,7 @@ class NeurohubPortalController < NeurohubApplicationController
before_action :login_required

# Main welcome/dashboard page
def welcome #:nodoc:
def news #:nodoc:
@username = current_user.login
bourreau_ids = Bourreau.find_all_accessible_by_user(current_user).raw_first_column("remote_resources.id")
user_ids = current_user.available_users.raw_first_column(:id)
Expand All @@ -41,6 +41,11 @@ def welcome #:nodoc:
.select { |m| m.expiry.nil? || m.expiry > Time.now }
end

def welcome
@username = current_user.login
end


# This action searches among all sorts of models for IDs or strings,
# and reports links to the matches found.
def search
Expand Down
3 changes: 1 addition & 2 deletions BrainPortal/app/views/layouts/_neurohub_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
</div>
<div class="nh_navbar_buttons">
<%= link_to 'Dashboard', neurohub_path, { :class => "btn-nav secondary", "data-active"=> request.path_info.include?('welcome') || action_name==="welcome" } %>
<%= link_to 'Projects', nh_projects_path, { :class => "btn-nav secondary", "data-active"=> request.path_info.include?('nh_projects') && action_name==="index" } %>
<%= link_to "Storage", nh_storages_path, { :class => "btn-nav secondary", "data-active"=> request.path_info.include?('nh_storages') && action_name==="index" } %>
<%= link_to 'News', nh_news_path, { :class => "btn-nav secondary", "data-active"=> request.path_info.include?('welcome') && action_name==="news" } %>
<% if @nh_invites_count > 0 %>
<%= link_to 'Invitations', nh_invitations_path, { :class => "btn-nav secondary badge", "data-badge"=> @nh_new_invites_count > 0 ? @nh_new_invites_count : nil, "data-active"=> request.path_info.include?('nh_invitations') && action_name==="index" } %>
<% end %>
Expand Down
208 changes: 208 additions & 0 deletions BrainPortal/app/views/neurohub_portal/news.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<%-
#
# NeuroHub Project
#
# Copyright (C) 2020
# The Royal Institution for the Advancement of Learning
# McGill University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-%>

<%
new_invites = Invitation.where(user_id: current_user.id, active: true, read: false).all || []
%>


<% title("Dashboard", '') %>

<div id="nh_neurohub_portal_welcome">
<div class="main">
<div class="notifications">
<% if new_invites.count > 0 %>
<div id="mb-7" class="nh_invitations">
<div class="section primary">
<p class="section-title">New Notifications</p>
<% new_invites.each do |invitation| %>
<div class="card">
<div class="card-row header">
<p class="card-item"><%= invitation.header.html_safe %></p>
</div>
<div class="btn-section">
<%= button_to 'Accept', nh_invitation_path(invitation.id), :method => :put, :class => "btn-solid primary btn" %>
<%= button_to 'Decline', nh_invitation_path(invitation.id), :method => :delete, :class => "btn-solid secondary wash btn" %>
<%= button_to 'Save for Later', nh_invitation_path(invitation.id, :read => true), :method => :put, :class => "btn-solid primary wash btn" %>
</div>
</div>
<% end %>
</div>
</div>
<% end %>

<div class="section secondary flex-1">
<div class="section-title">
<img src="/images/neurohub/NH_hbhl_icon_RGB.png" alt="neurohub-logo"/>
NeuroHub News
</div>

<% @dashboard_messages.each do |message| %>
<div class="card">
<div class="card-row header bg-secondary-alt">
<p class="heading-xs default-bg"><%= message.header %></p>
</div>
<div class="card-item dashboard-news">
(Posted: <%= message.created_at.strftime("%B %e, %Y") %>)<br>
<%= (message.description.presence || "").html_safe %>
</div>
</div>
<% end %>

</div>
</div>

<div class="section user">
<div class="card">
<%=
scope_link('<p class="btn-text cbrain external card-heading">Latest Tasks</p>'.html_safe,
'tasks#index', { :order => [{ :a => 'updated_at', :d => 'desc' }], },
url: { :controller => :tasks, :action => :index },
link: { :target => "_blank" }
)
%>
<% if @tasks.size > 0 %>
<div>
<% for task in @tasks %>
<div class="card-row">
<div class="card-section">
<div class="card-item btn-text cbrain">
<div class="card-icon"><%= nh_icon_task %></div>
<%= link_to_task_if_accessible(task, nil, :name_method => :name_and_bourreau, :html_options => { :target => "_blank" }) %>
</div>
<div class="card-item btn-text cbrain">
<div class="card-icon"><%= nh_icon_user %></div>
<div class="text-ellipsis flex-1">
<%= link_to_user_if_accessible(task.user, nil, :html_options => { :target => "_blank" })%>
</div>
</div>
<div class="card-item" style="max-width:150px">
<div class="text-ellipsis flex-1">
<%= colored_status(task.status) %>
</div>
</div>
</div>
<div class="card-section">
<div class="card-item btn-text primary">
<div class="card-icon"><%= nh_icon_project %></div>
<div class="text-ellipsis flex-1">
<%= link_to task.group.name, {:controller => :nh_projects, :action => :show, :id => task.group.id}, :method => :get %>
</div>
</div>

<div class="card-item">
<div class="text-ellipsis flex-1">
<%= to_localtime(task.updated_at,:date) %>
<%= to_localtime(task.updated_at,:time) %>
</div>
</div>
</div>
</div>
<% end %>
</div>
<% else %>
<%- # empty state -%>
<div class="card-item">
<div class="empty-wrapper">
<div style="position: unset" class="empty">
<div>
<div class="empty-icon">
<%= nh_empty_tasks %>
</div>
<p class="empty-text">No tasks have been updated lately.</p>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="card">
<%=
scope_link('<p class="btn-text cbrain external card-heading">Latest Updated Files</p>'.html_safe,
'userfiles#index', { :order => [{ :a => 'updated_at', :d => 'desc' }], },
url: { :controller => :userfiles, :action => :index },
link: { :target => "_blank" }
)
%>
<% if @files.size > 0 %>
<div>
<% for file in @files %>
<div class="card-row">
<div class="card-section">
<div class="card-item btn-text cbrain">
<div class="card-icon"><%= nh_icon_file %></div>
<div class="text-ellipsis flex-1">
<%= link_to_userfile_if_accessible(file, nil, :html_options => { :target => "_blank" }) %>
</div>
</div>
<div class="card-item btn-text cbrain">
<div class="card-icon"><%= nh_icon_user %></div>
<div class="text-ellipsis flex-1">
<%= link_to_user_if_accessible(file.user, nil, :html_options => { :target => "_blank" }) %>
</div>
</div>
<div class="card-item" style="max-width:150px">
<div class="text-ellipsis flex-1">
<%= colored_pretty_size(file.size) %>
</div>
</div>
</div>
<div class="card-section">
<div class="card-item btn-text primary">
<div class="card-icon"><%= nh_icon_project %></div>
<div class="text-ellipsis flex-1">
<%= link_to(file.group.name,{:controller => :nh_projects, :action => :show, :id => file.group.id}, :method => :get) %>
</div>
</div>
<div class="card-item">
<div class="text-ellipsis flex-1">
<%= to_localtime(file.updated_at,:date) %>
<%= to_localtime(file.updated_at,:time) %>
</div>
</div>
</div>

</div>
<% end %>
</div>
<% else %>
<%- # empty state -%>
<div class="card-item">
<div class="empty-wrapper">
<div style="position: unset" class="empty">
<div>
<div class="empty-icon">
<%= nh_empty_files %>
</div>
<p class="empty-text">No files have been updated lately.</p>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>

</div>

</div>
Loading
Loading