-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgraded the export, for log and csv, added edit
- Loading branch information
1 parent
5ed9f3f
commit 02f25f5
Showing
6 changed files
with
42 additions
and
19 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,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require "csv" | ||
|
||
class OptimizationExportsController < ApplicationController | ||
def new | ||
optim_id = params[:optimization_id] | ||
format = params[:format] | ||
|
||
optim = Optimization.find(optim_id) | ||
authorize optim | ||
|
||
if format == "log" | ||
path = "#{Rails.root}/log/optimizations/optim_#{optim_id}.log" | ||
if File.exist?(path) | ||
send_file(path) | ||
else | ||
redirect_to optimization_path(optim), notice: "There isn't a log file" | ||
end | ||
elsif format == "csv" | ||
attributes = %w{kind config inputs outputs} | ||
content = CSV.generate(headers: true) do |csv| | ||
csv << attributes | ||
csv << attributes.map{ |attr| optim.send(attr) } | ||
end | ||
send_data content, filename: "optim_#{optim_id}.csv" | ||
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 @@ | ||
<h2>Add inputs to optimization #<%= @optimization.id %></h2> |
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
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