X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=trash%2Fsliceview.py;h=7cbb4f9ec469ce872d24313d8de442c55cbfc028;hb=f2cd8cf9eeefd7c1d546ee41d7862ee9016a20c4;hp=4f4202df6cec1fc70af716199e82ae680f31df56;hpb=64be7f204b6f00244951821884a37fb74b3bbe36;p=myslice.git diff --git a/trash/sliceview.py b/trash/sliceview.py index 4f4202df..7cbb4f9e 100644 --- a/trash/sliceview.py +++ b/trash/sliceview.py @@ -8,12 +8,16 @@ from django.contrib.auth.decorators import login_required from unfold.page import Page from manifold.manifoldquery import ManifoldQuery +from plugins.raw.raw import Raw from plugins.stack.stack import Stack from plugins.tabs.tabs import Tabs -from plugins.hazelnut.hazelnut import Hazelnut from plugins.lists.slicelist import SliceList +from plugins.hazelnut.hazelnut import Hazelnut +from plugins.googlemap.googlemap import GoogleMap +from plugins.senslabmap.senslabmap import SensLabMap from plugins.querycode.querycode import QueryCode from plugins.quickfilter.quickfilter import QuickFilter +from plugins.messages.messages import Messages from myslice.viewutils import quickfilter_criterias @@ -29,28 +33,35 @@ def slice_view (request, slicename=tmp_default_slice): main_query = ManifoldQuery (action='get', subject='resource', timestamp='latest', - fields=['hrn','hostname'], + fields=['network','type','hrn','hostname'], filters= [ [ 'slice_hrn', '=', slicename, ] ], - # xxx filter : should filter on the slices the logged user can see - # we don't have the user's hrn yet - # in addition this currently returns all slices anyways - # filter = ... - sort='slice_hrn', ) page.enqueue_query (main_query) main_plugin = Stack ( page=page, - title="global container", + title="Slice view for %s"%slicename, + domid='thestack', togglable=False, - sons=[Tabs ( + sons=[ + Messages ( + page=page, + title="Runtime messages", + domid="msgs-pre", + levels="ALL", + ), + Tabs ( page=page, - title="different angles", - active_domid='with-checkboxes', + title="2 tabs : w/ and w/o checkboxes", + domid='thetabs', + # active_domid='checkboxes', + active_domid='gmap', sons=[ Hazelnut ( page=page, title='a sample and simple hazelnut', + domid='simple', + # tab's sons preferably turn this off togglable=False, # this is the query at the core of the slice list query=main_query, @@ -58,53 +69,95 @@ def slice_view (request, slicename=tmp_default_slice): Hazelnut ( page=page, title='with checkboxes', - domid='with-checkboxes', + domid='checkboxes', + # tab's sons preferably turn this off togglable=False, - checkboxes=True, # this is the query at the core of the slice list query=main_query, + checkboxes=True, + datatables_options = { + # for now we turn off sorting on the checkboxes columns this way + # this of course should be automatic in hazelnut + 'aoColumns' : [ None, None, None, None, {'bSortable': False} ], + 'iDisplayLength' : 25, + 'bLengthChange' : True, + }, + ), + GoogleMap ( + page=page, + title='geographic view', + domid='gmap', + # tab's sons preferably turn this off + togglable=False, + query=main_query, + # center on Paris + latitude=49., + longitude=2.2, + zoom=3, + ), + Raw ( +# SensLabMap ( + page=page, + title='3D view (disabled)', + domid='smap', +# # tab's sons preferably turn this off + togglable=False, +# query=main_query, + html="""

+Thierry: I am commeting off the use of which, + although rudimentarily ported to the django framework, +causes a weird behaviour especially wrt scrolling. +On my Mac any longer +if I keep this active, so for now it's disabled +

""", ), ]), - QueryCode ( + Hazelnut ( + page=page, + title='a hazelnut not in tabs', + domid='standalone', + # this is the query at the core of the slice list + query=main_query, + columns=['hrn','hostname'], + ), + # you don't *have to* set a domid, but if you plan on using toggled=persistent then it's required + # because domid is the key for storing toggle status in the browser + QueryCode ( page=page, - title='xmlrpc code', + title='xmlrpc code (toggled=False)', query=main_query, +# domid='xmlrpc', toggled=False, ), + QuickFilter ( + page=page, + title="QuickFilter - requires metadata (toggled=False)", + criterias=quickfilter_criterias, + domid='filters', + toggled=False, + ), + Messages ( + page=page, + title="Runtime messages (again)", + domid="msgs-post", + ) ]) - # variables that will get passed to the view-plugin.html template + # variables that will get passed to the view-unfold1.html template template_env = {} - # define 'unfold1_main' to the template engine + # define 'unfold1_main' to the template engine - the main contents template_env [ 'unfold1_main' ] = main_plugin.render(request) # more general variables expected in the template - template_env [ 'title' ] = 'Test view for hazelnut' + template_env [ 'title' ] = 'Test view that combines various plugins' # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items('slice', request) # so we can sho who is logged template_env [ 'username' ] = the_user (request) -### # ########## add another plugin with the same request, on the RHS pane -### # will show up in the right-hand side area named 'related' -### related_plugin = SliceList ( -### page=page, -### title='Same request, other layout', -### domid='sidelist', -### with_datatables=True, -### header='paginated main', -### # share the query -### query=main_query, -### ) -### # likewise but on the side view -### template_env [ 'unfold1_margin' ] = related_plugin.render (request) -### -### # add our own css in the mix -### page.add_css_files ( 'css/hazelnut.css') - # don't forget to run the requests - page.exec_queue_asynchroneously () + page.expose_queries () # xxx create another plugin with the same query and a different layout (with_datatables) # show that it worls as expected, one single api call to backend and 2 refreshed views @@ -113,5 +166,6 @@ def slice_view (request, slicename=tmp_default_slice): # define {js,css}_{files,chunks} prelude_env = page.prelude_env() template_env.update(prelude_env) - return render_to_response ('view-plugin.html',template_env, + result=render_to_response ('view-unfold1.html',template_env, context_instance=RequestContext(request)) + return result