<!doctype html>
<html lang="en-US">
{{> control/partials/head-includes }}
<head><title>Control Service: Actions</title></head>
<body>
{{> control/partials/nav}}

<div class="container">
    <h1 class="my-3">System Actions [WORK IN PROGRESS]</h1>

    <div class="my-3 border p-3 bg-light">
        <p>
        These are actions that perform system-wide operations,
        on each node in the system.  Nodes are included if they are
        configured to be part of the <em>precession</em> in the Node Configuration.
        For a single-node system, most of these actions may be triggered from the
        single node's actions tab.
        </p>
        <p>
        <em>
            More actions will be added here in the future, including node-by-node sequences of
            crawling and processing.  These are still a bit broken, and need some work.  For now,
            you can trigger these actions from each individual Node.
        </em>
        </p>
    </p>
    </div>

    <div class="accordion mt-3" id="accordionActions">

        <div class="accordion-item">
            <h2 class="accordion-header">
                <button class="accordion-button collapsed"
                        type="button"
                        data-bs-toggle="collapse"
                        data-bs-target="#collapseCalculateAdjacencies"
                        aria-expanded="false"
                        aria-controls="collapseCalculateAdjacencies">
                    Calculate Adjacencies
                </button>
            </h2>
            <div id="collapseCalculateAdjacencies" class="accordion-collapse collapse p-3" data-bs-parent="#accordionActions">
                <div class="mb-3">
                    This will re-calculate the adjacencies graph.  The adjacencies graph is used to calculate the domain ranking.
                </div>
                <form method="post" action="actions/recalculate-adjacencies-graph">
                    <button
                            class="btn btn-primary me-md-2"
                            onclick="return confirm('Confirm recalculation of adjacencies graph');"
                            type="submit">
                        Recalculate Graph</button>
                </form>
            </div>
        </div>

        <div class="accordion-item">
            <h2 class="accordion-header">
                <button class="accordion-button collapsed"
                        type="button"
                        data-bs-toggle="collapse"
                        data-bs-target="#collapseCalculateExportAll"
                        aria-expanded="false"
                        aria-controls="collapseCalculateExportAll">
                    Export From All Nodes
                </button>
            </h2>
            <div id="collapseCalculateExportAll" class="accordion-collapse collapse p-3" data-bs-parent="#accordionActions">
                <div class="mb-3">
                    This will trigger an export job from all nodes in succession
                </div>
                <form method="post" action="actions/export-all">
                    <div class="form-check mb-3">
                        <input class="form-check-input" type="radio" name="exportType" id="exportFeeds" value="feeds">
                        <label class="form-check-label" for="exportFeeds">
                            RSS Feeds
                        </label>
                    </div>
                    <div class="form-check mb-3">
                        <input class="form-check-input" type="radio" name="exportType" id="exportAtags" value="atags">
                        <label class="form-check-label" for="exportAtags">
                            Anchor Tags
                        </label>
                    </div>
                    
                    <button
                            class="btn btn-primary me-md-2"
                            onclick="return confirm('Confirm export');"
                            type="submit">
                        Export</button>
                </form>
            </div>
        </div>
        <!--
        <div class="accordion-item">
            <h2 class="accordion-header">
                <button class="accordion-button collapsed"
                        type="button"
                        data-bs-toggle="collapse"
                        data-bs-target="#collapseReindexAll"
                        aria-expanded="false"
                        aria-controls="collapseReindexAll">
                    Recalculate Rankings
                </button>
            </h2>
            <div id="collapseReindexAll" class="accordion-collapse collapse p-3" data-bs-parent="#accordionActions">
                <div class="mb-3">
                    This will successively re-calculate the domain rankings for all nodes configured to be part in the precession,
                    and then re-construct the indexes from existing journal data.
                </div>
                <form method="post" action="actions/reindex-all">
                    <button
                            class="btn btn-primary me-md-2"
                            onclick="return confirm('Confirm reindexing of all nodes');"
                            type="submit">
                        Reconstruct Indexes</button>
                </form>
            </div>
        </div>

        <div class="accordion-item">
            <h2 class="accordion-header">
                <button class="accordion-button collapsed"
                        type="button"
                        data-bs-toggle="collapse"
                        data-bs-target="#collapseReprocessAll"
                        aria-expanded="false"
                        aria-controls="collapseReprocessAll">
                    Reprocess Data
                </button>
            </h2>
            <div id="collapseReprocessAll" class="accordion-collapse collapse p-3" data-bs-parent="#accordionActions">
                <div class="mb-3">
                    This will reprocess the crawl data on each node configured to be part in the precession, based on
                    the currently ACTIVE crawl data.  If no crawl data is ACTIVE, the node will be omitted.
                </div>
                <form method="post" action="actions/reprocess-all">
                    <button
                            class="btn btn-primary me-md-2"
                            onclick="return confirm('Confirm reprocessing');"
                            type="submit">
                        Reprocess Crawl Data</button>
                </form>
            </div>
        </div>

        <div class="accordion-item">
            <h2 class="accordion-header">
                <button class="accordion-button collapsed"
                        type="button"
                        data-bs-toggle="collapse"
                        data-bs-target="#collapseRecrawlAll"
                        aria-expanded="false"
                        aria-controls="collapseRecrawlAll">
                    Recrawl Data
                </button>
            </h2>
            <div id="collapseRecrawlAll" class="accordion-collapse collapse p-3" data-bs-parent="#accordionActions">
                <div class="mb-3">
                    This will recrawl the crawl data on each node configured to be part in the precession, based on
                    the currently ACTIVE crawl data.  If no crawl data is ACTIVE, the node will be omitted.  After
                    each node is recrawled, the crawl data will automatically be reprocessed.
                </div>
                <form method="post" action="actions/recrawl-all">
                    <button
                            class="btn btn-primary me-md-2"
                            onclick="return confirm('Confirm recrawling');"
                            type="submit">
                        Recrawl Data</button>
                </form>
            </div>
        </div> -->
    </div>

    <div class="my-3">
        <h1>Precession Nodes</h1>

        <div class="my-3 border p-3 bg-light">
{{#unless precessionNodes}} No nodes are configured to be part of the precession. {{/unless}}
{{#if precessionNodes}} These nodes are configured to be part of the precession,
        and will be included in the above actions unless otherwise noted. {{/if}}
        </div>
    </div>

        {{#if precessionNodes}}
            <table class="table">
                <tr><th>Node</th><th>Storage</th></tr>
                {{#each precessionNodes}}
                    <tr {{#unless storage}}class="table-danger"{{/unless}}>
                        <td><a href="/nodes/{{node.node}}">{{node.description}}</a></td>
                        <td>
                            {{#if storage}}
                                <a href="/nodes/{{node.node}}/storage/details?fid={{storage.id}}">
                                {{storage.path}}
                                </a>
                            {{/if}}
                            {{#unless storage}}
                                NOT CONFIGURED
                            {{/unless}}
                        </td>
                    </tr>
                {{/each}}
            </table>
        {{/if}}
    </div>
</div>

</body>
{{> control/partials/foot-includes }}
</html>