Files
igny8/frontend/dist/assets/js/pages-thinker-DjafPZNF.js
Gitea Deploy 961362e088 Add SEO fields to Tasks model, improve content generation response handling, and enhance progress bar animation
- Added primary_keyword, secondary_keywords, tags, and categories fields to Tasks model
- Updated generate_content function to handle full JSON response with all SEO fields
- Improved progress bar animation: smooth 1% increments every 300ms
- Enhanced step detection for content generation vs clustering vs ideas
- Fixed progress modal to show correct messages for each function type
- Added comprehensive logging to Keywords and Tasks pages for AI functions
- Fixed error handling to show meaningful error messages instead of generic failures
2025-11-09 21:22:34 +00:00

2 lines
16 KiB
JavaScript

import{j as e,r as g}from"./vendor-react-core-DjsjKnCi.js";import{P as f,C as N}from"./page-analytics.tsx-1KCk8AGD.js";import{b as C,B as p,o as I}from"./page-authpages-CY7hjDHU.js";import{u as P}from"./page-reference-aC0iABvU.js";import{i as _,S as A,T as E,U as O,V as T}from"./page-dashboard-DxYTR5eF.js";import{C as F}from"./page-components.tsx-DYfg5dka.js";import{F as G}from"./pages-planner-COGkFLJh.js";import{B as D}from"./page-clusters.config.tsx-9GAd-_h-.js";function Y(){return e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"Thinker Dashboard - IGNY8",description:"AI thinker overview"}),e.jsx(N,{title:"Coming Soon",desc:"AI thinker overview",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Thinker Dashboard - Coming Soon"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2",children:"Overview of AI tools and strategies will be displayed here"})]})})]})}const Q=Object.freeze(Object.defineProperty({__proto__:null,default:Y},Symbol.toStringTag,{value:"Module"})),S=({placeholder:o="Enter your message",rows:d=3,value:j="",onChange:b,className:y="",disabled:s=!1,error:n=!1,hint:m=""})=>{const u=x=>{b&&b(x.target.value)};let l=`w-full rounded-lg border px-4 py-2.5 text-sm shadow-theme-xs focus:outline-hidden ${y} `;return s?l+=" bg-gray-100 opacity-50 text-gray-500 border-gray-300 cursor-not-allowed opacity40 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700":n?l+=" bg-transparent border-gray-300 focus:border-error-300 focus:ring-3 focus:ring-error-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-error-800":l+=" bg-transparent text-gray-900 dark:text-gray-300 text-gray-900 border-gray-300 focus:border-brand-300 focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-brand-800",e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{placeholder:o,rows:d,value:j,onChange:u,disabled:s,className:l}),m&&e.jsx("p",{className:`mt-2 text-sm ${n?"text-error-500":"text-gray-500 dark:text-gray-400"}`,children:m})]})},v=[{key:"clustering",label:"Clustering Prompt",description:"Group keywords into topic clusters. Use [IGNY8_KEYWORDS] to inject keyword data.",icon:"🌐",color:"green"},{key:"ideas",label:"Ideas Generation Prompt",description:"Generate content ideas from clusters. Use [IGNY8_CLUSTERS] and [IGNY8_CLUSTER_KEYWORDS] to inject data.",icon:"💡",color:"amber"},{key:"content_generation",label:"Content Generation Prompt",description:"Generate content from ideas. Use [IGNY8_IDEA], [IGNY8_CLUSTER], and [IGNY8_KEYWORDS] to inject data.",icon:"📝",color:"blue"},{key:"image_prompt_extraction",label:"Image Prompt Extraction",description:"Extract image prompts from article content. Use {title}, {content}, {max_images} placeholders.",icon:"🔍",color:"indigo"},{key:"image_prompt_template",label:"Image Prompt Template",description:"Template for generating image prompts. Use {post_title}, {image_prompt}, {image_type} placeholders.",icon:"🖼️",color:"purple"},{key:"negative_prompt",label:"Negative Prompt",description:"Specify elements to avoid in generated images (text, watermarks, logos, etc.).",icon:"🚫",color:"red"}];function M(){const o=P(),[d,j]=g.useState({}),[b,y]=g.useState(!0),[s,n]=g.useState({});g.useEffect(()=>{m()},[]);const m=async()=>{y(!0);try{const t=v.map(async c=>{try{const h=await _(`/v1/system/prompts/by_type/${c.key}/`);return{key:c.key,data:h}}catch(h){return console.error(`Error loading prompt ${c.key}:`,h),{key:c.key,data:null}}}),a=await Promise.all(t),i={};a.forEach(({key:c,data:h})=>{var k;h?i[c]=h:i[c]={prompt_type:c,prompt_type_display:((k=v.find(r=>r.key===c))==null?void 0:k.label)||c,prompt_value:"",default_prompt:"",is_active:!0}}),j(i)}catch(t){console.error("Error loading prompts:",t),o.error("Failed to load prompts")}finally{y(!1)}},u=async t=>{const a=d[t];if(a){n({...s,[t]:!0});try{const i=await _("/v1/system/prompts/save/",{method:"POST",body:JSON.stringify({prompt_type:t,prompt_value:a.prompt_value})});if(i.success)o.success(i.message||"Prompt saved successfully"),await m();else throw new Error(i.error||"Failed to save prompt")}catch(i){console.error("Error saving prompt:",i),o.error(`Failed to save prompt: ${i.message}`)}finally{n({...s,[t]:!1})}}},l=async t=>{if(confirm("Are you sure you want to reset this prompt to default? This will overwrite any custom changes.")){n({...s,[t]:!0});try{const a=await _("/v1/system/prompts/reset/",{method:"POST",body:JSON.stringify({prompt_type:t})});if(a.success)o.success(a.message||"Prompt reset to default"),await m();else throw new Error(a.error||"Failed to reset prompt")}catch(a){console.error("Error resetting prompt:",a),o.error(`Failed to reset prompt: ${a.message}`)}finally{n({...s,[t]:!1})}}},x=(t,a)=>{j({...d,[t]:{...d[t],prompt_value:a}})};return b?e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"Prompts - IGNY8",description:"AI prompts management"}),e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading prompts..."})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"Prompts - IGNY8",description:"AI prompts management"}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(C,{className:"text-primary-500 size-6"}),e.jsx("h1",{className:"text-2xl font-semibold text-gray-800 dark:text-white",children:"AI Prompts Management"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for clustering, idea generation, content writing, and image generation"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Planner Prompts"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for clustering and idea generation"})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:v.filter(t=>["clustering","ideas"].includes(t.key)).map(t=>{const a=d[t.key]||{prompt_type:t.key,prompt_type_display:t.label,prompt_value:""};return e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:t.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(S,{value:a.prompt_value||"",onChange:i=>x(t.key,i),rows:12,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>u(t.key),disabled:s[t.key],className:"flex-1",variant:"solid",color:"primary",children:s[t.key]?"Saving...":"Save Prompt"}),e.jsx(p,{onClick:()=>l(t.key),disabled:s[t.key],variant:"outline",children:"Reset to Default"})]})]})]},t.key)})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Writer Prompts"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for content writing"})]}),e.jsx("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:v.filter(t=>t.key==="content_generation").map(t=>{const a=d[t.key]||{prompt_type:t.key,prompt_type_display:t.label,prompt_value:""};return e.jsxs("div",{children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:t.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(S,{value:a.prompt_value||"",onChange:i=>x(t.key,i),rows:15,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>u(t.key),disabled:s[t.key],className:"flex-1",variant:"solid",color:"primary",children:s[t.key]?"Saving...":"Save Prompt"}),e.jsx(p,{onClick:()=>l(t.key),disabled:s[t.key],variant:"outline",children:"Reset to Default"})]})]})]},t.key)})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Image Generation"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI image generation prompts"})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:v.filter(t=>["image_prompt_extraction","image_prompt_template","negative_prompt"].includes(t.key)).map(t=>{const a=d[t.key]||{prompt_type:t.key,prompt_type_display:t.label,prompt_value:""};return e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:t.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:t.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(S,{value:a.prompt_value||"",onChange:i=>x(t.key,i),rows:t.key==="negative_prompt"?4:8,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>u(t.key),disabled:s[t.key],className:"flex-1",variant:"solid",color:"primary",children:s[t.key]?"Saving...":"Save Prompt"}),t.key==="image_prompt_template"&&e.jsx(p,{onClick:()=>l(t.key),disabled:s[t.key],variant:"outline",children:"Reset to Default"})]})]})]},t.key)})})]})]})]})}const X=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));function $(){const o=P(),[d,j]=g.useState([]),[b,y]=g.useState(!0),[s,n]=g.useState(!1),[m,u]=g.useState(null),[l,x]=g.useState({name:"",description:"",tone:"",language:"en",is_active:!0});g.useEffect(()=>{t()},[]);const t=async()=>{try{y(!0);const r=await A();j(r.results||[])}catch(r){o.error(`Failed to load author profiles: ${r.message}`)}finally{y(!1)}},a=()=>{u(null),x({name:"",description:"",tone:"",language:"en",is_active:!0}),n(!0)},i=r=>{u(r),x({name:r.name,description:r.description,tone:r.tone,language:r.language,is_active:r.is_active}),n(!0)},c=async()=>{try{m?(await E(m.id,l),o.success("Author profile updated successfully")):(await O(l),o.success("Author profile created successfully")),n(!1),t()}catch(r){o.error(`Failed to save: ${r.message}`)}},h=async r=>{if(confirm("Are you sure you want to delete this author profile?"))try{await T(r),o.success("Author profile deleted successfully"),t()}catch(w){o.error(`Failed to delete: ${w.message}`)}},k=[{name:"name",label:"Name",type:"text",required:!0},{name:"description",label:"Description",type:"textarea",required:!1},{name:"tone",label:"Tone",type:"text",required:!0},{name:"language",label:"Language",type:"text",required:!0},{name:"is_active",label:"Active",type:"checkbox",required:!1}];return e.jsxs("div",{className:"p-6",children:[e.jsx(f,{title:"Author Profiles"}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Author Profiles"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Manage writing style profiles"})]}),e.jsxs(p,{onClick:a,variant:"primary",children:[e.jsx(I,{className:"w-4 h-4 mr-2"}),"Create Profile"]})]}),b?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:d.map(r=>e.jsxs(F,{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r.name}),e.jsx(D,{variant:"light",color:r.is_active?"success":"dark",children:r.is_active?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:r.description}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Tone:"})," ",e.jsx("span",{className:"text-gray-900 dark:text-white",children:r.tone})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Language:"})," ",e.jsx("span",{className:"text-gray-900 dark:text-white",children:r.language})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(p,{variant:"secondary",size:"sm",onClick:()=>i(r),children:"Edit"}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>h(r.id),children:"Delete"})]})]},r.id))}),e.jsx(G,{isOpen:s,onClose:()=>n(!1),onSave:c,title:m?"Edit Author Profile":"Create Author Profile",fields:k,data:l,onChange:x})]})}const Z=Object.freeze(Object.defineProperty({__proto__:null,default:$},Symbol.toStringTag,{value:"Module"}));function R(){return e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"AI Profile - IGNY8",description:"AI profile settings"}),e.jsx(N,{title:"Coming Soon",desc:"AI profile settings",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"AI Profile Settings - Coming Soon"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2",children:"Configure AI personality and writing style"})]})})]})}const ee=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"}));function z(){return e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"Strategies - IGNY8",description:"Content strategies"}),e.jsx(N,{title:"Coming Soon",desc:"Content strategies",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Content Strategies - Coming Soon"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2",children:"Plan and manage content strategies and approaches"})]})})]})}const te=Object.freeze(Object.defineProperty({__proto__:null,default:z},Symbol.toStringTag,{value:"Module"}));function L(){return e.jsxs(e.Fragment,{children:[e.jsx(f,{title:"Image Testing - IGNY8",description:"AI image testing"}),e.jsx(N,{title:"Coming Soon",desc:"AI image testing",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Image Testing - Coming Soon"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2",children:"Test and configure AI image generation capabilities"})]})})]})}const re=Object.freeze(Object.defineProperty({__proto__:null,default:L},Symbol.toStringTag,{value:"Module"}));export{Z as A,Q as D,re as I,X as P,te as S,ee as a};