You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by gj...@apache.org on 2012/04/01 03:34:45 UTC
svn commit: r1307986 - in /incubator/bloodhound/trunk/bloodhound_dashboard:
./ bhdashboard/ bhdashboard/layouts/ bhdashboard/layouts/templates/
bhdashboard/widgets/
Author: gjm
Date: Sun Apr 1 01:34:45 2012
New Revision: 1307986
URL: http://svn.apache.org/viewvc?rev=1307986&view=rev
Log:
Dashboard code import: BH_Dashboard: ContainerWidget used to embed layouts inside another layout
Added:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html (with props)
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html (with props)
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py (with props)
Removed:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bootstrap.html
Modified:
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py
incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
incubator/bloodhound/trunk/bloodhound_dashboard/setup.py
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py?rev=1307986&r1=1307985&r2=1307986&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/api.py Sun Apr 1 01:34:45 2012
@@ -88,6 +88,10 @@ class ILayoutProvider(Interface):
:param options: additional options supplied in so as to adapt layout
considering data specific to this request. This allows to
customize (parts of) the layout for a given request.
+ Suported options are :
+
+ :field schema: data to be used in order to populate layout
+ :field embed: embed layout inside another page (true / false)
"""
class DashboardSystem(Component):
@@ -164,15 +168,16 @@ class InvalidIdentifier(WidgetException)
class InvalidWidgetArgument(WidgetException):
"""Something went wrong with widget parameter"""
-
+
title = 'Invalid Argument'
-
+
def __init__(self, argname, message, title=None, show_traceback=False):
+ message = _("Invalid argument `") + argname + "`. " + message
TracError.__init__(self, message, title, show_traceback)
self.argname = argname
-
+
def __unicode__(self):
- return unicode(_("Invalid argument `") + self.argname + "`. " + \
+ return unicode(
self.message)
#--------------------------------------
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py?rev=1307986&r1=1307985&r2=1307986&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/bootstrap.py Sun Apr 1 01:34:45 2012
@@ -52,6 +52,7 @@ class BootstrapLayout(Component):
req = context.req
add_stylesheet(req, 'dashboard/bootstrap.css')
return {
- 'template' : 'bootstrap.html',
+ 'template' : options.get('embed') and \
+ 'bs_grid.html' or 'bs_grid_full.html',
}
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html?rev=1307986&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html Sun Apr 1 01:34:45 2012
@@ -0,0 +1,47 @@
+<div
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ py:strip="" >
+
+ <div py:def="widget_container(w)" role="application">
+ <h1 style="display: inline;">${w.title}</h1>
+ <py:if test="w.ctxtnav">
+ <py:for each="itm in w.ctxtnav">
+ $itm
+ </py:for>
+ </py:if>
+
+ <div class="btn-group" py:if="w.altlinks" style="display: inline-block;">
+ <a class="btn btn-mini dropdown-toggle" href="#" data-toggle="dropdown">
+ <i class="icon-download-alt"></i>Download<b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu">
+ <li py:for="idx, link in enumerate(w.altlinks)"
+ class="${first_last(idx, w.altlinks)}">
+ <a rel="nofollow" href="${link.href}" class="link.class"
+ py:content="link.title"></a>
+ </li>
+ </ul>
+ </div>
+ <br/>
+ ${w.content}
+ </div>
+
+ <div py:def="bsdiv(ui)" class="${ui._class}">
+ <py:choose test="">
+ <py:when test="ui.div">
+ <py:for each="_ui in ui.div">${bsdiv(_ui)}</py:for>
+ </py:when>
+ <py:when test="ui.widgets">
+ <py:for each="widx in ui.widgets">
+ ${widget_container(widgets[widx])}
+ </py:for>
+ </py:when>
+ </py:choose>
+ </div>
+
+ <py:for each="ui in layout.div">
+ ${bsdiv(ui)}
+ </py:for>
+</div>
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html?rev=1307986&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html Sun Apr 1 01:34:45 2012
@@ -0,0 +1,22 @@
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:py="http://genshi.edgewall.org/"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="layout.html" />
+ <head>
+ <title>$title</title>
+ </head>
+
+ <body>
+ <xi:include href="bs_grid.html" />
+ <div id="ft" class="row">
+ <div id="help">
+ <strong>Note:</strong> See
+ <a href="${href.wiki('BloodhoundDashboard')}">BloodhoundDashboard</a>
+ for help on using the dashboard.
+ </div>
+ </div>
+ </body>
+</html>
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/layouts/templates/bs_grid_full.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1307986&r1=1307985&r2=1307986&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Sun Apr 1 01:34:45 2012
@@ -153,9 +153,42 @@ class DashboardModule(Component):
'args' : ['Timeline', None, {'args' : {}}]
},
{
- 'args' : ['TicketFieldCloud', None,
- {'args' : {'field' : 'component',
- 'verbose' : True}
+ 'args' : ['Container', None,
+ {'args' : {'layout' : 'bootstrap_grid',
+ 'schema' : """
+ {
+ "div" : [{
+ "_class" : "row",
+ "div" : [{
+ "_class" : "span3",
+ "widgets" : [0]
+ },
+ {
+ "_class" : "span5",
+ "widgets" : [1]
+ }]
+ }],
+ "widgets" : [
+ {
+ "args" : [
+ "TicketFieldCloud",
+ null,
+ {"args" : {
+ "field" : "component",
+ "verbose" : true}}]
+ },
+ {
+ "args" : [
+ "TicketFieldCloud",
+ null,
+ {"args" : {
+ "field" : "type",
+ "verbose" : true}}]
+ }
+ ]
+ }
+ """
+ }
}]
},
]
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py?rev=1307986&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py Sun Apr 1 01:34:45 2012
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+r"""Project dashboard for Apache(TM) Bloodhound
+
+Widgets acting as containers.
+"""
+
+from genshi.builder import tag
+from trac.core import implements, TracError
+
+from bhdashboard.api import DashboardSystem, InvalidWidgetArgument, JsonField
+from bhdashboard.util import WidgetBase, check_widget_name, \
+ dummy_request, merge_links, minmax, \
+ pretty_wrapper, trac_version, trac_tags
+from bhdashboard.web_ui import DashboardModule
+
+class ContainerWidget(WidgetBase):
+ """Embed widgets positioned according to the rules defined by a layout.
+ """
+ def get_widget_params(self, name):
+ """Return a dictionary containing arguments specification for
+ the widget with specified name.
+ """
+ return {
+ 'layout' : {
+ 'desc' : """Name of layout used to arrange widgets""",
+ 'required' : True,
+ },
+ 'schema' : {
+ 'desc' : """Widgets and position (in JSON)""",
+ 'required' : True,
+ 'type' : JsonField()
+ },
+ 'show_captions' : {
+ 'desc' : """Show widget titles""",
+ 'default' : False,
+ },
+ 'title' : {
+ 'desc' : """User-defined title""",
+ },
+ }
+ get_widget_params = pretty_wrapper(get_widget_params, check_widget_name)
+
+ def render_widget(self, name, context, options):
+ """Count ocurrences of values assigned to given ticket field.
+ """
+ dbsys = DashboardSystem(self.env)
+ req = context.req
+ params = ('layout', 'schema', 'show_captions', 'title')
+ layout, schema, show_captions, title = \
+ self.bind_params(name, options, *params)
+ lp = dbsys.resolve_layout(layout)
+ dbmod = DashboardModule(self.env)
+ layout_data = lp.expand_layout(layout, context,
+ { 'schema' : schema, 'embed' : True })
+ widgets = dbmod.expand_widget_data(req, schema)
+
+ return layout_data['template'], \
+ {
+ 'title' : '',
+ 'data' : dict(
+ context=context,
+ layout=schema,
+ widgets=widgets,
+ title='',
+ default={
+ 'height' : dbmod.default_widget_height or None
+ }
+ ),
+ }, \
+ context
+
+ render_widget = pretty_wrapper(render_widget, check_widget_name)
+
Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/containers.py
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/bloodhound/trunk/bloodhound_dashboard/setup.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/setup.py?rev=1307986&r1=1307985&r2=1307986&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/setup.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/setup.py Sun Apr 1 01:34:45 2012
@@ -109,6 +109,7 @@ ENTRY_POINTS = r"""
bhdashboard.api = bhdashboard.api
bhdashboard.layouts.bootstrap = bhdashboard.layouts.bootstrap
bhdashboard.web_ui = bhdashboard.web_ui
+ bhdashboard.widgets.containers = bhdashboard.widgets.containers
bhdashboard.widgets.query = bhdashboard.widgets.query
bhdashboard.widgets.report = bhdashboard.widgets.report
bhdashboard.widgets.ticket = bhdashboard.widgets.ticket