|
|
|
1\. On the workflow model add `staged_dir_relative_path`:
|
|
|
|
|
|
|
|
```diff
|
|
|
|
# Get path to staged simulation directory relative to dataroot
|
|
|
|
# i.e. given staged_dir of
|
|
|
|
#
|
|
|
|
# /path/to/dataroot/containers/12
|
|
|
|
#
|
|
|
|
# this method returns
|
|
|
|
#
|
|
|
|
# containers/12
|
|
|
|
#
|
|
|
|
# WARNING: Assumes staged_dir is inside dataroot!
|
|
|
|
#
|
|
|
|
# @return [Pathname] path to staged_dir relative to dataroot
|
|
|
|
def staged_dir_relative_path
|
|
|
|
- Pathname.new(staged_dir).relative_path_from(AwesimRails.dataroot)
|
|
|
|
+ Pathname.new(staging_target_dir_name).join(Pathname.new(staged_dir).basename)
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
2\. `files_path` is a helper provided to build URLs to files under the dataroot of the user. See https://github.com/AweSim-OSC/awesim_rails#filesrackapp for details. Add a model specific helper to build a URL, prepending the `files_path` URL. An example from ContainerFillSim:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
module ContainersHelper
|
|
|
|
# URL path helper
|
|
|
|
def container_results_path(container, path)
|
|
|
|
Pathname.new(files_path).join(container.staged_dir_relative_path, path).to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
3\. Use the helper in your views. In this example we iterate over each step of the container and display the corresponding image for each:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<% (0..@container.steps).each do |i| %>
|
|
|
|
<div class="item <%= 'active' if i == 0 %>">
|
|
|
|
<%= image_tag container_results_path(@container, "images/t#{sprintf '%02d', i}.png") %>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
```
|
|
|
|
|
|
|
|
|