From: <pn...@hy...> - 2008-12-30 20:09:55
|
Author: pnguyen Date: 2008-12-30 12:09:50 -0800 (Tue, 30 Dec 2008) New Revision: 12114 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=12114 Modified: trunk/web/common/components/ListToolbar.jsp trunk/web/js/lib/lib.js trunk/web/js/requests.js trunk/web/portlet/criticalAlerts/View.jsp Log: HHQ-2720: updated to work with multiple Recent Alerts portlets Modified: trunk/web/common/components/ListToolbar.jsp =================================================================== --- trunk/web/common/components/ListToolbar.jsp 2008-12-30 19:12:46 UTC (rev 12113) +++ trunk/web/common/components/ListToolbar.jsp 2008-12-30 20:09:50 UTC (rev 12114) @@ -34,6 +34,7 @@ <tiles:importAttribute name="listNewParamName" ignore="true"/> <tiles:importAttribute name="listNewParamValue" ignore="true"/> <tiles:importAttribute name="widgetInstanceName" ignore="true"/> +<tiles:importAttribute name="portletToken" ignore="true"/> <tiles:importAttribute name="noButtons" ignore="true"/> <tiles:importAttribute name="newOnly" ignore="true"/> <tiles:importAttribute name="deleteOnly" ignore="true"/> @@ -117,11 +118,11 @@ </td> </c:if> <c:if test="${alerts}"> - <td align="left" id="<c:out value="${widgetInstanceName}"/>FixedButtonTd" style="white-space: nowrap"> - <div id="<c:out value="${widgetInstanceName}"/>FixedButtonDiv"> - <input type="button" id="<c:out value="${widgetInstanceName}"/>_FixButton" value="<fmt:message key="resource.common.alert.action.fixed.label"/>" class="CompactButtonInactive" disabled="disabled" onclick="MyAlertCenter.processButtonAction(this)" /> + <td align="left" id="<c:out value="${widgetInstanceName}${portletToken}"/>FixedButtonTd" style="white-space: nowrap"> + <div id="<c:out value="${widgetInstanceName}${portletToken}"/>FixedButtonDiv"> + <input type="button" id="<c:out value="${widgetInstanceName}${portletToken}"/>_FixButton" value="<fmt:message key="resource.common.alert.action.fixed.label"/>" class="CompactButtonInactive" disabled="disabled" onclick="MyAlertCenter.processButtonAction(this)" /> - <input type="button" id="<c:out value="${widgetInstanceName}"/>_AckButton" value="<fmt:message key="resource.common.alert.action.acknowledge.label"/>" class="CompactButtonInactive" disabled="disabled" onclick="MyAlertCenter.processButtonAction(this)" /> + <input type="button" id="<c:out value="${widgetInstanceName}${portletToken}"/>_AckButton" value="<fmt:message key="resource.common.alert.action.acknowledge.label"/>" class="CompactButtonInactive" disabled="disabled" onclick="MyAlertCenter.processButtonAction(this)" /> <input type="hidden" name="buttonAction" value="" /> <input type="hidden" name="fixedNote" value="" /> </div> Modified: trunk/web/js/lib/lib.js =================================================================== --- trunk/web/js/lib/lib.js 2008-12-30 19:12:46 UTC (rev 12113) +++ trunk/web/js/lib/lib.js 2008-12-30 20:09:50 UTC (rev 12114) @@ -2650,6 +2650,7 @@ that.message_area.request_status.style.display = "none"; that.button_area.fixed_active.style.display = ""; that.button_area.fixed_inactive.style.display = "none"; + that.dialogs.FixAlert.data.fixedNote.value = ""; that.dialogs.FixAlert.show(); } @@ -2667,7 +2668,7 @@ } } - that.acknowledgeAlert = function() { + that.acknowledgeAlerts = function() { that.stopAutoRefresh(); var myForm = that.dialogs.FixAlert.data.form; @@ -2677,6 +2678,29 @@ myForm.submit(); } } + + that.acknowledgeAlert = function(inputId) { + var myInput = dojo11.byId(inputId); + var myParam = {buttonAction: "ACKNOWLEDGE", output: "json"} + + myParam[myInput.name] = myInput.value; + that.init(myInput.form); + that.stopAutoRefresh(); + + dojo11.xhrPost( { + url: myInput.form.action, + content: myParam, + handleAs: 'json', + load: function(data) { + that.startAutoRefresh(); + }, + error: function(data){ + var errorText = "An error occurred processing your request."; + that.displayError(errorText); + console.debug(errorText, data); + } + }); + } that.xhrSubmit = function(myForm) { dojo11.xhrPost( { @@ -2700,7 +2724,6 @@ var checkAllBox = dojo11.byId(subgroup + "_CheckAllBox"); checkAllBox.checked = false; that.toggleAll(checkAllBox); - that.dialogs.FixAlert.data.fixedNote.value = ""; myForm.fixedNote.value = ""; } @@ -2771,7 +2794,7 @@ if (myButton.value == "FIXED") { that.confirmFixAlert(); } else if (myButton.value == "ACKNOWLEDGE") { - that.acknowledgeAlert(); + that.acknowledgeAlerts(); } } Modified: trunk/web/js/requests.js =================================================================== --- trunk/web/js/requests.js 2008-12-30 19:12:46 UTC (rev 12113) +++ trunk/web/js/requests.js 2008-12-30 20:09:50 UTC (rev 12114) @@ -118,7 +118,6 @@ } function showRecentAlerts(originalRequest) { - var alertText = eval("(" + originalRequest.responseText + ")"); var aList = alertText.criticalAlerts; var token = alertText.token; @@ -163,7 +162,7 @@ var td5 = document.createElement('td'); var td6 = document.createElement('td'); var alertAnchor = document.createElement("a"); - var checkBox = document.createElement("input"); + var checkbox = document.createElement("input"); var urlAmp = "&a=" tbody.appendChild(tr); @@ -176,7 +175,8 @@ td1.innerHTML = " "; } else { - var checkbox = document.createElement('input'); + var checkboxId = "alert" + (token == null ? "" : token) + "_" + aList[i].appdefKey + "_" + aList[i].alertId; + checkbox.id = checkboxId.replace(":", "_"); checkbox.setAttribute("type", "checkbox"); checkbox.setAttribute("name", "ealerts"); checkbox.onclick = new Function("MyAlertCenter.toggleAlertButtons(this)"); @@ -233,10 +233,9 @@ imgNode.setAttribute("border", "0"); imgNode.setAttribute("alt", "Acknowledge"); imgNode.setAttribute('id', 'ack_'+ aList[i].alertId); - ackAnchor.appendChild(imgNode); + ackAnchor.href = "javascript:MyAlertCenter.acknowledgeAlert('" + checkbox.id + "');"; ackInstruction.style.display = ""; - } else { imgNode = document.createElement('img'); Modified: trunk/web/portlet/criticalAlerts/View.jsp =================================================================== --- trunk/web/portlet/criticalAlerts/View.jsp 2008-12-30 19:12:46 UTC (rev 12113) +++ trunk/web/portlet/criticalAlerts/View.jsp 2008-12-30 20:09:50 UTC (rev 12114) @@ -38,7 +38,7 @@ <script type="text/javascript"> var pageData = new Array(); -var _hqu_<c:out value="${widgetInstanceName}"/>_refreshTimeout; +var _hqu_<c:out value="${widgetInstanceName}${portlet.token}"/>_refreshTimeout; initializeWidgetProperties('<c:out value="${widgetInstanceName}"/>'); widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>'); @@ -48,8 +48,8 @@ new Ajax.Request(critAlertUrl, {method: 'get', onSuccess:showRecentAlerts, onFailure :reportError}); } -function _hqu_<c:out value="${widgetInstanceName}"/>_autoRefresh() { - _hqu_<c:out value="${widgetInstanceName}"/>_refreshTimeout = setTimeout("_hqu_<c:out value="${widgetInstanceName}"/>_autoRefresh()", 30000); +function _hqu_<c:out value="${widgetInstanceName}${portlet.token}"/>_autoRefresh() { + _hqu_<c:out value="${widgetInstanceName}${portlet.token}"/>_refreshTimeout = setTimeout("_hqu_<c:out value="${widgetInstanceName}${portlet.token}"/>_autoRefresh()", 30000); requestRecentAlerts<c:out value="${portlet.token}"/>(); } @@ -58,11 +58,13 @@ var MyAlertCenter = null; dojo11.addOnLoad(function(){ - MyAlertCenter = new hyperic.alert_center("<fmt:message key="dash.home.CriticalAlerts"/>"); + if (MyAlertCenter == null) { + MyAlertCenter = new hyperic.alert_center("<fmt:message key="dash.home.CriticalAlerts"/>"); + } - dojo11.connect("requestRecentAlerts<c:out value="${portlet.token}"/>", function() { MyAlertCenter.resetAlertTable(dojo11.byId('<c:out value="${widgetInstanceName}"/>_FixForm')); }); + dojo11.connect("requestRecentAlerts<c:out value="${portlet.token}"/>", function() { MyAlertCenter.resetAlertTable(dojo11.byId('<c:out value="${widgetInstanceName}${portlet.token}"/>_FixForm')); }); - _hqu_<c:out value="${widgetInstanceName}"/>_autoRefresh(); + _hqu_<c:out value="${widgetInstanceName}${portlet.token}"/>_autoRefresh(); }); </script> <c:set var="rssUrl" value="/rss/ViewCriticalAlerts.rss"/> @@ -85,13 +87,13 @@ </tiles:insert> <!-- JSON available at /dashboard/ViewCriticalAlerts.do --> - <html:form styleId="${widgetInstanceName}_FixForm" method="POST" action="/alerts/RemoveAlerts.do"> + <html:form styleId="${widgetInstanceName}${portlet.token}_FixForm" method="POST" action="/alerts/RemoveAlerts.do"> <html:hidden property="output" value="json" /> <table width="100%" cellpadding="0" cellspacing="0" border="0" id="<c:out value="${tableName}"/>" class="portletLRBorder"> <thead> <tr class="ListRow"> <td width="1%" class="ListHeaderCheckbox"> - <input type="checkbox" onclick="MyAlertCenter.toggleAll(this)" name="listToggleAll" id="<c:out value="${widgetInstanceName}"/>_CheckAllBox"> + <input type="checkbox" onclick="MyAlertCenter.toggleAll(this)" name="listToggleAll" id="<c:out value="${widgetInstanceName}${portlet.token}"/>_CheckAllBox"> </td> <td width="30%" class="ListHeaderInactiveSorted" align="left"> Date / Time<html:img page="/images/tb_sortdown.gif" height="9" width="9" border="0" /> @@ -119,6 +121,10 @@ </tr> <tr class="ListRow" id="<c:out value="ackInstruction${portlet.token}"/>" style="display: none;"> <td class="ListCell" colspan="6" align="right" style="font-style: italic;"> + <c:url var="path" value="/"/> + <fmt:message key="dash.settings.criticalAlerts.ack.instruction"> + <fmt:param value="${path}"/> + </fmt:message> </td> </tr> <tr> @@ -126,7 +132,8 @@ <tiles:insert definition=".toolbar.list"> <tiles:put name="noButtons" value="true"/> <tiles:put name="alerts" value="true"/> - <tiles:put name="widgetInstanceName" beanName="widgetInstanceName"/> + <tiles:put name="widgetInstanceName" beanName="widgetInstanceName"/> + <tiles:put name="portletToken"><c:out value="${portlet.token}"/></tiles:put> <%--none of this is being used--%> <tiles:put name="pageSizeAction" value="" /> <tiles:put name="pageNumAction" value=""/> @@ -137,6 +144,10 @@ </tr> </tfoot> </table> - <div id="AlertCenterFixedNoteDialog" style="display:none;"></div> + <script type="text/javascript"> + if (dojo11.byId("AlertCenterFixedNoteDialog") == null) { + document.write('<div id="AlertCenterFixedNoteDialog" style="display:none;"></div>'); + } + </script> </html:form> </div> |