-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple-image-export #693
Open
divyabaid16
wants to merge
8
commits into
publiclab:main
Choose a base branch
from
divyabaid16:multiple-image-export
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−10
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cadc9b3
Export improved
divyabaid16 e9fc4dc
Changes made
divyabaid16 d52d6fb
Changes in unit test made
divyabaid16 a72d22b
Test passing
divyabaid16 ae11bae
Opacity to uplaced images added
divyabaid16 3582af8
Error resolved
divyabaid16 d7e55ef
Rubocop fix
divyabaid16 e0f73c8
Rubocop fix
divyabaid16 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -42,11 +42,41 @@ | |
<% end %> | ||
|
||
<% if logged_in? || @map.anonymous? %> | ||
<div> | ||
<% if @map.warpables.empty? %> | ||
<p id="no-images">No images are uploaded</p> | ||
<% else %> | ||
<p>Select the images to be exported:</p> | ||
<%end%> | ||
<% @map.warpables.each do |warpable| %> | ||
<div style="display: inline-grid;" id="warpable-<%= warpable.id %>"> | ||
<% if warpable.placed? %> | ||
<p class="warpable export-warpable" style="margin-right: 20px;"> | ||
<% else %> | ||
<p class="warpable" rel="tooltip" title="This image has not yet been placed on the map." style="margin-right: 20px; opacity: 0.5; cursor: not-allowed;"> | ||
<% end %> | ||
<%= image_tag warpable.image.url(:thumb), | ||
:'data-warpable-id' => warpable.id, | ||
:'data-map-id' => @map.id, | ||
:'id' => "warpable-img-#{warpable.id}" | ||
%> | ||
</p> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div class="progress"<% unless @map.exporting? %> style="display:none;"<% end %>> | ||
<div class="progress-bar progress-bar-striped progress-bar-animated active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> | ||
<span class="" id="export_progress"><%= @map.export ? @map.export.status : "Loading..." %></span> | ||
</div> | ||
</div> | ||
|
||
<div style="margin-top: 30px;"> | ||
<p> | ||
<button id="begin-export" class="btn btn-lg btn-primary"<% if @map.export && @map.exporting? %> style="display:none;"<% end %>>Start export</button> | ||
<button <% unless @map.export && @map.exporting? %>style="display:none;"<% end %> id="cancel-export" class="btn btn-lg btn-outline-secondary"><i class="fas fa-times"></i> Cancel export</button> | ||
</p> | ||
|
||
</div> | ||
<% if @map.exporting? && ((@map.export.updated_at-DateTime.now)/1.hours.to_i).abs > 4 %> | ||
<p class="alert alert-warning alert-toolong"> | ||
This export is taking a while; consider cancelling it and following the tips linked to below. | ||
|
@@ -81,6 +111,35 @@ | |
</div> | ||
</div> | ||
<script> | ||
var exp1 = 0; | ||
// //var arr = []; | ||
// var b = $('.export-warpable').length; | ||
// console.log(b); | ||
// var k = [0, 0, 0]; | ||
// console.log(k); | ||
$('.export-warpable').click(function() { | ||
var warpable_id = $(this).children('img').attr("data-warpable-id"); | ||
console.log(warpable_id); | ||
if(exp1==0){ | ||
$(this).css('border', "solid 2px red"); | ||
$(this).parent().addClass('export-image'); | ||
exp1 = 1; | ||
} | ||
else{ | ||
$(this).css('border', "none"); | ||
$(this).parent().removeClass('export-image'); | ||
exp1 = 0; | ||
} | ||
}); | ||
function check_export(){ | ||
if($('.export-image').length > 0){ | ||
$('#begin-export').attr('disabled',false).attr('title','Start Export'); | ||
} | ||
else{ | ||
$('#begin-export').attr('disabled',true).attr('title','Select images to export'); | ||
} | ||
}; | ||
|
||
Comment on lines
+134
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not being called anywhere, so doesn't work. Also |
||
var exporting, exportResolutionSlider | ||
(function(){ | ||
exportResolutionSlider = $("#export-resolution").ionRangeSlider({ | ||
|
@@ -142,7 +201,16 @@ var exporting, exportResolutionSlider | |
}) | ||
|
||
$('#begin-export').click(function() { | ||
if (images.length < 30 || confirm('This map has over 30 images; this is a lot! Please read the tips on exporting maps listed below the Export button.')) { | ||
var arr = [] | ||
//var a = $('.export-image').length; | ||
//console.log(a); | ||
$('.export-image').each(function(i,obj){ | ||
var warpable_id = $(this).children('p').children('img').attr("data-warpable-id"); | ||
arr.push(warpable_id); | ||
}) | ||
//console.log(arr); | ||
//var arr = [101,102,103] | ||
if (1 || confirm('This map has over 30 images; this is a lot! Please read the tips on exporting maps listed below the Export button.')) { | ||
$('.alert-toolong').hide() | ||
$('.progress').show() | ||
$('.progress-bar').addClass('active') | ||
|
@@ -159,8 +227,9 @@ var exporting, exportResolutionSlider | |
$('#export_progress').html("starting export") | ||
$('.map-exports').html('') | ||
$.ajax({ | ||
url: '/maps/export/<%= @map.id %>?authenticity_token=<%= form_authenticity_token %>', | ||
method: 'POST', | ||
//url: '/maps/export/<%= @map.id %>,101,102,103,104,105', | ||
url: '/maps/export/<%= @map.id %>,'+arr, | ||
method: 'GET', | ||
data: { | ||
<% if Rails.env.production? && !logged_in? && @map.anonymous? %> | ||
'g-recaptcha-response': grecaptcha.getResponse(), | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just got around to reviewing this! So this code assumes that you're only toggling the border on one image. If you select 1, and then select a 2nd, the 2nd won't get a border unless you click it twice. You could refactor maybe to something like this:
{
spacingexport-image
class in css, and then all you have to do is toggle the class