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

Inherit all ann #602

Open
wants to merge 10 commits into
base: master
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
1 change: 0 additions & 1 deletion omeroweb/webclient/static/webclient/css/dusty.css
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ button::-moz-focus-inner {

.tag_annotation_wrapper .tag, .imagefilter .tag {
display:inline-block;
float:left;
margin:1px 3px;
position:relative;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ var CommentsPane = function CommentsPane($element, opts) {
},
});

var compareParentName = function(a, b){
if (!a.parent.name || !b.parent.name) {
return 1;
}
return a.parent.name.toLowerCase() > b.parent.name.toLowerCase() ? 1 : -1;
};


this.render = function render() {

Expand All @@ -95,7 +102,7 @@ var CommentsPane = function CommentsPane($element, opts) {
});
request = request.join("&");

$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?type=comment&" + request, function(data){
$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?parents=true&type=comment&" + request, function(data){


// manipulate data...
Expand All @@ -115,24 +122,137 @@ var CommentsPane = function CommentsPane($element, opts) {
return ann;
});

var inh_anns = []
if (data.hasOwnProperty("parents")){
inh_anns = data.parents.annotations.map(function(ann) {
ann.owner = experimenters[ann.owner.id];
if (ann.link && ann.link.owner) {
ann.link.owner = experimenters[ann.link.owner.id];
}
ann.addedBy = [ann.link.owner.id];
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
children = data.parents.lineage[class_][id_];
class_ = children[0].class;
ann.childClass = class_.substring(0, class_.length - 1);
ann.childNames = [];
if (children[0].hasOwnProperty("name")){
for(j = 0; j < children.length; j++){
ann.childNames.push(children[j].name);
}
}
return ann;
});
}

// If we are batch annotating multiple objects, we show a summary of each ann
if (objects.length > 1) {

// Map ann.id to summary for that ann
var summary = {};
anns.forEach(function(ann){
var annId = ann.id,
linkOwner = ann.link.owner.id;
if (summary[annId] === undefined) {
ann.canRemove = false;
ann.canRemoveCount = 0;
ann.links = [];
ann.addedBy = [];
summary[annId] = ann;
}
// Add link to list...
var l = ann.link;
// slice parent class 'ProjectI' > 'Project'
l.parent.class = l.parent.class.slice(0, -1);
summary[annId].links.push(l);

// ...and summarise other properties on the ann
if (l.permissions.canDelete) {
summary[annId].canRemoveCount += 1;
}
summary[annId].canRemove = summary[annId].canRemove || l.permissions.canDelete;
if (summary[annId].addedBy.indexOf(linkOwner) === -1) {
summary[annId].addedBy.push(linkOwner);
}
});

// convert summary back to list of 'anns'
anns = [];
for (var annId in summary) {
if (summary.hasOwnProperty(annId)) {
summary[annId].links.sort(compareParentName);
anns.push(summary[annId]);
}
}

// Map ann.id to summary for that ann
summary = {};
inh_anns.forEach(function(ann){
var annId = ann.id,
linkOwner = ann.link.owner.id;
if (summary[annId] === undefined) {
ann.canRemove = false;
ann.canRemoveCount = 0;
ann.links = [];
ann.addedBy = [];
summary[annId] = ann;
}
// Add link to list...
var l = ann.link;
// slice parent class 'ProjectI' > 'Project'
l.parent.class = l.parent.class.slice(0, -1);
summary[annId].links.push(l);

// ...and summarise other properties on the ann
if (summary[annId].addedBy.indexOf(linkOwner) === -1) {
summary[annId].addedBy.push(linkOwner);
}
for(j = 0; j < ann.childNames; j++){
summary[annId].childNames.push(ann.childNames[j]);
}
});

// convert summary back to list of 'anns'
inh_anns = [];
for (var annId in summary) {
if (summary.hasOwnProperty(annId)) {
summary[annId].links.sort(compareParentName);
inh_anns.push(summary[annId]);
}
}
}

// Show most recent comments at the top
anns.sort(function(a, b) {
return a.date < b.date ? 1 : -1;
});

// Remove duplicates (same comment on multiple objects)
anns = anns.filter(function(ann, idx){
// already sorted, so just compare with last item
return (idx === 0 || anns[idx - 1].id !== ann.id);
hierarchy = {"ProjectI":0, "DatasetI":1, "ScreenI":2, "PlateI":3, "PlateAcquisitionI":4, "WellI":5}
inh_anns.sort(function(a, b) {
if (hierarchy[a.link.parent.class] != hierarchy[b.link.parent.class]){
return hierarchy[a.link.parent.class] > hierarchy[b.link.parent.class] ? 1 : -1;
} else{
return a.date < b.date ? 1 : -1;
}
});

// Update html...
var html = "";
if (anns.length > 0) {
html = commentsTempl({'anns': anns,
'static': WEBCLIENT.URLS.static_webclient,
'webindex': WEBCLIENT.URLS.webindex});
'webindex': WEBCLIENT.URLS.webindex,
'userId': WEBCLIENT.USER.id,
'isInherited': false});
}
if (inh_anns.length > 0) {
html = html + commentsTempl({'anns': inh_anns,
'static': WEBCLIENT.URLS.static_webclient,
'webindex': WEBCLIENT.URLS.webindex,
'userId': WEBCLIENT.USER.id,
'isInherited': true});
}


$("#comments_spinner").hide();
$comments_container.html(html);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var FileAnnsPane = function FileAnnsPane($element, opts) {
});
request = request.join("&");

$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?type=file&" + request, function(data){
$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?parents=true&type=file&" + request, function(data){

var checkboxesAreVisible = $(
"#fileanns_container input[type=checkbox]:visible"
Expand All @@ -170,11 +170,36 @@ var FileAnnsPane = function FileAnnsPane($element, opts) {
// Don't show companion files
anns = anns.filter(isNotCompanionFile);


// If we are batch annotating multiple objects, we show a summary of each tag
var inh_anns = []
if (data.hasOwnProperty("parents")){
inh_anns = data.parents.annotations.map(function(ann) {
ann.owner = experimenters[ann.owner.id];
if (ann.link && ann.link.owner) {
ann.link.owner = experimenters[ann.link.owner.id];
}
ann.addedBy = [ann.link.owner.id];
ann.file.size = ann.file.size !== null ? ann.file.size.filesizeformat() : "";
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
children = data.parents.lineage[class_][id_];
class_ = children[0].class;
ann.childClass = class_.substring(0, class_.length - 1);
ann.childNames = [];
if (children[0].hasOwnProperty("name")){
for(j = 0; j < children.length; j++){
ann.childNames.push(children[j].name);
}
}
return ann;
});
inh_anns = inh_anns.filter(isNotCompanionFile);
}


// If we are batch annotating multiple objects, we show a summary of each ann
if (objects.length > 1) {

// Map tag.id to summary for that tag
// Map ann.id to summary for that ann
var summary = {};
anns.forEach(function(ann){
var annId = ann.id,
Expand Down Expand Up @@ -210,14 +235,57 @@ var FileAnnsPane = function FileAnnsPane($element, opts) {
anns.push(summary[annId]);
}
}

// Map ann.id to summary for that ann
summary = {};
inh_anns.forEach(function(ann){
var annId = ann.id,
linkOwner = ann.link.owner.id;
if (summary[annId] === undefined) {
ann.canRemove = false;
ann.canRemoveCount = 0;
ann.links = [];
ann.addedBy = [];
summary[annId] = ann;
}
// Add link to list...
var l = ann.link;
// slice parent class 'ProjectI' > 'Project'
l.parent.class = l.parent.class.slice(0, -1);
summary[annId].links.push(l);

// ...and summarise other properties on the ann
if (summary[annId].addedBy.indexOf(linkOwner) === -1) {
summary[annId].addedBy.push(linkOwner);
}
for(j = 0; j < ann.childNames; j++){
summary[annId].childNames.push(ann.childNames[j]);
}
});

// convert summary back to list of 'anns'
inh_anns = [];
for (var annId in summary) {
if (summary.hasOwnProperty(annId)) {
summary[annId].links.sort(compareParentName);
inh_anns.push(summary[annId]);
}
}
}

// Update html...
var html = "";
if (anns.length > 0) {
html = filesTempl({'anns': anns,
'webindex': WEBCLIENT.URLS.webindex,
'userId': WEBCLIENT.USER.id});
'userId': WEBCLIENT.USER.id,
'isInherited': false});
}
if (inh_anns.length > 0) {
html = html + filesTempl({'anns': inh_anns,
'webindex': WEBCLIENT.URLS.webindex,
'userId': WEBCLIENT.USER.id,
'isInherited': true});
}
$fileanns_container.html(html);

Expand All @@ -228,7 +296,7 @@ var FileAnnsPane = function FileAnnsPane($element, opts) {
}
$(".tooltip", $fileanns_container).tooltip_init();
});

}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ var MapAnnsPane = function MapAnnsPane($element, opts) {
'showTableHead': false, 'showNs': false, 'clientMapAnn': true, 'showParent': showParent});
html = html + mapAnnsTempl({'anns': map_annotations, 'isInherited': false,
'showTableHead': false, 'showNs': true, 'clientMapAnn': false, 'showParent': showParent});
html = html + mapAnnsTempl({'anns': inh_map_annotations, 'isInherited': true,
'showTableHead': false, 'showNs': true, 'clientMapAnn': false, 'showParent': showParent});
if (inh_map_annotations.length > 0) {
html = html + mapAnnsTempl({'anns': inh_map_annotations, 'isInherited': true,
'showTableHead': false, 'showNs': true, 'clientMapAnn': false, 'showParent': showParent});
}
$mapAnnContainer.html(html);

// re-use the ajaxdata to set Object IDS data on the parent container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,37 @@ var RatingsPane = function RatingsPane($element, opts) {

$("#ratings_spinner").show();

$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?type=rating&" + request, function(data){
$.getJSON(WEBCLIENT.URLS.webindex + "api/annotations/?parents=true&type=rating&" + request, function(data){

var experimenters = data.experimenters.reduce(function(prev, exp){
prev[exp.id + ""] = exp;
return prev;
}, {});

var anns = data.annotations;
var inh_anns = [];
if (data.hasOwnProperty("parents")){
inh_anns = data.parents.annotations.map(function(ann) {
ann.owner = experimenters[ann.owner.id];
if (ann.link && ann.link.owner) {
ann.link.owner = experimenters[ann.link.owner.id];
}
ann.addedBy = [ann.link.owner.id];
let class_ = ann.link.parent.class;
let id_ = '' + ann.link.parent.id;
children = data.parents.lineage[class_][id_];
class_ = children[0].class;
ann.childClass = class_.substring(0, class_.length - 1);
ann.childNames = [];
if (children[0].hasOwnProperty("name")){
for(j = 0; j < children.length; j++){
ann.childNames.push(children[j].name);
}
}
return ann;
});
}

var sum = anns.reduce(function(prev, ann){
return prev + ann.longValue;
}, 0);
Expand All @@ -112,7 +140,8 @@ var RatingsPane = function RatingsPane($element, opts) {
'canAnnotate': canAnnotate,
'average': average,
'count': anns.length,
'static': WEBCLIENT.URLS.static_webclient});
'static': WEBCLIENT.URLS.static_webclient,
'isInherited': false});
$("#ratings_spinner").hide();
$rating_annotations.html(html);

Expand Down
Loading
Loading