Skip to content
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

updated matchagainst for bulk import #677

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/webapp/appadmin/resendBulkImportID.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ JSONObject res = new JSONObject();

//String queryEncounterId = null;
String importIdTask = request.getParameter("importIdTask");
List<String> locationIDs = new ArrayList<String>();
List<String> locationIDs = new ArrayList<String>();
String ownerFilter = "";
if(request.getParameterValues("locationID")!=null) {
String[] vals=request.getParameterValues("locationID");
locationIDs = Arrays.asList(vals);
}

if(request.getParameter("owner")!=null) {
ownerFilter=request.getParameter("owner");
}

try {
res.put("success","false");

Expand All @@ -55,6 +60,9 @@ try {
//matchingSetFilter = { locationIds: locationIds }
if(locationIDs!=null && locationIDs.size()>0)mf.put("locationIds",locationIDs);
//mf.put("projectId", project.getId());
if (!ownerFilter.isEmpty()) {
mf.put("owner", ownerFilter);
}
taskParameters.put("matchingSetFilter", mf);


Expand Down
199 changes: 193 additions & 6 deletions src/main/webapp/import.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,62 @@ a.button:hover {
background-color: #DDA;
text-decoration: none;
}

.ia-match-filter-dialog .option-cols {
-webkit-column-count: 1;
-moz-column-count: 1;
column-count: 1;
}
.ia-match-filter-dialog .option-cols input {
vertical-align: top;
}
.ia-match-filter-dialog .option-cols .item {
padding: 1px 4px;
border-radius: 5px;
}
.ia-match-filter-dialog .option-cols .item:hover {
background-color: #AAA;
}
.ia-match-filter-dialog .option-cols .item label {
font-size: 0.9em;
width: 90%;
margin-left: 5px;
line-height: 1.0em;
}
.ia-match-filter-dialog .option-cols .item-checked label {
font-weight: bold;
}
.ia-match-filter-dialog ul {
list-style-type: none;
}
.ia-match-filter-dialog .item-count {
font-size: 0.8em;
color: #777;
margin-left: 9px;
}
.ia-match-filter-section {
margin-top: 10px;
border-top: solid 3px #999;
}
.ia-match-filter-title {
margin: 20px 0 5px 0;
padding: 1px 0 1px 20px;
background-color: #b491c8;
color: #555;
font-weight: bold;
}
.ia-match-filter-dialog {
display: none;
z-index: 3000;
position: fixed;
top: 10%;
width: 80%;
padding: 15px;
border: solid 5px #888;
background-color: #fff;
}


</style>


Expand All @@ -302,6 +358,8 @@ String context = ServletUtilities.getContext(request);
Shepherd myShepherd = new Shepherd(context);
myShepherd.setAction("import.jsp");
myShepherd.beginDBTransaction();
String langCode = ServletUtilities.getLanguageCode(request);
Properties encprops = ShepherdProperties.getOrgProperties("encounter.properties", langCode, context, request, myShepherd);

//should the user see the detect and/or detect+ID buttons?
boolean allowIA=false;
Expand Down Expand Up @@ -437,7 +495,7 @@ try{
int numMatchAgainst=0;
boolean foundChildren = false;
int numMatchTasks=0;

HashMap<String,JSONArray> jarrs = new HashMap<String,JSONArray>();
if (Util.collectionSize(itask.getEncounters()) > 0) {
for (Encounter enc : itask.getEncounters()) {
Expand Down Expand Up @@ -802,6 +860,11 @@ try{
};
for (let [encId, maIds] of js_jarrs) { data.bulkImport[encId] = maIds; } // convert js_jarrs map into js object
if (!skipIdent && locationIds && (locationIds.indexOf('') < 0)) data.taskParameters.matchingSetFilter = { locationIds: locationIds };

if ($('#match-filter-owner-me').is(':checked')){
if(!data.taskParameters.matchingSetFilter) data.taskParameters.matchingSetFilter = {};
data.taskParameters.matchingSetFilter["owner"] = ["me"]
}

console.log('sendToIA() SENDING: locationIds=%o data=%o', locationIds, data);
$.ajax({
Expand All @@ -826,16 +889,20 @@ try{
$('#ia-send-div').hide().after('<div id="ia-send-wait"><i>sending... <b>please wait</b></i></div>');
//var locationIds = $('#id-locationids').val();
var locationIds = '';
var owner = '';
$("#id-locationids option:selected").each(function(){
locationIds+='&locationID='+this.value;
});
if(locationIds.indexOf('ALL locations')>-1)locationIds='';
//if (locationIds && (locationIds.indexOf('') < 0)) data.taskParameters.matchingSetFilter = { locationIds: locationIds };

console.log('resendToID() SENDING: locationIds=%o', locationIds);
if ($('#match-filter-owner-me').is(':checked')){
owner = "&owner=" + encodeURIComponent(JSON.stringify(["me"]));
}

$.ajax({
url: wildbookGlobals.baseUrl + '/appadmin/resendBulkImportID.jsp?importIdTask=<%=taskId%>'+locationIds,
url: wildbookGlobals.baseUrl + '/appadmin/resendBulkImportID.jsp?importIdTask=<%=taskId%>'+locationIds + owner,
dataType: 'json',
type: 'GET',
contentType: 'application/javascript',
Expand All @@ -850,6 +917,20 @@ try{
});

}

function shouldselectAllOptions(shouldselect){
$("#id-locationids option").each(function(index,option){
if(option.value){
option.selected = shouldselect;
}

});
}

function showModal(){

$('.ia-match-filter-dialog').show()
}

</script>
</p>
Expand All @@ -875,7 +956,7 @@ try{

%>

<div style="margin-bottom: 20px;"><a class="button" style="margin-left: 20px;" onClick="sendToIA(true); return false;">Send to detection (no identification)</a></div>
<div style="margin-bottom: 30px;margin-top: 30px;"><a class="button" style="margin-left: 20px;" onClick="$('.ia-match-filter-dialog').show()">Send to detection (no identification)</a></div>


<%
Expand All @@ -889,9 +970,8 @@ try{

if (allowReID) {
%>
<div style="margin-bottom: 20px;">
<a class="button" style="margin-left: 20px;" onClick="resendToID(); return false;">Send to identification</a> matching against <b>location(s):</b>
<%=LocationID.getHTMLSelector(true, locationIds, null, "id-locationids", "locationID", "") %>
<div style="margin-bottom: 30px;margin-top: 30px;">
<a class="button" style="margin-left: 20px;" onClick="showModal()">Send to identification</a>
</div>

<%
Expand All @@ -910,6 +990,112 @@ try{
</form>
</div>

<div class="ia-match-filter-dialog">
<h2><%=encprops.getProperty("matchFilterHeader")%></h2>
<%

String queueStatementID2="";
int wbiaIDQueueSize2 = WbiaQueueUtil.getSizeDetectionJobQueue(false);
if(wbiaIDQueueSize2==0){
queueStatementID2 = "The machine learning queue is empty and ready for work.";
}
else if(Prometheus.getValue("wildbook_wbia_turnaroundtime_detection")!=null){
String val=Prometheus.getValue("wildbook_wbia_turnaroundtime_detection");
try{
Double d = Double.parseDouble(val);
d=d/60.0;
queueStatementID2 = "There are currently "+wbiaIDQueueSize2+" ID jobs in the small batch queue. Time to completion is averaging "+(int)Math.round(d)+" minutes based on recent matches. Your time may be faster or slower.";
}
catch(Exception de){de.printStackTrace();}
}
if(!queueStatementID2.equals("")){
%>
<p><em><%=queueStatementID2 %></em></p>
<%
}
%>
<div class="ia-match-filter-title search-collapse-header" style="padding-left:0; border:none;">
<span class="el el-lg el-chevron-right rotate-chevron down" style="margin-right: 8px;"></span><%=encprops.getProperty("locationID")%> &nbsp; <span class="item-count" id="total-location-count"></span>
</div>
<div class="ia-match-filter-container" style="display: block">
<div style="width: 100%; max-height: 500px; overflow-y: scroll">
<div id="ia-match-filter-location" class="option-cols">

<div>
<input type="button" value="<%=encprops.getProperty("selectAll")%>"
onClick="shouldselectAllOptions(true)" />
<input type="button" value="<%=encprops.getProperty("selectNone")%>"
onClick="shouldselectAllOptions(false)" />
</div>
<br>

<%=LocationID.getHTMLSelector(true, locationIds, null, "id-locationids", "locationID", "") %>


</div>

</div>


<style type="text/css">
/* this .search-collapse-header .rotate-chevron logic doesn't work
because animatedcollapse.js is eating the click event (I think.).
It's unclear atm where/whether to modify animatedcollapse.js to
rotate this chevron.
*/
.search-collapse-header .rotate-chevron {
-moz-transition: transform 0.5s;
-webkit-transition: transform 0.5s;
transition: transform 0.5s;
}
.search-collapse-header .rotate-chevron.down {
-ms-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.search-collapse-header:hover {
cursor: pointer;
}

</style>
<script>
$(".search-collapse-header").click(function(){
console.log("LOG!: collapse-header is clicked!");
$(this).children(".rotate-chevron").toggleClass("down");
$(this).next().slideToggle();
});
</script>

</div>


<div class="ia-match-filter-title"><%=encprops.getProperty("matchFilterOwnership")%></div>
<div class="item">
<input type="checkbox" id="match-filter-owner-me" name="match-filter-owner" value="me" />
<label for="match-filter-owner-me"><%=encprops.getProperty("matchFilterOwnershipMine")%></label>
</div>

<div class="ia-match-filter-section">
<% if(allowIA) {%>
<input id="matchbutton" type="button" value="<%=encprops.getProperty("doMatch")%>" onClick="sendToIA(false)" />
<%}
if (allowReID){
%>
<input id="matchbutton" type="button" value="<%=encprops.getProperty("doMatch")%>" onClick="resendToID()" />

<% }%>
<input style="background-color: #DDD;" type="button" value="<%=encprops.getProperty("cancel")%>"
onClick="$('.ia-match-filter-dialog').hide()" />
</div>



</div>
</div>



<%
}
%>
Expand All @@ -932,6 +1118,7 @@ finally{
}
%>

</div>
</div>

<jsp:include page="footer.jsp" flush="true"/>
Expand Down