All Apps and Add-ons

How to use the Paginator with EntityLinkLister

xtrjx
Explorer

I created a dashboard view that will display a list of saved searches using the EntityLinkLister module. I also use the Paginator module to page through the list of saved searches since there are a lot of them. The problem is that the Paginator wants to open the flashtimeline view whenever "prev", "next", or any of the page numbers are clicked instead of simply paging through the list. How do I configure the Paginator to simply page through the list, but wait until one of the saved search links is clicked before firing up the flashtimeline view?

Here's the complete code in my view:

<view template="dashboard.html">
    <label>Saved Searches</label>
    <module name="AccountBar" layoutPanel="appHeader"/>
    <module name="SideviewUtils" layoutPanel="appHeader" />
    <module name="AppBar" layoutPanel="navigationHeader"/>
    <module name="Message" layoutPanel="messaging">
        <param name="filter">*</param>
        <param name="clearOnJobDispatch">False</param>
        <param name="maxSize">3</param>
    </module>

    <!--Display List of Saved Searches -->
    <module name="Paginator" layoutPanel="panel_row1_col1" >
        <param name="entityName">settings</param>
            <module name="EntityLinkLister"  >
            <param name="count">10</param>
            <param name="entityPath">saved/searches</param>
            <param name="settingToCreate">SavedSearches</param>
            <param name="entityFieldsToDisplay">
                <list>
                    <param name="label">name</param>
                    <param name="value">search</param>
                </list>
            </param>
            <module name="Search">
                <param name="search">$SavedSearches$</param>
                    <module name="ViewRedirector">
                        <param name="viewTarget">flashtimeline</param>
                    </module> <!-- ViewRedirector -->
            </module> <!-- Search -->
        </module> <!-- EntityLinkLister -->
    </module> <!-- Paginator -->
</view>

Thanks.

1 Solution

xtrjx
Explorer

Although I read Jason's post at http://splunk-base.splunk.com/answers/5129/3x-style-list-of-saved-searches-on-dashboard-followup a hundred times, it finally made sense after posting this question myslef. Article 5129 really contained the fix / workaround for the issue with the EntityLinkLister not stopping pushes to downstream modules. Thanks Jason and others that contributed to that article. The push downstream is what caused the annoying behaviour of opening the flashtimeline when "prev","next", or page numbers are clicked in the Paginator.

To paraphrase article 5129 a bit, I fixed my issue by:

  1. Created the new file called "application.js" (see code below) and put it in $SPLUNK_HOME/etc/apps/myapp/appserver/static. Note this script refers to the value of the EntityLinkLister's "settingToCreate" parameter. I called this "SavedSearches" in my original view xml. I changed this to "savedSearchName" to match the application.js. Any name will do, as long as the names match between the EntityLinkLister and the applicaion.js script.

  2. Replaced the Hidden Search/ConvertToIntention/ViewRedirector modules ( or just the search module if using Sideview Utils ) with the NullModule module.

  3. Restarted splunkd to get splunk to see the new application.js script.

That's it. The paginator and EntityLinkLister work as I expect now with the added bonus, compliments of the application.js script, is that the saved searches run by default in the view and with the timerang that was saved with the save search.

My new view xml code now looks like this:

<view template="dashboard.html">
<label>Saved Searches</label>
<module name="AccountBar" layoutPanel="appHeader"/>
<module name="AppBar" layoutPanel="navigationHeader"/>
<module name="Message" layoutPanel="messaging">
<param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">3</param>
</module>
<!--Display List of Saved Searches -->
<module name="Paginator" layoutPanel="panel_row1_col1" >
    <param name="entityName">settings</param>
    <param name="count">20</param>
    <module name="EntityLinkLister">
        <param name="namespace">ADP_Performance</param>
        <param name="count">20</param>
        <param name="entityPath">/saved/searches</param>
        <param name="settingToCreate">savedSearchName</param>
        <param name="entityFieldsToDisplay">
            <list>
                <param name="label">name</param>
                <param name="value">name</param>
            </list>
        </param>
        <!-- PLACE NULL MODULE HERE , EntitiyLinkLister module is processed by application.js -->
        <module name="NullModule" />
    </module> <!-- EntityLinkLister -->
</module> <!-- Paginator -->

$SPLUNK_HOME/etc/apps/your-application-name-goes-here/appserver/static/application.js looks like this:

switch (Splunk.util.getCurrentView()) {
case "SavedSearches" :
    // PATCH 1 
    //   -- the entityLinkLister does not stop framework pushes. 

    if (Splunk.Module.EntityLinkLister) {
        Splunk.Module.EntityLinkLister= $.klass(Splunk.Module.EntityLinkLister, {
            onUserAction: function($super, event) {
                $super(event);
                this.pushContextToChildren(null, true);
            },
            pushContextToChildren: function($super, explicitContext, simonSays) {
                if (!this.isPageLoadComplete || simonSays) {
                    $super(explicitContext);
                }
            }

        });
    }
    // PATCH 2 - Neither ViewRedirector nor anyone else 
    // allows you to redirect a saved search link such that 
    // the displayView and the timerange are set correctly. 
    if (Splunk.Module.NullModule) {
        Splunk.Module.NullModule= $.klass(Splunk.Module.NullModule, {
            onContextChange: function() {
                var context = this.getContext();
                var savedSearchName = context.get("savedSearchName");
                Splunk.util.redirect_to("/app/" + Splunk.util.getCurrentApp() + "/@go?s=" + encodeURIComponent(savedSearchName));
            }
        });
    }
    break;

}

Thanks.

View solution in original post

0 Karma

xtrjx
Explorer

Although I read Jason's post at http://splunk-base.splunk.com/answers/5129/3x-style-list-of-saved-searches-on-dashboard-followup a hundred times, it finally made sense after posting this question myslef. Article 5129 really contained the fix / workaround for the issue with the EntityLinkLister not stopping pushes to downstream modules. Thanks Jason and others that contributed to that article. The push downstream is what caused the annoying behaviour of opening the flashtimeline when "prev","next", or page numbers are clicked in the Paginator.

To paraphrase article 5129 a bit, I fixed my issue by:

  1. Created the new file called "application.js" (see code below) and put it in $SPLUNK_HOME/etc/apps/myapp/appserver/static. Note this script refers to the value of the EntityLinkLister's "settingToCreate" parameter. I called this "SavedSearches" in my original view xml. I changed this to "savedSearchName" to match the application.js. Any name will do, as long as the names match between the EntityLinkLister and the applicaion.js script.

  2. Replaced the Hidden Search/ConvertToIntention/ViewRedirector modules ( or just the search module if using Sideview Utils ) with the NullModule module.

  3. Restarted splunkd to get splunk to see the new application.js script.

That's it. The paginator and EntityLinkLister work as I expect now with the added bonus, compliments of the application.js script, is that the saved searches run by default in the view and with the timerang that was saved with the save search.

My new view xml code now looks like this:

<view template="dashboard.html">
<label>Saved Searches</label>
<module name="AccountBar" layoutPanel="appHeader"/>
<module name="AppBar" layoutPanel="navigationHeader"/>
<module name="Message" layoutPanel="messaging">
<param name="filter">*</param>
    <param name="clearOnJobDispatch">False</param>
    <param name="maxSize">3</param>
</module>
<!--Display List of Saved Searches -->
<module name="Paginator" layoutPanel="panel_row1_col1" >
    <param name="entityName">settings</param>
    <param name="count">20</param>
    <module name="EntityLinkLister">
        <param name="namespace">ADP_Performance</param>
        <param name="count">20</param>
        <param name="entityPath">/saved/searches</param>
        <param name="settingToCreate">savedSearchName</param>
        <param name="entityFieldsToDisplay">
            <list>
                <param name="label">name</param>
                <param name="value">name</param>
            </list>
        </param>
        <!-- PLACE NULL MODULE HERE , EntitiyLinkLister module is processed by application.js -->
        <module name="NullModule" />
    </module> <!-- EntityLinkLister -->
</module> <!-- Paginator -->

$SPLUNK_HOME/etc/apps/your-application-name-goes-here/appserver/static/application.js looks like this:

switch (Splunk.util.getCurrentView()) {
case "SavedSearches" :
    // PATCH 1 
    //   -- the entityLinkLister does not stop framework pushes. 

    if (Splunk.Module.EntityLinkLister) {
        Splunk.Module.EntityLinkLister= $.klass(Splunk.Module.EntityLinkLister, {
            onUserAction: function($super, event) {
                $super(event);
                this.pushContextToChildren(null, true);
            },
            pushContextToChildren: function($super, explicitContext, simonSays) {
                if (!this.isPageLoadComplete || simonSays) {
                    $super(explicitContext);
                }
            }

        });
    }
    // PATCH 2 - Neither ViewRedirector nor anyone else 
    // allows you to redirect a saved search link such that 
    // the displayView and the timerange are set correctly. 
    if (Splunk.Module.NullModule) {
        Splunk.Module.NullModule= $.klass(Splunk.Module.NullModule, {
            onContextChange: function() {
                var context = this.getContext();
                var savedSearchName = context.get("savedSearchName");
                Splunk.util.redirect_to("/app/" + Splunk.util.getCurrentApp() + "/@go?s=" + encodeURIComponent(savedSearchName));
            }
        });
    }
    break;

}

Thanks.

0 Karma

sideview
SplunkTrust
SplunkTrust

Technically with Sideview Multiplex module you can now basically make an HTML module to hold the $foo$ tokens for the href and value of your link, and then "multiplex" that HTML module... See Multiplexer docs for more info. Coming shortly in Sideview Utils 2.5 is a "urlEncodeKeys" param on the HTML module that will makes this even easier. (prior to 2.5 users had to use a ValueSetter to url encode the relevant key(s))

0 Karma

dturnbull_splun
Splunk Employee
Splunk Employee

I've had good results doing similar things using just a normal search with the rest search command to enumerate.

0 Karma

sideview
SplunkTrust
SplunkTrust

Note since we're already using Sideview Utils on this page (Note the direct replacement of $SavedSearches$ in the Search module, with no intentions), then it's a little easier to use Sideview's customBehavior mechanism to attach the behavior, instead of using a NullModule. But I agree, EntityLinkLister doesn't act properly here. It should act like SimpleResultsTable and FlashChart and only push downstream when the user has clicked on it directly.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...