Skip to content

Commit

Permalink
ui: showing previous annotations per image
Browse files Browse the repository at this point in the history
  • Loading branch information
iSkore committed Jan 15, 2019
1 parent 2a2ebfc commit 69e3681
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions apps/tlv-app/grails-app/assets/javascripts/menus/annotations-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ function saveAnnotations() {
$( pre ).css( 'color', '#c8c8c8' );
$( pre ).html( JSON.stringify( data, null, 2 ) );
$( '#dragoMetadata' ).prepend( pre );

if( json.response ) {
displayData.push( data );
$( '#dragoMetadata' )
Expand Down Expand Up @@ -672,8 +672,10 @@ function generateRandomStyle( min, max ) {

function searchForAnnotations() {
var usernames = {};

$.each( tlv.layers, function( index, layer ) {

tlv.layers.forEach( function( layer ) {
console.log( layer );

$.ajax( {
url: '/annotation/imageAnnotations' + '?' + $.param( { imgId: layer.imageId } )
} )
Expand All @@ -693,28 +695,28 @@ function searchForAnnotations() {
}
}
};

data.forEach( function( annotation ) {
var geoJSON = {
id: 'annotation.' + annotation.id,
type: 'Feature',
properties: annotation
};

if( !usernames.hasOwnProperty( annotation.username ) ) {
usernames[ annotation.username ] = generateRandomStyle( 140, 255 );
}

geoJSON.properties.style = usernames[ annotation.username ];

geoJSON.properties.geometry_ortho = annotation.geometryOrtho;
geoJSON.properties.geometry_pixel = annotation.geometryPixel;
geoJSON.properties.image_id = annotation.imageId;
geoJSON.properties.saved = true;

collection.features.push( geoJSON );
} );

layer.annotations = collection;
if( collection.features.length > 0 ) {
try {
Expand All @@ -728,24 +730,23 @@ function searchForAnnotations() {
.fail( function( e ) {
console.error( e );
} );

refreshLayer();

return false;
} );
}

function bindWindowUnload() {
window.addEventListener( 'beforeunload', function( e ) {
e.preventDefault();

var unsaved = tlv.layers[ tlv.currentLayer ]
.annotationsLayer
.getSource()
.getFeatures()
.filter( function( feature ) {
return !feature.getProperties().saved;
} );

if( unsaved.length ) {
var message = 'Important: You have unsaved changes!';
e.returnValue = message;
Expand All @@ -757,9 +758,9 @@ function bindWindowUnload() {
var setupTimeLapseAnnotations = setupTimeLapse;
setupTimeLapse = function() {
setupTimeLapseAnnotations();

searchForAnnotations();
annotationsLayerToggle();

// annotationsLayerToggle();
bindWindowUnload();
};

0 comments on commit 69e3681

Please sign in to comment.