<%@ page import="com.lightinit.hsdataplatform.dictionary.DicPublishApiState" %>
<%@ page import="com.lightinit.hsdataplatform.dictionary.DicResourceType" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String basePath = request.getContextPath();
%>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover " >
        <thead>
        <tr>
            <th>资源名称</th>
            <th>资源类型</th>
            <th>所属机构</th>
            <th>标签</th>
            <th class="hidden-print">操 作</th>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${list!=null}">
                <c:forEach items="${list}" var="item" >
                    <tr>
                        <td>${item.resourceName}</td>
                        <td>${item.resourceType}</td>
                        <td>${item.provider}</td>
                        <td>${item.tag}</td>
                        <td>
                            <input type="hidden" name="id" value="${item.resourceId}" />
                            <input type="hidden" name="resourceType" value="${item.resourceType}" />
                            <input type="hidden" name="publishInfoId" value="${item.publishInfoId}" />
                            <input type="hidden" name="resourceMicroappId" value="${item.resourceMicroappId}" />
                            <button name="btnEdit" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>归类</button>
                            <button name="btnDetail" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-check"></i>详情</button>
                        </td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
    </table>
</div>
<jsp:include page="../../../common/admin/pager.jsp">
    <jsp:param name="pageNo" value="${pager.pageNo}"/>
    <jsp:param name="pageSize" value="${pager.pageSize}"/>
    <jsp:param name="total" value="${pager.total}"/>
</jsp:include>
<script type="text/javascript">
    $("#divGrid table tbody tr td:last-child")
        .on("click", "button[name='btnEdit']", function () {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.popBsPartial({ url: "<%=basePath%>/admin/classificationAndAggregation/aggregation.htm/" + id });
        })
        .on("click", "button[name='btnDetail']", function () {

            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            var resourceType = $(this).parent().children("input[type='hidden'][name='resourceType']").val();
            var publishInfoId = $(this).parent().children("input[type='hidden'][name='publishInfoId']").val();
            var resourceMicroappId = $(this).parent().children("input[type='hidden'][name='resourceMicroappId']").val();
            if(resourceType=="<%=DicResourceType.DATA%>") {

                $.popBsPartial({ url: "<%=basePath%>/admin/datapublish_mgr/detail.htm/" + publishInfoId });
            }else if(resourceType == "<%=DicResourceType.MICROAPP%>") {

                $.popBsPartial({ url: "<%=basePath%>/admin/microapp_publish/detail.htm/" + resourceMicroappId });
            }else if(resourceType=="<%=DicResourceType.API%>") {
              window.location.href="<%=basePath%>/admin/classificationAndAggregation/apiview.htm/"+id+"/"+publishInfoId ;
            }

        })

</script>