<script id="machine_view-container-template" type="text/x-handlebars-template">
    <div id="server-view">
        <div class="operations">
            <div class="dropdown">
                <button class="btn dropdown-toggle" data-toggle="dropdown">Operations</button>
                <ul class="dropdown-menu">
                    <li><a href="#" class="rename">Rename server</a></li>
                    <li><a href="#" class="change-datacenter">Change datacenter</a></li>
                    <li class="unassign-datacenter_li"><a href="#" class="unassign-datacenter">Unassign datacenter</a></li>
                </ul>
            </div>
        </div>
        <div class="main_title"></div>
        <div id="user-alert-space"></div>
        <div class="section statistics">
            <h2 class="title">Statistics</h3>
            <div class="content row-fluid">
                <div class="span4 profile"></div>
                <div class="span8 performance-graph"></div>
            </div>
        </div>
        <div class="section server-data tree-view"></div>
        <div class="recent-log-entries"></div>
    </div>
</script>

<script id="machine_view_title-template" type="text/x-handlebars-template">
    <h1 class="title">Server overview for {{name}}</h1>
</script>

<script id="machine_view-ghost-template" type="text/x-handlebars-template">
    <div id="server-view">
        <h1 class="title">Error - Zombie server</h1>
        <div class="section statistics">
            <p>This server was previously declared dead, but has been reconnected to the cluster.<br/>
            Please kill the RethinkDB instance on this server.</p>
            <p>List of IPs: {{comma_separated_simple ips}}</p>
            <p></p>
        </div>
    </div>
</script>

<script id="machine_view_profile-template" type="text/x-handlebars-template">
    <div class="summary">
        <div class="stat-row first">
            <p class="availability"><span class="big">{{humanize_machine_reachability reachability}}</span></p>
        </div>
        <div class="stat-row">
            <p class="datacenter">
                {{#if assigned_to_datacenter}}
                    <span class="big">{{datacenter_name}} </span> datacenter
                {{else}}
                    <span class="big">Unassigned </span>datacenter
                {{/if}}
            </p>
        </div>
        <div class="stat-row">
            <p class="uptime"><span class="big">{{uptime}} </span>uptime</p>
        </div>
        <div class="stat-row">
            <p class="ips"><span class="big">{{#if main_ip}}{{main_ip}}{{else}}N/A{{/if}} </span>IP address</p>
        </div>
    </div>
</script>

<script id="machine_view_data-template" type="text/x-handlebars-template">
    <h2 class="title">Data on this server</h2>
    {{#if has_data}}
    <ul class="tables">
        {{#each tables}}
            <li class="table parent">
                <div class="tree-line"></div>
                <div class="table-info parent-info">
                    <p class="name">Table <a href="/#tables/{{id}}">{{name}}</a></p>
                </div>
                <ul class="shards">
                    {{#each shards}}
                        <li class="shard child">
                            <div class="tree-node"></div>
                            <div class="shard-info child-info">
                                <p class="name"><span class="highlight">{{shard.from}}</span> to <span class="highlight">{{shard.to}}</span></p>
                                <p class="role"><span class="highlight">
                                    {{#if primary}}
                                        Primary
                                    {{else}}{{#if secondary}}
                                        Secondary
                                    {{/if}}{{/if}}
                                </span> Role</p>
                                <p class="num-keys">
                                    {{#if num_keys}}
                                        <span class="highlight">~{{num_keys}}</span> {{pluralize_noun "document" num_keys}}
                                    {{else}}
                                        <span class="highlight">N/A</span> documents  
                                    {{/if}}
                                </p>
                            </div>
                        </li>
                    {{/each}}
                </ul>
            </li>
        {{/each}}
    </ul>
    {{else}}
    <div class="no_element">
        This server does not have any data.
    </div>
    {{/if}}
</script>

<script id="reason-set_secondary-need_replica-template" type="text/x-handlebars-template">
    You need a replica to replace this master, please <a href="#tables/{{namespace_id}}/replication">increase</a> your number of replicas.
</script>

<script id="reason-set_nothing-set_secondary_first-template" type="text/x-handlebars-template">
    First set this server as a secondary before removing all responsabilities.
</script>

<script id="reason-set_master-datacenter_not_primary-template" type="text/x-handlebars-template">
    You have to <a href="#tables/{{namespace_id}}/replication">set</a> this server's datacenter as the primary one first.
</script>


<script id="reason-set_nothing-unsatisfiable_goals-template" type="text/x-handlebars-template">
    <a href="#tables/{{namespace_id}}/replication">Lower</a> the number of replicas or <a href="#servers">add a server</a> in this datacenter to avoid unsatisfiable goals.
</script>

<script id="reason-set_primary-set_secondary_first-template" type="text/x-handlebars-template">
    The server must be a secondary before becoming a master.
</script>

<script id="reason-set_primary-set_datecenter_as_primary-template" type="text/x-handlebars-template">
    You have to <a href="#tables/{{namespace_id}}/replication">set</a> this server's datacenter as the primary one first.
</script>

<script id="reason-set_primary-no_datacenter-template" type="text/x-handlebars-template">
    You have to <a href="#servers">assign</a> this server to a datacenter first.
</script>

<script id="reason-set_secondary-increase_replicas-template" type="text/x-handlebars-template">
    You have to <a href="#tables/{{namespace_id}}/replication">increase</a> your number of replicas first.
</script>

<script id="alert-set_server-template" type="text/x-handlebars-template">
    <div class="alert" data-alert="alert">
        <a class="close" href="#">&times;</a>
        <p>You successfully set this server as a {{role}} for the shard {{shard}} of the table {{namespace_name}}</p>
    </div>
</script>

<script id="machine_view-recent_log_entry-template" type="text/x-handlebars-template">
    <div class="entry-metadata">
        <p class="datetime"><abbr class="timeago" title="{{timeago_timestamp}}">{{timeago_timestamp}}</abbr></p>
    </div>
    <p class="level">{{level}}</p>
    <p class="message">
        {{formatted_message}}
        {{#if json}}
            <a href="#" class="json" rel="popover" data-content="<pre>{{json}}</pre>" data-title="JSON applied to server">examine JSON</a>
        {{/if}}
    </p>
</script>

<script id="outdated_data-template" type="text/x-handlebars-template">
    <p>Sorry, we couldn't find any secondary up to date to replace this master.</p>
</script>

<script id="unassign-modal-template" type="text/x-handlebars-template">
    {{#if has_warning}}
    <div class="alert alert-error displayed_alert">
        <h4>Warning</h4>
        {{#if namespaces_with_critical_issue}}
        <p>You have just one server left in this datacenter and this server is master for the {{pluralize_noun "table" num_namespaces_with_critical_issue}} {{links_to_namespaces_inline namespaces_with_critical_issue}}.<br/>
        Moving this server will results in a loss of availability as long as a no server are added in <a href="#datacenters/{{datacenter_id}}">{{datacenter_name}}</a> or a new datacenter is set primary for {{pluralize_this num_namespaces_with_critical_issue}} {{pluralize_noun "table" num_namespaces_with_critical_issue}}.</a></p>
        {{/if}}
        {{#if namespaces_with_unsatisfiable_goals}}
        <p>The number of replicas for {{pluralize_noun "table" num_namespaces_with_unsatisfiable_goals}} {{links_to_namespaces_inline namespaces_with_unsatisfiable_goals}} you require will be lower than the number of servers available in <a href="#datacenters/{{datacenter_id}}">{{datacenter_name}}</a>.<br/>
        You can lower the number of replicas required or add a server in this datacenter to avoid creating unsatisfiable goals.</p>
        {{/if}}
    </div>
    {{/if}}

    <div class="alert displayed_alert">Removing this server from its datacenter will remove all its responsabilities.</div>
    <div class="alert alert-error error_answer"></div>
    <p>Are you sure you want to remove this server <a href="#servers/{{id}}">{{name}}</a> from its datacenter?</p>
</script>

<script id="unassign-alert-template" type="text/x-handlebars-template">
    <div class="alert displayed_alert" data-alert="alert">
        <a class="close" href="#">&times;</a>
        <p>You removed this server from its datacenter</p>
    </div>
</script>
