From b4b0c7e72d7eaee2fbfc7022022c9698323203dd Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 31 Dec 2009 13:16:41 +0000 Subject: import rt 3.8.7 --- .../html/Dashboards/Elements/DashboardsForObject | 81 ++++++ .../html/Dashboards/Elements/DashboardsForObjects | 81 ++++++ rt/share/html/Dashboards/Elements/Deleted | 62 +++++ rt/share/html/Dashboards/Elements/HiddenSearches | 79 ++++++ rt/share/html/Dashboards/Elements/ListOfDashboards | 19 ++ rt/share/html/Dashboards/Elements/SelectPrivacy | 64 +++++ rt/share/html/Dashboards/Elements/ShowDashboards | 112 ++++++++ .../html/Dashboards/Elements/ShowPortlet/component | 54 ++++ .../html/Dashboards/Elements/ShowPortlet/dashboard | 89 +++++++ .../html/Dashboards/Elements/ShowPortlet/search | 63 +++++ rt/share/html/Dashboards/Elements/ShowSubscription | 75 ++++++ rt/share/html/Dashboards/Elements/Tabs | 113 ++++++++ rt/share/html/Dashboards/Modify.html | 168 ++++++++++++ rt/share/html/Dashboards/Queries.html | 280 ++++++++++++++++++++ rt/share/html/Dashboards/Render.html | 143 ++++++++++ rt/share/html/Dashboards/Subscription.html | 292 +++++++++++++++++++++ rt/share/html/Dashboards/dhandler | 56 ++++ rt/share/html/Dashboards/index.html | 107 ++++++++ 18 files changed, 1938 insertions(+) create mode 100644 rt/share/html/Dashboards/Elements/DashboardsForObject create mode 100644 rt/share/html/Dashboards/Elements/DashboardsForObjects create mode 100644 rt/share/html/Dashboards/Elements/Deleted create mode 100644 rt/share/html/Dashboards/Elements/HiddenSearches create mode 100644 rt/share/html/Dashboards/Elements/ListOfDashboards create mode 100644 rt/share/html/Dashboards/Elements/SelectPrivacy create mode 100644 rt/share/html/Dashboards/Elements/ShowDashboards create mode 100644 rt/share/html/Dashboards/Elements/ShowPortlet/component create mode 100644 rt/share/html/Dashboards/Elements/ShowPortlet/dashboard create mode 100644 rt/share/html/Dashboards/Elements/ShowPortlet/search create mode 100644 rt/share/html/Dashboards/Elements/ShowSubscription create mode 100755 rt/share/html/Dashboards/Elements/Tabs create mode 100755 rt/share/html/Dashboards/Modify.html create mode 100644 rt/share/html/Dashboards/Queries.html create mode 100644 rt/share/html/Dashboards/Render.html create mode 100644 rt/share/html/Dashboards/Subscription.html create mode 100644 rt/share/html/Dashboards/dhandler create mode 100644 rt/share/html/Dashboards/index.html (limited to 'rt/share/html/Dashboards') diff --git a/rt/share/html/Dashboards/Elements/DashboardsForObject b/rt/share/html/Dashboards/Elements/DashboardsForObject new file mode 100644 index 000000000..3e5d1e2f3 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/DashboardsForObject @@ -0,0 +1,81 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +$Object => undef + +<%init> +# Returns a hash of dashboards associated on $Object + +use RT::Dashboard; +my %dashboards; +my $privacy = RT::Dashboard->_build_privacy($Object); + +while (my $attr = $Object->Attributes->Next) { + if ($attr->Name =~ /^Dashboard\b/) { + my $dashboard = RT::Dashboard->new($session{'CurrentUser'}); + my ($ok, $msg) = $dashboard->Load($privacy, $attr->id); + + if (!$ok) { + $RT::Logger->debug("Unable to load dashboard $ok (privacy $privacy): $msg"); + next; + } + + if ($Object->isa('RT::System')) { + push @{ $dashboards{system} }, $dashboard; + } + elsif ($Object->isa('RT::User')) { + push @{ $dashboards{personal} }, $dashboard; + } + elsif ($Object->isa('RT::Group')) { + push @{ $dashboards{group}{$Object->Name} }, $dashboard; + } + } +} +return \%dashboards; + + diff --git a/rt/share/html/Dashboards/Elements/DashboardsForObjects b/rt/share/html/Dashboards/Elements/DashboardsForObjects new file mode 100644 index 000000000..b4fdcf74e --- /dev/null +++ b/rt/share/html/Dashboards/Elements/DashboardsForObjects @@ -0,0 +1,81 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +$Objects => undef +$dashboards => {} +$flatten => 0 + +<%init> +# Returns a hash of dashboards associated with @Objects +if (!defined($Objects)) { + @$Objects = RT::Dashboard->new($session{CurrentUser})->_PrivacyObjects; +} + +for my $object (@$Objects) { + my $new_dashboards = $m->comp("/Dashboards/Elements/DashboardsForObject", Object => $object); + + push @{ $dashboards->{$_} }, @{ $new_dashboards->{$_} || [] } + for qw/personal system/; + + push @{ $dashboards->{group}{$_} }, @{ $new_dashboards->{group}{$_} } + for keys %{ $new_dashboards->{group} || {} }; +} + +if ($flatten) { + my @dashboards; + push @dashboards, @{ $dashboards->{personal} || [] }; + push @dashboards, map { @{ $_ || [] } } values %{ $dashboards->{group} }; + push @dashboards, @{ $dashboards->{system} || [] }; + + return \@dashboards; +} + +return $dashboards; + + + diff --git a/rt/share/html/Dashboards/Elements/Deleted b/rt/share/html/Dashboards/Elements/Deleted new file mode 100644 index 000000000..62d0b8db8 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/Deleted @@ -0,0 +1,62 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +@searches + +% if (@searches) { +<&| /Widgets/TitleBox, title => loc('Deleted queries') &> +

<% loc("The following queries have been deleted and each will be removed from the dashboard once its pane is updated.") %>

+ +
    +% for (@searches) { +
  • <% loc('[_1] (from pane [_2])', ($_->{description} || $_->{name}), $_->{pane}) %>
  • +% } +
+ +% } + diff --git a/rt/share/html/Dashboards/Elements/HiddenSearches b/rt/share/html/Dashboards/Elements/HiddenSearches new file mode 100644 index 000000000..aa3a67ebb --- /dev/null +++ b/rt/share/html/Dashboards/Elements/HiddenSearches @@ -0,0 +1,79 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +@searches +$Dashboard + +<%init> +return if @searches == 0; + +my @display; + +for my $search (@searches) { + if ($search->Name eq 'SavedSearch') { + push @display, $search->Description; + } + elsif ($search->Name =~ m/^Search - (.*)/) { + push @display, $1; + } + else { + push @display, $search->Name; + } +} + + +<&| /Widgets/TitleBox, title => loc('Possible hidden searches') &> +

<% loc("The following queries may not be visible to all users who can see this dashboard.") %>

+ +
    +% for (@display) { +
  • <% $_ %>
  • +% } +
+ + diff --git a/rt/share/html/Dashboards/Elements/ListOfDashboards b/rt/share/html/Dashboards/Elements/ListOfDashboards new file mode 100644 index 000000000..b2cbd3ebe --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ListOfDashboards @@ -0,0 +1,19 @@ +<%init> +# put the list of dashboards into the navigation +use RT::Dashboard; + +my @objs = RT::Dashboard->new($session{CurrentUser})->_PrivacyObjects(ShowSystem => 1); +my $dashboard_map = $m->comp("/Dashboards/Elements/DashboardsForObjects", Objects => \@objs); + +my @dashboards = ( + (sort { $a->Id <=> $b->Id } @{ $dashboard_map->{personal} || [] }), + (sort { $a->Id <=> $b->Id } @{ $dashboard_map->{system} || [] }), + + map { sort { $a->Id <=> $b->Id } @{ $dashboard_map->{group}{$_} } } + keys %{ $dashboard_map->{group} || {} }, +); + +$m->callback(%ARGS, dashboards => \@dashboards, CallbackName => 'ModifyDashboards'); + +return @dashboards; + diff --git a/rt/share/html/Dashboards/Elements/SelectPrivacy b/rt/share/html/Dashboards/Elements/SelectPrivacy new file mode 100644 index 000000000..ff2c27f94 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/SelectPrivacy @@ -0,0 +1,64 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +@Objects => undef +$Name => undef +$Default => undef + + diff --git a/rt/share/html/Dashboards/Elements/ShowDashboards b/rt/share/html/Dashboards/Elements/ShowDashboards new file mode 100644 index 000000000..d7014b943 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ShowDashboards @@ -0,0 +1,112 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<&| /Widgets/TitleBox, title => $Title &> +<& SELF:table, %ARGS &> + +<%ARGS> +$Title => undef + + +<%METHOD table> +<%ARGS> +$Dashboards => undef +$Verbose => 1 + +<%INIT> +# map each subscription to a dashboard ID +my %subscription_for; + +for my $attr ($session{'CurrentUser'}->UserObj->Attributes->Named('Subscription')) { + $subscription_for{$attr->SubValue('DashboardId')} = $attr; +} + + +% if (@$Dashboards == 0) { +% if ($Verbose) { +

<% loc("No dashboards.") %>

+% } +% } else { + + +% if ($Verbose) { + +% } + + + + +% my $i = 0; +% for my $dashboard (@$Dashboards) { +% my $url = sprintf '%s/Dashboards/%d/%s', +% RT->Config->Get('WebPath'), +% $dashboard->Id, +% $dashboard->Name; + + +% if ($Verbose) { + +% } + + + +% } + +
<% loc("#") %><% loc("Name") %><% loc("Subscription") %>
+ + <% $dashboard->Id %> + + + + <% $dashboard->Name %> + + + <& /Dashboards/Elements/ShowSubscription, Dashboard => $dashboard, Subscription => $subscription_for{$dashboard->Id} &> +
+% } + + diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/component b/rt/share/html/Dashboards/Elements/ShowPortlet/component new file mode 100644 index 000000000..d5e9ccd22 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ShowPortlet/component @@ -0,0 +1,54 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +$Dashboard +$Portlet +$Rows => 20 +$Preview => 0 + +% $m->comp($Portlet->{path}); diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard b/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard new file mode 100644 index 000000000..ccefe7c04 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ShowPortlet/dashboard @@ -0,0 +1,89 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +$Dashboard +$Pane +$Portlet +$Rows => 20 +$Preview => 0 +$Depth => 0 + +<%init> +my $current_dashboard; + +use Scalar::Util 'blessed'; +if (blessed($Portlet) && $Portlet->isa('RT::Dashboard')) { + $current_dashboard = $Portlet; +} +else { + $current_dashboard = RT::Dashboard->new($session{CurrentUser}); + my ($ok, $msg) = $current_dashboard->LoadById($Portlet->{id}); + if (!$ok) { + $m->out($msg); + return; + } +} + +my @panes = @{ $current_dashboard->Panes->{$Pane} || [] }; + +Abort("Possible recursive dashboard detected.") if $Depth > 8; + + +<%perl> +for my $portlet (@panes) { + $m->comp($portlet->{portlet_type}, + Portlet => $portlet, + Rows => $Rows, + Preview => $Preview, + Dashboard => $current_dashboard, + Pane => $Pane, + Depth => $Depth + 1, + ); +} + + diff --git a/rt/share/html/Dashboards/Elements/ShowPortlet/search b/rt/share/html/Dashboards/Elements/ShowPortlet/search new file mode 100644 index 000000000..eb65cb81b --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ShowPortlet/search @@ -0,0 +1,63 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%args> +$Dashboard +$Portlet +$Rows => 20 +$Preview => 0 + +<%init> +my @for_showsearch = $Dashboard->ShowSearchName($Portlet); + + +<& /Elements/ShowSearch, + @for_showsearch, + Override => { Rows => $Rows }, + hideable => $Preview, + ShowCustomize => $Preview, +&> diff --git a/rt/share/html/Dashboards/Elements/ShowSubscription b/rt/share/html/Dashboards/Elements/ShowSubscription new file mode 100644 index 000000000..208e4c2c1 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/ShowSubscription @@ -0,0 +1,75 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<% $frequency %> +<%ARGS> +$Dashboard => undef +$Subscription => undef + +<%INIT> +my $url = sprintf '%s/Dashboards/Subscription.html?DashboardId=%d', + RT->Config->Get('WebPath'), + $Dashboard->Id,; + +my $frequency = loc("None"); + +if (defined $Subscription) { + my $freq = $Subscription->SubValue('Frequency'); + my $hour = $Subscription->SubValue('Hour'); + + if ($freq eq 'weekly') { + my $day = $Subscription->SubValue('Dow'); + $frequency = loc("weekly (on [_1]) at [_2]", loc($day), $hour); + } + elsif ($freq eq 'monthly') { + $frequency = loc("monthly (day [_1]) at [_2]", $Subscription->SubValue('Dom'), $hour); + } + elsif ($freq eq 'daily') { + $frequency = loc("daily at [_1]", $hour); + } +} + diff --git a/rt/share/html/Dashboards/Elements/Tabs b/rt/share/html/Dashboards/Elements/Tabs new file mode 100755 index 000000000..d82b9d0b6 --- /dev/null +++ b/rt/share/html/Dashboards/Elements/Tabs @@ -0,0 +1,113 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Tools/Elements/Tabs, + subtabs => $subtabs, + current_tab => 'Dashboards/index.html', + current_subtab => $current_subtab, + actions => $actions, + Title => $Title &> + +<%INIT> +my $subtabs; +my $actions; + +if ( $DashboardObj and $DashboardObj->Id ) { + my $id = $DashboardObj->Id; + my $name = $DashboardObj->Name; + + my $modify = "Dashboards/Modify.html?id=$id"; + my $queries = "Dashboards/Queries.html?id=$id"; + my $render = "Dashboards/$id/$name"; + my $subscribe = "Dashboards/Subscription.html?DashboardId=$id"; + + $subtabs = $m->comp('/Elements/DashboardTabs', CurrentDashboard => $DashboardObj); + $current_subtab = $render; + + $actions = { + a_Basics => { + title => loc('Basics'), + path => $modify, + }, + + b_Queries => { + title => loc('Queries'), + path => $queries, + }, + + c_Subscription => { + title => loc('Subscription'), + path => $subscribe, + }, + }; + + delete $actions->{"c_Subscription"} + unless $DashboardObj->CurrentUserCanSubscribe; +} +else { + $subtabs->{"a_Select"} = { + title => loc('Select'), + path => "Dashboards/index.html", + }; + + my $dashboard = RT::Dashboard->new($session{'CurrentUser'}); + my @objects = $dashboard->_PrivacyObjects(Create => 1); + + if (@objects) { + $subtabs->{"b_Create"} = { + title => loc('New'), + path => "Dashboards/Modify.html?Create=1", + separator => 1, + }; + } +} + +<%ARGS> +$DashboardObj => undef +$current_subtab => undef +$Title => undef + diff --git a/rt/share/html/Dashboards/Modify.html b/rt/share/html/Dashboards/Modify.html new file mode 100755 index 000000000..35a804649 --- /dev/null +++ b/rt/share/html/Dashboards/Modify.html @@ -0,0 +1,168 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Elements/Header, Title => $title &> +<& /Dashboards/Elements/Tabs, + current_subtab => $current_subtab, + Title => $title, + $Create ? () : (DashboardObj => $Dashboard), +&> +<& /Elements/ListActions, actions => \@results &> + +
+ +%unless ($Dashboard->Id) { + +% } else { + +% } + + + + + +
+<&|/l&>Name: +
+<&|/l&>Privacy: + +<& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &> +
+% if ( $Create ) { +<& /Elements/Submit, Name => 'Save', Label => loc('Create') &> +% } else { +<& /Elements/Submit, Name => 'Save', Label => loc('Save Changes') &> +% } +% if ($Dashboard->Id && $can_delete) { +<& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &> +% } +
+<%INIT> + +my $current_subtab; +my ($title, @results); +my $tried_create = 0; + +# user went directly to Modify.html +$Create = 1 if !$id; + +use RT::Dashboard; + +my $Dashboard = RT::Dashboard->new($session{'CurrentUser'}); +my @privacies = $Dashboard->_PrivacyObjects(($Create ? 'Create' : 'Modify') => 1); + +Abort(loc("Permission denied")) if @privacies == 0; + +if ($Create) { + $current_subtab = 'Dashboards/Modify.html?Create=1'; + $title = loc("Create a new dashboard"); +} +else { + if ($id eq 'new') { + $tried_create = 1; + + my ($val, $msg) = $Dashboard->Save( + Name => $ARGS{'Name'}, + Privacy => $ARGS{'Privacy'}, + ); + + if (!$val) { + Abort(loc("Dashboard could not be created: [_1]", $msg)); + } + + push @results, $msg; + $id = $Dashboard->Id; + } + else { + my ($ok, $msg) = $Dashboard->LoadById($id); + $ok || Abort($msg); + } + + if ($id) { + $title = loc("Modify the dashboard [_1]", $Dashboard->Name); + $current_subtab = 'Dashboards/Modify.html?id=' . $id; + } + # If the create failed + else { + $Create = 1; + $current_subtab = 'Dashboards/Modify.html?Create=1'; + $title = loc("Create a new dashboard"); + } +} + +if (!$Create && !$tried_create && $id && $ARGS{'Save'}) { + my ($ok, $msg) = $Dashboard->Update(Privacy => $ARGS{'Privacy'}, + Name => $ARGS{'Name'}); + + if ($ok) { + push @results, loc("Dashboard updated"); + } + else { + push @results, loc("Dashboard could not be updated: [_1]", $msg); + } + +} + +my $can_delete = $Dashboard->CurrentUserCanDelete; + +if (!$Create && !$tried_create && $id && $ARGS{'Delete'}) { + my ($ok, $msg) = $Dashboard->Delete(); + $ok || Abort(loc("Couldn't delete dashboard [_1]: [_2]", $id, $msg)); + + # put the user back into a useful place with a message + RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Dashboards/index.html?Deleted=$id"); + +} + + +<%ARGS> +$Create => undef +$Name => undef +$id => '' unless defined $id +$Delete => undef + + diff --git a/rt/share/html/Dashboards/Queries.html b/rt/share/html/Dashboards/Queries.html new file mode 100644 index 000000000..1a1066be6 --- /dev/null +++ b/rt/share/html/Dashboards/Queries.html @@ -0,0 +1,280 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Elements/Header, Title => $title &> +<& /Dashboards/Elements/Tabs, + current_subtab => $current_subtab, + Title => $title, + DashboardObj => $Dashboard &> + +<& /Widgets/SelectionBox:header, nojs => 1 &> + +<& /Elements/ListActions, actions => \@results &> + +<& Elements/Deleted, searches => \@deleted, Dashboard => $Dashboard &> + +<& Elements/HiddenSearches, searches => \@hidden_searches, Dashboard => $Dashboard &> + + +% for my $pane (@panes) { + +% } +
+
+ + + +<&| /Widgets/TitleBox, title => $pane->{DisplayName} &> +% my ( $pane_name ) = $pane->{Name} =~ /Searches-(.+)/; + <& /Widgets/SelectionBox:show, self => $pane, nojs => 1, grep( { + $_->{pane} eq $pane_name} @deleted ) ? ( ShowUpdate => 1 ) : () &> + +
+
+ +<%INIT> + +my $current_subtab = 'Dashboards/Queries.html?id=' . $id; +my @results; + +use RT::Dashboard; +my $Dashboard = new RT::Dashboard($session{'CurrentUser'}); +my ($ok, $msg) = $Dashboard->LoadById($id); +$ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg)); +my $title = loc("Modify the queries of dashboard [_1]", $Dashboard->Name); + +my %desc_of; +my @items; +my %selected; +my %still_exists; + +# add portlets (homepage componenets) +my @components = @{ RT->Config->Get('HomepageComponents') }; + +for my $desc (@components) { + my $name = "component-$desc"; + push @items, [$name, $desc]; + $desc_of{$name} = $desc; + $still_exists{$name} = 1; +} + +# add dashboards +my $dashboards = $m->comp("/Dashboards/Elements/DashboardsForObjects", flatten => 1); +for my $dashboard (@{ $dashboards || [] }) { + # Users *can* set up mutually recursive dashboards, but don't make it THIS + # easy for them to shoot themselves in the foot. + next if $dashboard->Id == $Dashboard->Id; + + my $name = 'dashboard-' . $dashboard->Id . '-' . $dashboard->Privacy; + my $desc = "Dashboard: " . $dashboard->Name; + push @items, [$name, $desc]; + $desc_of{$name} = $desc; + $still_exists{$name} = 1; +} + +# add saved searches +my @objs = RT::System->new($session{'CurrentUser'}); + +push @objs, RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects + if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch', + Object => $RT::System ); + +for my $object (@objs) { + for ($m->comp("/Search/Elements/SearchesForObject", Object => $object)) { + my ($desc, $search) = @$_; + my $SearchType = $search->Content->{'SearchType'} || 'Ticket'; + my $type = ($SearchType eq 'Ticket') ? 'Saved Search' : $SearchType; # loc + $desc = "$type: $desc"; + my $privacy = $Dashboard->_build_privacy($object); + my $name = 'search-' . $search->Id . '-' . $privacy; + push @items, [$name, $desc]; + $desc_of{$name} = $desc; + $still_exists{$name} = 1; + } +} + +# Get the list of queries already in use +my @deleted; +do { + my $panes = $Dashboard->Panes; + for my $pane (keys %$panes) { + for my $portlet (@{ $panes->{$pane} }) { + my $name; + my $type = $portlet->{portlet_type}; + + if ($type eq 'search' || $type eq 'dashboard') { + $name = join '-', $type, $portlet->{id}, $portlet->{privacy}; + } + elsif ($type eq 'component') { + $name = join '-', 'component', $portlet->{component}; + } + + if (!$still_exists{$name}) { + push @deleted, { + pane => $pane, + name => $name, + description => $portlet->{description}, + }; + next; + } + + push @{ $selected{$pane} }, $name; + $desc_of{$name} = $portlet->{description}; + } + } +}; + +$m->callback( + CallbackName => 'PopulatePossibilities', + Dashboard => $Dashboard, + items => \@items, + desc_of => \%desc_of, + still_exists => \%still_exists, + selected => \%selected, +); + +# Create selectionbox widgets for those queries + +my %pane_name = ( + 'body' => loc('Body'), + 'sidebar' => loc('Sidebar'), +); + +$m->callback( + CallbackName => 'Panes', + Dashboard => $Dashboard, + panes => \%pane_name, +); + +my @panes; +for my $pane (keys %pane_name) { + my $sel = $m->comp( + '/Widgets/SelectionBox:new', + Action => 'Queries.html', + Name => "Searches-$pane", + DisplayName => $pane_name{$pane}, + Available => \@items, + Selected => $selected{$pane}, + AutoSave => 1, + OnSubmit => sub { + my $self = shift; + + $m->callback( + CallbackName => 'Submit', + Dashboard => $Dashboard, + Selected => $self->{Current}, + pane => $pane, + ); + + my @portlets; + for (@{ $self->{Current} }) { + my $item = $_; + my $desc = $desc_of{$item}; + my $portlet_type = $1 if $item =~ s/^(\w+)-//; + + if ($portlet_type eq 'search' || $portlet_type eq 'dashboard') { + my ($id, $privacy) = split '-', $item, 2; + push @portlets, { + portlet_type => $portlet_type, + privacy => $privacy, + id => $id, + description => $desc, + pane => $pane, + }; + } + elsif ($portlet_type eq 'component') { + # Absolute paths stay absolute, relative paths go into + # /Elements. This way, extensions that add portlets work. + my $path = $item; + $path = "/Elements/$path" if substr($path, 0, 1) ne '/'; + + push @portlets, { + portlet_type => $portlet_type, + component => $item, + path => $path, + description => $item, + pane => $pane, + }; + } + } + + # we want to keep all the other panes the same + my $panes = $Dashboard->Panes; + $panes->{$pane} = \@portlets; + + # remove "deleted" warnings about this pane + @deleted = grep { $_->{pane} ne $pane } @deleted; + + $m->callback( + CallbackName => 'BeforeUpdate', + Dashboard => $Dashboard, + panes => $panes, + ); + + my ($ok, $msg) = $Dashboard->Update(Panes => $panes); + + if ($ok) { + push @results, loc("Dashboard updated"); + } + else { + push @results, loc("Dashboard could not be updated: [_1]", $msg); + } + }, + ); + + push @panes, $sel; +} + +$m->comp('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1) + for @panes; + +my @hidden_searches = $Dashboard->PossibleHiddenSearches; + +<%ARGS> +$id => '' unless defined $id + + diff --git a/rt/share/html/Dashboards/Render.html b/rt/share/html/Dashboards/Render.html new file mode 100644 index 000000000..1893b533f --- /dev/null +++ b/rt/share/html/Dashboards/Render.html @@ -0,0 +1,143 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Elements/Header, + Title => $title, + JavaScript => $Preview, + ShowBar => $Preview, + Refresh => $Refresh, +&> + +% if ($Preview) { +<& /Dashboards/Elements/Tabs, + current_subtab => $current_subtab, + Title => $title, + DashboardObj => $DashboardObj &> +% } + +% $m->callback(CallbackName => 'BeforeTable', Dashboard => $DashboardObj, show_cb => $show_cb); + + + + +% $m->callback(CallbackName => 'BeforePanes', Dashboard => $DashboardObj, show_cb => $show_cb); + + + + + + + + + +% $m->callback(CallbackName => 'AfterPanes', Dashboard => $DashboardObj, show_cb => $show_cb); + +
+% $show_cb->('body'); + +% $show_cb->('sidebar'); +
+ +% $m->callback(CallbackName => 'AfterTable', Dashboard => $DashboardObj, show_cb => $show_cb); + + + + + + + +<%INIT> + +my $current_subtab = 'Dashboards/Render.html?id=' . $id; + +use RT::Dashboard; +my $DashboardObj = RT::Dashboard->new($session{'CurrentUser'}); +my ($ok, $msg) = $DashboardObj->LoadById($id); +Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg)) if !$ok; + +my $SubscriptionObj = RT::Attribute->new($session{'CurrentUser'}); +my $rows; + +# try to load the subscription to this id to get a better idea of number of rows +for my $sub ($session{'CurrentUser'}->UserObj->Attributes->Named('Subscription')) { + next unless $sub->SubValue('DashboardId') == $id; + $SubscriptionObj = $sub; + $rows = $SubscriptionObj->SubValue('Rows'); + last; +} + +# otherwise honor their search preferences.. otherwise 20 rows +if (!$rows) { + my $prefs = $session{'CurrentUser'}->UserObj->Preferences("SearchDisplay") || {}; + $rows = defined($prefs->{'RowsPerPage'}) ? $prefs->{'RowsPerPage'} : 20; +} + +my $title = loc 'Dashboard [_1]', $DashboardObj->Name; + +my $show_cb = sub { + my $pane = shift; + $m->comp('Elements/ShowPortlet/dashboard', + Portlet => $DashboardObj, + Rows => $rows, + Preview => $Preview, + Dashboard => $DashboardObj, + Pane => $pane, + Depth => 0, + ); +}; + +my $Refresh = $Preview + ? $session{'home_refresh_interval'} + || RT->Config->Get('HomePageRefreshInterval', $session{'CurrentUser'}) + : 0; + + +<%ARGS> +$id => undef +$Preview => 1 + + diff --git a/rt/share/html/Dashboards/Subscription.html b/rt/share/html/Dashboards/Subscription.html new file mode 100644 index 000000000..3de58acdd --- /dev/null +++ b/rt/share/html/Dashboards/Subscription.html @@ -0,0 +1,292 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Elements/Header, Title => $title &> +<& /Dashboards/Elements/Tabs, + current_subtab => $current_subtab, + Title => $title, + DashboardObj => $DashboardObj &> + +<& /Elements/ListActions, actions => \@results &> + +
+ + + + + + +
+<&| /Widgets/TitleBox, title => loc('Dashboard') &> + + + + + + +
+<&|/l&>Dashboard: + +<% $DashboardObj->Name %> +
+<&|/l&>Queries: + +% my @portlets = grep { defined } $DashboardObj->Portlets; +% if (!@portlets) { +(<&|/l&>none) +% } else { +
    +% for my $portlet (@portlets) { +
  1. + <% loc($portlet->{description}, $fields{'Rows'}) %> +
  2. +% } +
+% } +
+ + +<&| /Widgets/TitleBox, title => loc('Subscription') &> + + + + + + + +
+<&|/l&>Frequency: + + +> + <&|/l&>daily +
+ +> + <&|/l&>Monday through Friday +
+ +> +<&|/l&>weekly, <&|/l&>on + +<&|/l&>every + +<&|/l&>weeks +
+ +> +<&|/l&>monthly , <&|/l&>on day + +
+ +> + <&|/l&>never + + +
+<&|/l&>Hour: + + +(<%$timezone%>) +
+<&|/l&>Rows: + + +
+<&|/l&>Recipient: + + +
<% loc("Leave blank to send to your current email address ([_1])", $session{'CurrentUser'}->UserObj->EmailAddress) %>
+
+ +
+ +% if ($SubscriptionObj->Id) { + <& /Elements/Submit, Name => "Save", Label => loc('Save Changes') &> +% } else { + <& /Elements/Submit, Name => "Save", Label => loc('Subscribe') &> +% } +
+ +<%INIT> + +my $current_subtab = 'Dashboards/Subscription.html?DashboardId=' . $DashboardId; + +my ($title, @results); +my ($val, $msg); +my $Loaded = 0; +my $timezone = $session{'CurrentUser'}->UserObj->Timezone || RT->Config->Get('Timezone'); + +use RT::Dashboard; +my $DashboardObj = RT::Dashboard->new($session{'CurrentUser'}); + +my $SubscriptionObj = RT::Attribute->new($session{'CurrentUser'}); + +# first let's see if we already have a subscription to this DashboardId +for my $sub ($session{'CurrentUser'}->UserObj->Attributes->Named('Subscription')) { + next unless $sub->SubValue('DashboardId') == $DashboardId; + $SubscriptionObj = $sub; + last; +} + +$DashboardId = $SubscriptionObj->Id + ? $SubscriptionObj->SubValue('DashboardId') + : $ARGS{'DashboardId'}; + +($val, $msg) = $DashboardObj->LoadById($DashboardId); +$val || Abort(loc("Couldn't load dashboard [_1]: [_2].", $DashboardId, $msg)); + +my %fields = ( + DashboardId => $DashboardId, + Frequency => 'daily', + Hour => '06:00', + Dow => 'Monday', + Dom => 1, + Rows => 20, + Recipient => '', + Fow => 1, + Counter => 0, +); + +# update any fields with the values from the subscription object +if ($SubscriptionObj->Id) { + for my $field (keys %fields) { + $fields{$field} = $SubscriptionObj->SubValue($field); + } +} + +# finally, update any fields with arguments passed in by the user +for my $field (keys %fields) { + next if $field eq 'DashboardId'; # but this one is immutable + $fields{$field} = $ARGS{$field} + if defined($ARGS{$field}); +} +# this'll be defined on submit +if (defined $ARGS{Save}) { + # update + if ($SubscriptionObj->Id) { + $DashboardId = delete $fields{'DashboardId'}; # immutable + ($val, $msg) = $SubscriptionObj->SetSubValues(%fields); + $fields{'DashboardId'} = $DashboardId; + + # not so good to spew base64-encoded data at the user :) + if ($msg =~ /^Content changed from/) { + $msg = "Subscription updated."; + } + + push @results, $msg; + } + # create + else { + Abort(loc("Unable to subscribe to dashboard [_1]: Permission denied", $DashboardId)) + unless $DashboardObj->CurrentUserCanSubscribe; + + my ($val, $msg) = $SubscriptionObj->Create( + Name => 'Subscription', + Description => 'Subscription to dashboard ' . $DashboardId, + ContentType => 'storable', + Object => $session{'CurrentUser'}->UserObj, + Content => \%fields, + ); + if ($val) { + push @results, loc("Subscribed to dashboard [_1]", $DashboardObj->Name); + push @results, loc("Warning: you have no email address set, so you will not receive this dashboard until you have it set") + unless $session{'CurrentUser'}->EmailAddress || $fields{Recipient}; + } + else { + push @results, loc('Subscription could not be created: [_1]', $msg); + } + } +} + +if ($SubscriptionObj->Id) { + $title = loc("Modify the subscription to dashboard [_1]", $DashboardObj->Name); +} +else { + $title = loc("Subscribe to dashboard [_1]", $DashboardObj->Name); +} + + +<%ARGS> +$DashboardId => undef +$Frequency => undef +$Hour => undef +$Dow => undef +$Dom => undef +$Rows => undef +$Recipient => undef + + diff --git a/rt/share/html/Dashboards/dhandler b/rt/share/html/Dashboards/dhandler new file mode 100644 index 000000000..056476bf9 --- /dev/null +++ b/rt/share/html/Dashboards/dhandler @@ -0,0 +1,56 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%INIT> +if ($m->dhandler_arg =~ /^(\d+)/) { + $m->comp('/Dashboards/Render.html', id => $1, %ARGS); +} +else { + $m->decline; +} + + diff --git a/rt/share/html/Dashboards/index.html b/rt/share/html/Dashboards/index.html new file mode 100644 index 000000000..8f71ab060 --- /dev/null +++ b/rt/share/html/Dashboards/index.html @@ -0,0 +1,107 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<& /Elements/Header, Title => $title &> +<& /Dashboards/Elements/Tabs, + current_subtab => 'Dashboards/index.html', + Title => $title &> + +<& /Elements/ListActions, actions => \@actions &> + +<& /Dashboards/Elements/ShowDashboards, + Title => loc('Personal Dashboards'), + Dashboards => \@personal_dashboards, +&> + +<& /Dashboards/Elements/ShowDashboards, + Title => loc('System Dashboards'), + Dashboards => \@system_dashboards, +&> + +% for (@grouped_dashboards) { +% my $group = $_->{name}; +% my $dashboards = $_->{dashboards}; + + <& /Dashboards/Elements/ShowDashboards, + Title => loc('[_1] DashBoards', $group), + Dashboards => $dashboards, + &> +% } + +<%INIT> +my $title = loc("Dashboards"); +use RT::Dashboard; + +my $dashboards = $m->comp("/Dashboards/Elements/DashboardsForObjects"); + +my @actions; +if (defined $Deleted) { + push @actions, loc("Deleted dashboard [_1]", $Deleted); +} + +my @personal_dashboards = sort { $a->Id <=> $b->Id } @{ $dashboards->{personal} || [] }; +my @system_dashboards = sort { $a->Id <=> $b->Id } @{ $dashboards->{system} || [] }; + +my @groups = sort keys %{ $dashboards->{group} || {} }; +my @grouped_dashboards = map { + { + name => $_, + dashboards => [ sort { $a->Id <=> $b->Id } @{ $dashboards->{group}{$_} || [] } ], + } +} @groups; + +$m->callback( + PersonalDashboards => \@personal_dashboards, + SystemDashboards => \@system_dashboards, + GroupedDashboards => \@grouped_dashboards, + CallbackName => 'MassageDashboards', +); + +<%ARGS> +$Deleted => undef + + -- cgit v1.2.1