Skip to content

Commit

Permalink
Use webclient mapr_extension instead of overwriting right_plugin.gene…
Browse files Browse the repository at this point in the history
…ral.js.html
  • Loading branch information
will-moore committed Dec 9, 2022
1 parent bb93f49 commit 9ff9a7c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@


<script type="text/javascript">
alert("mapr lives!")
/**
* This script is included in the main containers.html page as well as the container_tags.html and public.html pages,
* adding itself as a selection listener to the jsTree in each case.
Expand Down Expand Up @@ -151,140 +152,4 @@
}
};



$(function () {

$("#annotation_tabs").tabs({cache: true, disabled: true});
var $metadata_general = $("#metadata_general");
var general_tab_index = 0;

// make sure details are ALWAYS opened
OME.setPaneExpanded('details', true);
// make sure maps are ALWAYS opened
OME.setPaneExpanded('maps', true);

// this is called on change in jstree selection, or switching tabs
var update_metadata_general_tab = function() {
var selected = $("body").data("selected_objects.ome");

var prefix = '{% url 'webindex' %}';

if(selected.length == 0) {
return;
}
if (selected.length > 1) {
// handle batch annotation...
var productListQuery = new Array();
var well_index;
for (var i=0; i<selected.length; i++) {
productListQuery[i] = selected[i]["id"].replace("-","=");
well_index = well_index || selected[i]["index"];
}
var query = '{% url 'batch_annotate' %}'+"?"+productListQuery.join("&");
if (well_index) {
query += "&index=" + well_index;
}
// Load right hand panel...
$.ajax({
url: query,
dataType: "html",
// Need to check that the selected objects haven't changed during AJAX call...
success: function(data) {
var selected_ids = [], i,
selected_data = $("body").data("selected_objects.ome");
for(i=0; i<selected_data.length; i++) {
selected_ids.push(selected_data[i].id);
}
var oids = $(data).filter("#object-ids").text().split("|");
// need to compare two arrays of strings...
selected_ids.sort();
oids.sort();
for(i=0;i<oids.length; i++) {
if (oids[i] !== selected_ids[i]) {
return; // any differences, don't load panel.
}
}
$metadata_general.html(data);
}
});

} else {
$("#annotation_tabs").tabs("enable", general_tab_index); // always want metadata_general enabled
var url = null;
var data = {};
//var oid = selected.attr('id');
//var orel = selected[0].attr('rel');
var oid = selected[0]["id"];
var orel = oid.split("-")[0];
if (typeof oid =="undefined" || oid==false) return;

// handle loading of GENERAL tab
if ($metadata_general.is(":visible") && $metadata_general.is(":empty")) {
// orphaned
if (oid.indexOf("orphaned")>=0) {
$metadata_general.html('<div class="right_tab_inner"><p class="description">{{ ui.orphans.description }}</p></div>');
//return;
// experimenter
} else if (oid.indexOf("experimenter")>=0) {
//$metadata_general.html('<p>'+selected.children().eq(1).text()+'</p>');
} else if (orel.indexOf("map")>=0) {
var map_prefix = '{% url "maprindex" %}';
url = map_prefix+'metadata_details/{{ menu }}/';
data = {'value': oid.split(/-(.+)/)[1]};
// everything else
} else {
if(orel=="image") {
if (selected[0]["shareId"]) {
url = prefix+'metadata_details/'+orel+'/'+oid.split("-")[1]+'/'+selected[0]["shareId"]+'/';
} else {
url = prefix+'metadata_details/'+orel+'/'+oid.split("-")[1]+'/';
}
} else if(orel=="well"){
var well_index = selected[0]["index"] || 0;
url = '{% url "load_metadata_details" %}well/'+oid.split('-')[1]+'/';
data = {'index': well_index};
} else {
url = prefix+'metadata_details/'+orel+'/'+oid.split("-")[1]+'/';
}
}
if (url !== null) {
// We are effectively doing $metadata_general.load(url) BUT we need to check that selection
// is still correct (hasn't changed during the AJAX call);
$.ajax({
url: url,
data: $.param(data),
dataType: "html",
success: function(data) {
var selected_id = $("body").data("selected_objects.ome")[0].id;
var oid = $(data).filter("#object-id").text();
if (oid === selected_id) {
$metadata_general.html(data);
}
}
});
}
}
}
}

// update tabs when tabs switch
$("#annotation_tabs").on( "tabsactivate", function(event, ui){
// we get a "tabsactivate" event, but need to check if 'this' tab was chosen...
if (ui.newTab.index() == general_tab_index) {
// sometimes this doesn't get shown until too late, so the :visible check above failed
$metadata_general.show();
update_metadata_general_tab();
}
});

// on selection change, clear tab contents then update
$("body").on("selection_change.ome", function(event) {
// clear contents of panel
$("#metadata_general").empty();

update_metadata_general_tab(); // update
});

});
</script>
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests
omero-web[redis]>=5.14.0
omero-web[redis]>=5.16.0

0 comments on commit 9ff9a7c

Please sign in to comment.