{$layout}
{$template "menu"}

<div v-if="countClusters == 0">
    <not-found-box>
        暂时还没有集群，请先 <a href="/ns/clusters/create">创建集群</a>。
    </not-found-box>
</div>

<div v-if="countClusters > 0">
    <form class="ui form" method="get" action="/ns/domains">
        <div class="ui fields inline">
            <div class="ui field">
                <ns-cluster-selector :v-cluster-id="clusterId"></ns-cluster-selector>
            </div>
            <div class="ui field">
                <ns-user-selector :v-user-id="userId"></ns-user-selector>
            </div>
            <div class="ui field">
                <input type="text" name="keyword" v-model="keyword" placeholder="域名..."/>
            </div>
            <div class="ui field">
                <button class="ui button" type="submit">搜索</button>
                &nbsp;
                <a :href="Tea.url('.')" v-if="clusterId > 0 || userId > 0 || keyword.length > 0">[清除条件]</a>
            </div>
        </div>
    </form>

    <div v-if="domains.length == 0">
        <div class="margin"></div>
        <p class="comment">暂时还没有域名。</p>
    </div>

    <!-- 域名列表 -->
    <table class="ui table selectable celled" v-if="domains.length > 0">
        <thead>
            <tr>
                <th>域名</th>
                <th>集群</th>
                <th>用户</th>
                <th class="two wide">状态</th>
                <th class="two op">操作</th>
            </tr>
        </thead>
        <tr v-for="domain in domains">
            <td>
                <a :href="'/ns/domains/domain?domainId=' + domain.id"><keyword :v-word="keyword">{{domain.name}}</keyword></a>
            </td>
            <td>
                {{domain.cluster.name}}<link-icon :href="'/ns/clusters/cluster?clusterId=' + domain.cluster.id"></link-icon>
            </td>
            <td>
                <span v-if="domain.user != null">
                    {{domain.user.fullname}} ({{domain.user.username}})
                </span>
                <span v-else class="disabled">-</span>
            </td>
            <td><label-on :v-is-on="domain.isOn"></label-on></td>
            <td>
                <a :href="'/ns/domains/domain?domainId=' + domain.id">详情</a> &nbsp; <a href="" @click.prevent="deleteDomain(domain.id)">删除</a>
            </td>
        </tr>
    </table>
</div>