added imae adn prompt icons on contetn page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from rest_framework import serializers
|
||||
from django.db import models
|
||||
from .models import Tasks, Images, Content
|
||||
from igny8_core.modules.planner.models import Clusters, ContentIdeas
|
||||
|
||||
@@ -180,6 +181,8 @@ class ContentSerializer(serializers.ModelSerializer):
|
||||
"""Serializer for Content model"""
|
||||
task_title = serializers.SerializerMethodField()
|
||||
sector_name = serializers.SerializerMethodField()
|
||||
has_image_prompts = serializers.SerializerMethodField()
|
||||
has_generated_images = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = Content
|
||||
@@ -202,6 +205,8 @@ class ContentSerializer(serializers.ModelSerializer):
|
||||
'generated_at',
|
||||
'updated_at',
|
||||
'account_id',
|
||||
'has_image_prompts',
|
||||
'has_generated_images',
|
||||
]
|
||||
read_only_fields = ['id', 'generated_at', 'updated_at', 'account_id']
|
||||
|
||||
@@ -225,4 +230,20 @@ class ContentSerializer(serializers.ModelSerializer):
|
||||
except Sector.DoesNotExist:
|
||||
return None
|
||||
return None
|
||||
|
||||
def get_has_image_prompts(self, obj):
|
||||
"""Check if content has any image prompts generated"""
|
||||
# Check if any images exist with prompts for this content
|
||||
return Images.objects.filter(
|
||||
models.Q(content=obj) | models.Q(task=obj.task)
|
||||
).exclude(prompt__isnull=True).exclude(prompt='').exists()
|
||||
|
||||
def get_has_generated_images(self, obj):
|
||||
"""Check if content has any generated images (status='generated' and has URL)"""
|
||||
# Check if any images are generated (have status='generated' and image_url)
|
||||
return Images.objects.filter(
|
||||
models.Q(content=obj) | models.Q(task=obj.task),
|
||||
status='generated',
|
||||
image_url__isnull=False
|
||||
).exclude(image_url='').exists()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import Badge from '../../components/ui/badge/Badge';
|
||||
import { formatRelativeDate } from '../../utils/date';
|
||||
import { Content } from '../../services/api';
|
||||
import { FileIcon, MoreDotIcon } from '../../icons';
|
||||
|
||||
export interface ColumnConfig {
|
||||
key: string;
|
||||
@@ -194,7 +195,72 @@ export const createContentPageConfig = (
|
||||
sortable: true,
|
||||
sortField: 'generated_at',
|
||||
label: 'Generated',
|
||||
render: (value: string) => formatRelativeDate(value),
|
||||
align: 'right',
|
||||
render: (value: string, row: Content) => {
|
||||
const hasPrompts = row.has_image_prompts || false;
|
||||
const hasImages = row.has_generated_images || false;
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-end gap-3 pr-10">
|
||||
<span className="text-gray-700 dark:text-gray-300 whitespace-nowrap">
|
||||
{formatRelativeDate(value)}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Prompt Icon */}
|
||||
<div
|
||||
className={`w-5 h-5 flex items-center justify-center flex-shrink-0 ${
|
||||
hasPrompts
|
||||
? 'text-green-500 dark:text-green-400'
|
||||
: 'text-gray-300 dark:text-gray-600'
|
||||
}`}
|
||||
title={hasPrompts ? 'Image prompts generated' : 'No image prompts'}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className="w-4 h-4"
|
||||
>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
||||
<polyline points="14 2 14 8 20 8" />
|
||||
<line x1="16" y1="13" x2="8" y2="13" />
|
||||
<line x1="16" y1="17" x2="8" y2="17" />
|
||||
<polyline points="10 9 9 9 8 9" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
{/* Image Icon */}
|
||||
<div
|
||||
className={`w-5 h-5 flex items-center justify-center flex-shrink-0 ${
|
||||
hasImages
|
||||
? 'text-green-500 dark:text-green-400'
|
||||
: 'text-gray-300 dark:text-gray-600'
|
||||
}`}
|
||||
title={hasImages ? 'Images generated' : 'No images generated'}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className="w-4 h-4"
|
||||
>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
|
||||
<circle cx="8.5" cy="8.5" r="1.5" />
|
||||
<polyline points="21 15 16 10 5 21" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
filters: [
|
||||
|
||||
@@ -1517,6 +1517,8 @@ export interface Content {
|
||||
metadata: Record<string, any>;
|
||||
generated_at: string;
|
||||
updated_at: string;
|
||||
has_image_prompts?: boolean;
|
||||
has_generated_images?: boolean;
|
||||
}
|
||||
|
||||
export interface ContentResponse {
|
||||
|
||||
Reference in New Issue
Block a user