Skip to content

Commit

Permalink
1.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
djtfmartin committed Sep 4, 2019
1 parent bc5380e commit e182f22
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}
}

version "1.0.1-SNAPSHOT"
version "1.1"
group "au.org.ala.plugins.grails"

apply plugin:"eclipse"
Expand Down
17 changes: 8 additions & 9 deletions grails-app/assets/javascripts/ala-image-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ var imgvwr = {};
function initViewer(opts) {
$.ajax( {
dataType: 'jsonp',
url: imageServiceBaseUrl + "/ws/getImageInfo/" + _imageId,
url: imageServiceBaseUrl + "/ws/image/" + _imageId,
crossDomain: true
}).done(function(image) {
if (image.success) {
_createViewer(opts, image);
} else {
alert('Unable to load image from ' + imageServiceBaseUrl + "/ws/getImageInfo/" + _imageId)
alert('Unable to load image from ' + imageServiceBaseUrl + "/ws/image/" + _imageId)
}
}).fail(function(){
alert('Unable to load image from ' + imageServiceBaseUrl + "/ws/getImageInfo/" + _imageId)
alert('Unable to load image from ' + imageServiceBaseUrl + "/ws/image/" + _imageId)
});
}

Expand All @@ -288,7 +288,7 @@ var imgvwr = {};

_imageOverlays = new L.FeatureGroup();

if(opts.addCalibration) {
if (opts.addCalibration) {
measureControlOpts = {
mmPerPixel: image.mmPerPixel,
imageScaleFactor: _imageScaleFactor,
Expand All @@ -297,7 +297,7 @@ var imgvwr = {};
hideCalibration: !opts.addCalibration,
onCalibration: function (pixels) {
var opts = {
url: imageClientUrl + "/imageClient/calibrateImage?id=" + _imageId + "&pixelLength=" + Math.round(pixels),
url: imageClientUrl + "/imageClient/calibrateImage?id=" + _imageId + "&pixelLength=" + Math.round(pixels) + '&callback=calibrationCallback',
title: 'Calibrate image scale'
};
lib.showModal(opts);
Expand Down Expand Up @@ -349,7 +349,7 @@ var imgvwr = {};
},
onAdd: function (map) {
var container = L.DomUtil.create("div", "leaflet-bar");
var detailsUrl = imageServiceBaseUrl + "/image/details/" + _imageId;
var detailsUrl = imageServiceBaseUrl + "/image/" + _imageId;
$(container).html("<a href='" + detailsUrl + "' title='" + this.options.title + "'><span class='fa fa-external-link'></span></a>");
return container;
}
Expand Down Expand Up @@ -486,7 +486,7 @@ var imgvwr = {};
var height = maxy - miny;
var width = maxx - minx;

var url = imageClientUrl + "/imageClient/createSubImage?id=" + _imageId + "&x=" + minx + "&y=" + miny + "&width=" + width + "&height=" + height;
var url = imageClientUrl + "/imageClient/createSubImage?id=" + _imageId + "&x=" + minx + "&y=" + miny + "&width=" + width + "&height=" + height + "&callback=createSubImageCallback";
var opts = {
title: "Create subimage",
url: url,
Expand Down Expand Up @@ -914,7 +914,7 @@ var imgvwr = {};
feature.on("click", function(e) {
var imageId = e.target.options.imageId;
if (imageId) {
window.location = imageServiceBaseUrl + "/image/details?imageId=" + imageId;
window.location = imageServiceBaseUrl + "/image/" + imageId;
}
});

Expand Down Expand Up @@ -1048,7 +1048,6 @@ var imgvwr = {};
html += '</div>';
html += '</div>';
$("body").append(html);
console.log(opts.url);
$("#modal_content_" + opts.id).load(opts.url);
$("#" + opts.id).modal('show');
};
Expand Down
21 changes: 17 additions & 4 deletions grails-app/assets/vendor/leaflet/leaflet.measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ L.Control.Measure = L.Control.extend({
return container;
},
_calibrate : function(e) {
this.mmPerPixel = this.onCalibration(this._pixelDistance);
this._toggleMeasure();
console.log('_calibrate = ' + this.lastMeasurement);
this.mmPerPixel = this.onCalibration(this.lastMeasurement);
// this._toggleMeasure();
},
_disableCalibration: function() {
$(".btnCalibrateMMPerPixels").addClass("leaflet-disabled");
Expand Down Expand Up @@ -50,6 +51,8 @@ L.Control.Measure = L.Control.extend({
L.DomUtil.removeClass(this._container, 'leaflet-control-measure-on');
this._stopMeasuring();
}

console.log('_toggleMeasure ' + this._pixelDistance);
},

_startMeasuring: function() {
Expand All @@ -69,6 +72,7 @@ L.Control.Measure = L.Control.extend({
this._layerPaint = L.layerGroup().addTo(this._map);
}

console.log('_startMeasuring ' + this._pixelDistance);
},

_stopMeasuring: function() {
Expand All @@ -91,6 +95,11 @@ L.Control.Measure = L.Control.extend({
this._restartPath();

this._disableCalibration();

console.log('_stopMeasuring ' + this._pixelDistance);
if( this._pixelDistance > 0) {
this.lastMeasurement = this._pixelDistance;
}
},

_mouseMove: function(e) {
Expand Down Expand Up @@ -188,6 +197,9 @@ L.Control.Measure = L.Control.extend({
// Save current location as last location
this._lastPoint = e.latlng;
this._lastPixelPoint = this._getPixelPoint(e.latlng);

console.log('_mouseClick ' + this._pixelDistance);
this.lastMeasurement = this._pixelDistance;
},

_finishPath: function() {
Expand Down Expand Up @@ -283,14 +295,15 @@ L.Control.Measure = L.Control.extend({
};
},
mmPerPixel: 0,
lastMeasurement:0,
imageScaleFactor: 0,
imageHeight: 0,
imageWidth: 0,
hideCalibration: false,
onCalibration: function(pixelDistance) {
return 0;
console.log('onCalibration = ' + this._pixelDistance);
return this._pixelDistance;
}

});

L.Map.mergeOptions({
Expand Down
9 changes: 6 additions & 3 deletions grails-app/views/imageClient/calibrateImage.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<div>
<div class="control-group">
<div class="controls">
<g:textField class="input-small" name="pixelLength" value="${params.pixelLength}"/> pixels =
<g:textField class="input-small" name="mmLength" value="" />
<g:textField class="form-control" name="pixelLength" value="${params.pixelLength}"/> pixels =
<g:textField class="form-control" name="mmLength" value="" />
<g:select name="units" class="input-small" from="${['mm','inches', 'metres','feet']}" value="mm"/>
</div>
</div>
Expand All @@ -16,7 +16,7 @@
<div class="control-group">
<div class="controls">
<button class="btn btn-primary" id="btnCalibrateImageScale">Save</button>
<button class="btn" id="btnCancelCalibrateImageScale">Cancel</button>
<button class="btn btn-default" id="btnCancelCalibrateImageScale">Cancel</button>
</div>
</div>
<script type="text/javascript">
Expand All @@ -33,6 +33,9 @@
$.ajax(imgvwr.getImageServiceBaseUrl() + "/ws/calibrateImageScale?imageId=${params.id}&units=${params.units}&pixelLength=" + pixelLength + "&userId=${userId}&actualLength=" + actualLength).done(function(data) {
imgvwr.setPixelLength(data.pixelsPerMM);
imgvwr.hideModal();
<g:if test="${params.callback}">
${params.callback}(data.pixelsPerMM);
</g:if>
});
});
</script>
Expand Down
57 changes: 39 additions & 18 deletions grails-app/views/imageClient/createSubImage.gsp
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<div class="form-horizontal">
<form>
<label for="description">
Description
</label>
<input id="description" type="text" class="form-control input-xlarge" name="description" value=""/>
</form>
<div>
<p id="mandatoryFieldsRequest">Please supply a title and description</p>
<div>
<form>
<div class="form-group">
<label for="title">
Title*
</label>
<input id="title" type="text" class="form-control input-xlarge" name="title" value=""/>
</div>

<div class="control-group">
<div class="controls">
<div class="form-group">
<label for="description">
Description*
</label>
<input id="description" type="text" class="form-control input-xlarge" name="description" value=""/>
</div>
</form>
<div class="control-group">
<btn class="btn btn-default" id="btnCancelSubimage">Cancel</btn>
<btn class="btn btn-primary" id="btnCreateSubimage2">Create subimage</btn>
</div>
Expand All @@ -21,15 +30,27 @@
$("#btnCreateSubimage2").click(function(e) {
e.preventDefault();
var url = imgvwr.getImageServiceBaseUrl() + "/ws/createSubimage?id=${params.id}&x=${params.x}&y=${params.y}&width=${params.width}&height=${params.height}&userId=${userId}&description=" + encodeURIComponent($('#description').val());
$.ajax(url).done(function(results) {
if (results.success) {
imgvwr.hideModal();
imgvwr.showSubimages();
} else {
alert("Failed to create sub image: " + results.message);
}
});
if ($('#description').val().length == 0 || $('#title').val().length == 0){
$('#mandatoryFieldsRequest').addClass('alert alert-danger');
} else {
var url = imgvwr.getImageServiceBaseUrl() + "/ws/createSubimage?id=${params.id}&x=${params.x}&y=${params.y}&width=${params.width}&height=${params.height}&userId=${userId}&description=" + encodeURIComponent($('#description').val()) + "&title=" + encodeURIComponent($('#title').val());
$.ajax(url).done(function (results) {
if (results.success) {
imgvwr.hideModal();
imgvwr.showSubimages();
<g:if test="${params.callback}">
${params.callback}();
</g:if>
} else {
alert("Failed to create sub image: " + results.message);
}
}).fail(function(data){
$('#mandatoryFieldsRequest').html('Please re-login to create a subimage');
$('#mandatoryFieldsRequest').addClass('alert alert-danger');
});
}
});
</script>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ImagesClientPluginGrailsPlugin extends Plugin {

Closure doWithSpring() {
{ ->
println("ImagesClientPluginGrailsPlugin starting")
// println("ImagesClientPluginGrailsPlugin starting")
}
}

Expand Down

0 comments on commit e182f22

Please sign in to comment.