Custom Dashboard Dashlet

Moderator: crythias

Locked
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Custom Dashboard Dashlet

Post by brendanlim »

Hi guys,

I'm just wondering if I missed a step somewhere, I'm on OTRS 5 and I know this guide to create custom dashlet is out dated:
http://blog.otrs.org/2010/09/26/keep-an ... entTSearch

but I managed to get the following custom XML to load into SysConfig but I can't add that into my dashboard (Screenshots attached).

The objective of this custom dashlet is to list only the tickets the Agent logged in is Responsible for and nothing else.

Custom.xml Code

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
 <otrs_config version="1.0" init="Application">
  <ConfigItem Name="DashboardBackend###0140-Responsible" Required="0" Valid="1">
  <Description Lang="en" Translatable="1">Parameters  for the dashboard backend. ...</Description>
  <Group>Ticket</Group>
  <SubGroup>Frontend::Agent::Dashboard</SubGroup>
  <Setting>
   <Hash>
    <Item Key="Module">Kernel::Output::HTML::DashboardTicketGeneric</Item>
    <Item Key="Title">Tickets from my customers</Item>
    <Item Key="Description">Tickets which need to be answered!</Item>
    <Item Key="Attributes">StateType=open;StateType=new;</Item>
    <Item Key="Filter">Responsible</Item>
    <Item Key="Time">Age</Item>
    <Item Key="Limit">10</Item>
    <Item Key="Permission">rw</Item>
    <Item Key="Block">ContentLarge</Item>
    <Item Key="Group"></Item>
    <Item Key="Default">1</Item>
    <Item Key="CacheTTLLocal">0.5</Item>
    <Item Key="DefaultColumns">
                    <Hash>
                        <Item Key="Age">2</Item>
                        <Item Key="Changed">1</Item>
                        <Item Key="CustomerID">1</Item>
                        <Item Key="CustomerName">1</Item>
                        <Item Key="CustomerUserID">1</Item>
                        <Item Key="EscalationResponseTime">1</Item>
                        <Item Key="EscalationSolutionTime">1</Item>
                        <Item Key="EscalationTime">1</Item>
                        <Item Key="EscalationUpdateTime">1</Item>
                        <Item Key="TicketNumber">2</Item>
                        <Item Key="Lock">1</Item>
                        <Item Key="Owner">1</Item>
                        <Item Key="PendingTime">1</Item>
                        <Item Key="Queue">1</Item>
                        <Item Key="Responsible">1</Item>
                        <Item Key="Priority">1</Item>
                        <Item Key="Service">1</Item>
                        <Item Key="State">1</Item>
                        <Item Key="SLA">1</Item>
                        <Item Key="Title">2</Item>
                        <Item Key="Type">1</Item>
                    </Hash>
                </Item>

    </Hash>
        </Setting>
 </ConfigItem>
</otrs_config>
Anybody know what I'm missing? There's no custom dashlet guide on OTRS v 5 guide online. Appreciate the assistance!
You do not have the required permissions to view the files attached to this post.
Last edited by brendanlim on 30 Mar 2016, 05:00, edited 1 time in total.
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Re: Custom Dashboard Dashlet not showing

Post by brendanlim »

Just to add, found these in the error log:

Module Kernel/Output/HTML/DashboardTicketGeneric.pm not in @INC (/opt/otrs/Custom /opt/otrs/Kernel/cpan-lib /opt/otrs/ /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl . /etc/apache2)

And I've edited the custom.xml with this line item to add a :: since there's supposed to be a / after the dashboard directory.

Code: Select all

    <Item Key="Module">Kernel::Output::HTML::Dashboard::TicketGeneric</Item>
Still doesn't show anything.. I think I'm only a step away but I can't figure it out..
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Custom Dashboard Dashlet not showing

Post by RStraub »

Hey there,

I copied your .xml just as you wrote it and it works.

Make sure to click on the SysConfig link once after each change, as the SysConfig then gets rebuild.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Re: Custom Dashboard Dashlet not showing

Post by brendanlim »

Umm.. not really.. I thought by defining "Filter" > Responsible means that they cannot view other cases that the user is not responsible for.

The agent can still view other people's cases in the "All Tickets" menu.. As you can see, the agent's responsible for only 12 tickets but if he clicks the "All Tickets" he can view all 31 total which is not right.. he should be able to only view 12 tickets regardless..

I'm thinking along the lines right now to copy the Kernel/Output/HTML/Dashboard/TicketGeneric.pm to another file and modify it to remove the "All Tickets" link from it but I can't seem to find the part where the link is in the coding? Then refer the custom dash let to that custom.pm file.
You do not have the required permissions to view the files attached to this post.
Last edited by brendanlim on 17 Mar 2016, 10:39, edited 1 time in total.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Custom Dashboard Dashlet not showing

Post by RStraub »

Oh, I thought your problem is that the dashlet is not showing.

The "Filter" key only defines what the default selected filter is.

If you want to only show the dashlet with the "my responsibilities" you'd have to customize the module or a write a new one. The generic one always adds all the filters (if the modules for it are active).
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Re: Custom Dashboard Dashlet not showing

Post by brendanlim »

Yeah exactly my chain of thought.. but I can't seem to find the .pm file that has that "All Tickets" link.. it's not in TicketsGeneric.pm as far as I searched.. I just need to remove that line of code that shows that link..
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Custom Dashboard Dashlet not showing

Post by RStraub »

It's a combination of these two files:
https://github.com/OTRS/otrs/blob/rel-5 ... ic.pm#L680

and:
https://github.com/OTRS/otrs/blob/rel-5 ... eric.tt#L9


But I'll warn you, if you edit these files, it will be reflected on all the dashboard widgets. Thus my recommendation to copy and modify it to your needs for that single widget.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Re: Custom Dashboard Dashlet not showing

Post by brendanlim »

Thanks RStraub!

Was wondering my grep -r "All Tickets" /opt/otrs didn't pull out those 2 files.. anyway..

So assuming this is the way to do it I'll just have to change my XML to:

Code: Select all

<Item Key="Module">Kernel::Output::HTML::Dashboard::CustomTicketGeneric</Item>
Which leads to CustomTicketGeneric.pm where we will copy the entire TicketGeneric.pm codes here and modify this section for Template File to "CustomAgentDashboardTicketGeneric"

Code: Select all

  
  my $Content = $LayoutObject->Output(
        TemplateFile => 'CustomAgentDashboardTicketGeneric',
        Data         => {
            %{ $Self->{Config} },
            Name => $Self->{Name},
            %{$Summary},
            FilterValue => $Self->{Filter},
            CustomerID  => $Self->{CustomerID},
        },
        KeepScriptTags => $Param{AJAX},
    );

    return $Content;
}
which then leads to "AgentDashboardTicketGeneric".tt i'm assuming. Which then I'll remove this line

Code: Select all

<li class="[% Data.item("All::Selected") | html %] Last"><a href="#" id="Dashboard[% Data.Name | html %]All" data-filter="All">[% Translate("All tickets") | html %] ([% Data.All | html %])</a></li>
So I guess my last question for this topic will be, do I need to do any commands to register my custom.tt and .pm files so that it will load those? Or just writing those in the same directory will automatically load those files?
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Custom Dashboard Dashlet not showing

Post by RStraub »

You figured that out pretty well :)

Yes you need to register any module, but only the .pm, the .tt doesn't need any registration. A simple registration could look like this (standalone .xml file):

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<otrs_config version="1.0" init="Application">
    <ConfigItem Name="Frontend::Module###CustomTicketGeneric" Required="0" Valid="1">
        <Description Translatable="1">Frontend module registration for the agent interface.</Description>
        <Group>Custom Framework</Group>
        <SubGroup>Frontend::Agent::ModuleRegistration</SubGroup>
        <Setting>
            <Hash>
                <Item Key="Module">Kernel::Output::HTML::Dashboard::CustomTicketGeneric</Item>
            </Hash>
        </Setting>
    </ConfigItem>
</otrs_config>
A vew hints to help you on your way:
- Copy the to-be-modified files in the same folder structure to ~otrs/Custom/...
- Make sure to also modify the first line in the .pm, it contains the name of the package and has to match with the name of the file, e.g.:
The FILE "Kernel/Output/HTML/Dashboard/CustomTicketGeneric.pm" should contain the LINE "package Kernel::Output::HTML::Dashboard::CustomTicketGeneric" (neither require the Custom/ folder prepended)
- After changes to a .xml in ~otrs/Kernel/Config/Files, click on the SysConfig link in the webfronted to rebuild the sysconfig
- After adding/changing/deleting perl modules, delete the cache with the shell script

EDIT: Oh yea the reason you didn't find the name in the modules is, because the name is dynamically generated through the name key-value pair in the sysconfig.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
brendanlim
Znuny newbie
Posts: 13
Joined: 26 Jan 2016, 07:02
Znuny Version: OTRS5.0.7
Real Name: Brendan Lim
Company: Trans Niaga Sdn Bhd

Re: Custom Dashboard Dashlet not showing

Post by brendanlim »

Weird and I got no idea where to start looking.. Thought I had the right chain of thought..

The XML file works as I can see the .pm is being loaded (as I have the Responsible filter on) so the dash let defaults to Responsible view.

/opt/otrs/Kernel/Config/Files/CustomDashboard.xml

Code: Select all

<Item Key="Module">Kernel::Output::HTML::Dashboard::CustomTicketGeneric</Item>
I've copied out the file from
/opt/otrs/Kernel/Output/HTML/Dashboard/TicketGeneric.pm
to
/opt/otrs/Custom/CustomTicketGeneric.pm

Edited the CustomTicketGeneric.pm lines for Package to

Code: Select all

package Kernel::Output::HTML::Dashboard::CustomTicketGeneric;
And also this portion to point to a separate .tt file

Code: Select all

    my $Content = $LayoutObject->Output(
        TemplateFile => 'CustomAgentDashboardTicketGeneric',
        Data         => {
            %{ $Self->{Config} },
            Name => $Self->{Name},
            %{$Summary},
            FilterValue => $Self->{Filter},
            CustomerID  => $Self->{CustomerID},
        },
        KeepScriptTags => $Param{AJAX},
    );
Then I copied the .tt file from
/opt/otrs/Kernel/Output/HTML/Templates/Standard/AgentDashboardTicketGeneric.tt
to
/opt/otrs/Custom/CustomAgentDashboardTicketGeneric.tt

But it throws me an error that it can't locate the CustomAgentDashboardTicketGeneric.tt when I try to load the Dashboard.

If I copy the Custom... tt file into the original path of /opt/otrs/Kernel/Output/HTML/Templates/Standard/ then it can detect the file but it throws other reference errors to other modules..

No idea what I'm missing or I'm getting the .tt portion idea wrong.. where it's just not a file I need to modify to remove the "All Tickets" link, but an entire directory of files that links to each other?
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Custom Dashboard Dashlet

Post by reneeb »

move

Code: Select all

/opt/otrs/Custom/CustomTicketGeneric.pm
to

Code: Select all

/opt/otrs/Custom/Kernel/Output/HTML/Dashboar/CustomTicketGeneric.pm
and

Code: Select all

/opt/otrs/Custom/CustomAgentDashboardTicketGeneric.tt
to

Code: Select all

/opt/otrs/Custom/Kernel/Output/HTML/Templates/Standard/CustomAgentDashboardTicketGeneric.tt
.

You have to keep the same directory layout in /opt/otrs/Custom/Kernel/ as in /opt/otrs/Kernel/!
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Locked