<!--
  ~ Copyright 2013-2026, Seqera Labs
  ~
  ~ Licensed 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.
  -->

<html>
<head>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Nextflow notification email">
    <title>Workflow completion notification</title>
</head>
<body>
<div style="font-family: Helvetica, Arial, sans-serif; padding: 30px; max-width: 800px; margin: 0 auto;">

    <h1>Workflow completion notification</h1>
    <h2>Run Name: ${workflow.runName}</h2>

    <% if ( workflow.success && workflow.stats.ignoredCount ){ %>
    <div style="color: #856404; background-color: #fff3cd; border-color: #ffeeba; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
        Workflow execution completed successfully. One or more tasks reported an error condition.
    </div>
    <% } else if (workflow.success) { %>
    <div style="color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
        Execution completed successfully!
    </div>
    <% } else { %>
    <div style="color: #a94442; background-color: #f2dede; border-color: #ebccd1; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
        <h4 style="margin-top:0; color: inherit;">Execution completed unsuccessfully!</h4>
        <p>The exit status of the task that caused the workflow execution to fail was: <code>${workflow.exitStatus != null ? workflow.exitStatus : '-'}</code>.</p>
        <p>The full error message was:</p>
        <pre style="white-space: pre-wrap; overflow: visible; margin-bottom: 0;">${workflow.errorReport ?: 'n/a'}</pre>
    </div>
    <% } %>

    <p>The command used to launch the workflow was as follows:</p>
    <pre style="white-space: pre-wrap; overflow: visible; background-color: #ededed; padding: 15px; border-radius: 4px; margin-bottom:30px;">${workflow.commandLine}</pre>

    <h2>Execution summary</h2>

    <table cellpadding="4" >
        <tr>
        <td>Launch time</td>
        <td>${SysHelper.fmtDate(workflow.start)}</td>
        </tr>

        <tr>
        <td>Ending time</td>
        <td>${SysHelper.fmtDate(workflow.complete)} (duration: ${workflow.duration})</td>
        </tr>

        <tr>
        <td>Total CPU-Hours</td>
        <td>${workflow.stats.computeTimeFmt ?: '-'}</td>
        </tr>

        <tr>
            <td>Tasks stats</td>
            <td>
                Succeeded: ${workflow.stats.succeedCountFmt}&nbsp;&nbsp;
                Cached: ${workflow.stats.cachedCountFmt}&nbsp;&nbsp;
                Ignored: ${workflow.stats.ignoredCountFmt}&nbsp;&nbsp;
                Failed: ${workflow.stats.failedCountFmt}
            </td>
        </tr>

        <tr>
        <td>Launch directory</td>
        <td>${workflow.launchDir}</td>
        </tr>

        <tr>
        <td>Work directory</td>
        <td>${workflow.workDir.toUriString()}</td>
        </tr>

        <tr>
        <td>Project directory</td>
        <td>${workflow.projectDir}</td>
        </tr>

        <tr>
        <td>Script name</td>
        <td>${workflow.scriptName ?: '-'}</td>
        </tr>

        <tr>
        <td>Script ID</td>
        <td>${workflow.scriptId ?: '-'}</td>
        </tr>

        <tr>
        <td>Workflow session</td>
        <td>${workflow.sessionId}</td>
        </tr>

        <tr>
        <td>Workflow repo</td>
        <td>${workflow.repository ?: '-' }</td>
        </tr>

        <tr>
        <td>Workflow revision</td>
        <td>${workflow.repository ? "$workflow.revision ($workflow.commitId)" : '-'}</td>
        </tr>

        <tr>
        <td>Workflow profile</td>
        <td>${workflow.profile ?: '-'}</td>
        </tr>

        <tr>
        <td>Workflow container</td>
        <td>${workflow.container ?: '-'}</td>
        </tr>

        <tr>
        <td>Container engine</td>
        <td>${workflow.containerEngine?:'-'}</td>
        </tr>

        <tr>
        <td>Wave enabled</td>
        <td>${workflow.wave.enabled}</td>
        </tr>

        <tr>
        <td>Fusion enabled</td>
        <td>${workflow.fusion.enabled}, version ${workflow.fusion.enabled ? workflow.fusion.version : '-'}</td>
        </tr>

        <tr>
        <td>Nextflow version</td>
        <td>${workflow.nextflow.version}, build ${workflow.nextflow.build} (${workflow.nextflow.timestamp})</td>
        </tr>
    </table>

    <hr style="height: 3px; padding: 0; margin: 24px 0; background-color: #e1e4e8; border: 0;">
    <img style="float:right; height: 35px" src="cid:nxf-logo">
    This email was sent by Nextflow<br>
    cite <a href="https://doi.org/10.1038/nbt.3820">doi:10.1038/nbt.3820</a><br>
    <a href="http://nextflow.io">http://nextflow.io</a> <br>

</div>

</body>
</html>
