I just developed the technique to do exactly what you want. It is a bit complicated but it works perfectly.
You will need to use the SideView Utils library, and add a "Run" button which will run the searches in your dashboard.
Set the parameters of this button like this:
<module name="Button" layoutPanel="viewHeader">
<param name="allowSoftSubmit">False</param>
<param name="allowAutoSubmit">False</param>
<param name="label">Run</param>
<param name="customBehavior">TimeRangeExceeds7DaysError</param>
In the application.js file which sits in your search head, (I think that's the right path:
[home]/etc/apps/search/appserver/static/application.js)
add the following function:
if (typeof(Sideview)!="undefined")
{
Sideview.utils.declareCustomBehavior("TimeRangeExceeds7DaysError", function(buttonModule)
{
methodReference = buttonModule.onContextChange.bind(buttonModule);
buttonModule.onContextChange = function()
{
var context = this.getContext();
var search = context.get("search");
var range = search.getTimeRange();
var earliestTime = range.getEarliestTimeTerms();
var n = 0;
if( range.isRelative() )
{
n = parseInt(earliestTime.toString().substr(1), 10);
}
var rexw = /-\d+w/i;
var rexd = /-\d+d/i;
var rexh = /-\d+h/i;
var rexm = /-\d+m/i
var rexs = /-\d+s/i;
if(
range.getDuration() > 604800000 ||
earliestTime.toString().indexOf("mon") > -1 ||
earliestTime.toString().indexOf("y") > -1 ||
(rexw.test(earliestTime) && n > 1 ) ||
(rexd.test(earliestTime) && n > 7) ||
(rexh.test(earliestTime) && n > 168) ||
(rexm.test(earliestTime) && n > 10080) ||
(rexs.test(earliestTime) && n > 604800)
)
{
alert('This dashboard can only run for a maximum time range of 7 days.\r\nThe Run button will remain hidden until you set a valid time range');
this.hide("run_button");
}
else
{
this.show("run_button");
}
}
return methodReference();
});
}
In this particular case, whenever the time range selected exceeds 7 days, a message pops-up with the text informing the user of the dashboard limitation, and what needs to be done, to enable the "Run" button.
Note that the recognition handles both absolute and relative time range selections. This allows users to pick specific time ranges in the past so long as they do not exceed 7 days. And, it will even trigger if time range is set in hours, minutes or seconds but the total amount of time is greater than 7 days.
... View more