-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic admin list and view for analysis jobs
- Loading branch information
Showing
7 changed files
with
203 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Admin | ||
class AnalysisJobsController < BaseController | ||
|
||
# GET /admin/analysis_jobs | ||
def index | ||
page = paging_params[:page].blank? ? 1 : paging_params[:page].to_i | ||
order_by = paging_params[:order_by].blank? ? :id : paging_params[:order_by].to_s.to_sym | ||
order_dir = paging_params[:order_dir].blank? ? :desc : paging_params[:order_dir].to_s.to_sym | ||
|
||
commit = (paging_params[:commit].blank? ? 'filter' : paging_params[:commit]).to_s | ||
|
||
fail 'Invalid order by.' unless [:id, :name, :started_at, :overall_status, :overall_status_modified_at].include?(order_by) | ||
fail 'Invalid order dir.' unless [:asc, :desc].include?(order_dir) | ||
|
||
redirect_to admin_analysis_jobs_path if commit.downcase == 'clear' | ||
|
||
@analysis_jobs_info = { | ||
order_by: order_by, | ||
order_dir: order_dir | ||
} | ||
|
||
query = AnalysisJob.includes(:script, :creator).all | ||
@analysis_jobs = query.order(order_by => order_dir).page(page) | ||
end | ||
|
||
# GET /admin/analysis_jobs/:id | ||
def show | ||
@analysis_job = AnalysisJob.find(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def paging_params | ||
params.permit(:page, :order_by, :order_dir) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
- content_for :title, 'Analysis Jobs' | ||
|
||
= render partial: 'shared/admin/sidebar_analysis_jobs' | ||
|
||
- content_for :right_sidebar do | ||
= render partial: 'shared/sidebar_metadata_heading', locals: {title: 'Analysis Jobs', icon_class: 'tasks'} | ||
|
||
- order_dir_icon = @analysis_jobs_info[:order_dir] == :asc ? 'caret-down' : 'caret-up' | ||
- order_by_opposite = @analysis_jobs_info[:order_dir] == :asc ? :desc : :asc | ||
- order_by = @analysis_jobs_info[:order_by] | ||
|
||
.col-sm-12 | ||
.row | ||
.col-sm-6 | ||
%p= page_entries_info @analysis_jobs | ||
|
||
.row | ||
.col-sm-12 | ||
= paginate @analysis_jobs | ||
|
||
%table.table.table-striped.table-hover | ||
%thead | ||
%tr | ||
%th | ||
= link_to admin_analysis_jobs_path order_by: :id, order_dir: order_by_opposite do | ||
%span.fa.fa-thumb-tack{aria: {hidden: 'true' }} | ||
Id | ||
- if order_by == :id | ||
%span.fa{class: "fa-#{order_dir_icon}"} | ||
%th | ||
= link_to admin_analysis_jobs_path order_by: :name, order_dir: order_by_opposite do | ||
%span.fa.fa-tasks{aria: {hidden: 'true' }} | ||
Name | ||
- if order_by == :name | ||
%span.fa{class: "fa-#{order_dir_icon}"} | ||
%th | ||
%span.fa.fa-file-text-o{aria: {hidden: 'true' }} | ||
Script | ||
%th | ||
%span.fa.fa-user{aria: {hidden: 'true' }} | ||
Creator | ||
%th | ||
= link_to admin_analysis_jobs_path order_by: :started_at, order_dir: order_by_opposite do | ||
%span.fa.fa-calendar{aria: {hidden: 'true' }} | ||
Started | ||
- if order_by == :started_at | ||
%span.fa{class: "fa-#{order_dir_icon}"} | ||
%th | ||
= link_to admin_analysis_jobs_path order_by: :overall_status, order_dir: order_by_opposite do | ||
%span.fa.fa-flag{aria: {hidden: 'true' }} | ||
Status | ||
- if order_by == :overall_status | ||
%span.fa{class: "fa-#{order_dir_icon}"} | ||
%th | ||
= link_to admin_analysis_jobs_path order_by: :overall_status_modified_at, order_dir: order_by_opposite do | ||
%span.fa.fa-calendar{aria: {hidden: 'true' }} | ||
Status Updated | ||
- if order_by == :overall_status_modified_at | ||
%span.fa{class: "fa-#{order_dir_icon}"} | ||
|
||
%tbody | ||
- @analysis_jobs.each do |item| | ||
%tr | ||
%td= link_to item.id, admin_analysis_job_path(item) | ||
%td= item.name | ||
%td= link_to item.script.name, admin_script_path(item.script) | ||
%td= link_to item.creator.user_name, user_account_path(item.creator) | ||
%td= format_sidebar_datetime(item.started_at) | ||
%td= item.overall_status | ||
%td= format_sidebar_datetime(item.overall_status_modified_at) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
- content_for :title, 'Analysis Job Details' | ||
|
||
= render partial: 'shared/admin/sidebar_analysis_jobs', locals: {aj_to_manage: @analysis_job} | ||
|
||
- content_for :right_sidebar do | ||
= render partial: 'shared/sidebar_metadata_heading', locals: {title: 'Analysis Jobs', icon_class: 'tasks'} | ||
|
||
.col-sm-12 | ||
|
||
= simple_form_for(@analysis_job, url: admin_analysis_job_path(@analysis_job), html: {class: 'form-horizontal', multipart: true, method: :put }) do |f| | ||
= field_set_tag do | ||
= f.error_notification | ||
|
||
- [:id, :name, :description, :annotation_name, | ||
:creator_id, :updater_id, :deleter_id, | ||
:created_at, :updated_at, :deleted_at, | ||
:started_at, | ||
:overall_status, :overall_status_modified_at, | ||
:overall_progress, :overall_progress_modified_at, | ||
:overall_count, :overall_duration_seconds, | ||
:script_id, :saved_search_id, | ||
:custom_settings].each do |item| | ||
- human_ed = item.to_s.humanize | ||
- param_ed = item.to_s.parameterize | ||
- sym_ed = item | ||
- str_ed = item.to_s | ||
- value = begin @analysis_job[sym_ed]; rescue => e; "Error: #{e.inspect}"; end | ||
.form-group.optional{class:param_ed} | ||
%label.optional.control-label.col-sm-3{class:param_ed, for: param_ed} | ||
= human_ed | ||
.col-sm-8 | ||
%p.form-control-static{id: param_ed} | ||
- unless value.blank? | ||
- if value.is_a?(Time) | ||
= value.iso8601 | ||
%small | ||
="(#{time_ago_in_words(value)} ago)" | ||
- elsif str_ed.end_with?('er_id') || str_ed.end_with?('or_id') | ||
- user = User.find(value) | ||
= link_to user.user_name, user_account_path(user) | ||
%small | ||
="(#{value})" | ||
- elsif sym_ed == :overall_duration_seconds | ||
= distance_of_time_in_words(value) | ||
%small | ||
= "(#{value})" | ||
- elsif sym_ed == :overall_data_length_bytes | ||
= number_to_human_size(value) | ||
- elsif sym_ed == :script_id | ||
= link_to @analysis_job.script.name, admin_script_path(@analysis_job.script) | ||
%small | ||
="(#{value})" | ||
- elsif sym_ed == :saved_search_id | ||
= @analysis_job.saved_search.name | ||
%small | ||
="(#{value})" | ||
%pre | ||
= @analysis_job.saved_search.description | ||
%pre | ||
= @analysis_job.saved_search.stored_query | ||
- elsif sym_ed == :overall_progress || sym_ed == :custom_settings | ||
%pre | ||
= value | ||
- else | ||
= value | ||
- else | ||
%small | ||
(no value) | ||
|
||
|
||
.form-group.optional{class: 'projects'} | ||
%label.optional.control-label.col-sm-3{class:'projects', for: 'projects'} | ||
Saved Search Projects | ||
.col-sm-8 | ||
%p.form-control-static{id: 'projects'} | ||
- @analysis_job.saved_search.projects.each do |project| | ||
= link_to project.name, project_path(project) | ||
| ||
- if @analysis_job.saved_search.projects.blank? | ||
No projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-# locals: aj_to_manage | ||
- content_for(:left_sidebar_header, 'Analysis Jobs') | ||
- content_for(:left_sidebar) do | ||
%li{class: ('active' if current_page?(admin_dashboard_path))} | ||
= link_to 'Admin Home', admin_dashboard_path | ||
%li{class: ('active' if current_page?(admin_analysis_jobs_path))} | ||
= link_to 'Analysis Jobs', admin_analysis_jobs_path, title: 'Manage audio recordings', data: {toggle: 'tooltip', placement: 'right'} | ||
- if defined?(aj_to_manage) | ||
- if can?(:show, aj_to_manage) | ||
%li{class: ('active' if current_page?(admin_analysis_job_path(aj_to_manage)))} | ||
= link_to 'View Analysis Job', admin_analysis_job_path(aj_to_manage), title: 'View analysis job details', data: {toggle: 'tooltip', placement: 'right'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters