<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What is wrong in this JS and CSS for row color? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440266#M29016</link>
    <description>&lt;P&gt;Hello @ljalvrdz,&lt;/P&gt;

&lt;P&gt;did you on purpose rename to different fields into &lt;CODE&gt;USUARIO&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;I see form the last rename : &lt;CODE&gt;vpn_user AS USUARIO ... vpn_username AS USUARIO&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This seems a bit strange to me. Can you please confirm?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 07:02:44 GMT</pubDate>
    <dc:creator>poete</dc:creator>
    <dc:date>2018-07-17T07:02:44Z</dc:date>
    <item>
      <title>What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440264#M29014</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm having issues with Splunk 7.1.1 making this row colour thing to work, this is my dashboard:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard script="table_row_highlighting.js" stylesheet="table_decorations.css"&amp;gt;
  &amp;lt;label&amp;gt;Network Dashboard&amp;lt;/label&amp;gt;
  &amp;lt;description&amp;gt;Network Dashboard - Dev01&amp;lt;/description&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;VPN Client Login&amp;lt;/title&amp;gt;
      &amp;lt;table id='highlight'&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=main login_result=* vpn_user=* vpn_port=XXXX OR XXXX OR XXXX ip_vpn_source=*
          | table  _time vpn_user vpn_port login_result ip_vpn_source
          | lookup vpn_lookup vpn_user OUTPUTNEW vpn_username
          | eval _time=strftime(_time, "%d/%m/%Y %H:%M:%S %p")
          | sort - _time
          | replace "XXXX" WITH XXXX IN vpn_port
          | replace "XXXX" WITH XXXX IN vpn_port
          | replace "XXXX" WITH XXXX IN vpn_port
          | replace "Login failed" WITH DENEGADA IN login_result
          | replace "Login Success" WITH APROBADA IN login_result
          | rename _time AS HORA vpn_user AS USUARIO vpn_port AS CONEXION login_result AS AUTORIZACIÓN ip_vpn_source AS ORIGEN vpn_username AS USUARIO
          &amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;rt-12h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;rtnow&amp;lt;/latest&amp;gt;
          &amp;lt;sampleRatio&amp;gt;1&amp;lt;/sampleRatio&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="dataOverlayMode"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="percentagesRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="rowNumbers"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="totalsRow"&amp;gt;false&amp;lt;/option&amp;gt;
        &amp;lt;option name="wrap"&amp;gt;false&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What it basically does is to create a table and provide time, username, port and result of credentials from a VPN client access, so we can monitor approved and unapproved users.&lt;/P&gt;

&lt;P&gt;I am using this JS to change the row colour (red) when unapproved users show:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

     // Row Coloring Example with custom, client-side range interpretation

    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for both the active_hist_searches and the active_realtime_searches field
            return _(["login_result"]).contains(cell.field);
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            var value = cell.value;

            // Apply interpretation for string of autorización
            if (cell.field === "login_result") {
                if (value == "Login failed") {
                    $td.addClass('range-cell').addClass('range-severe');
                }
            }

            // Update the cell content
            $td.text(value).addClass('string');
        }
    });

    mvc.Components.get('highlight').getVisualization(function(tableView) {
        tableView.on('rendered', function() {

            setTimeout(function(){
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.range-cell').each(function() {
                $(this).parents('tr').addClass(this.className);
            });
         },100);
        });
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addCellRenderer(new CustomRangeRenderer());
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I took it from Splunk Dashboard Examples App and also this CSS:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/* Custom Icons */

td.icon {
    text-align: center;
}

td.icon i {
    font-size: 25px;
    text-shadow: 1px 1px #aaa;
}

td.icon .severe {
    color: red;
}

td.icon .elevated {
    color: orangered;
}

td.icon .low {
    color: #006400;
}

/* Row Coloring */

#highlight tr td {
    background-color: #c1ffc3 !important;
}

#highlight tr.range-elevated td {
    background-color: #ffc57a !important;
}

#highlight tr.range-severe td {
    background-color: #d59392 !important;
}


#highlight .table td {
    border-top: 1px solid #fff;
}

#highlight td.range-severe, td.range-elevated {
    font-weight: bold;
}

.icon-inline i {
    font-size: 18px;
    margin-left: 5px;
}
.icon-inline i.icon-alert-circle {
    color: #ef392c;
}
.icon-inline i.icon-alert {
    color: #ff9c1a;
}
.icon-inline i.icon-check {
    color: #5fff5e;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The colour is not changing to red, the whole table is green doesn't matter if the column "login_result" shows "Login failed". I would appreciate any ideas.&lt;/P&gt;

&lt;P&gt;Gracias,&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 01:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440264#M29014</guid>
      <dc:creator>ljalvrdz</dc:creator>
      <dc:date>2018-07-17T01:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440265#M29015</link>
      <description>&lt;P&gt;@ljalvrdz have you removed the following rename pipe to test?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;login_result AS AUTORIZACIÓN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also can you check with historical search instead of real-time (maybe refresh panel every 30 seconds instead)?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;       &amp;lt;earliest&amp;gt;-12h&amp;lt;/earliest&amp;gt;
       &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 03:55:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440265#M29015</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-07-17T03:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440266#M29016</link>
      <description>&lt;P&gt;Hello @ljalvrdz,&lt;/P&gt;

&lt;P&gt;did you on purpose rename to different fields into &lt;CODE&gt;USUARIO&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;I see form the last rename : &lt;CODE&gt;vpn_user AS USUARIO ... vpn_username AS USUARIO&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This seems a bit strange to me. Can you please confirm?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 07:02:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440266#M29016</guid>
      <dc:creator>poete</dc:creator>
      <dc:date>2018-07-17T07:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440267#M29017</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; I removed the rename:&lt;BR /&gt;
    &lt;QUERY&gt;index=main login_result=* vpn_user=* vpn_port=9050 OR 9010 OR 9100 ip_vpn_source=* &lt;BR /&gt;
              | table  _time vpn_user vpn_port login_result ip_vpn_source &lt;BR /&gt;
              | lookup vpn_lookup vpn_user OUTPUTNEW vpn_username &lt;BR /&gt;
              | eval _time=strftime(_time, "%d/%m/%Y %H:%M:%S %p") &lt;BR /&gt;
              | sort - _time &lt;BR /&gt;
              | replace "9010" WITH EOS-CFE IN vpn_port &lt;BR /&gt;
              | replace "9100" WITH ELSTER IN vpn_port &lt;BR /&gt;
              | replace "9050" WITH EOS-SAP IN vpn_port &lt;BR /&gt;
              | replace "Login failed" WITH DENEGADA IN login_result &lt;BR /&gt;
              | replace "Login Success" WITH APROBADA IN login_result &lt;BR /&gt;
              | rename _time AS HORA vpn_user AS USUARIO vpn_port AS CONEXION ip_vpn_source AS ORIGEN vpn_username AS USUARIO&lt;BR /&gt;
              &lt;/QUERY&gt;&lt;/P&gt;

&lt;P&gt;And changed the historical search with no luck:&lt;BR /&gt;
    &lt;EARLIEST&gt;-12hrs&lt;/EARLIEST&gt;&lt;BR /&gt;
              &lt;LATEST&gt;now&lt;/LATEST&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440267#M29017</guid>
      <dc:creator>ljalvrdz</dc:creator>
      <dc:date>2020-09-29T20:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440268#M29018</link>
      <description>&lt;P&gt;Hello @poete,&lt;/P&gt;

&lt;P&gt;Yes I did that on purpose.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 15:25:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440268#M29018</guid>
      <dc:creator>ljalvrdz</dc:creator>
      <dc:date>2018-07-17T15:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440269#M29019</link>
      <description>&lt;P&gt;Hello  @ljalvrdz,&lt;BR /&gt;
it seems there is a problem of consistency between your js code and  your renames and replaces.&lt;/P&gt;

&lt;P&gt;In case you keep &lt;CODE&gt;| replace "Login failed" WITH DENEGADA IN login_result&lt;/CODE&gt; in the query, then you need to modify your js accordingly &lt;BR /&gt;
&lt;CODE&gt;if (value == "Login failed") {&lt;/CODE&gt; then becomes &lt;CODE&gt;if (value == "DENEGADA") {&lt;/CODE&gt;&lt;BR /&gt;
Accordingly, &lt;BR /&gt;
In case you keep &lt;CODE&gt;| rename ... login_result AS AUTORIZACIÓN&lt;/CODE&gt;, then you need to modify &lt;CODE&gt;if (cell.field === "login_result") {&lt;/CODE&gt; to &lt;CODE&gt;if (cell.field === "AUTORIZACIÓN") {&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Do not forget to '_bump' in order to make sure the changes are taken into account.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 15:59:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440269#M29019</guid>
      <dc:creator>poete</dc:creator>
      <dc:date>2018-07-17T15:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440270#M29020</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/208450"&gt;@poete&lt;/a&gt;,&lt;/P&gt;

&lt;P&gt;Thanks for the answer but I'm still unable to make it work. I keep the XML code of the dashboard like this:&lt;BR /&gt;
    &lt;DASHBOARD script="table_row_highlighting.js" stylesheet="table_decorations.css"&gt;&lt;BR /&gt;
      &lt;LABEL&gt;Network Dashboard&lt;/LABEL&gt;&lt;BR /&gt;
      &lt;DESCRIPTION&gt;Network Dashboard - Dev01&lt;/DESCRIPTION&gt;&lt;BR /&gt;
      &lt;ROW&gt;&lt;BR /&gt;
        &lt;PANEL&gt;&lt;BR /&gt;
          &lt;TITLE&gt;VPN Client Login&lt;/TITLE&gt;&lt;BR /&gt;
          &lt;TABLE id="highlight"&gt;&lt;BR /&gt;
            &lt;SEARCH&gt;&lt;BR /&gt;
              &lt;QUERY&gt;index=main login_result=* vpn_user=* vpn_port=9050 OR 9010 OR 9100 ip_vpn_source=*&lt;BR /&gt;
              | table  _time vpn_user vpn_port login_result ip_vpn_source&lt;BR /&gt;
              | lookup vpn_lookup vpn_user OUTPUTNEW vpn_username&lt;BR /&gt;
              | eval _time=strftime(_time, "%d/%m/%Y %H:%M:%S %p")&lt;BR /&gt;
              | sort - _time&lt;BR /&gt;
              | replace "9010" WITH EOS-CFE IN vpn_port&lt;BR /&gt;
              | replace "9100" WITH ELSTER IN vpn_port&lt;BR /&gt;
              | replace "9050" WITH EOS-SAP IN vpn_port&lt;BR /&gt;
              | replace "Login failed" WITH DENEGADA IN login_result&lt;BR /&gt;
              | replace "Login Success" WITH APROBADA IN login_result&lt;BR /&gt;
              | rename _time AS HORA vpn_user AS USUARIO vpn_port AS CONEXION login_result as AUTORIZACIÓN ip_vpn_source AS ORIGEN vpn_username AS USUARIO&lt;BR /&gt;
              &lt;/QUERY&gt;&lt;BR /&gt;
              &lt;EARLIEST&gt;rt-12hrs&lt;/EARLIEST&gt;&lt;BR /&gt;
              &lt;LATEST&gt;rtnow&lt;/LATEST&gt;&lt;BR /&gt;
              &lt;SAMPLERATIO&gt;1&lt;/SAMPLERATIO&gt;&lt;BR /&gt;
            &lt;/SEARCH&gt;&lt;BR /&gt;
            none&lt;BR /&gt;
            none&lt;BR /&gt;
            false&lt;BR /&gt;
            false&lt;BR /&gt;
            false&lt;BR /&gt;
            false&lt;BR /&gt;
          &lt;/TABLE&gt;&lt;BR /&gt;
        &lt;/PANEL&gt;&lt;BR /&gt;
      &lt;/ROW&gt;&lt;BR /&gt;
    &lt;/DASHBOARD&gt;&lt;/P&gt;

&lt;P&gt;And modify the JS code like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'underscore',
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/tableview',
    'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {

     // Row Coloring Example with custom, client-side range interpretation

    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function(cell) {
            // Enable this custom cell renderer for both the active_hist_searches and the active_realtime_searches field
            return _(["AUTORIZACIÓN"]).contains(cell.field);
        },
        render: function($td, cell) {
            // Add a class to the cell based on the returned value
            var value = cell.value;

            // Apply interpretation for string of autorización
            if (cell.field === "AUTORIZACIÓN") {
                if (value == "DENEGADA") {
                    $td.addClass('range-cell').addClass('range-severe');
                }
            }

            // Update the cell content
            $td.text(value).addClass('string');
        }
    });

    mvc.Components.get('highlight').getVisualization(function(tableView) {
        tableView.on('rendered', function() {

            setTimeout(function(){
            // Apply class of the cells to the parent row in order to color the whole row
            tableView.$el.find('td.range-cell').each(function() {
                $(this).parents('tr').addClass(this.className);
            });
         },100);
        });
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addCellRenderer(new CustomRangeRenderer());
    });

});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Did the &lt;EM&gt;_bump&lt;/EM&gt;, &lt;EM&gt;splunk restart splunkweb&lt;/EM&gt; and even restart all splunk service but no success.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440270#M29020</guid>
      <dc:creator>ljalvrdz</dc:creator>
      <dc:date>2020-09-29T20:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: What is wrong in this JS and CSS for row color?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440271#M29021</link>
      <description>&lt;P&gt;I tried in another web browser and it worked. Maybe something to do with my caché.&lt;/P&gt;

&lt;P&gt;Thank you for the help! @poete&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 17:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/What-is-wrong-in-this-JS-and-CSS-for-row-color/m-p/440271#M29021</guid>
      <dc:creator>ljalvrdz</dc:creator>
      <dc:date>2018-07-17T17:58:05Z</dc:date>
    </item>
  </channel>
</rss>

