16
16
#
17
17
18
18
from django .shortcuts import render
19
+ from django .http import HttpResponseRedirect
19
20
20
21
from omeroweb .decorators import login_required
21
22
@@ -37,9 +38,6 @@ def vitessce_index(request, conn=None, **kwargs):
37
38
38
39
@login_required ()
39
40
def vitessce_panel (request , obj_type , obj_id , conn = None , ** kwargs ):
40
-
41
- # Generate an openlink space
42
-
43
41
# Get all .json.txt attachements and generate links for them
44
42
# This way the config files can be served as text
45
43
# to the config argument of the vitessce webapp
@@ -60,3 +58,37 @@ def vitessce_panel(request, obj_type, obj_id, conn=None, **kwargs):
60
58
61
59
# Render the html template and return the http response
62
60
return render (request , "omero_vitessce/vitessce_panel.html" , context )
61
+
62
+
63
+ @login_required ()
64
+ def vitessce_open (request , conn = None , ** kwargs ):
65
+ # Get the first .json.txt attachement and generate a link for it
66
+ # This way the config files can be served as text
67
+ # If no config files are present send to the panel html to ask to make one
68
+ if request .GET .get ("project" ) is not None :
69
+ obj_type = "project"
70
+ obj_id = int (request .GET .get ("project" ))
71
+ elif request .GET .get ("dataset" ) is not None :
72
+ obj_type = "dataset"
73
+ obj_id = int (request .GET .get ("dataset" ))
74
+ elif request .GET .get ("image" ) is not None :
75
+ obj_type = "image"
76
+ obj_id = int (request .GET .get ("image" ))
77
+ else :
78
+ context = {"json_configs" : dict (),
79
+ "obj_type" : obj_type , "obj_id" : obj_id }
80
+ return render (request , "omero_vitessce/vitessce_panel.html" , context )
81
+
82
+ obj = conn .getObject (obj_type , obj_id )
83
+ files = [i for i in obj .listAnnotations () if i .OMERO_TYPE ().NAME ==
84
+ "ome.model.annotations.FileAnnotation_name" ]
85
+ config_ids = [i .getId () for i in files
86
+ if i .getFileName ().endswith (".json.txt" )]
87
+ if len (config_ids ) > 0 :
88
+ vitessce_url = SERVER + "/omero_vitessce/?config=" + SERVER + \
89
+ "/webclient/annotation/" + str (config_ids [0 ])
90
+ return HttpResponseRedirect (vitessce_url )
91
+ else :
92
+ context = {"json_configs" : dict (),
93
+ "obj_type" : obj_type , "obj_id" : obj_id }
94
+ return render (request , "omero_vitessce/vitessce_panel.html" , context )
0 commit comments