-
Notifications
You must be signed in to change notification settings - Fork 159
/
new.html.erb
executable file
·147 lines (103 loc) · 5.79 KB
/
new.html.erb
1
2
3
4
5
6
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<div class="container-fluid" style="clear:both;">
<div class="">
<h1>Upload a spectrum</h1>
</div>
<div class="row">
<form id="upload" action="/spectrums/create" class="form well span10" enctype="multipart/form-data" method="post">
<% if !params[:webrtc].nil? && params[:webrtc] == 'false' %>
<div class="alert alert-error">
Your browser <a href="http://caniuse.com/#search=webrtc">doesn't support live capture via USB</a>, so we've redirected you to the Upload page; if you believe you're seeing this message in error, please <a href="https://publiclab.org/wiki/issues">file an issue</a>.
</div>
<% end %>
<% if @spectrum.errors.any? %>
<div class="alert alert-error">
<h3>There were errors with your data.</h3>
<ul>
<% @spectrum.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row-fluid">
<div class="span6">
<input name="spectrum[data_type]" type="hidden" id="spectrum_upload_type" value="image" />
<ul class="nav nav-tabs nav-upload-types">
<li class="active"><a data-upload-type="image" href="#tab-image" data-toggle="tab"><i class="fa fa-camera"></i> Choose an image</a></li>
<li> <a data-upload-type="json" href="#tab-json" data-toggle="tab"><i class="fa fa-code"></i> Upload json (beta)</a></li>
<li> <a data-upload-type="csv" href="#tab-csv" data-toggle="tab"><i class="fa fa-code"></i> Upload csv (beta)</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-image">
<%= render partial: 'spectrums/new_image' %>
</div>
<div class="tab-pane" id="tab-json">
<h4>Paste in valid JSON data</h4>
<p>Please use <a href="https://publiclab.org/wiki/spectral-workbench-api#Uploading+data">this format</a>.</p>
<textarea class="spectrum-json" name="spectrum[json]" style="width:90%;height:200px;" placeholder='[
{ "average": 64.3333, "r": 69, "g": 46, "b": 78, "wavelength":269.089 },
{ "average": 35, "r": 33, "g": 19, "b": 41, "wavelength":432.241 },
{ "average": 31, "r": 33, "g": 19, "b": 41, "wavelength":958.521 }
]'></textarea>
</div>
<div class="tab-pane" id="tab-csv">
<h4>Paste in valid CSV data</h4>
<p>Please use <code>wavelength (in nanometers),intensity (0-255)</code> as <a href="https://publiclab.org/wiki/spectral-workbench-api#Uploading+data">shown here</a>.</p>
<textarea class="spectrum-csv" name="spectrum[csv]" style="width:90%;height:200px;" placeholder='400,24
410,44
420,42
430,45
440,20'></textarea>
</div>
</div>
</div>
<div class="span6">
<h3>Describe your spectrum</h3>
<div class="control-group" id="title">
<input name="spectrum[title]" type="text" id="inputTitle" placeholder="Title">
<span class="help-inline"></span>
</div>
<div>
<textarea name="spectrum[notes]" id="textareaNotes" cols="8" rows="6" placeholder="Notes: where, what, why"></textarea>
</div>
<label for="device">If possible, identify your device:</label>
<select name="device" id="device">
<option value="none">- choose a device -</option>
<option value="device:dsk3">Desktop Spectrometry Kit v3</option>
<option value="device:dsk2">Desktop Spectrometry Kit v2</option>
<option value="device:dsk1">Desktop Spectrometry Kit v1</option>
<option value="device:foldable">Foldable Mini-Spectrometer</option>
<option value="device:countertop">Countertop Spectrometer</option>
<option value="device:smartphone">Smartphone Spectrometer</option>
<option value="device:custom">custom design</option>
</select>
</div>
<div class="row-fluid">
<p>
<% if logged_in? && current_user.calibrations.length > 0 %>
<label for="calibration_id">Use or create a calibration (<a href="//publiclab.org/wiki/spectral-workbench-calibration">Learn more</a>):</label>
<select name="spectrum[calibration_id]" id="calibration_id">
<% current_user.tag('calibration',20).each do |spectrum| %>
<option value="<%= spectrum.id %>"><%= spectrum.title %> (<%= time_ago_in_words(spectrum.created_at) %> ago)</option>
<% end %>
<option value="calibration">[+] New calibration</option>
</select>
<% end %>
</p>
<input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>"/>
<input name="upload" type="hidden" id="upload" value="true" />
<input name="geotag" type="hidden" id="geotag" />
<input name="lat" type="hidden" id="lat" />
<input name="lon" type="hidden" id="lon" />
<a href="#" data-loading-text="Saving..." id="uploadBtn" class="btn btn-primary btn-large" onClick="$W.save(true)">Upload with selected calibration</a>
<a href="#" data-loading-text="Saving..." id="uploadUncalibrated" class="btn btn-large" onClick="$W.save(false)">Upload & calibrate later</a>
<label rel="tooltip" title="Detect your location and tag this data?" class="checkbox inline" style="margin-left:10px;">
<input type="checkbox" style="display:none;" id="geotagInput" value="geotag" checked="true" /> Geotag
</label>
</div>
<hr />
<p>By uploading your data, you agree to release it under the <a href="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Zero license</a></p>
</div>
</form>
</div>
<%= javascript_include_tag "upload" %>