Пример #1
0
    def get_context_data(self, **kwargs):
        # We might have slices on different registries with different user accounts 
        # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things
        # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn

        #messages.info(self.request, 'You have logged in')
        page = Page(self.request)

        print "Dashboard page"
        # Slow...
        #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
        testbed_query  = Query().get('network').select('network_hrn','platform','version')
        # DEMO GEC18 Query only PLE
#        user_query  = Query().get('local:user').select('config','email')
#        user_details = execute_query(self.request, user_query)

        # not always found in user_details...
#        config={}
  #      for user_detail in user_details:
  #          #email = user_detail['email']
  #          if user_detail['config']:
  #              config = json.loads(user_detail['config'])
  #      user_detail['authority'] = config.get('authority',"Unknown Authority")
#
#        print user_detail
#        if user_detail['authority'] is not None:
#            sub_authority = user_detail['authority'].split('.')
#            root_authority = sub_authority[0]
#            slice_query = Query().get(root_authority+':user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn')
#        else:
        slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('slice.slice_hrn')
        page.enqueue_query(slice_query)
        page.enqueue_query(testbed_query)

        slicelist = SliceList(
            page  = page,
            title = "slices",
            warning_msg = "<a href='../slice_request'>Request Slice</a>",
            query = slice_query,
        )
        testbedlist = TestbedList(
            page  = page,
            title = "testbeds",
            query = testbed_query,
        )
 
        context = super(DashboardView, self).get_context_data(**kwargs)
        context['person']   = self.request.user
        context['testbeds'] = testbedlist.render(self.request) 
        context['slices']   = slicelist.render(self.request)

        # XXX This is repeated in all pages
        # more general variables expected in the template
        context['title'] = 'Dashboard'
        # the menu items on the top
        context['topmenu_items'] = topmenu_items_live('Dashboard', page) 
        # so we can sho who is logged
        context['username'] = the_user(self.request) 

        page.expose_js_metadata()

        # the page header and other stuff
        context.update(page.prelude_env())

        return context
Пример #2
0
    def get_context_data(self, **kwargs):
        # We might have slices on different registries with different user accounts
        # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things
        # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn
        #messages.info(self.request, 'You have logged in')
        page = Page(self.request)

        logger.info("Dashboard page")
        # Slow...
        #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
        testbed_query = Query().get('network').select('network_hrn',
                                                      'platform', 'version')
        # DEMO GEC18 Query only PLE
        #        user_query  = Query().get('local:user').select('config','email')
        #        user_details = execute_query(self.request, user_query)

        # not always found in user_details...
        #        config={}
        #      for user_detail in user_details:
        #          #email = user_detail['email']
        #          if user_detail['config']:
        #              config = json.loads(user_detail['config'])
        #      user_detail['authority'] = config.get('authority',"Unknown Authority")
        #
        #        print user_detail
        #        if user_detail['authority'] is not None:
        #            sub_authority = user_detail['authority'].split('.')
        #            root_authority = sub_authority[0]
        #            slice_query = Query().get(root_authority+':user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn')
        #        else:
        logger.debug("SLICE QUERY")
        logger.debug("-" * 80)
        slice_query = Query().get('myslice:user').filter_by(
            'user_hrn', '==', '$user_hrn').select('slices.slice_hrn')
        page.enqueue_query(slice_query)
        page.enqueue_query(testbed_query)

        slicelist = SliceList(
            page=page,
            title="slices",
            warning_msg="<a href='../slice_request'>Request Slice</a>",
            query=slice_query,
        )
        testbedlist = TestbedList(
            page=page,
            title="testbeds",
            query=testbed_query,
        )

        context = super(DashboardView, self).get_context_data(**kwargs)
        context['person'] = self.request.user
        context['testbeds'] = testbedlist.render(self.request)
        context['slices'] = slicelist.render(self.request)

        # XXX This is repeated in all pages
        # more general variables expected in the template
        context['title'] = 'Dashboard'
        # the menu items on the top
        context['topmenu_items'] = topmenu_items_live('Dashboard', page)
        # so we can sho who is logged
        context['username'] = the_user(self.request)

        context['theme'] = self.theme

        page.expose_js_metadata()

        # the page header and other stuff
        context.update(page.prelude_env())

        return context
Пример #3
0
def dashboard_view(request):

    page = Page(request)

    slices_query = Query.get('slice').select('slice_hrn')
    #old#                                  # xxx filter : should filter on the slices the logged user can see
    #old#                                  # we don't have the user's hrn yet
    #old#                                  # in addition this currently returns all slices anyways
    #old#                                  # filter = ...
    #old#                                  sort='slice_hrn',)
    page.enqueue_query(slices_query)

    main_plugin = Stack(
        page=page,
        title="Putting stuff together",
        sons=[
            QueryCode(
                page=page,
                title="Vizualize your query",
                query=slices_query,
                toggled=False,
            ),
            QuickFilter(
                # we play with this one for demo purposes in dashboard.css
                domid='myquickfilter',
                page=page,
                title='play with filters',
                criterias=quickfilter_criterias,
                toggled=False,
            ),
            SliceList(  # setting visible attributes first
                page=page,
                title='Asynchroneous SliceList',
                header='slices list',
                with_datatables=False,
                # this is the query at the core of the slice list
                query=slices_query,
            ),
        ])

    # variables that will get passed to the view-unfold2.html template
    template_env = {}

    # define 'unfold_main' to the template engine
    template_env['unfold_main'] = main_plugin.render(request)

    # more general variables expected in the template
    template_env['title'] = 'Test view for a full request cycle'
    # the menu items on the top
    template_env['topmenu_items'] = topmenu_items_live('dashboard', page)
    # 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 slices',
        # share the query
        query=slices_query,
    )
    # likewise but on the side view
    template_env['unfold_margin'] = related_plugin.render(request)

    # add our own css in the mix
    #page.add_css_files ( 'css/dashboard.css')

    # the prelude object in page contains a summary of the requirements() for all plugins
    # define {js,css}_{files,chunks}
    prelude_env = page.prelude_env()
    template_env.update(prelude_env)
    return render_to_response('view-unfold2.html',
                              template_env,
                              context_instance=RequestContext(request))
Пример #4
0
def dashboard_view(request):

    page = Page(request)

    slices_query = Query.get("slice").select("slice_hrn")
    # old#                                  # xxx filter : should filter on the slices the logged user can see
    # old#                                  # we don't have the user's hrn yet
    # old#                                  # in addition this currently returns all slices anyways
    # old#                                  # filter = ...
    # old#                                  sort='slice_hrn',)
    page.enqueue_query(slices_query)

    main_plugin = Stack(
        page=page,
        title="Putting stuff together",
        sons=[
            QueryCode(page=page, title="Vizualize your query", query=slices_query, toggled=False),
            QuickFilter(
                # we play with this one for demo purposes in dashboard.css
                domid="myquickfilter",
                page=page,
                title="play with filters",
                criterias=quickfilter_criterias,
                toggled=False,
            ),
            SliceList(  # setting visible attributes first
                page=page,
                title="Asynchroneous SliceList",
                header="slices list",
                with_datatables=False,
                # this is the query at the core of the slice list
                query=slices_query,
            ),
        ],
    )

    # variables that will get passed to the view-unfold2.html template
    template_env = {}

    # define 'unfold_main' to the template engine
    template_env["unfold_main"] = main_plugin.render(request)

    # more general variables expected in the template
    template_env["title"] = "Test view for a full request cycle"
    # the menu items on the top
    template_env["topmenu_items"] = topmenu_items_live("dashboard", page)
    # 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 slices",
        # share the query
        query=slices_query,
    )
    # likewise but on the side view
    template_env["unfold_margin"] = related_plugin.render(request)

    # add our own css in the mix
    # page.add_css_files ( 'css/dashboard.css')

    # the prelude object in page contains a summary of the requirements() for all plugins
    # define {js,css}_{files,chunks}
    prelude_env = page.prelude_env()
    template_env.update(prelude_env)
    return render_to_response("view-unfold2.html", template_env, context_instance=RequestContext(request))