--- a/web/app/controllers/imports_controller.rb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/controllers/imports_controller.rb Fri Oct 31 17:50:24 2014 +0100
@@ -12,7 +12,6 @@
end
def show_post_import
- @runtimes = Runtime.all
end
def text_import
@@ -42,7 +41,7 @@
end
def push_import
- if request.content_type == "application/json"
+ if request.content_type == "application/json"
@import_query = JsonImportQuery.new(
json: params[:import])
else
--- a/web/app/models/benchmark_batch.rb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/models/benchmark_batch.rb Fri Oct 31 17:50:24 2014 +0100
@@ -7,16 +7,18 @@
validates_presence_of :performed_at
def self.archive_directory
- archive_dir = File.join(Rails.root, 'public', 'archive')
+ File.join(Rails.root, "public", "uploads", "archive").tap do |archive_dir|
+ FileUtils.mkdir_p(archive_dir)
+ end
+ end
- Dir.mkdir(archive_dir) unless File.exist? archive_dir
-
- archive_dir
+ def self.for_dashboard
+ includes(benchmark_results: [ :benchmark_durations, :benchmark_info ]).last
end
def self.from_json(data)
batch = BenchmarkBatch.create!(
- benchmark_configuration: BenchmarkConfiguration.from_json(data['configuration']),
+ benchmark_configuration: BenchmarkConfiguration.from_json(data["configuration"]),
performed_at: DateTime.parse(data["timestamp"]),
archive_filename: archive_name_for_data(data))
@@ -47,10 +49,6 @@
batch
end
- def self.for_dashboard
- includes(benchmark_results: [ :benchmark_durations, :benchmark_info ]).last
- end
-
def result_for(info_id)
benchmark_results.find_by(benchmark_info_id: info_id)
end
@@ -61,7 +59,7 @@
# Returns full path to archive file
def archive_path
- File.join(BenchmarkBatch.archive_directory, archive_filename)
+ File.join(self.class.archive_directory, archive_filename)
end
def to_json
@@ -69,11 +67,7 @@
end
def performed_at_ensured
- if performed_at.present?
- performed_at
- else
- Date.today
- end
+ performed_at || Date.today
end
private
@@ -99,6 +93,7 @@
#
# id :integer not null, primary key
# performed_at :datetime
+# archive_filename :text
# created_at :datetime
# updated_at :datetime
# configuration_id :integer
--- a/web/app/models/benchmark_configuration.rb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/models/benchmark_configuration.rb Fri Oct 31 17:50:24 2014 +0100
@@ -66,7 +66,7 @@
end
end
- def find_or_create_by_name(ctx, name)
+ def self.find_or_create_by_name(ctx, name)
inst = ctx.where(name: name).first
inst = ctx.create!(name: name) unless inst
inst
--- a/web/app/models/import_query.rb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/models/import_query.rb Fri Oct 31 17:50:24 2014 +0100
@@ -4,11 +4,7 @@
include ActiveModel::Model
def store!
- return benchmarkBatch.new_from_json data_from_json
+ BenchmarkBatch.from_json(data_from_json)
end
- private
-
-
-
end
--- a/web/app/views/imports/_imports_nav.html.erb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/views/imports/_imports_nav.html.erb Fri Oct 31 17:50:24 2014 +0100
@@ -1,14 +1,13 @@
<%= content_for :imports_navigation do %>
<ul class="nav nav-tabs">
- <li class="nav-header">Imports</li>
- <%= nav_tab("text",
- current_tab: current_tab,
+ <%= nav_tab("text",
+ current_tab: current_tab,
class: "special") { link_to("Text Import", new_text_imports_path) } %>
- <%= nav_tab("file",
- current_tab: current_tab,
+ <%= nav_tab("file",
+ current_tab: current_tab,
class: "special") { link_to("File Import", new_file_imports_path) } %>
- <%= nav_tab("post",
- current_tab: current_tab,
+ <%= nav_tab("post",
+ current_tab: current_tab,
class: "special") { link_to("Post Import", new_post_imports_path) } %>
</ul>
<% end %>
--- a/web/app/views/imports/show_file_import.html.erb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/views/imports/show_file_import.html.erb Fri Oct 31 17:50:24 2014 +0100
@@ -2,12 +2,19 @@
<%= form_for @file_import_query,
url: file_imports_path,
- builder: CalipelFormBuilder,
- html: { multipart: true, class: "form-horizontal" } do |f| %>
-
- <%= f.fieldset_item "Upload file with data" do %>
- <%= f.file_field_item :file %>
- <%= f.submit_item "Import" %>
- <% end %>
-
+ html: { multipart: true, class: "form-horizontal" } do |f| %>
+ <fieldset>
+ <legend>Upload file with data</legend>
+ <div class="form-group">
+ <%= f.label :file, "File", class: "control-label col-sm-2" %>
+ <div class="col-sm-10 col-md-6">
+ <%= f.file_field :file %>
+ </div>
+ </div>
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <%= f.submit "Import", class: "btn btn-default" %>
+ </div>
+ </div>
+ </fieldset>
<% end %>
--- a/web/app/views/imports/show_post_import.html.erb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/views/imports/show_post_import.html.erb Fri Oct 31 17:50:24 2014 +0100
@@ -1,23 +1,30 @@
<%= currently_importing "post" %>
-<legend>Upload via HTTP POST</legend>
-
-<p>
- Benchmark data are required to be sent using POST method.
- Both <strong>x-www-form-urlencoded</strong> and <strong>JSON</strong>
- content types are supported. Example <strong>curl</strong> parameters:
-</p>
+<div class="row">
+ <div class="col-sm-12">
+ <legend>Upload via HTTP POST</legend>
+ <p>
+ Benchmark data are required to be sent using POST method.
+ Both <strong>x-www-form-urlencoded</strong> and <strong>JSON</strong>
+ content types are supported. Example <strong>curl</strong> parameters:
+ </p>
+ </div>
-<pre>
- curl '<%= push_imports_url %>' \
- --compressed \
- -H 'Content-Type: application/x-www-form-urlencoded' \
- --data-urlencode 'import={"timestamp": "2013-06-25T10:30:03Z","configuration": ... }'
-</pre>
+ <div class="col-xs-12 col-lg-6">
+ <pre>
+ curl '<%= push_imports_url %>' \
+ --compressed \
+ -H 'Content-Type: application/x-www-form-urlencoded' \
+ --data-urlencode 'import={"timestamp": "2013-06-25T10:30:03Z","configuration": ... }'
+ </pre>
+ </div>
-<pre>
- curl '<%= push_imports_url %>' \
- --compressed \
- -H 'Content-Type: application/json' \
- --data '{"timestamp": "2013-06-25T10:30:03Z","configuration": ... }'
-</pre>
+ <div class="col-xs-12 col-lg-6">
+ <pre>
+ curl '<%= push_imports_url %>' \
+ --compressed \
+ -H 'Content-Type: application/json' \
+ --data '{"timestamp": "2013-06-25T10:30:03Z","configuration": ... }'
+ </pre>
+ </div>
+</div>
--- a/web/app/views/imports/show_text_import.html.erb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/views/imports/show_text_import.html.erb Fri Oct 31 17:50:24 2014 +0100
@@ -2,12 +2,19 @@
<%= form_for @text_import_query,
url: text_imports_path,
- builder: CalipelFormBuilder,
- html: { class: "form-horizontal" } do |f| %>
-
- <%= f.fieldset_item "Paste text directly" do %>
- <%= f.text_area_item :text, class: "span4", size: "30x10" %>
- <%= f.submit_item "Import" %>
- <% end %>
-
+ html: { class: "form-horizontal" } do |f| %>
+ <fieldset>
+ <legend>Paste text directly</legend>
+ <div class="form-group">
+ <%= f.label :text, "Text", class: "control-label col-sm-2" %>
+ <div class="col-sm-10 col-md-6">
+ <%= f.text_area :text, class: "form-control", size: "60x10" %>
+ </div>
+ </div>
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <%= f.submit "Import", class: "btn btn-default" %>
+ </div>
+ </div>
+ </fieldset>
<% end %>
--- a/web/app/views/layouts/imports.html.erb Thu Oct 30 15:10:12 2014 +0100
+++ b/web/app/views/layouts/imports.html.erb Fri Oct 31 17:50:24 2014 +0100
@@ -7,10 +7,16 @@
<div class="tab-content">
<%= bootstrap_flash %>
<%= yield %>
- <legend>Example JSON data</legend>
- <pre>
- <%= @example_json %>
- </pre>
+ <div class="row">
+ <div class="col-sm-12">
+ <legend>Example JSON data</legend>
+ </div>
+ <div class="col-xs-12 col-sm-offset-2 col-sm-10 col-md-offset-2 col-md-6">
+ <pre>
+ <%= @example_json %>
+ </pre>
+ </div>
+ </div>
</div>
</div>