<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<document xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <body>
    <row>
      <column>
        <section>
          <title>List of Cron Job scheduled</title>
  
          <table border="1">
            <tr>
              <th>Entry name</th>
              <th>Job name</th>
              <th>Next scheduled run</th>
              <th>Is running</th>
              <th>The Schedule</th>
              <th>Action</th>
            </tr>
            <jx:forEach var="entry" items="${entries}">
              <tr>
                <td>${entry.name}</td>
                <td>${entry.jobName}</td>
                <td>${formatter.format(entry.nextTime)}</td>
                <td>
                  <jx:choose>
                    <jx:when test="${entry.isRunning() == true}">
                      <div style="color: red">${entry.isRunning()}</div>
                    </jx:when>
                    <jx:otherwise>
                      <div style="color: green">${entry.isRunning()}</div>
                    </jx:otherwise>
                  </jx:choose>
                </td>
                <td>${entry.schedule}</td>
                <td>
                  <a href="continue.${continuation.id}?action=remove&amp;name=${entry.name}">remove</a>
                </td>
              </tr>
            </jx:forEach>
          </table>
        </section>
      </column>
    </row>

    <row>
      <column>
        <section>
          <title>Manage Cron Jobs scheduled</title>
          <p>
            Here you can define new CronJobs based on the sample class
            org.apache.cocoon.components.cron.TestCronJob.
          </p>
          <form method="post" action="continue.${continuation.id}?action=add">
            <table>
              <tr>
                <td align="right">Name the new job should have:</td>
                <td><input name="jobname" size="10" value="${jobname}"/></td>
              </tr>
              <tr>
                <td align="right">Message the job should print into the log:</td>
                <td><input name="message" size="40" value="${message}"/></td>
              </tr>
              <tr>
                <td align="right">The seconds the job should sleep before finishing:</td>
                <td><input name="sleep" size="4" value="${sleep}"/></td>
              </tr>
              <tr>
                <td align="right">Call a pipeline:</td>
                <td><input name="pipeline" size="40" value="${pipeline}"/></td>
              </tr>                            
              <tr>
                <td align="right">
                  <p>Choose the type of triggering:</p>
                </td>
                <td>
                  <table style="border: 1px solid #336699;">
                    <tr>
                      <td align="right">
                        Enter a 
                        <a href="http://quartz.sourceforge.net/javadoc/org/quartz/CronTrigger.html">
                          Cron
                        </a>
                        expression:
                      </td>
                      <td>
                        <input name="cronexpr" size="20" value="${cronexpr}"/> 
                      </td>
                      <td>
                        <input type="submit" name="cron" value="Add Cron"/>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Enter the interval in seconds:
                      </td>
                      <td>
                        <input name="intervalexpr" size="4" value="${intervalexpr}"/> 
                      </td>
                      <td>
                        <input type="submit" name="periodic" value="Add Periodic"/>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Fire at yyyy-MM-dd HH:mm:ss
                      </td>
                      <td>
                        <input name="atexpr" size="20" value="${atexpr}"/> 
                      </td>
                      <td>
                        <input type="submit" name="at" value="Fire at"/>
                      </td>
                    </tr>
                    <tr>
                      <td align="right">
                        Fire immediately
                      </td>
                      <td>&#160;</td>
                      <td>
                        <input type="submit" name="immediately" value="Fire now"/>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </form>
        </section>
      </column>
    </row>

    <row>
      <column>
        <section>
          <title>The Cron Scheduler Logfile</title>
          <p><a href="continue.${continuation.id}">Refresh</a></p>
          <jx:forEach var="line" items="${log}">
            <code>${line}</code><br/>
          </jx:forEach>
        </section>
      </column>
    </row>
  </body>
</document>
