Commit 3903e9cf authored by ira.maier's avatar ira.maier
Browse files

Final for now: download link for files

parent 79d0ecb6
...@@ -9,6 +9,8 @@ Things you may want to cover: ...@@ -9,6 +9,8 @@ Things you may want to cover:
* Bootstrap 3 * Bootstrap 3
* JavaScript: no ES6
* System dependencies * System dependencies
* Configuration * Configuration
......
...@@ -29,12 +29,10 @@ p { ...@@ -29,12 +29,10 @@ p {
.row.content {height: 650px} .row.content {height: 650px}
/* Set gray background color and 100% height */ /* Set gray background color and 100% height */
//todo
.sidenav { .sidenav {
padding-top: 20px; padding-top: 20px;
background-color: #f1f1f1; background-color: #f1f1f1;
height: 100%; height: 100%;
} }
/* Set black background color, white text and some padding */ /* Set black background color, white text and some padding */
...@@ -52,19 +50,12 @@ footer { ...@@ -52,19 +50,12 @@ footer {
/* On small screens, set height to 'auto' for sidenav and grid */ /* On small screens, set height to 'auto' for sidenav and grid */
@media screen and (max-width: 767px) { @media screen and (max-width: 767px) {
.sidenav { .sidenav {
height: auto; height: auto;
padding: 15px; padding: 15px;
} }
.row.content {height:auto;} .row.content {height:auto;}
} }
body {
// done removed --> navbar sticks on the top
//padding-top: 25px;
}
section { section {
overflow: auto; overflow: auto;
} }
...@@ -119,7 +110,7 @@ aside { ...@@ -119,7 +110,7 @@ aside {
input, textarea, select, .uneditable-input { input, textarea, select, .uneditable-input {
border: 1px solid #bbb; border: 1px solid #bbb;
display: inline-block; // new todo? display: inline-block;
height: auto !important; height: auto !important;
width: 100%; width: 100%;
margin-bottom: 10px; margin-bottom: 10px;
...@@ -151,15 +142,6 @@ input[type="checkbox"]{ ...@@ -151,15 +142,6 @@ input[type="checkbox"]{
} }
} }
//form{
// input{
// margin: 0.5rem 0.5rem 0.5rem 0.5rem;
// }
// label{
// margin: 0;
// }
//}
#edit_sample_table{ #edit_sample_table{
border-radius: 0.5rem; border-radius: 0.5rem;
...@@ -217,7 +199,6 @@ input[type="checkbox"]{ ...@@ -217,7 +199,6 @@ input[type="checkbox"]{
.timestamp { .timestamp {
color: lightgrey; color: lightgrey;
//todo
display: block; display: block;
margin-left: 4rem; margin-left: 4rem;
} }
...@@ -275,7 +256,6 @@ input.transparent-input{ ...@@ -275,7 +256,6 @@ input.transparent-input{
text-decoration: underline; text-decoration: underline;
} }
// todo?
.panel-default{ .panel-default{
//max-height:400px; //max-height:400px;
width: 145%; width: 145%;
...@@ -294,11 +274,11 @@ input.transparent-input{ ...@@ -294,11 +274,11 @@ input.transparent-input{
div.absolute { div.absolute {
margin-top:10px; margin-top:10px;
width: 99%;
} }
.div-table{ .div-table{
display:table; display:table;
width: auto !important; width: auto !important;
// background-color:#eee;
border-spacing:5px;/*cellspacing:poor IE support for this*/ border-spacing:5px;/*cellspacing:poor IE support for this*/
} }
.div-table-row{ .div-table-row{
...@@ -316,13 +296,23 @@ div.absolute { ...@@ -316,13 +296,23 @@ div.absolute {
padding: 12px; padding: 12px;
} }
.comment_button{
background: #337ab7;
border: #337ab7;
border-radius: 0.5rem;
color:white;
padding: 0.5rem;
margin: 0.5rem;
width: 98%;
}
.file_storage_button{ .file_storage_button{
background: #5bc0de; background: #5bc0de;
border: #5bc0de; border: #5bc0de;
border-radius: 0.5rem; border-radius: 0.5rem;
color:white; color:white;
magin: none;
padding: 0.5rem; padding: 0.5rem;
text-align: left;
} }
.font { .font {
...@@ -330,7 +320,6 @@ div.absolute { ...@@ -330,7 +320,6 @@ div.absolute {
} }
// todo rmv?
#form_delete_files{ #form_delete_files{
input{ input{
width:auto; // important width:auto; // important
...@@ -343,10 +332,6 @@ div.absolute { ...@@ -343,10 +332,6 @@ div.absolute {
} }
} }
.form_with{
// class: "btn btn-info";
}
.remember-me { .remember-me {
display: flex; display: flex;
#user_remember_me { #user_remember_me {
...@@ -355,7 +340,13 @@ div.absolute { ...@@ -355,7 +340,13 @@ div.absolute {
} }
.rm-mg-bottom { .rm-mg-bottom {
border-collapse: collapse;
margin-bottom: unset; margin-bottom: unset;
.form-control{
padding: 0.5rem;
margin: 0.5rem;
width: 96%;
}
} }
.form-inline { .form-inline {
...@@ -369,10 +360,12 @@ div.absolute { ...@@ -369,10 +360,12 @@ div.absolute {
table{ table{
text-align: center; text-align: center;
tbody{
//border: solid lightgray;
}
td{ td{
border: 1px solid lightgray; border: 1px solid lightgray;
} }
}
//for downloading file attached to sample
.download_label:hover::after{
content: attr(tooltip);
} }
\ No newline at end of file
...@@ -6,47 +6,35 @@ ...@@ -6,47 +6,35 @@
box-sizing: inherit; box-sizing: inherit;
} }
.div{ #samples_list{
display:inline-block; border-collapse: collapse;
display:inline-block;
float: left;
margin: 0rem 0.5rem 0rem 0rem;
max-width:49%;
width:30%;
} }
#show{ #show{
display:inline-block; display:inline-block;
float: left;
margin: 0rem 0.5rem 0.5rem 0.5rem; margin: 0rem 0.5rem 0.5rem 0.5rem;
padding: 0rem 0.5rem 0.5rem 0.5rem; padding: 0rem 0.5rem 0.5rem 0.5rem;
width:65%; width:55%;
} }
.splitScreen{ .splitScreen{
margin: 0rem 0rem 0rem 0rem; margin: 0;
padding : 0rem 0rem 0rem 0rem; padding : 0;
width:100%; width:100%;
} }
.table{ .table{
margin: 0rem 0rem 0rem 0rem; margin: 0;
padding : 0rem 0rem 0rem 0rem; padding : 0;
/*overflow-y: scroll;*/
} }
/*.scrollbar{*/
/* margin: 0;*/
/* overflow-y: scroll;*/
/* padding: 0;*/
/* max-width:49%;*/
/* width:30%;*/
/*}*/
#samples_list{
display:inline-block;
float: left;
margin: 0rem 0.5rem 0rem 0rem;
// err scrolling not working
max-width:49%;
width:30%;
}
......
...@@ -76,17 +76,14 @@ class SamplesController < ApplicationController ...@@ -76,17 +76,14 @@ class SamplesController < ApplicationController
# files processing: # files processing:
if params[:sample][:add_files] if params[:sample][:add_files]
logger.debug "add my files"
sample.files.attach(params[:sample][:add_files]) sample.files.attach(params[:sample][:add_files])
end end
if params[:sample][:delete_files] == "1" if params[:sample][:delete_files] == "1"
logger.debug "purged all at once"
sample.files.purge_later sample.files.purge_later
elsif params[:sample][:delete_files] == "0" and params[:sample][:delete_file] elsif params[:sample][:delete_files] == "0" and params[:sample][:delete_file]
params[:sample][:delete_file].each{ |id| params[:sample][:delete_file].each{ |id|
unless id && id.to_s.strip.empty? unless id && id.to_s.strip.empty?
@file = ActiveStorage::Attachment.find(id) @file = ActiveStorage::Attachment.find(id)
logger.debug "purged sample by sample"
@file.purge_later @file.purge_later
end end
} }
......
class Sample < ApplicationRecord class Sample < ApplicationRecord
attr_reader :formul attr_reader :formul
# todo delete? attr_accessor :mw
attr_accessor :mw #:add_file, :delete_files, :delete_file
has_many :results has_many :results
accepts_nested_attributes_for :results, :reject_if => :all_blank, :allow_destroy => true accepts_nested_attributes_for :results, :reject_if => :all_blank, :allow_destroy => true
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
<%= yield %> <%= yield %>
</div> </div>
</div> </div>
<%# todo don't hide page content under footer %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
</div> </div>
</body> </body>
......
...@@ -15,20 +15,18 @@ ...@@ -15,20 +15,18 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table rm-mg-bottom"> <table class="table rm-mg-bottom">
<tbody> <tbody>
<tr> <tr style="border-top: 0;">
<td> <td style="border-bottom: 0; border-right: 0;">
<label for="comment_by_op">Operator comments</label> <label for="comment_by_op">Operator comments</label>
<%= f.text_area :comment_by_operator, class: 'form-control', rows: 3, id: 'comment_by_op', readonly: !operator? %> <%= f.text_area :comment_by_operator, class: 'form-control', rows: 3, id: 'comment_by_op', readonly: !operator? %>
</td> </td>
<td> <td style="border-bottom: 0; border-left: 0;">
<label for="comment_by_user">Submitter comments</label> <label for="comment_by_user">Submitter comments</label>
<%= f.text_area :comment_by_user, class: 'form-control', rows: 3, id: 'comment_by_user', readonly: operator? %> <%= f.text_area :comment_by_user, class: 'form-control', rows: 3, id: 'comment_by_user', readonly: operator? %>
</td> </td>
</tr> </tr>
<tr><td colspan="2" style="border-top: 0;"><%= f.submit "Save Comments", class: "comment_button" %></td></tr>
</tbody> </tbody>
</table> </table>
<div class="links">
<%= f.submit "Save Comments", class: "btn btn-primary" %>
</div>
</div> </div>
<% end %> <% end %>
<% provide(:title, "Edit sample") %> <% provide(:title, "Edit sample") %>
<%if @sample.status=="in preparation"%> <%if @sample.status=="in preparation"%>
<%# todo %>
<%= form_for(@sample) do |f| %> <%= form_for(@sample) do |f| %>
<%= render 'shared/error_messages', object: f.object %> <%= render 'shared/error_messages', object: f.object %>
<table id="edit_sample_table"> <table id="edit_sample_table">
......
<%= form_with model: @sample do |f| %> <%= form_with model: @sample do |f| %>
<div style="text-align: right"> <div style="text-align: right">
<%= f.file_field :add_files, multiple: true, class: "file_storage_button", style: "float: right; text-align: left; width: 70%" %> <%= f.file_field :add_files, multiple: true, direct_upload: true, class: "file_storage_button", style: "float: right; width: 70%" %>
<%= f.submit "Add Files", class: "file_storage_button", style: "text-align: left; width: 70%"%> <%= f.submit "Add Files", class: "file_storage_button", style: "width: 70%"%>
</div> </div>
<% end %> <% end %>
\ No newline at end of file
...@@ -4,23 +4,19 @@ ...@@ -4,23 +4,19 @@
<%= f.check_box :delete_files, :id => "sample_delete_files"%> <%= f.check_box :delete_files, :id => "sample_delete_files"%>
<%= f.label :delete_files, "All", :for => "sample_delete_files"%> <%= f.label :delete_files, "All", :for => "sample_delete_files"%>
</div> </div>
<%= f.collection_check_boxes :delete_file, @sample.files, :id, :filename do |b| %> <%= f.collection_check_boxes :delete_file, @sample.files, :id, :filename do |b| %>
<div style="text-align: left"> <div style="text-align: left">
<%= b.check_box%> <%= b.check_box%>
<%= b.label %> <%= link_to b.label, rails_blob_path(b.object, disposition: 'attachment'), {:class=>"download_label", :tooltip=>" Download"}%>
</div> </div>
<% end %> <% end %>
<div style="text-align: left">
<%= f.submit "Delete Files", data: { confirm: "Are you sure?" }, class: "file_storage_button"%> <%= f.submit "Delete Files", data: { confirm: "Are you sure?" }, class: "file_storage_button"%>
</div>
<% end %> <% end %>
<% end %> <% end %>
<script> <script>
let selectAllCheckbox = document.querySelector('#sample_delete_files'); let selectAllCheckbox = document.querySelector('#sample_delete_files');
// let selectAllCheckboxElem = document.getElementById('sample_delete_files');
let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]'); let filenameCheckboxes = document.querySelectorAll('[name="sample[delete_file][]"]');
function shiftToSelect() { function shiftToSelect() {
...@@ -30,7 +26,6 @@ ...@@ -30,7 +26,6 @@
// Check if shift key is down and check if checkbox is checked // Check if shift key is down and check if checkbox is checked
let inBetween = false; let inBetween = false;
if (e.shiftKey && this.checked) { if (e.shiftKey && this.checked) {
// console.log(e.shiftKey);
filenameCheckboxes.forEach(checkbox => { filenameCheckboxes.forEach(checkbox => {
if (checkbox === this || checkbox === lastChecked) { if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween; inBetween = !inBetween;
...@@ -60,13 +55,9 @@ ...@@ -60,13 +55,9 @@
} }
if (selectAllCheckbox) { if (selectAllCheckbox) {
// console.log(selectAllCheckbox);
console.log("hit all checkboxes from form_delete_files.html.erb");
selectAllCheckbox.addEventListener('click', handleSelectAll, false); selectAllCheckbox.addEventListener('click', handleSelectAll, false);
} }
if(filenameCheckboxes){ if(filenameCheckboxes){
// console.log(filenameCheckboxes);
console.log("hit filename checkboxes from form_delete_files.html.erb");
shiftToSelect(); shiftToSelect();
} }
</script> </script>
......
<h1>File Attachments for <%=@sample.name %></h1>
<h2>Delete Files</h2>
<p>
<%= render 'samples/form_delete_files'%>
</p>
<h2>Add Files</h2>
<p>
<%= form_with model: @sample do |f| %>
<%= f.file_field :add_files, multiple: true %><br>
<%= f.submit "Add Files", data: { confirm: "Are you sure?" } %>
<% end %>
</p>
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
<%end%> <%end%>
<!--left side--> <!--left side-->
<!--<div class="scrollbar">--> <table id="samples_list" class="table table-hover table-bordered">
<table id="samples_list" class="table table-hover table-bordered" style="overflow-y: scroll">
<thead> <thead>
<tr> <tr>
<th class="text-center">ID</th> <th class="text-center">ID</th>
...@@ -83,16 +82,13 @@ ...@@ -83,16 +82,13 @@
data: { confirm: "You sure?"}%> data: { confirm: "You sure?"}%>
<%end%> <%end%>
</td> </td>
<td> <td>
<%# todo %>
<%= sample.files.attached? %> <%= sample.files.attached? %>
</td> </td>
</tr> </tr>
<%end%> <%end%>
</tbody> </tbody>
</table> </table>
<!--</div>-->
<%if @sample&.persisted? %> <%if @sample&.persisted? %>
<div class="panel panel-default" id="show"> <div class="panel panel-default" id="show">
......
...@@ -137,15 +137,15 @@ ...@@ -137,15 +137,15 @@
<%if @sample.status == "in preparation" %> <%if @sample.status == "in preparation" %>
<div class='absolute'><%=link_to (@sample.status ? "Submit for Measurement" : "No"), <div class='absolute'><%=link_to (@sample.status ? "Submit for Measurement" : "No"),
Measured_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success' %> Measured_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success', :style=>"width:99%"%>
</div> </div>
<%elsif current_user?(@sample.user) && @sample.status == "submitted" %> <%elsif current_user?(@sample.user) && @sample.status == "submitted" %>
<div class='absolute'><%=link_to (@sample.status ? "Withdraw this Sample" : "No"), <div class='absolute'><%=link_to (@sample.status ? "Withdraw this Sample" : "No"),
Withdraw_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-danger' %> Withdraw_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-danger', :style=>"width:99%" %>
</div> </div>
<%elsif operator? && @sample.status == "submitted" %> <%elsif operator? && @sample.status == "submitted" %>
<div class='absolute'><%=link_to (@sample.status ? "Release Measurement" : "No"), <div class='absolute'><%=link_to (@sample.status ? "Release Measurement" : "No"),
ReleaseMeasurment_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success' %> ReleaseMeasurment_sample_path(@sample), :action => 'solve', :class => 'btn btn-block btn-success', :style=>"width:99%" %>
</div> </div>
<%end%> <%end%>
...@@ -157,19 +157,17 @@ ...@@ -157,19 +157,17 @@
<%= form_with model: @sample do |f| %> <%= form_with model: @sample do |f| %>
<div style="text-align: left"> <div style="text-align: left">
<%= f.label "Create new File Attachment:" %> <%= f.label "Create new File Attachment:" %>
<%= f.file_field :add_files, multiple: true, class: "file_storage_button", style: "text-align: left; width: 70%" %> <%= f.file_field :add_files, multiple: true, direct_upload: true, class: "file_storage_button", style: "width: 70%" %>