PageSourceSearch

https://myliveroom.com/assets/AdminPosts-CtT40fmc.js

js myliveroom.com collected 2026-09-24 10:33:13 UTC 9,317 bytes, 1 lines download raw bytes

1import{a as q,y as z,r as l,j as e}from"./index-DBSR3mmU.js";import{A as L}from"./AdminLayout-CulU2gKz.js";import{f5 as B,f6 as G}from"./admin-CIGbsrv7.js";import"./markdown-vvQDngQ1.js";import"./marked.esm-r2HKmrw_.js";const O=()=>{const{t:s}=q(),[N,$]=z(),m="/assets/images/blank_profile.png",[f,_]=l.useState([]),[d,v]=l.useState({posts:0,pending_posts:0,comments:0,reactions:0}),[y,p]=l.useState(!1),[w,g]=l.useState(null),[S,b]=l.useState(null),[h,C]=l.useState(""),[o]=l.useState(10),[x,i]=l.useState(1),[u,T]=l.useState("all"),[t,k]=l.useState({current_page:1,last_page:1,per_page:10,total:0}),P=async a=>{p(!0),g(null),b(null);try{const n=await B(a);_(n?.data?.posts||[]),v(n?.data?.stats||{posts:0,pending_posts:0,comments:0,reactions:0}),k(n?.data?.meta||{current_page:a?.page||x,last_page:1,per_page:a?.per_page||o,total:0})}catch(n){console.error("Failed to load posts",n),g(s("admin.posts.load_failed")),_([]),v({posts:0,pending_posts:0,comments:0,reactions:0}),k({current_page:1,last_page:1,per_page:o,total:0})}finally{p(!1)}};l.useEffect(()=>{const a=N.get("filter")||"all";T(a),i(1)},[N]),l.useEffect(()=>{const a=setTimeout(()=>{P({page:x,per_page:o,search:h.trim()||void 0,filter:u})},350);return()=>clearTimeout(a)},[x,o,h,u]);const A=a=>{a.preventDefault(),i(1)},I=async a=>{if(window.confirm(s("admin.posts.delete_confirm"))){p(!0),g(null),b(null);try{await G(a),b(s("admin.posts.delete_success")),await P({page:x,per_page:o,search:h.trim()||void 0,filter:u})}catch(n){console.error("Failed to delete post",n),g(s("admin.posts.delete_failed"))}finally{p(!1)}}},M=a=>{if(!a)return"—";const n=new Date(a);return Number.isNaN(n.getTime())?a:new Intl.DateTimeFormat("en-GB",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(n)},E=l.useMemo(()=>{if(!t.total)return s("admin.table.showing",{start:0,end:0,total:0});const a=(t.current_page-1)*t.per_page+1,n=Math.min(t.current_page*t.per_page,t.total);return s("admin.table.showing",{start:a,end:n,total:t.total})},[t,s]),F=l.useMemo(()=>{const a=[],n=Math.max(1,t.current_page-2),D=Math.min(t.last_page,t.current_page+2);for(let j=n;j<=D;j+=1)a.push(j);return a},[t.current_page,t.last_page]),r=t.current_page<=1,c=t.current_page>=t.last_page;return e.jsx(L,{title:s("admin.posts.title"),subtitle:s("admin.posts.subtitle"),children:e.jsx("div",{className:"col-md-8 col-lg-9 sg-offcanvas-mainbar",children:e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header with-icon",children:[e.jsx("i",{className:"feather-file-text mr10"}),s("admin.posts.title")]}),e.jsxs("div",{className:"card-body",children:[e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-6 col-lg-6 col-xl-3",children:e.jsx("div",{className:"stat-panel bg-gradient-indigo",children:e.jsxs("div",{className:"stat-cell narrow",children:[e.jsx("i",{className:"feather-file-text bg-icon"}),e.jsx("span",{className:"text-xxlg",children:d.posts}),e.jsx("br",{}),e.jsx("span",{className:"text-lg",children:s("admin.posts.stats.posts")}),e.jsx("br",{})]})})}),e.jsx("div",{className:"col-md-6 col-lg-6 col-xl-3",children:e.jsx("div",{className:"stat-panel bg-gradient-warning",children:e.jsxs("div",{className:"stat-cell narrow",children:[e.jsx("i",{className:"feather-clock bg-icon"}),e.jsx("span",{className:"text-xxlg",children:d.pending_posts}),e.jsx("br",{}),e.jsx("span",{className:"text-lg",children:s("admin.posts.stats.pending_posts")}),e.jsx("br",{})]})})}),e.jsx("div",{className:"col-md-6 col-lg-6 col-xl-3",children:e.jsx("div",{className:"stat-panel bg-gradient-primary",children:e.jsxs("div",{className:"stat-cell narrow",children:[e.jsx("i",{className:"feather-message-square bg-icon"}),e.jsx("span",{className:"text-xxlg",children:d.comments}),e.jsx("br",{}),e.jsx("span",{className:"text-lg",children:s("admin.posts.stats.comments")}),e.jsx("br",{})]})})}),e.jsx("div",{className:"col-md-6 col-lg-6 col-xl-3",children:e.jsx("div",{className:"stat-panel bg-gradient-info",children:e.jsxs("div",{className:"stat-cell narrow",children:[e.jsx("i",{className:"feather-heart bg-icon"}),e.jsx("span",{className:"text-xxlg",children:d.reactions}),e.jsx("br",{}),e.jsx("span",{className:"text-lg",children:s("admin.posts.stats.reactions")}),e.jsx("br",{})]})})})]}),e.jsx("div",{className:"mb20",children:e.jsx("div",{className:"btn-group mb15",role:"group",children:[["all","All"],["pending","Pending"],["approved","Approved"]].map(([a,n])=>e.jsx("button",{type:"button",className:`btn btn-sm ${u===a?"btn-primary":"btn-light"}`,onClick:()=>{$({filter:a}),i(1)},children:a==="pending"&&d.pending_posts>0?`${n} (${d.pending_posts})`:n},a))})}),e.jsxs("div",{className:"mb20",children:[e.jsx("form",{className:"d-flex flex-row align-items-center flex-wrap",onSubmit:A,children:e.jsx("div",{className:"form-group mb0",children:e.jsxs("div",{className:"input-group",children:[e.jsx("input",{type:"text",className:"form-control",name:"query",value:h,onChange:a=>C(a.target.value),placeholder:s("admin.posts.search_placeholder")}),e.jsxs("button",{type:"submit",className:"btn btn-sm btn-light",disabled:y,children:[e.jsx("i",{className:"feather-search mr5"}),s("admin.actions.search")]})]})})}),e.jsx("div",{className:"form-text small",children:s("admin.posts.search_help")})]}),w&&e.jsx("div",{className:"alert alert-danger",children:w}),S&&e.jsx("div",{className:"alert alert-success",children:S}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table table-striped table-bordered table-hover table-dark",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("admin.table.id")}),e.jsx("th",{children:s("admin.table.author")}),e.jsx("th",{children:s("admin.table.type")}),e.jsx("th",{children:s("admin.table.approved")}),e.jsx("th",{children:s("admin.table.time")}),e.jsx("th",{children:s("admin.table.link")}),e.jsx("th",{children:s("admin.table.actions")})]})}),e.jsx("tbody",{children:f.length>0?f.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.post_id}),e.jsx("td",{children:a.author.profile_url?e.jsxs("a",{target:"_blank",rel:"noreferrer",href:a.author.profile_url,children:[e.jsx("img",{className:"tbl-image",src:a.author.avatar_url||m,alt:a.author.name,loading:"lazy",onError:n=>{n.currentTarget.src=m}}),a.author.name]}):e.jsxs("span",{children:[e.jsx("img",{className:"tbl-image",src:a.author.avatar_url||m,alt:a.author.name,loading:"lazy",onError:n=>{n.currentTarget.src=m}}),a.author.name]})}),e.jsx("td",{children:e.jsx("span",{className:"badge rounded-pill badge-lg bg-secondary",children:a.type_label})}),e.jsx("td",{children:e.jsx("span",{className:`badge rounded-pill ${a.approved?"bg-success":"bg-danger"}`,children:a.approved?s("admin.table.yes"):s("admin.table.no")})}),e.jsx("td",{children:M(a.created_at)}),e.jsx("td",{children:a.post_id?e.jsxs("a",{className:"btn btn-sm btn-light",href:`/posts/${a.post_id}`,target:"_blank",rel:"noreferrer",children:[e.jsx("i",{className:"feather-eye mr5"}),s("admin.actions.view")]}):"—"}),e.jsx("td",{children:e.jsx("button",{"data-bs-toggle":"tooltip",title:s("admin.actions.delete"),className:"btn btn-sm btn-icon btn-rounded btn-danger",onClick:()=>I(a.post_id),disabled:y,children:e.jsx("i",{className:"feather-trash-2"})})})]},a.post_id)):e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:s("admin.posts.empty")})})})]})}),e.jsxs("div",{className:"row mt-2 justify-content-between",children:[e.jsx("div",{className:"d-md-flex justify-content-between align-items-center dt-layout-start col-md-auto me-auto",children:e.jsx("div",{className:"dt-info","aria-live":"polite",role:"status",children:E})}),e.jsx("div",{className:"d-md-flex justify-content-between align-items-center dt-layout-end col
1-md-auto ms-auto",children:e.jsx("div",{className:"dt-paging",children:e.jsx("nav",{"aria-label":"pagination",children:e.jsxs("ul",{className:"pagination",children:[e.jsx("li",{className:`dt-paging-button page-item ${r?"disabled":""}`,children:e.jsx("button",{className:"page-link first",type:"button","aria-disabled":r,"aria-label":s("admin.pagination.first"),tabIndex:r?-1:0,onClick:()=>!r&&i(1),children:s("admin.pagination.first")})}),e.jsx("li",{className:`dt-paging-button page-item ${r?"disabled":""}`,children:e.jsx("button",{className:"page-link previous",type:"button","aria-disabled":r,"aria-label":s("admin.pagination.previous"),tabIndex:r?-1:0,onClick:()=>!r&&i(t.current_page-1),children:s("admin.pagination.previous")})}),F.map(a=>e.jsx("li",{className:`dt-paging-button page-item ${a===t.current_page?"active":""}`,children:e.jsx("button",{className:"page-link",type:"button","aria-current":a===t.current_page?"page":void 0,onClick:()=>i(a),children:a})},a)),e.jsx("li",{className:`dt-paging-button page-item ${c?"disabled":""}`,children:e.jsx("button",{className:"page-link next",type:"button","aria-disabled":c,"aria-label":s("admin.pagination.next"),tabIndex:c?-1:0,onClick:()=>!c&&i(t.current_page+1),children:s("admin.pagination.next")})}),e.jsx("li",{className:`dt-paging-button page-item ${c?"disabled":""}`,children:e.jsx("button",{className:"page-link last",type:"button","aria-disabled":c,"aria-label":s("admin.pagination.last"),tabIndex:c?-1:0,onClick:()=>!c&&i(t.last_page),children:s("admin.pagination.last")})})]})})})})]})]})]})})})};export{O as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.