<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:template match="Root">
		<xsl:call-template name="hostListSection" />
	</xsl:template>

	<xsl:template name="hostListSection">
		<xsl:variable name="hostList" select="JobHostStatus/JobHost" />
		<fieldset>
			<legend>Job Queue Status</legend>
					<table class="textChart">
						<tr>
							<th>Hostname</th>
                            <th>OS</th>
							<th>PID</th>
							<th>Last Heartbeat</th>
							<th>Load 1 Min</th>
							<th>Load 5 Min</th>
							<th>Load 15 Min</th>
<!-- Let's hold off on this <th>On Hold</th> -->
						</tr>
						<xsl:for-each select="$hostList">
                            <xsl:sort select="Hostname" />
							<xsl:call-template name="hostRow" />
						</xsl:for-each>
					</table>
		</fieldset>
		<br />
	</xsl:template>

	<xsl:template name="hostRow">
        <tr class="row{position() mod 2}">
			<td><xsl:value-of select="Hostname" /></td>
			<td><xsl:value-of select="OS" /></td>
			<td><xsl:value-of select="PID" /></td>
			<td>
                <xsl:if test="HeartbeatStale = 1"><xsl:attribute name="class">error</xsl:attribute></xsl:if>
			    <xsl:value-of select="Heartbeat" />
            </td>
			<td><xsl:value-of select="LoadAverage1" /></td>
			<td><xsl:value-of select="LoadAverage5" /></td>
			<td><xsl:value-of select="LoadAverage15" /></td>
<!--            <xsl:call-template name="hostOnHoldCheckBox" /> -->
		</tr>
	</xsl:template>

    <xsl:template name="hostOnHoldCheckBox">
    <xsl:variable name="url">/support/job_queue?c=togglehosthold&amp;host=<xsl:value-of select="Hostname" /></xsl:variable>
    <td>
        <input type="checkbox" name="hostOnHold" id="hostOnHold">
        <xsl:attribute name="onclick">ajaxToggleCheckbox( '<xsl:value-of select="$url" />', this, null );</xsl:attribute>
            <xsl:if test="OnHold = 1">
                <xsl:attribute name="checked">checked</xsl:attribute>
            </xsl:if>
        </input>
    </td>
    </xsl:template>
</xsl:stylesheet>
