%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# %# This software is Copyright (c) 1996-2024 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, ShowBar => $Preview, Refresh => $Refresh, &> % if ($Preview) { <& /Elements/Tabs &> % } <& /Elements/ListActions, actions => \@results &> % # honor the chosen language for just the dashboard content % my $original_handle; % if ($SubscriptionObj->id) { % if (my $lang = $SubscriptionObj->SubValue('Language')) { % $original_handle = $session{'CurrentUser'}->{'LangHandle'}; % $session{'CurrentUser'}->{'LangHandle'} = RT::I18N->get_handle($lang); % } % } % $m->callback(CallbackName => 'BeforeTable', Dashboard => $Dashboard, show_cb => $show_cb);
% $m->callback(CallbackName => 'BeforePanes', Dashboard => $Dashboard, show_cb => $show_cb); % my $body = $show_cb->('body'); % my $sidebar = $show_cb->('sidebar');
<% $body |n %>
% if ( $sidebar =~ /\S/ ) {
<% $sidebar |n %>
% } % $m->callback(CallbackName => 'AfterPanes', Dashboard => $Dashboard, show_cb => $show_cb);
% $m->callback(CallbackName => 'AfterTable', Dashboard => $Dashboard, show_cb => $show_cb); % if (!$Preview) { % if ( $session{ContextUser}->id != $session{CurrentUser}->id ) {

<&|/l, $Dashboard->Name, $session{CurrentUser}->Name &>This is generated from dashboard "[_1]" by the subscription of user "[_2]".

% } % my $edit = RT->Config->Get('WebPath') . '/Dashboards/Modify.html?id='.$id; % my $subscription = RT->Config->Get('WebPath') . '/Dashboards/Subscription.html?id='.$id;

<&|/l, $edit, $subscription &>You may edit this dashboard and your subscription to it in RT.

%# We disable autohandlers when mailing (!$Preview) so /Elements/Footer isn't %# run for us. Tidy up the end of the HTML. We don't use /Elements/Tabs (and %# hence PageLayout) so we don't need to close any other tags. % } % # restore the original language for anything else on the page % if ($original_handle) { % $session{'CurrentUser'}->{'LangHandle'} = $original_handle; % } <%INIT> my @results; my $skip_create = 0; # Don't permit someone to supply "self_service_dashboard=1" directly # on the URL line if ($m->request_path !~ m{^/SelfService/}) { $self_service_dashboard = 0; } $m->callback(ARGSRef => \%ARGS, results => \@results, CallbackName => 'Initial', skip_create => \$skip_create); # Add selected user to notes if it was submitted my $SavedSearchSelectedUserName; if ( $SavedSearchSelectedUserName = $m->request_args->{'SavedSearchSelectedUserName'} ) { my $user = RT::User->new( $session{CurrentUser} ); my ($ret, $msg) = $user->Load($SavedSearchSelectedUserName); if ( $ret and $user->Id ) { $m->notes->{SavedSearchSelectedUserName} = $user->Name; $m->notes->{SavedSearchSelectedUserId} = $user->Id; } else { RT->Logger->error("Unable to load user in dashboard for SelectedUserName " . $SavedSearchSelectedUserName . " : $msg"); } } my $class = $self_service_dashboard ? 'RT::Dashboard::SelfService' : 'RT::Dashboard'; RT::StaticUtil::RequireModule($class); my $Dashboard = $class->new($session{'CurrentUser'}); my ($ok, $msg) = $Dashboard->LoadById($id); unless ($ok) { RT::Logger->error("Unable to load dashboard with $id: $msg"); Abort(loc("Could not load dashboard [_1]", $id), Code => HTTP::Status::HTTP_NOT_FOUND); } # Pick reasonable defaults my $body_width = $Dashboard->Width->{body} // 8; my $sidebar_width = $Dashboard->Width->{sidebar} // 4; my $path = '/Dashboards/' . $Dashboard->id . '/' . $Dashboard->Name; unless ( $skip_create ) { push @results, ProcessQuickCreate( Path => $path, ARGSRef => \%ARGS ); } 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; } $session{ContextUser} ||= $session{CurrentUser}; # otherwise honor their search preferences.. otherwise default search result rows and fall back to 50 # $rows == 0 means unlimited, which we don't want to ignore from above unless (defined($rows)) { my $prefs = $session{'ContextUser'}->UserObj->Preferences("SearchDisplay") || {}; $rows = $prefs->{'RowsPerPage'} // RT->Config->Get('DefaultSearchResultRowsPerPage') // 50; } my $title; if ($self_service_dashboard) { $title = loc('Self-Service Dashboard'); } else { $title = loc('[_1] Dashboard', $Dashboard->Name); } my $show_cb = sub { my $pane = shift; return $m->scomp('Elements/ShowPortlet/dashboard', Portlet => $Dashboard, Rows => $rows, Preview => $Preview, Dashboard => $Dashboard, Pane => $pane, Depth => 0, HasResults => $HasResults, ); }; my $Refresh = $Preview ? $session{'home_refresh_interval'} || RT->Config->Get('HomePageRefreshInterval', $session{'CurrentUser'}) : 0; <%ARGS> $id => undef $Preview => 1 $HasResults => undef $self_service_dashboard => 0