Files
igny8/frontend/dist/assets/js/page-images.config.tsx-D2qUfhK2.js
IGNY8 VPS (Salman) ca5bf13c74 buid node modules
2025-11-13 14:02:26 +00:00

6 lines
6.0 KiB
JavaScript

import{r as p,j as e}from"./vendor-react-core-DRQGgXXF.js";import{B as x}from"./page-clusters.config.tsx-FJ8SgY77.js";import{g as b}from"./page-authpages-BaiNliVr.js";function u({image:a,maxPromptLength:c=100}){const[i,t]=p.useState(!1),r=s=>s.startsWith("http://")||s.startsWith("https://")?!1:s.includes("ai-images"),o=s=>{if(s.includes("ai-images")){const m=s.split("ai-images/")[1]||s.split("ai-images\\")[1];if(m)return`/images/ai-images/${m}`}return s.startsWith("/images/")?s:`/images/ai-images/${s.split("/").pop()||s.split("\\").pop()}`};if(!a)return e.jsx("div",{className:"text-gray-400 dark:text-gray-500 text-sm",children:"-"});const l=a.prompt||"",d=l.length>c,g=i||!d?l:`${l.substring(0,c)}...`;return e.jsxs("div",{className:"space-y-2",children:[l&&e.jsx("div",{className:"text-sm",children:e.jsxs("p",{className:"text-gray-700 dark:text-gray-300",children:[g,d&&e.jsx("button",{onClick:()=>t(!i),className:"ml-1 text-brand-500 hover:text-brand-600 text-xs",children:i?"Show less":"Show more"})]})}),e.jsxs("div",{className:"relative",children:[a.status==="pending"&&e.jsx("div",{className:"w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-8 h-8 mx-auto text-gray-400 dark:text-gray-500 mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Pending"})]})}),a.status==="generated"&&e.jsx("div",{className:"space-y-1",children:a.image_path&&a.image_path.trim()&&r(a.image_path)?e.jsx(e.Fragment,{children:e.jsx("img",{src:o(a.image_path),alt:l||"Generated image",className:"w-full h-24 object-cover rounded border border-gray-300 dark:border-gray-600",onError:s=>{const n=s.target;n.style.display="none";const m=n.parentElement;m&&(m.innerHTML=`
<div class="w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center">
<p class="text-xs text-gray-500 dark:text-gray-400">Image not available</p>
</div>
`)}})}):e.jsx("div",{className:"w-full h-24 bg-gray-200 dark:bg-gray-700 rounded border-2 border-dashed border-gray-300 dark:border-gray-600 flex items-center justify-center",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"No image available"})})}),a.status==="failed"&&e.jsx("div",{className:"w-full h-24 bg-red-100 dark:bg-red-900/20 rounded border border-red-300 dark:border-red-700 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-6 h-6 mx-auto text-red-500 mb-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"text-xs text-red-700 dark:text-red-400",children:"Failed"})]})}),e.jsx("div",{className:"absolute top-1 right-1",children:e.jsx(x,{color:a.status==="generated"?"success":a.status==="failed"?"error":"warning",size:"xs",variant:"light",children:a.status})})]})]})}const y=a=>{const c=a.maxInArticleImages||5,i=[{key:"content_title",label:"Content Title",sortable:!0,sortField:"content_title",width:"250px",render:(t,r)=>e.jsxs("div",{children:[e.jsx("a",{href:`/writer/content/${r.content_id}`,className:"font-medium text-brand-500 hover:text-brand-600 dark:text-brand-400",children:r.content_title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["ID: ",r.content_id]})]})},{key:"featured_image",label:"Featured Image",sortable:!1,width:"200px",render:(t,r)=>e.jsx(u,{image:r.featured_image,onImageClick:a.onImageClick?()=>a.onImageClick(r.content_id,"featured"):void 0})}];for(let t=1;t<=c;t++)i.push({key:`in_article_${t}`,label:`In-Article ${t}`,sortable:!1,width:"200px",render:(r,o)=>{const l=o.in_article_images.find(d=>d.position===t);return e.jsx(u,{image:l||null,onImageClick:a.onImageClick&&l?()=>a.onImageClick(o.content_id,"in_article",t):void 0})}});return i.push({key:"overall_status",label:"Status",sortable:!0,sortField:"overall_status",width:"180px",render:(t,r)=>{var g,s;const o={complete:"success",partial:"info",pending:"warning",failed:"error"},l={complete:"Complete",partial:"Partial",pending:"Pending",failed:"Failed"},d=((g=r.featured_image)==null?void 0:g.status)==="pending"&&((s=r.featured_image)==null?void 0:s.prompt)||r.in_article_images.some(n=>n.status==="pending"&&n.prompt);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{color:o[t]||"warning",size:"sm",children:l[t]||t}),d&&a.onGenerateImages&&e.jsxs("button",{onClick:n=>{n.stopPropagation(),a.onGenerateImages(r.content_id)},className:"inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-brand-500 hover:bg-brand-600 rounded transition-colors",title:"Generate Images",children:[e.jsx(b,{className:"w-3 h-3"}),"Generate"]})]})}}),{columns:i,filters:[{key:"search",label:"Search",type:"text",placeholder:"Search by content title..."},{key:"status",label:"Status",type:"select",options:[{value:"",label:"All Status"},{value:"complete",label:"Complete"},{value:"partial",label:"Partial"},{value:"pending",label:"Pending"},{value:"failed",label:"Failed"}]}],headerMetrics:[{label:"Total Content",value:0,accentColor:"blue",calculate:t=>t.totalCount||0},{label:"Complete",value:0,accentColor:"green",calculate:t=>t.images.filter(r=>r.overall_status==="complete").length},{label:"Partial",value:0,accentColor:"info",calculate:t=>t.images.filter(r=>r.overall_status==="partial").length},{label:"Pending",value:0,accentColor:"amber",calculate:t=>t.images.filter(r=>r.overall_status==="pending").length}],maxInArticleImages:c}};export{y as c};