From b5bbfabb7c002f4958f5908355d5026793fb4403 Mon Sep 17 00:00:00 2001 From: Tom-TBT Date: Sun, 16 Jun 2024 10:31:15 +0200 Subject: [PATCH 01/10] inherited comment --- .../ome.right_panel_comments_pane.js | 44 ++++++++++++++++++- .../annotations/comments_underscore.html | 23 +++++++--- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_comments_pane.js b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_comments_pane.js index b4c18f9671..e7bea06a42 100644 --- a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_comments_pane.js +++ b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_comments_pane.js @@ -95,7 +95,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... @@ -115,10 +115,41 @@ 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; + }); + } + // Show most recent comments at the top anns.sort(function(a, b) { return a.date < b.date ? 1 : -1; }); + 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; + } + }); // Remove duplicates (same comment on multiple objects) anns = anns.filter(function(ann, idx){ @@ -131,8 +162,17 @@ var CommentsPane = function CommentsPane($element, opts) { if (anns.length > 0) { html = commentsTempl({'anns': anns, 'static': WEBCLIENT.URLS.static_webclient, - 'webindex': WEBCLIENT.URLS.webindex}); + 'webindex': WEBCLIENT.URLS.webindex, + 'isInherited': false}); } + if (inh_anns.length > 0) { + html = html + commentsTempl({'anns': inh_anns, + 'static': WEBCLIENT.URLS.static_webclient, + 'webindex': WEBCLIENT.URLS.webindex, + 'isInherited': true}); + } + + $("#comments_spinner").hide(); $comments_container.html(html); diff --git a/omeroweb/webclient/templates/webclient/annotations/comments_underscore.html b/omeroweb/webclient/templates/webclient/annotations/comments_underscore.html index bdf030cef3..719959dd1a 100644 --- a/omeroweb/webclient/templates/webclient/annotations/comments_underscore.html +++ b/omeroweb/webclient/templates/webclient/annotations/comments_underscore.html @@ -1,3 +1,7 @@ +<% if (isInherited) { %> +

Inherited comments



+ <% } %> + <% _.each(anns, function(ann) { %>
@@ -12,11 +16,16 @@ <%- ann.owner.firstName %> <%- ann.owner.lastName %> - at - <% print(OME.formatDate(ann.link.date)) %> + <% if (isInherited) { %> + on + <%- ann.link.parent.class.substring(0, ann.link.parent.class.length - 1) %> <%- ann.link.parent.name.slice(0, 30) %> + <% } else { %> + at + <% print(OME.formatDate(ann.link.date)) %> + <% } %>
- <% if (ann.permissions.canDelete) { %> + <% if (ann.permissions.canDelete && !isInherited) { %> <%- ann.textValue %> - <% if (ann.ns || ann.description) { %> - <% } %> <% }) %> From 9fe5137da2efd5b3292c2ad003bf12b2e93bcdfc Mon Sep 17 00:00:00 2001 From: Tom-TBT Date: Sun, 16 Jun 2024 10:31:43 +0200 Subject: [PATCH 02/10] inherited file --- .../ome.right_panel_fileanns_pane.js | 80 +++++++++++++++++-- .../annotations/fileanns_underscore.html | 47 +++++++---- 2 files changed, 106 insertions(+), 21 deletions(-) diff --git a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_fileanns_pane.js b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_fileanns_pane.js index a823b96297..3e336a5f64 100644 --- a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_fileanns_pane.js +++ b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_fileanns_pane.js @@ -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" @@ -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, @@ -210,6 +235,42 @@ 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... @@ -217,7 +278,14 @@ var FileAnnsPane = function FileAnnsPane($element, opts) { 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); @@ -228,7 +296,7 @@ var FileAnnsPane = function FileAnnsPane($element, opts) { } $(".tooltip", $fileanns_container).tooltip_init(); }); - + } }; diff --git a/omeroweb/webclient/templates/webclient/annotations/fileanns_underscore.html b/omeroweb/webclient/templates/webclient/annotations/fileanns_underscore.html index 79edbb1948..eb9b6f578c 100644 --- a/omeroweb/webclient/templates/webclient/annotations/fileanns_underscore.html +++ b/omeroweb/webclient/templates/webclient/annotations/fileanns_underscore.html @@ -1,3 +1,6 @@ +<% if (isInherited) { %> +

Inherited attachements



+<% } %> <% _.each(anns, function(ann) { %>
  • <% }) %> + <% if (isInherited) { %> + Inherited by:
    + <% _.each(ann.childNames, function(cname) { %> +   <%- cname %>
    + <% }) %> + <% } %> <% } else { %> Annotation ID: <%- ann.id %>
    Owner: <%- ann.owner.firstName %> <%- ann.owner.lastName %>
    @@ -43,26 +52,34 @@
    Mimetype: <%- ann.file.mimetype %> <% } %>
    File ID: <%- ann.file.id %> + <% if (isInherited) { %> +
    Inherited by:
    + <% _.each(ann.childNames, function(cname) { %> +   <%- cname %>
    + <% }) %> + <% } %> <% } %> -
    - - <% if ((ann.ns && ann.ns === 'openmicroscopy.org/omero/bulk_annotations') || ann.file.mimetype == 'OMERO.tables' ){ %> -   - <% } %> - <% if (ann.link.permissions.canDelete) { %> - - <% } %> + <% if (!isInherited) { %> +
    + + <% if ((ann.ns && ann.ns === 'openmicroscopy.org/omero/bulk_annotations') || ann.file.mimetype == 'OMERO.tables' ){ %> +   + <% } %> + <% if (ann.link.permissions.canDelete) { %> + + <% } %> - <% if (ann.permissions.canDelete) { %> - × - <% } %> + <% if (ann.permissions.canDelete) { %> + × + <% } %> -
    +
    + <% } %>
  • <% }) %> From 86dd288b822da1253dfcd486bec85b45e0f6a1c7 Mon Sep 17 00:00:00 2001 From: Tom-TBT Date: Sun, 16 Jun 2024 10:32:23 +0200 Subject: [PATCH 03/10] mapann inherited section title --- .../webclient/javascript/ome.right_panel_mapanns_pane.js | 6 ++++-- .../templates/webclient/annotations/mapanns_underscore.html | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_mapanns_pane.js b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_mapanns_pane.js index 8fca4b09a1..fe1c1b7cc5 100644 --- a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_mapanns_pane.js +++ b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_mapanns_pane.js @@ -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 diff --git a/omeroweb/webclient/templates/webclient/annotations/mapanns_underscore.html b/omeroweb/webclient/templates/webclient/annotations/mapanns_underscore.html index 71f809b7aa..fd8c719b8b 100644 --- a/omeroweb/webclient/templates/webclient/annotations/mapanns_underscore.html +++ b/omeroweb/webclient/templates/webclient/annotations/mapanns_underscore.html @@ -1,3 +1,7 @@ +<% if (isInherited) { %> +

    Inherited key-value pairs



    +<% } %> + <% _.each(anns, function(ann) { %> From 4ad580d53be2abd8ec935fb00d6dfebe7a42d737 Mon Sep 17 00:00:00 2001 From: Tom-TBT Date: Sun, 16 Jun 2024 10:32:51 +0200 Subject: [PATCH 04/10] inherited rating --- .../ome.right_panel_ratings_pane.js | 49 ++++++++++++++++++- .../annotations/ratings_underscore.html | 4 ++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_ratings_pane.js b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_ratings_pane.js index 76c17b17f8..3302a77175 100644 --- a/omeroweb/webclient/static/webclient/javascript/ome.right_panel_ratings_pane.js +++ b/omeroweb/webclient/static/webclient/javascript/ome.right_panel_ratings_pane.js @@ -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); @@ -107,12 +135,29 @@ var RatingsPane = function RatingsPane($element, opts) { }); var average = Math.round(sum/anns.length); + var sum_inh = inh_anns.reduce(function(prev, ann){ + return prev + ann.longValue; + }, 0); + var myRatings_inh = inh_anns.filter(function(ann){ + return ann.owner.id == WEBCLIENT.USER.id; + }); + var average_inh = Math.round(sum_inh/inh_anns.length); + // Update html... var html = ratingsTempl({'anns': anns, 'canAnnotate': canAnnotate, 'average': average, 'count': anns.length, - 'static': WEBCLIENT.URLS.static_webclient}); + 'static': WEBCLIENT.URLS.static_webclient, + 'isInherited': false}); + if (inh_anns.length > 0) { + html = html + ratingsTempl({'anns': inh_anns, + 'canAnnotate': false, + 'average': average_inh, + 'count': inh_anns.length, + 'static': WEBCLIENT.URLS.static_webclient, + 'isInherited': true}); + } $("#ratings_spinner").hide(); $rating_annotations.html(html); diff --git a/omeroweb/webclient/templates/webclient/annotations/ratings_underscore.html b/omeroweb/webclient/templates/webclient/annotations/ratings_underscore.html index c6ff468f7b..21f37a4aa9 100644 --- a/omeroweb/webclient/templates/webclient/annotations/ratings_underscore.html +++ b/omeroweb/webclient/templates/webclient/annotations/ratings_underscore.html @@ -1,3 +1,7 @@ +<% if (isInherited) { %> +

    Inherited ratings



    +<% } %> +