extends ../layouts/main
block content

  include ../user/components/list-item
  include ../../components/pagination-bar

  h1.uk-text-center Image Manager

  if Array.isArray(images.images) && (images.images.length > 0)
    div(uk-grid).uk-flex-center
      each image in images.images
        .uk-width-medium
          .uk-margin-small(uk-lightbox)
            a(href=`/image/${image._id}`, data-type="image", data-caption=`id: ${image._id}`)
              div
                img(src= `/image/${image._id}`).responsive

          if image.owner
            .uk-margin-small
              +renderUserListItem(image.owner)

          .uk-margin-small.uk-text-center
            button(type="button").uk-button.uk-button-default.uk-button-small.uk-border-rounded
              span Image Menu

            div(uk-drop={ mode: 'click', pos: 'top-center' }).uk-card.uk-card-default.uk-card-small.uk-border-rounded
              .uk-card-header
                .uk-text-small.uk-text-muted.uk-text-center id:#{image._id}
              .uk-card-body
                ul.uk-nav.uk-dropdown-nav
                  li
                    a(href="#", data-image-id= image._id, onclick="dtp.adminApp.deleteImage(event);")
                      span
                        i.fas.fa-trash
                      span.uk-margin-small-left Delete image
                  if image.owner
                    li
                      a(href=`/admin/image/${image._id}/archive-user`).uk-text-truncate
                        span
                          i.fas.fa-file-archive
                        span.uk-margin-small-left Archive and ban #[span.uk-text-bold= image.owner.username]

    +renderPaginationBar('/admin/image', images.totalImageCount)

  else
    .uk-text-center There are no images.