Tips_tutorials   >   Studiojs202   >   Web App Stats Web Page
First we will create the remote task that responds to the request.
; Run the superclass code which set the task variables.
Do inherited Returns FlagOK
If FlagOK
; Convert the string text dates to dates vars.
Calculate BeginDate as dat(pParamsRow.BeginDate,'y-M-D')
Calculate EndDate as dat(pParamsRow.EndDate,'y-M-D')
Do webmon.$retWebStatsList(BeginDate,EndDate) Returns List
If List.$colcount=0
Calculate FlagOK as kFalse
Else
Do webmon.$convertWebStatsListToText(List) Returns Text
If len(Text)
Calculate Text as replaceall(Text,kCr,'<br />')
Do ioHTMLTools.$retHTMLPageTemplate Returns HTML
; Replace the placeholders with content.
Calculate HTML as replaceall(HTML,'##LINK##','')
Calculate HTML as replaceall(HTML,'##JAVASCRIPT##','')
Calculate HTML as replaceall(HTML,'##TITLE##','Web App Stats')
Calculate HTML as replaceall(HTML,'##BODY##',Text)
; Add the HTTP content header.
Do ioHTMLTools.$addHTTPContentHeader(HTML) Returns FlagOK
End If
End If
End If
If not(FlagOK)
; An error occurred. Get the last error as an HTML page.
Do ioHTMLTools.$retLastErrorHTML() Returns HTML
End If
Quit method HTML
We will now create a web page for getting the web apps stats.
<html>
<head>
<title>Web App Stats</title>
<link rel="stylesheet" type="text/css" href="http://localhost/css/master.css" />
<script type="text/javascript" src="../js/webappstats.js"></script>
</head>
<body>
<div class="container"> <!-- open container div -->
<div class="title">Web App Stats</div> <!-- title div -->
<div class="search"> <!-- open search div -->
<p>
Enter the date range for the web stats which you would like to view
and then click the 'View Stats' button
</p>
<table>
<tr>
<td>Begin Date</td>
<td><input type="text" id="BeginDate" name="BeginDate" value="2007-01-01" size="15" /></td>
<td>yyyy-mm-dd</td>
</tr>
<tr>
<td>End Date</td>
<td><input type="text" id="EndDate" name="EndDate" value="2007-12-31" size="15" /></td>
<td>yyyy-mm-dd</td>
</tr>
<tr>
<td></td>
<td><input type="button" value="View Stats" onclick="submitRequestViaFrame()" /></td>
</tr>
</table>
</div> <!-- close search div -->
<iframe id="ResultsFrame" src="" width="100%" height="100%" scrolling="yes" frameborder="0"></iframe>
</div> <!-- close container div -->
<input type="hidden" id="WebAppServerCGI" value="http://localhost/cgi-bin/nph-omniscgi" />
<input type="hidden" id="OmnisServer" value="5912" />
<input type="hidden" id="OmnisLibrary" value="ContactsWeb" />
<input type="hidden" id="OmnisClass" value="rtWebAppStats" />
</body>
</html>
function pingFile() {
alert("Ping File");
}
function submitRequestViaFrame() {
// Gather the hidden inputs needed to assemble the URL
var CGI = document.getElementById("WebAppServerCGI").value
var OmnisServer = document.getElementById("OmnisServer").value
var OmnisLibrary = document.getElementById("OmnisLibrary").value
var OmnisClass = document.getElementById("OmnisClass").value
var BeginDate = document.getElementById("BeginDate").value
var EndDate = document.getElementById("EndDate").value
var URL = CGI + "?" + "OmnisServer=" + OmnisServer + "&OmnisLibrary=" + OmnisLibrary + "&OmnisClass=" + OmnisClass;
//alert("URL = " + URL);
URL = URL + "&BeginDate=" + BeginDate + "&EndDate=" + EndDate ;
// Get a reference to the frame
var rFrame = document.getElementById("ResultsFrame");
// Point the frame to the URL
rFrame.src = URL ;
}
There you have it! The ability to get your web app stats on-line.
We could get much fancier with the format and presentation of the web app stats report by putting them into a couple of tables on the web page and tinkering with the CSS. I'll leave that for you to do in your spare time. :-)