Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into vite
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Feb 19, 2024
2 parents 9f07d81 + e87afd1 commit e159f51
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
17 changes: 15 additions & 2 deletions src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
else if (property === "h") property = "height";
else if (property === "rot") property = "rotation";


var x_symbol = this.get('pixel_size_x_symbol'),
z_symbol = this.get('pixel_size_z_symbol');
z_symbol = z_symbol ? z_symbol : x_symbol // Using x symbol when z not defined
Expand Down Expand Up @@ -1034,9 +1034,22 @@
var image_ids = this.map(function(s){return s.get('imageId')})
image_ids = "image=" + image_ids.join("&image=");
// TODO: Use /api/ when annotations is supported
var url = WEBINDEX_URL + "api/annotations/?type=tag&limit=1000&" + image_ids;
var url = WEBINDEX_URL + "api/annotations/?type=tag&parents=true&limit=1000&" + image_ids;
$.getJSON(url, function(data){
// Map {iid: {id: 'tag'}, {id: 'names'}}
if (data.hasOwnProperty('parents')){
data.parents.annotations.forEach(function(ann) {
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
let lineage = data.parents.lineage[class_][id_];
for(j = 0; j < lineage.length; j++){
// Unpacking the parent annoations for each image
let clone_ann = JSON.parse(JSON.stringify(ann));
clone_ann.link.parent.id = lineage[j].id;
data.annotations.push(clone_ann);
}
});
}
var imageTags = data.annotations.reduce(function(prev, t){
var iid = t.link.parent.id;
if (!prev[iid]) {
Expand Down
24 changes: 18 additions & 6 deletions src/js/views/labels_from_maps_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,27 @@ export var LabelFromMapsModal = Backbone.View.extend({
this.isLoading = true;
$('select', this.el).html("<option>Loading data...</option>");

var url = WEBINDEX_URL + "api/annotations/?type=map&image=";
var url = WEBINDEX_URL + "api/annotations/?type=map&parents=true&image=";
url += imageIds.join("&image=");

getJson(url).then(data => {
this.isLoading = false;
this.annotations = data.annotations;
this.render();
if (data.hasOwnProperty('parents')){
data.parents.annotations.forEach(function(ann) {
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
let lineage = data.parents.lineage[class_][id_];
for(let j = 0; j<lineage.length; j++){
// Unpacking the parent annoations for each image
let clone_ann = JSON.parse(JSON.stringify(ann));
clone_ann.link.parent.id = lineage[j].id;
data.annotations.push(clone_ann);
}
});
}
);
this.isLoading = false;
this.annotations = data.annotations;
this.render();
});
},

/**
Expand Down Expand Up @@ -163,7 +175,7 @@ export var LabelFromMapsModal = Backbone.View.extend({
}
}
keyList.sort(function(a, b) {
return (a.toUpperCase() < b.toUpperCase()) ? -1 : 1;
return (a.toUpperCase() < b.toUpperCase()) ? -1 : 1;
});

var html = keyList.map(function(key) {
Expand Down
3 changes: 2 additions & 1 deletion src/js/views/modal_views.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ import { hideModal } from "./util";
h_mm = Math.round(h_pixels * 25.4 / dpi);
}

if (orientation == 'horizontal' && size != 'mm') {
if (orientation == 'horizontal' && size != 'mm' && size != 'crop') {
var tmp = w_mm; w_mm = h_mm; h_mm = tmp;
tmp = w_pixels; w_pixels = h_pixels; h_pixels = tmp;
}
Expand Down Expand Up @@ -338,6 +338,7 @@ import { hideModal } from "./util";
sel.forEach(function(p) {
p.setId(self.newImg);
});
this.model.set('unsaved', true);

},

Expand Down

0 comments on commit e159f51

Please sign in to comment.