Class: ProjectsController
Instance Method Summary
collapse
#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #render_not_found, #require_admin_user
Instance Method Details
#details ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/projects_controller.rb', line 7
def details
return if project.blank?
add_breadcrumb(@presenter.title, project_path)
add_breadcrumb("Details")
project_metadata = @project.metadata
storage_capacity = project_metadata[:storage_capacity]
size = storage_capacity[:size]
unit = storage_capacity[:unit]
@requested_size = size[:requested]
@requested_unit = unit[:requested]
@approved_size = size[:approved]
@approved_unit = unit[:approved]
@project_session = "details"
@show_quota_breakdown = params["quota"] == "true"
respond_to do |format|
format.html do
render
end
format.json do
render json: project.to_json
end
format.xml do
render xml: @presenter.to_xml
end
end
end
|
#file_explorer ⇒ Object
GET “projects/:id/file-explorer” Used via an AJAX call to retrieve the list of files for a given path within a project
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'app/controllers/projects_controller.rb', line 75
def file_explorer
project
if params["pathId"].to_i == 0
path = @presenter.project_directory
path_id = project.mediaflux_id
else
path = params["path"]
path_id = params["pathId"].to_i
end
iterator_id = if params["iteratorId"].to_i == 0
project.file_explorer_setup(session_id: current_user.mediaflux_session, path_id: path_id)
else
params["iteratorId"].to_i
end
mediaflux_data = project.file_explorer_iterate(session_id: current_user.mediaflux_session, iterator_id: iterator_id)
if mediaflux_data[:error]
render json: {}, status: 500
else
data = {
fileListUrl: project_file_explorer_url,
currentPath: path,
currentPathId: path_id,
iteratorId: iterator_id,
files: mediaflux_data[:files],
complete: mediaflux_data[:complete]
}
render json: data
end
end
|
#file_list_download ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
|
# File 'app/controllers/projects_controller.rb', line 143
def file_list_download
job_id = params[:job_id]
file_inventory_request = FileInventoryRequest.where(job_id:job_id).first
if file_inventory_request.nil?
redirect_to "/"
else
filename = file_inventory_request.output_file
send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
end
end
|
#index ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'app/controllers/projects_controller.rb', line 40
def index
if current_user.eligible_sysadmin?
search_projects
else
flash[:alert] = I18n.t(:access_denied)
redirect_to dashboard_path
end
end
|
#list_contents ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'app/controllers/projects_controller.rb', line 127
def list_contents
return if project.blank?
project_job_service.list_contents_job(user: current_user)
json_response = {
message: "File list for \"#{project.title}\" is being generated in the background. A link to the downloadable file list will be available in the \"Recent Activity\" section of your dashboard when it is available. You may safely navigate away from this page or close this tab."
}
render json: json_response
rescue => ex
message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
Rails.logger.error(message)
Honeybadger.notify(message)
render json: { message: "Document list could not be generated." }
end
|
#send_globus_access_request ⇒ Object
155
156
157
158
159
160
|
# File 'app/controllers/projects_controller.rb', line 155
def send_globus_access_request
project_id = params[:project_id].to_i
TigerdataMailer.with(project_id: project_id, submitter: current_user).globus_access_request.deliver_later
rescue StandardError => e
render json: { error: e.message }, status: :unprocessable_entity
end
|
#show ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/projects_controller.rb', line 49
def show
return if project.blank?
add_breadcrumb(@presenter.title, project_path)
add_breadcrumb("Contents")
@latest_completed_download = current_user.inventory_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
@storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
@storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
@num_files = project.asset_count(session_id: current_user.mediaflux_session)
@file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
@files = @file_list[:files]
@files.sort_by!(&:path)
@project_session = "content"
respond_to do |format|
format.html { render }
format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
}
end
end
|
GET “projects/:id/:id-mf”
This action is used to render the mediaflux metadata for a project.
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'app/controllers/projects_controller.rb', line 113
def show_mediaflux
project_id = params[:id]
project = Project.find(project_id)
respond_to do |format|
format.xml do
render xml: project.mediaflux_meta_xml(user: current_user)
end
end
rescue => ex
Rails.logger.error "Error getting MediaFlux XML for project #{project_id}, user #{current_user.uid}: #{ex.message}"
flash[:alert] = "Error fetching Mediaflux XML for this project"
redirect_to project_path(project_id)
end
|