{$layout "layout_popup"}

<!-- <h3>
  正在同步的DNS任务<span v-if="tasks.length > 0">(共{{taskCount}}个)</span>
</h3> -->
<b-settings-header :sub-title="tasks.length > 0?`共${taskCount}个`:''">
  正在同步的DNS任务
</b-settings-header>

<!-- <p class="comment" v-if="tasks.length == 0">暂时没有同步的集群。</p> -->
<b-empty v-if="tasks.length == 0">暂时没有同步的集群。</b-empty>
<div v-if="tasks.length > 0">
    <b-table :data-source="tasks"
             :row-key="'id'"
             :scroll="{ x: 1200, y: 300 }"
             :pagination="false"
             :columns="[
                 { title: '对象', key: 'object', width: '15em', scopedSlots: { customRender: 'objectSlot' } },
                 { title: '任务', key: 'taskType', width: '8em', scopedSlots: { customRender: 'taskTypeSlot' } },
                 { title: '状态', key: 'status', scopedSlots: { customRender: 'statusSlot' } },
                 { title: '触发时间', key: 'updatedTime', width: '12em', scopedSlots: { customRender: 'timeSlot' } },
                 { title: '操作', key: 'action', width: '5em', scopedSlots: { customRender: 'actionSlot' }, align: 'center' }
             ]"
    >
        <template slot="objectSlot" slot-scope="{ text, record }">
            <span v-if="(record.type == 'clusterChange' || record.type == 'clusterRemoveDomain') && record.cluster != null">
                {{record.cluster.name}}
                <link-icon :href="'/dns/clusters/cluster?clusterId=' + record.cluster.id" target="_top"></link-icon>
            </span>
            <span v-if="record.type == 'nodeChange'">{{record.node.name}}</span>
            <span v-if="record.type == 'serverChange'">{{record.server.name}}</span>
            <span v-if="record.type == 'domainChange'">{{record.domain.name}}</span>
        </template>
        <template slot="taskTypeSlot" slot-scope="{ text, record }">
            <span v-if="record.type == 'clusterChange' || record.type == 'clusterRemoveDomain'">集群</span>
            <span v-if="record.type == 'nodeChange'">节点</span>
            <span v-if="record.type == 'serverChange'">服务</span>
            <span v-if="record.type == 'domainChange'">域名</span>
        </template>
        <template slot="statusSlot" slot-scope="{ text, record }">
            <Tag v-if="record.isDone" color="red">{{record.error}}</Tag>
            <Tag v-else color="blue">正在同步...</Tag>
        </template>
        <template slot="timeSlot" slot-scope="{ text, record }">
            {{record.updatedTime}}
        </template>
        <template slot="actionSlot" slot-scope="{ text, record }">
            <a-button type="link" danger @click.prevent="deleteTask(record.id)">
                 <i class="pi pi-trash" style="font-size: 12px; padding: 4px;"></i>
            </a-button>
        </template>
    </b-table>

	<!-- <table class="ui table selectable celled">
		<thead>
			<tr>
				<th class="three wide">对象</th>
				<th>任务</th>
				<th>状态</th>
				<th>触发时间</th>
				<th class="one op"></th>
			</tr>
		</thead>
		<tr v-for="task in tasks">
			<td nowrap="">
				<span v-if="(task.type == 'clusterChange' || task.type == 'clusterRemoveDomain') && task.cluster != null">{{task.cluster.name}}
					<link-icon :href="'/dns/clusters/cluster?clusterId=' + task.cluster.id" target="_top"></link-icon>
				</span>
				<span v-if="task.type == 'nodeChange'">{{task.node.name}}</span>
				<span v-if="task.type == 'serverChange'">{{task.server.name}}</span>
				<span v-if="task.type == 'domainChange'">{{task.domain.name}}</span>
			</td>
			<td nowrap="">
				<span v-if="task.type == 'clusterChange' || task.type == 'clusterRemoveDomain'">集群</span>
				<span v-if="task.type == 'nodeChange'">节点</span>
				<span v-if="task.type == 'serverChange'">服务</span>
				<span v-if="task.type == 'domainChange'">域名</span>
			</td>
			<td style="word-break: break-word; width: 26em">
				<span v-if="task.isDone" class="red">{{task.error}}</span>
				<span v-else>正在同步...</span>
			</td>
			<td nowrap="">{{task.updatedTime}}</td>
			<td>
				<a href="" title="删除" class="remove-btn" @click.prevent="deleteTask(task.id)"><i class="icon remove small grey"></i></a>
			</td>
		</tr>
	</table> -->
</div>
