/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; import { Button, Progress, Tag, Typography } from '@douyinfe/semi-ui'; import { Palette, ZoomIn, Shuffle, Move, FileText, Blend, Upload, Minimize2, RotateCcw, PaintBucket, Focus, Move3D, Monitor, UserCheck, HelpCircle, CheckCircle, Clock, Copy, FileX, Pause, XCircle, Loader, AlertCircle, Hash, Video, } from 'lucide-react'; const colors = [ 'amber', 'blue', 'cyan', 'green', 'grey', 'indigo', 'light-blue', 'lime', 'orange', 'pink', 'purple', 'red', 'teal', 'violet', 'yellow', ]; // Render functions function renderType(type, t) { switch (type) { case 'IMAGINE': return ( }> {t('绘图')} ); case 'UPSCALE': return ( }> {t('放大')} ); case 'VIDEO': return ( }> {t('视频')} ); case 'EDITS': return ( }> {t('编辑')} ); case 'VARIATION': return ( }> {t('变换')} ); case 'HIGH_VARIATION': return ( }> {t('强变换')} ); case 'LOW_VARIATION': return ( }> {t('弱变换')} ); case 'PAN': return ( }> {t('平移')} ); case 'DESCRIBE': return ( }> {t('图生文')} ); case 'BLEND': return ( }> {t('图混合')} ); case 'UPLOAD': return ( }> 上传文件 ); case 'SHORTEN': return ( }> {t('缩词')} ); case 'REROLL': return ( }> {t('重绘')} ); case 'INPAINT': return ( } > {t('局部重绘-提交')} ); case 'ZOOM': return ( }> {t('变焦')} ); case 'CUSTOM_ZOOM': return ( }> {t('自定义变焦-提交')} ); case 'MODAL': return ( }> {t('窗口处理')} ); case 'SWAP_FACE': return ( } > {t('换脸')} ); default: return ( }> {t('未知')} ); } } function renderCode(code, t) { switch (code) { case 1: return ( } > {t('已提交')} ); case 21: return ( }> {t('等待中')} ); case 22: return ( }> {t('重复提交')} ); case 0: return ( }> {t('未提交')} ); default: return ( }> {t('未知')} ); } } function renderStatus(type, t) { switch (type) { case 'SUCCESS': return ( } > {t('成功')} ); case 'NOT_START': return ( }> {t('未启动')} ); case 'SUBMITTED': return ( }> {t('队列中')} ); case 'IN_PROGRESS': return ( }> {t('执行中')} ); case 'FAILURE': return ( }> {t('失败')} ); case 'MODAL': return ( } > {t('窗口等待')} ); default: return ( }> {t('未知')} ); } } const renderTimestamp = (timestampInSeconds) => { const date = new Date(timestampInSeconds * 1000); const year = date.getFullYear(); const month = ('0' + (date.getMonth() + 1)).slice(-2); const day = ('0' + date.getDate()).slice(-2); const hours = ('0' + date.getHours()).slice(-2); const minutes = ('0' + date.getMinutes()).slice(-2); const seconds = ('0' + date.getSeconds()).slice(-2); return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; }; function renderDuration(submit_time, finishTime, t) { if (!submit_time || !finishTime) return 'N/A'; const start = new Date(submit_time); const finish = new Date(finishTime); const durationMs = finish - start; const durationSec = (durationMs / 1000).toFixed(1); const color = durationSec > 60 ? 'red' : 'green'; return ( }> {durationSec} {t('秒')} ); } export const getMjLogsColumns = ({ t, COLUMN_KEYS, copyText, openContentModal, openImageModal, isAdminUser, }) => { return [ { key: COLUMN_KEYS.SUBMIT_TIME, title: t('提交时间'), dataIndex: 'submit_time', render: (text, record, index) => { return
{renderTimestamp(text / 1000)}
; }, }, { key: COLUMN_KEYS.DURATION, title: t('花费时间'), dataIndex: 'finish_time', render: (finish, record) => { return renderDuration(record.submit_time, finish, t); }, }, { key: COLUMN_KEYS.CHANNEL, title: t('渠道'), dataIndex: 'channel_id', render: (text, record, index) => { return isAdminUser ? (
} onClick={() => { copyText(text); }} > {' '} {text}{' '}
) : ( <> ); }, }, { key: COLUMN_KEYS.TYPE, title: t('类型'), dataIndex: 'action', render: (text, record, index) => { return
{renderType(text, t)}
; }, }, { key: COLUMN_KEYS.TASK_ID, title: t('任务ID'), dataIndex: 'mj_id', render: (text, record, index) => { return
{text}
; }, }, { key: COLUMN_KEYS.SUBMIT_RESULT, title: t('提交结果'), dataIndex: 'code', render: (text, record, index) => { return isAdminUser ?
{renderCode(text, t)}
: <>; }, }, { key: COLUMN_KEYS.TASK_STATUS, title: t('任务状态'), dataIndex: 'status', render: (text, record, index) => { return
{renderStatus(text, t)}
; }, }, { key: COLUMN_KEYS.PROGRESS, title: t('进度'), dataIndex: 'progress', render: (text, record, index) => { return (
{ }
); }, }, { key: COLUMN_KEYS.IMAGE, title: t('结果图片'), dataIndex: 'image_url', render: (text, record, index) => { if (!text) { return t('无'); } return ( ); }, }, { key: COLUMN_KEYS.PROMPT, title: 'Prompt', dataIndex: 'prompt', render: (text, record, index) => { if (!text) { return t('无'); } return ( { openContentModal(text); }} > {text} ); }, }, { key: COLUMN_KEYS.PROMPT_EN, title: 'PromptEn', dataIndex: 'prompt_en', render: (text, record, index) => { if (!text) { return t('无'); } return ( { openContentModal(text); }} > {text} ); }, }, { key: COLUMN_KEYS.FAIL_REASON, title: t('失败原因'), dataIndex: 'fail_reason', fixed: 'right', render: (text, record, index) => { if (!text) { return t('无'); } return ( { openContentModal(text); }} > {text} ); }, }, ]; };