You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by aj...@apache.org on 2007/02/12 15:24:39 UTC
svn commit: r506458 - in /incubator/tuscany/cpp/sca/samples/AlertAggregator:
httpserver/htdocs/index.html sample.display/HTMLDisplayImpl.py
Author: ajborley
Date: Mon Feb 12 06:24:38 2007
New Revision: 506458
URL: http://svn.apache.org/viewvc?view=rev&rev=506458
Log:
Improvements to Alert Aggregator sample
Modified:
incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver/htdocs/index.html
incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.display/HTMLDisplayImpl.py
Modified: incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver/htdocs/index.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver/htdocs/index.html?view=diff&rev=506458&r1=506457&r2=506458
==============================================================================
--- incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver/htdocs/index.html (original)
+++ incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver/htdocs/index.html Mon Feb 12 06:24:38 2007
@@ -23,7 +23,7 @@
<link REL="stylesheet" TYPE="text/css" href="style.css">
</HEAD>
-<BODY ONLOAD="getSources()">
+<BODY ONLOAD="getSources('')">
<script type="text/javascript">
function getXMLHTTP()
{
@@ -58,7 +58,7 @@
var callIsRunning = false;
-function getAlerts()
+function getAlerts(sourceid)
{
var xmlHttp = getXMLHTTP();
xmlHttp.onreadystatechange=function()
@@ -72,20 +72,27 @@
if(xmlHttp.readyState==4)
{
callIsRunning = false;
- refr.innerHTML="<SPAN CLASS=\"clickable link\" ONCLICK=\"getAlerts()\">Refresh</SPAN>";
+ refr.innerHTML="<SPAN CLASS=\"clickable link\" ONCLICK=\"getAlerts('')\">Refresh</SPAN>";
document.getElementById("alertTable").innerHTML=xmlHttp.responseText;
}
}
if(!callIsRunning)
{
- xmlHttp.open("GET","rest/sample.display.DisplayComponent/HTMLDisplayService/getAlertsHTMLTable",true);
+ if(sourceid=='')
+ {
+ xmlHttp.open("GET","rest/sample.display.DisplayComponent/HTMLDisplayService/updateAllAlertsHTMLTable",true);
+ }
+ else
+ {
+ xmlHttp.open("GET","rest/sample.display.DisplayComponent/HTMLDisplayService/updateSourceAlertsHTMLTable?sourceId="+sourceid,true);
+ }
xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
xmlHttp.send(null);
}
// Call this function again after x minutes
- setTimeout("getAlerts();", 5*60000);
+ setTimeout("getAlerts('');", 5*60000);
}
function displayAlert(url, alertid)
@@ -121,7 +128,7 @@
xmlHttp.send(null);
}
-function getSources()
+function getSources(sourceid)
{
var xmlHttp = getXMLHTTP()
xmlHttp.onreadystatechange=function()
@@ -137,7 +144,7 @@
{
refreshSources.innerHTML="";
document.getElementById("sourcesTable").innerHTML=xmlHttp.responseText;
- getAlerts();
+ getAlerts(sourceid);
}
}
xmlHttp.open("GET","rest/sample.display.DisplayComponent/HTMLDisplayService/getAlertSourcesHTMLTable",true);
@@ -161,11 +168,10 @@
var type = document.getElementById("source_"+sourceid+"_type").value;
var sourceXML = constructSourceXML(sourceid, type);
- sendSource("rest/sample.display.DisplayComponent/HTMLDisplayService/updateAlertSource", sourceXML);
-
+ sendSourceData("rest/sample.display.DisplayComponent/HTMLDisplayService/updateAlertSource", sourceXML, sourceid);
}
-function sendSource(url, sourceXML)
+function sendSourceData(url, sourceXML, sourceid)
{
var xmlHttp = getXMLHTTP()
xmlHttp.onreadystatechange=function()
@@ -179,7 +185,7 @@
}
if(xmlHttp.readyState==4)
{
- getSources();
+ getSources(sourceid);
}
}
xmlHttp.open("POST",url,true);
@@ -194,7 +200,7 @@
{
if(xmlHttp.readyState==4)
{
- getSources();
+ getSources('');
document.getElementById("alertData").innerHTML="";
}
}
@@ -238,7 +244,7 @@
var type = typeElem.options[typeElem.selectedIndex].value;
var sourceXML = constructSourceXML(sourceid, type);
- sendSource("rest/sample.display.DisplayComponent/HTMLDisplayService/addAlertSource", sourceXML);
+ sendSourceData("rest/sample.display.DisplayComponent/HTMLDisplayService/addAlertSource", sourceXML, sourceid);
}
@@ -273,7 +279,7 @@
<H1 ID="top">Apache Tuscany Alert Aggregator Sample</H1>
<P>Alert Sources<SPAN ID="refreshSources"></SPAN>:</P>
<DIV ID="sourcesTable"></DIV>
-<P>Recent Alerts (<SPAN ID="refresh"><SPAN CLASS="clickable link" ONCLICK="getAlerts()">Refresh</SPAN></SPAN>):</P>
+<P>Recent Alerts (<SPAN ID="refresh"><SPAN CLASS="clickable link" ONCLICK="getAlerts('')">Refresh</SPAN></SPAN>):</P>
<DIV ID="alertTable"></DIV>
<HR></HR>
<P><A ID="data" HREF="#top">Back to top</A></P>
Modified: incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.display/HTMLDisplayImpl.py
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.display/HTMLDisplayImpl.py?view=diff&rev=506458&r1=506457&r2=506458
==============================================================================
--- incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.display/HTMLDisplayImpl.py (original)
+++ incubator/tuscany/cpp/sca/samples/AlertAggregator/sample.display/HTMLDisplayImpl.py Mon Feb 12 06:24:38 2007
@@ -28,9 +28,8 @@
ns = "./{http://tuscany.apache.org/samples/alerter}"
-def getAlertsHTMLTable ():
- returnData = "<TABLE border=\"0\">"
+def updateAllAlertsHTMLTable ():
# Use the alertService reference
newAlertsElem = alertService.getAllNewAlerts();
@@ -41,6 +40,28 @@
alert.attrib["unread"]="True"
alertsElem.append(alert)
+ return generateHTMLTable()
+
+
+def updateSourceAlertsHTMLTable (sourceId):
+
+ # Use the alertService reference
+ newAlertsElem = alertService.getNewAlerts(sourceId);
+ #newAlertsElem = getAllNewAlerts(); # For testing
+
+ for alert in newAlertsElem.findall(ns+"alert"):
+
+ alert.attrib["unread"]="True"
+ alertsElem.append(alert)
+
+ return generateHTMLTable()
+
+
+
+def generateHTMLTable ():
+
+ returnData = "<TABLE border=\"0\">"
+
# If we have more than x alerts, clear out any that have been read
# x is determined by the showNumberOfReadAlerts property
alerts = alertsElem.findall(ns+"alert")
@@ -134,18 +155,20 @@
returnData += srcType
returnData += ".png\"/> "
returnData += source.find(ns+"name").text
- returnData += "</TD><TD CLASS=\"clickable link\" ONCLICK=\"showEditSource('"
+ returnData += "</TD><TD CLASS=\"clickable link\" ONCLICK=\"getAlerts('"
returnData += srcId
- returnData += "')\">Edit</TD><TD CLASS=\"clickable link\" ONCLICK=\"deleteSource('"
+ returnData += "')\">Update Alerts</TD><TD CLASS=\"clickable link\" ONCLICK=\"showEditSource('"
returnData += srcId
- returnData += "')\">Delete</TD></TR>\n"
+ returnData += "')\">Edit Source</TD><TD CLASS=\"clickable link\" ONCLICK=\"deleteSource('"
+ returnData += srcId
+ returnData += "')\">Delete Source</TD></TR>\n"
# Now write out the row that gets shown when "edit" is pressed
returnData += "<TR ID=\"edit_source_"
returnData += srcId
returnData += "\" CLASS=\"hidden source_"
returnData += srcId
- returnData += "\"><TD COLSPAN=\"3\"><TABLE CLASS=\"sourceDetailsTable\"><TR><TD>Source name:</TD><TD><INPUT ID=\"source_"
+ returnData += "\"><TD COLSPAN=\"4\"><TABLE CLASS=\"sourceDetailsTable\"><TR><TD>Source name:</TD><TD><INPUT ID=\"source_"
returnData += srcId
returnData += "_name\" TYPE=\"TEXT\" SIZE=\"50\" VALUE=\""
returnData += source.find(ns+"name").text
@@ -160,6 +183,22 @@
returnData += "_feedAddress\" TYPE=\"TEXT\" SIZE=\"50\" VALUE=\""
returnData += source.find(ns+"feedAddress").text
returnData += "\"/></TR>"
+ elif srcType=="pop":
+ returnData += "<TR><TD>POP3 server:</TD><TD><INPUT ID=\"source_"
+ returnData += srcId
+ returnData += "_popServer\" TYPE=\"TEXT\" SIZE=\"50\" VALUE=\""
+ returnData += source.find(ns+"popServer").text
+ returnData += "\"/></TR>"
+ returnData += "<TR><TD>Username:</TD><TD><INPUT ID=\"source_"
+ returnData += srcId
+ returnData += "_popUsername\" TYPE=\"TEXT\" SIZE=\"50\" VALUE=\""
+ returnData += source.find(ns+"popUsername").text
+ returnData += "\"/></TD></TR>"
+ returnData += "<TR><TD>Password:</TD><TD><INPUT ID=\"source_"
+ returnData += srcId
+ returnData += "_popPassword\" TYPE=\"PASSWORD\" SIZE=\"50\" VALUE=\""
+ returnData += source.find(ns+"popPassword").text
+ returnData += "\"/></TD></TR>"
returnData += "<TR><TD><INPUT ID=\"source_"
returnData += srcId
returnData += "_type\" TYPE=\"HIDDEN\" VALUE=\""
@@ -178,7 +217,7 @@
# Now write out the "add new source" row
returnData += "<TR CLASS=\"source_"
returnData += srcId
- returnData += "\"><TD COLSPAN=\"3\" CLASS=\"clickable link\" ONCLICK=\"showAddNewSource('"
+ returnData += "\"><TD COLSPAN=\"4\" CLASS=\"clickable link\" ONCLICK=\"showAddNewSource('"
returnData += srcId
returnData += "')\">Add new Alert Source</TD></TR>"
# Add the (initially hidden) new source details row
@@ -186,7 +225,7 @@
returnData += srcId
returnData += "\"CLASS=\"hidden source_"
returnData += srcId
- returnData += "\"><TD COLSPAN=\"3\"><TABLE CLASS=\"sourceDetailsTable\"><TR><TD>Source name:</TD><TD><INPUT ID=\"source_"
+ returnData += "\"><TD COLSPAN=\"4\"><TABLE CLASS=\"sourceDetailsTable\"><TR><TD>Source name:</TD><TD><INPUT ID=\"source_"
returnData += srcId
returnData += "_name\" TYPE=\"TEXT\" SIZE=\"50\"/></TD></TR><TR><TD>Source address:</TD><TD><INPUT ID=\"source_"
returnData += srcId
@@ -238,8 +277,18 @@
def updateAlertSource(alertSourceElem):
if xml.etree.ElementTree.iselement(alertSourceElem):
- # Use the alertService reference
+
+ # Get the sourceid
+ sourceId = alertSourceElem.attrib["id"]
+
+ # Remove all alerts with this sourceid - they may have changed
+ for alert in alertsElem.findall(ns+"alert"):
+ if alert.attrib["sourceid"]==sourceId:
+ alertsElem.remove(alert)
+
+ # Use the alertService reference to update the config
alertService.updateAlertSource(alertSourceElem)
+
return
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org