<!DOCTYPE html>
<html lang="en"
      th:replace="~{admin/dashboard/layout:: parent(~{::#content},~{::title},~{::script})}">
<head>
    <title >View A Post</title>
</head>
<body>
<!-- Page content-->
<section class="content" id="content">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-primary">
                    <div class="card-header">
                        <h3 class="card-title">View Post</h3>
                        <div class="card-tools">
                            <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                                <i class="fas fa-minus"></i>
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="card-header">
                            <div class="card-tools">
                                <div class="input-group input-group-sm" style="width: 150px;">
                                    <input type="text" name="table_search" class="form-control float-right" placeholder="Search">

                                    <div class="input-group-append">
                                        <button type="submit" class="btn btn-default">
                                            <i class="fas fa-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <table class="table table-striped projects display" id="myTable">
                            <thead>
                            <tr>
                                <th>
                                   Id
                                </th>
                                <th style="width: 40%">
                                    Post Name
                                </th >
                                <th style="width: 2%" >
                                    Date
                                </th >
                                <th  class="text-center" style="width: 2%">
                                    Published
                                </th>
                                <th class="text-center" style="width: 2%">
                                    Status
                                </th>
                                <th  class="text-center">
                                    Action
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr  th:each="post : ${posts}" >
                                <td th:text="${post.postId}"> </td>
                                <td th:text="${post.name}"></td>
                                <td th:text="${post.createdAt}"></td>
                                <td>
                                     <span th:text="${post.activeStatus == T(com.codenetworkz.blog.models.Status).YES ? 'Active' : 'Inactive'}"
                                           th:classappend="${post.activeStatus == T(com.codenetworkz.blog.models.Status).YES ? 'badge badge-success' : 'badge badge-warning'}"></span>
                                </td>
                                <td class="project-state">
                                      <span th:text="${post.adminStatus == T(com.codenetworkz.blog.models.Status).YES ? 'Accept' :
                                             (post.adminStatus == T(com.codenetworkz.blog.models.Status).NO ? 'Denied' : 'Pending')}"
                                            th:class="${post.adminStatus == T(com.codenetworkz.blog.models.Status).YES ? 'badge badge-success' :
                                             (post.adminStatus == T(com.codenetworkz.blog.models.Status).NO ? 'badge badge-warning' :
                                            'badge badge-danger')}"> </span>
                                </td>
                                <td class="project-actions text-right">
                                    <a class="btn btn-primary btn-sm" th:href="@{'/admin/posts/view/'+${post.slug}}"  title="View Tag">
                                        <i class="fas fa-folder">
                                        </i>
                                        View
                                    </a>
                                    <a class="btn btn-info btn-sm" th:href="@{'/admin/posts/update/'+${post.slug}}"  title="Edit Category">
                                        <i class="fas fa-pencil-alt">
                                        </i>
                                        Edit
                                    </a>
                                    <form th:action="@{'/admin/posts/change-status/' + ${post.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${post.slug}" />
                                        <button type="submit" class="btn btn-primary btn-sm" title="Active/Inactive">
                                            <i class="fas fa-user-shield"></i>
                                            Change Status
                                        </button>
                                    </form>
                                    <form th:action="@{'/admin/posts/admin-approve/' + ${post.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${post.slug}" />
                                        <button type="submit" class="btn btn-primary btn-sm" title="Admin Approved">
                                            <i class="fas fa-user-shield"></i>
                                            Change Approved
                                        </button>
                                    </form>
                                    <form th:action="@{'/admin/posts/delete/' + ${post.slug}}" method="post" style="display: inline;">
                                        <input type="hidden" name="slug" value="${post.slug}" />
                                        <button type="submit" class="btn btn-danger btn-sm" title="delete">
                                            <i class="fas fa-trash" ></i>
                                            Delete
                                        </button>
                                    </form>
                                </td>
                            </tr>
                            <tr th:if="${#lists.isEmpty(posts)}">
                                <td colspan="7" class="text-center">No Posts found.</td>
                            </tr>
                            </tbody>
                        </table>
                    </div><!-- /.card-body -->
                    <div class="card-footer clearfix" th:if="${!#lists.isEmpty(posts)}">
                        <ul class="pagination pagination-sm m-0 float-right">
                            <li class="page-item">
                                <a class="page-link" th:if="${posts.hasPrevious()}" th:href="@{/admin/posts/list(page=${posts.number - 1}, size=${posts.size})}">«</a></li>
                            <li class="page-item" th:each="i : ${#numbers.sequence(0, posts.totalPages - 1)}">
                                <a class="page-link" th:href="@{/admin/posts/list(page=${i}, size=${posts.size})}" th:text="${i + 1}">1</a></li>
                            <li class="page-item">
                                <a class="page-link" th:if="${posts.hasNext()}" th:href="@{/admin/posts/list(page=${posts.number + 1}, size=${posts.size})}">»</a></li>
                        </ul>
                    </div>
                </div>
                <!-- /.card -->
            </div>
        </div>
</section>

</body>

</html>
