Skip to content

Commit

Permalink
Merge pull request #6648 from saraycp/bootstrap_project_index
Browse files Browse the repository at this point in the history
Migrate project index page to bootstrap
  • Loading branch information
coolo committed Dec 19, 2018
2 parents 7cd0fb8 + f91efc9 commit be53038
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/app/assets/javascripts/webui2/application.js
Expand Up @@ -42,5 +42,6 @@
//= require webui2/cm2/use-codemirror.js
//= require webui2/package-view_file.js
//= require webui2/staging_workflow.js
//= require webui2/project.js
//= require webui2/project_monitor.js
//= require rails-timeago
29 changes: 29 additions & 0 deletions src/api/app/assets/javascripts/webui2/project.js
@@ -0,0 +1,29 @@
function renderProjectsTable(length) { // jshint ignore:line
length = length || 25;
var projects = mainProjects;
if (!$('#excludefilter').is(":checked"))
projects = projects.concat(exclProjects);
var projecturl = $("#projects-table-wrapper").data("url");
$("#projects-table").DataTable({
"data": projects,
"columns": [
{
"title": "Name",
"width": "60%",
"className": "text-word-break-all",
"render": function (obj, type, dataRow) {
var url = projecturl.replace(/REPLACEIT/, dataRow[0]);
return '<a href="' + url + '">' + dataRow[0] + '</a>';
}
},
{
"title": "Title",
"width": "40%",
"className": "text-nowrap"
}
],
"pageLength": length,
"stateSave": true,
"language": { "search": '', "searchPlaceholder": "Search..." }
});
}
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/project_controller.rb
Expand Up @@ -51,6 +51,7 @@ def index
if @spider_bot
render :list_simple, status: params[:nextstatus]
else
switch_to_webui2
render :list, status: params[:nextstatus]
end
end
Expand Down
1 change: 1 addition & 0 deletions src/api/app/views/layouts/webui2/webui.html.haml
Expand Up @@ -17,6 +17,7 @@
%style{ type: 'text/css' }
= yield :head_style
= javascript_tag do
= yield :head_javascript
var _paq = _paq || [];
$(function() { #{yield :ready_function} });

Expand Down
52 changes: 52 additions & 0 deletions src/api/app/views/webui2/webui/project/list.html.haml
@@ -0,0 +1,52 @@
:ruby
@pagetitle = 'Public Projects'
.card
- if @important_projects.present?
.card-body
%h3 Main Projects
.table-responsive
%table.table.table-sm.table-striped.table-bordered
%thead
%tr
%th Name
%th Title
%tbody
- @important_projects.each do |project|
%tr
%td
= link_to(project.first, action: :show, project: project.first)
%td
#{project.second}
.card-body
%h3= @pagetitle
%ul.list-inline
- if @show_all
%li.list-inline-item.mr-3
= link_to(projects_path) do
%i.fas.fa-toggle-on.text-primary
Exclude #{::Configuration.unlisted_projects_filter_description}
- else
%li.list-inline-item.mr-3
= link_to(projects_path(show_all: true)) do
%i.fas.fa-toggle-off.text-primary
Include #{::Configuration.unlisted_projects_filter_description}
- unless User.current.is_nobody?
%li.list-inline-item
= link_to(new_project_path) do
%i.fas.fa-plus-circle.text-primary
Add New Project
- cachekey = Digest::MD5.hexdigest(@projects.join)
- projecturl = project_show_path('REPLACEIT')
#project-list
- if @projects.blank?
%p
%i No projects found
- else
#projects-table-wrapper{ 'data-url' => projecturl }
%table.responsive.table.table-sm.table-striped.table-bordered.w-100#projects-table
- content_for :head_javascript do
- cache ['list_public_arrays', cachekey] do
var mainProjects = [ #{escape_nested_list(@projects)} ];
var exclProjects = [];
- content_for :ready_function do
renderProjectsTable();

0 comments on commit be53038

Please sign in to comment.