Return-Path: X-Original-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3225E9A4A for ; Sun, 1 Apr 2012 01:35:08 +0000 (UTC) Received: (qmail 4101 invoked by uid 500); 1 Apr 2012 01:35:08 -0000 Delivered-To: apmail-incubator-bloodhound-commits-archive@incubator.apache.org Received: (qmail 4080 invoked by uid 500); 1 Apr 2012 01:35:08 -0000 Mailing-List: contact bloodhound-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-commits@incubator.apache.org Received: (qmail 4073 invoked by uid 99); 1 Apr 2012 01:35:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 01:35:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 01:35:06 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3AAB6238896F; Sun, 1 Apr 2012 01:34:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1307986 - in /incubator/bloodhound/trunk/bloodhound_dashboard: ./ bhdashboard/ bhdashboard/layouts/ bhdashboard/layouts/templates/ bhdashboard/widgets/ Date: Sun, 01 Apr 2012 01:34:45 -0000 To: bloodhound-commits@incubator.apache.org From: gjm@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120401013446.3AAB6238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ +
+ +
+

${w.title}

+ + +   $itm + + +    +
+ + Download + + +
+
+ ${w.content} +
+ +
+ + + ${bsdiv(_ui)} + + + + ${widget_container(widgets[widx])} + + + +
+ + + ${bsdiv(ui)} + +
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 @@ + + + + + $title + + + + +
+
+ Note: See + BloodhoundDashboard + for help on using the dashboard. +
+
+ + 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