Skip to content

Commit

Permalink
Merge pull request #2675 from doug-salvati/ds2647
Browse files Browse the repository at this point in the history
Photos Vis works, looks nice, and photo upload is easier
  • Loading branch information
doug-salvati authored Aug 3, 2017
2 parents 6c142ed + 095fd69 commit dc0c24e
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/data_sets/editTable.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ IS.onReady 'data_sets/edit', ->
success: uploadSettings.successEdit

# ensure a minimum of ten rows per dataset
newRows = Math.max 1, 10 - grid.length()
newRows = Math.max 1, 5 - grid.length()
for i in [1 .. newRows]
grid.addRow false

Expand All @@ -404,5 +404,5 @@ IS.onReady 'data_sets/manualEntry', ->
success: uploadSettings.successEntry

# we get one row for free in slickgrid, so just add 9 more
for i in [1 .. 9]
for i in [1 .. 4]
grid.addRow false
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Handlebars template -->
<div class="group row" id="group-{{g_id}}">
<div class="col-xs-12 group-header">
<div class="col-xs-12 group-header" style="color: white">
{{group_label}}
</div>
<div class="col-xs-12 group-body" id="gbody-{{g_id}}">
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/visualizations/highvis/photos.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ $ ->
# create the groups to put the photos in
id = 0
for group in selectedGroups
if !groupedMedia[group[1]]? or groupedMedia[group[1]].length == 0
if (!groupedMedia[group[1].toLowerCase()]?) or (groupedMedia[group[1].toLowerCase()].length is 0)
continue

groupContext =
g_id: group[0]
group_label: group[1]
groupObj = $(grpTemp(groupContext))

# put the photos in their correct groups
for photo in groupedMedia[group[1]]
for photo in groupedMedia[group[1].toLowerCase()]
photoContext =
p_id: "pic-#{id}"
tn_src: photo.tn_src
Expand Down
8 changes: 5 additions & 3 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ body {
.item {
background-color: #ddd;
margin: auto;
box-shadow: 2px 3px 1px grey;

.badge {
float: left;
Expand All @@ -236,19 +235,22 @@ body {
}

.item-image {
background-color: #111133;
background-position: center;
background-repeat: no-repeat;
background-size: 100%;
height: 120px;
border-bottom: 1px solid gray;
}

.item-image.item-photo-image {
height: 200px;
height: 250px;
display: block;
margin-left: auto;
margin-right: auto;
}
.item-image.item-photo-image:hover {
height: 200px;
}

.item-title {
font-size: 1.25em;
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/data_sets.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
.data_sets-controller {
$slick-border-color: #C0C0C0;
$slick-border: thin solid $slick-border-color;
$slick-minheight: 412px;
$slick-maxheight: 2000px;
$slick-minheight: 270px;
$slick-maxheight: 270px;
$slick-defheight: 100%;
$slick-row-odd: #FFFFFF;
$slick-row-even: #EEEEEE;
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/visualizations.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ body[data-page-name='visualizations/show'] .visualizations-controller,
color: $hint;
}

// photos may require scrollbar; margin so photos do not touch top of canvas
// photos may require scrollbar
#photos-canvas {
overflow-y: auto;
margin-top: 20px;
background: #111133;
}

#radius-text {
Expand Down
29 changes: 25 additions & 4 deletions app/views/data_sets/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,45 @@
<div class="full_width_edit" style="font-size:2em;"><%= data_set_edit_helper 'title', can_edit?(@data_set), false, "/data_sets/#{@data_set.id}" %></div>
<div><strong>Project:</strong> <%= link_to @project.title.html_safe, project_path(@project.id)%></div>

<hr>

<div class="row">
<div class="span12 edit_table_control pull-left" style="font-size: 2em;">
Data
</div>
<div class="span12 edit_table_control pull-right">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--red edit_table_cancel">Cancel</button>
<button id="edit_table_add_1" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--green edit_table_add">Add Row</button>
<button id="edit_table_save_1" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--blue edit_table_save">Save</button>
</div>
</div>

<div class="row">
<div id="slickgrid-container"></div>
</div>

<div id="row-slickgrid-1" class="row">*Timestamps must be in the form "yyyy/MM/dd hh:mm:ss" or a unix timestamp</div>
<div id="row-slickgrid-1" class="row" style="color: silver;">*Timestamps must be in the form "yyyy/MM/dd hh:mm:ss" or a UNIX timestamp</div>

<hr>

<div class="row">
<div class="span12 edit_table_control pull-left" style="font-size: 2em;">
Photos & Media
</div>
</div>

<div>
<%= render layout: "shared/box",
locals: {title: '', width: '12',
unique_id: 'media', should_hide: false} do %>
<%= render "shared/media_objects_view",
{type: 'data_set', object: @data_set} %>
<% end %>
</div>

&nbsp<hr>

<div id="row-slickgrid-2" class="row">
<div class="span12 edit_table_control pull-right">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--red edit_table_cancel">Cancel</button>
<button id="edit_table_add_2" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--green edit_table_add">Add Row</button>
<button id="edit_table_save_2" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--blue edit_table_save">Save</button>
</div>
</div>
Expand Down
12 changes: 8 additions & 4 deletions app/views/data_sets/manualEntry.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@
<% end %>
</div>

<hr>

<div class="row">
<div class="span12 edit_table_control pull-left" style="font-size: 2em;">
Data
</div>
<div class="span12 edit_table_control pull-right">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--red edit_table_cancel">Cancel</button>
<button id="edit_table_add_1" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--green edit_table_add">Add Row</button>
<button id="edit_table_save_1" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--blue edit_table_save">Save</button>
</div>
</div>

Expand All @@ -42,12 +45,13 @@
</div>
</div>

<div id="row-slickgrid-1" class="row">*Timestamps must be in the form "yyyy/MM/dd hh:mm:ss" or a unix timestamp</div>
<div id="row-slickgrid-1" class="row" style="color: silver;">*Timestamps must be in the form "yyyy/MM/dd hh:mm:ss" or a UNIX timestamp</div>

<hr>

<div id="row-slickgrid-2" class="row">
<div class="span12 edit_table_control pull-right">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--red edit_table_cancel">Cancel</button>
<button id="edit_table_add_2" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--green edit_table_add">Add Row</button>
<button id="edit_table_save_2" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--blue edit_table_save">Save</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/clone_project_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def set_cell(row, col, value)

click_on 'Manual Entry'
fill_in 'Data Set Name', with: 'I Like Clones'
find('#edit_table_add_2').click
find('#edit_table_add_1').click
set_cell(0, 0, 47)
find('#edit_table_save_2').click

Expand Down
18 changes: 9 additions & 9 deletions test/integration/slickgrid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ def slickgrid_add_data(start, field_map)
# enter a valid project title
find(:css, '#data_set_name').set dataset_title

# assert that we start with ten blank rows
page.assert_selector '.slick-row', count: 10
# assert that we start with five blank rows
page.assert_selector '.slick-row', count: 5

# build a map of field ids to columns
fields = all :css, '.slick-header-column'
field_map = {}
fields.each.with_index { |x, i| field_map[x[:id][-3..-1]] = i }

# add three more rows
button = find :css, '#edit_table_add_2'
button = find :css, '#edit_table_add_1'
3.times { button.click }

# assert that we added some rows
page.assert_selector '.slick-row', count: 13
page.assert_selector '.slick-row', count: 8

# add data to the rows
slickgrid_add_data 0, field_map
Expand All @@ -131,7 +131,7 @@ def slickgrid_add_data(start, field_map)
2.times { all('.slick-cell.l3.r3').last.click }

# save the dataset
find(:css, '#edit_table_save_1').click
find(:css, '#edit_table_save_2').click

# assert that we're where we should be
find '#vis-container'
Expand Down Expand Up @@ -169,7 +169,7 @@ def slickgrid_add_data(start, field_map)
assert page.has_content? 'latitude_field, longitude_field'

# assert presence of data
page.assert_selector '.slick-row', count: 10
page.assert_selector '.slick-row', count: 5
assert page.has_content? '0, 0'
assert page.has_content? '1, 1'
assert page.has_content? '2, 2'
Expand All @@ -184,7 +184,7 @@ def slickgrid_add_data(start, field_map)
4.times { button.click }

# assert rows were actually added
page.assert_selector '.slick-row', count: 14
page.assert_selector '.slick-row', count: 9

# add data to those rows
slickgrid_add_data 4, field_map
Expand All @@ -196,10 +196,10 @@ def slickgrid_add_data(start, field_map)
find(:css, '.slick-row:nth-child(1) .slick-delete').click

# assert correct rows were deleted
page.assert_selector '.slick-row', count: 10
page.assert_selector '.slick-row', count: 5

# save the dataset
find(:css, '#edit_table_save_1').click
find(:css, '#edit_table_save_2').click

# assert that we're where we should be
find '#vis-container'
Expand Down
2 changes: 1 addition & 1 deletion test/integration/user_interactions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UserInteractionsTest < IntegrationTest

click_on 'Manual Entry'
first('.editor-text').set('<h1>Testing...</h1>')
find('#edit_table_save_1').click
find('#edit_table_save_2').click

assert page.has_no_content?('<h1>'), 'Users should not be able to inject code into the webpage.'
end
Expand Down

0 comments on commit dc0c24e

Please sign in to comment.