1 # Create your views here.
3 from django.template import RequestContext
4 from django.shortcuts import render_to_response
6 from django.contrib.auth.decorators import login_required
8 from unfold.page import Page
9 from manifold.manifoldquery import ManifoldQuery
11 from plugins.raw.raw import Raw
12 from plugins.stack.stack import Stack
13 from plugins.tabs.tabs import Tabs
14 from plugins.lists.slicelist import SliceList
15 from plugins.hazelnut.hazelnut import Hazelnut
16 from plugins.googlemap.googlemap import GoogleMap
17 from plugins.senslabmap.senslabmap import SensLabMap
18 from plugins.querycode.querycode import QueryCode
19 from plugins.quickfilter.quickfilter import QuickFilter
20 from plugins.messages.messages import Messages
22 from myslice.viewutils import quickfilter_criterias
24 from myslice.viewutils import topmenu_items, the_user
26 tmp_default_slice='ple.inria.sfatest'
29 def slice_view (request, slicename=tmp_default_slice):
33 main_query = ManifoldQuery (action='get',
36 fields=['network','type','hrn','hostname'],
37 filters= [ [ 'slice_hrn', '=', slicename, ] ],
39 page.enqueue_query (main_query)
43 title="Slice view for %s"%slicename,
49 title="Runtime messages",
55 title="2 tabs : w/ and w/o checkboxes",
57 # active_domid='checkboxes',
62 title='a sample and simple hazelnut',
64 # tab's sons preferably turn this off
66 # this is the query at the core of the slice list
71 title='with checkboxes',
73 # tab's sons preferably turn this off
75 # this is the query at the core of the slice list
78 datatables_options = {
79 # for now we turn off sorting on the checkboxes columns this way
80 # this of course should be automatic in hazelnut
81 'aoColumns' : [ None, None, None, None, {'bSortable': False} ],
82 'iDisplayLength' : 25,
83 'bLengthChange' : True,
88 title='geographic view',
90 # tab's sons preferably turn this off
97 title='3D view (disabled)',
99 # # tab's sons preferably turn this off
102 html="""<p class='well'>
103 Thierry: I am commeting off the use of <button class="btn btn-danger">SensLabMap</button> which,
104 although rudimentarily ported to the django framework,
105 causes a weird behaviour especially wrt scrolling.
106 On my Mac <button class="btn btn-warning"> I cannot use the mouse to scroll</button> any longer
107 if I keep this active, so for now it's disabled
115 # this is the query at the core of the slice list
117 columns=['hrn','hostname'],
119 # you don't *have to* set a domid, but if you plan on using toggled=persistent then it's required
120 # because domid is the key for storing toggle status in the browser
123 title='xmlrpc code (toggled=False)',
130 title="QuickFilter - requires metadata (toggled=False)",
131 criterias=quickfilter_criterias,
137 title="Runtime messages (again)",
142 # variables that will get passed to the view-unfold1.html template
145 # define 'unfold1_main' to the template engine - the main contents
146 template_env [ 'unfold1_main' ] = main_plugin.render(request)
148 # more general variables expected in the template
149 template_env [ 'title' ] = 'Test view that combines various plugins'
150 # the menu items on the top
151 template_env [ 'topmenu_items' ] = topmenu_items('slice', request)
152 # so we can sho who is logged
153 template_env [ 'username' ] = the_user (request)
155 # don't forget to run the requests
156 page.expose_queries ()
158 # xxx create another plugin with the same query and a different layout (with_datatables)
159 # show that it worls as expected, one single api call to backend and 2 refreshed views
161 # the prelude object in page contains a summary of the requirements() for all plugins
162 # define {js,css}_{files,chunks}
163 prelude_env = page.prelude_env()
164 template_env.update(prelude_env)
165 result=render_to_response ('view-unfold1.html',template_env,
166 context_instance=RequestContext(request))