Skip to content

Commit

Permalink
Merge pull request #2027 from ProjectSidewalk/1148-label-preview-user…
Browse files Browse the repository at this point in the history
…-admin-page

#1148 Labels Found in User Admin GSV Window
  • Loading branch information
misaugstad authored Mar 10, 2020
2 parents ba6ce88 + ab72112 commit e2c5820
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
3 changes: 3 additions & 0 deletions app/views/admin/user.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ <h1>Feedback</h1>
<script type="text/javascript" src='@routes.Assets.at("javascripts/Admin/build/Admin.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/SVLabel/src/SVLabel/util/UtilitiesSidewalk.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/SVLabel/src/SVLabel/util/UtilitiesColor.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/SVLabel/src/SVLabel/util/UtilitiesPanomarker.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/SVLabel/src/SVLabel/Panomarker.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/SVValidate/src/util/PanoProperties.js")'></script>
<script type="text/javascript" src='@routes.Assets.at("javascripts/TimestampLocalization.js")'></script>

<script src='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.js'></script>
Expand Down
32 changes: 19 additions & 13 deletions public/javascripts/Admin/src/Admin.GSVLabelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ function AdminGSVLabelView(admin) {
'<td colspan="3" id="tags"></td>'+
'</tr>'+
'<tr>'+
'<th>Description</th>'+
'<td colspan="3" id="label-description"></td>'+
'<th>Description</th>'+
'<td colspan="3" id="label-description"></td>'+
'</tr>'+
'<tr>'+
'<th>Validations</th>'+
'<td colspan="3" id="label-validations"></td>'+
'<th>Validations</th>'+
'<td colspan="3" id="label-validations"></td>'+
'</tr>'+
'<tr>'+
'<th>Time Submitted</th>'+
Expand All @@ -74,13 +74,18 @@ function AdminGSVLabelView(admin) {
'<td id="image-date" colspan="3"></td>'+
' </tr>';
if (self.admin) {
modalText += '<tr>'+
'<th>Task ID</th>' +
'<td id="task"></td>' +
'</tr>'+
'</table>'+
'</div>'+
'</div>'+
modalText +=
'<tr>'+
'<th>Label ID</th>'+
'<td id="label-id" colspan="3"></td>'+
'</tr>'+
'<tr>'+
'<th>Task ID</th>' +
'<td id="task"></td>' +
'</tr>'+
'</table>'+
'</div>'+
'</div>'+
'</div>'+
'</div>'
} else {
Expand Down Expand Up @@ -123,6 +128,7 @@ function AdminGSVLabelView(admin) {
self.modalValidations = self.modal.find("#label-validations");
self.modalImageDate = self.modal.find("#image-date");
self.modalTask = self.modal.find("#task");
self.modalLabelId = self.modal.find("#label-id")
}

/**
Expand Down Expand Up @@ -251,8 +257,8 @@ function AdminGSVLabelView(admin) {
self.modalDescription.html(labelMetadata['description'] != null ? labelMetadata['description'] : "No description");
self.modalValidations.html(validationsText);
self.modalImageDate.html(imageDate.format('MMMM YYYY'));

if (self.admin) {
self.modalLabelId.html(labelMetadata['label_id']);
self.modalTask.html("<a href='/admin/task/"+labelMetadata['audit_task_id']+"'>"+
labelMetadata['audit_task_id']+"</a> by <a href='/admin/user/" + labelMetadata['username'] + "'>" +
labelMetadata['username'] + "</a>");
Expand All @@ -264,4 +270,4 @@ function AdminGSVLabelView(admin) {
self.showLabel = showLabel;

return self;
}
}
14 changes: 7 additions & 7 deletions public/javascripts/Admin/src/Admin.Panorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ function AdminPanorama(svHolder, buttonHolder, admin) {
};

var icons = {
CurbRamp : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_CurbRamp.png',
NoCurbRamp : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_NoCurbRamp.png',
Obstacle : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Obstacle.png',
SurfaceProblem : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_SurfaceProblem.png',
Other : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Other.png',
Occlusion : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Other.png',
NoSidewalk : 'assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_NoSidewalk.png'
CurbRamp : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_CurbRamp.png',
NoCurbRamp : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_NoCurbRamp.png',
Obstacle : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Obstacle.png',
SurfaceProblem : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_SurfaceProblem.png',
Other : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Other.png',
Occlusion : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_Other.png',
NoSidewalk : '/assets/javascripts/SVLabel/img/admin_label_tool/AdminTool_NoSidewalk.png'
};

// Determined experimentally; varies w/ GSV Panorama size
Expand Down
21 changes: 18 additions & 3 deletions public/javascripts/Admin/src/Admin.User.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function AdminUser(params) {
var self = {};
var _data = {};
self.username = params.username;
self.adminGSVLabelView = AdminGSVLabelView(true);

// Initialize the map
L.mapbox.accessToken = 'pk.eyJ1Ijoia290YXJvaGFyYSIsImEiOiJDdmJnOW1FIn0.kJV65G6eNXs4ATjWCtkEmA';
Expand Down Expand Up @@ -74,7 +75,6 @@ function AdminUser(params) {
document.getElementById("td-number-of-obstacles").innerHTML = labelCounter["Obstacle"];
document.getElementById("td-number-of-surface-problems").innerHTML = labelCounter["SurfaceProblem"];
document.getElementById("td-number-of-no-sidewalks").innerHTML = labelCounter["NoSidewalk"];

document.getElementById("map-legend-curb-ramp").innerHTML = "<svg width='20' height='20'><circle r='6' cx='10' cy='10' fill='" + colorMapping['CurbRamp'].fillStyle + "'></svg>";
document.getElementById("map-legend-no-curb-ramp").innerHTML = "<svg width='20' height='20'><circle r='6' cx='10' cy='10' fill='" + colorMapping['NoCurbRamp'].fillStyle + "'></svg>";
document.getElementById("map-legend-obstacle").innerHTML = "<svg width='20' height='20'><circle r='6' cx='10' cy='10' fill='" + colorMapping['Obstacle'].fillStyle + "'></svg>";
Expand All @@ -88,9 +88,24 @@ function AdminUser(params) {
var style = $.extend(true, {}, geojsonMarkerOptions);
style.fillColor = colorMapping[feature.properties.label_type].fillStyle;
return L.circleMarker(latlng, style);
}
},
onEachFeature: onEachLabelFeature
}).addTo(map);
});

function onEachLabelFeature(feature, layer) {
layer.on('click', function () {
self.adminGSVLabelView.showLabel(feature.properties.label_id);
});
layer.on({
'mouseover': function () {
layer.setRadius(15);
},
'mouseout': function () {
layer.setRadius(5);
}
})
}

$.getJSON("/adminapi/tasks/" + self.username, function (data) {
_data.tasks = data;
Expand Down Expand Up @@ -155,4 +170,4 @@ function AdminUser(params) {

self.data = _data;
return self;
}
}
5 changes: 4 additions & 1 deletion public/javascripts/Admin/src/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,10 @@ function Admin(_, $, c3, turf, difficultRegionIds) {
if (e.target.id == "visualization" && self.mapLoaded == false) {
initializeNeighborhoodPolygons(map);
initializeAuditedStreets(map);
initializeSubmittedLabels(map);
// Adding a 1 second wait to ensure that labels are the top layer and are thus clickable.
setTimeout(function(){
initializeSubmittedLabels(map);
}, 1000);
initializeAdminGSVLabelView();
setTimeout(function () {
map.invalidateSize(false);
Expand Down

0 comments on commit e2c5820

Please sign in to comment.