🧹 Add Mongo indexes and frontend formatting
This commit is contained in:
parent
5253de26a1
commit
dd1cd1f249
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ node_modules/
|
||||
build/
|
||||
dist/
|
||||
coverage/
|
||||
tmp/
|
||||
.DS_Store
|
||||
*.log
|
||||
.env*
|
||||
|
||||
7
.prettierignore
Normal file
7
.prettierignore
Normal file
@ -0,0 +1,7 @@
|
||||
build/
|
||||
coverage/
|
||||
dist/
|
||||
node_modules/
|
||||
tmp/
|
||||
docs/
|
||||
backend/operator-runner/
|
||||
6
.prettierrc.json
Normal file
6
.prettierrc.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
@ -60,6 +60,8 @@ Drobodata is a workflow orchestration platform for embodied AI and vision pipeli
|
||||
### Useful Scripts
|
||||
|
||||
- `npm run lint`: type-check frontend and verify Go formatting
|
||||
- `npm run format`: format frontend source and frontend tests with Prettier
|
||||
- `npm run format:check`: check frontend formatting without writing files
|
||||
- `npm test`: Go unit and integration tests
|
||||
- `npm run build`: build frontend assets and Go binaries
|
||||
- `npm run verify`: lint, Go tests, Python operator-runner tests, frontend node tests, build, dependency audit, and Kubernetes manifest dry-run validation
|
||||
|
||||
@ -69,6 +69,10 @@ func main() {
|
||||
}()
|
||||
|
||||
dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
|
||||
if err := dataStore.EnsureIndexes(ctx); err != nil {
|
||||
fmt.Printf("[api] failed to ensure mongo indexes: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
aiService := ai.NewService(cfg.AIAPIBaseURL, cfg.AIAPIKey, cfg.AIModel)
|
||||
handler := spaHandler(api.NewHandler(dataStore, aiService), cfg.DistDir)
|
||||
|
||||
@ -44,6 +44,10 @@ func main() {
|
||||
}()
|
||||
|
||||
dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
|
||||
if err := dataStore.EnsureIndexes(ctx); err != nil {
|
||||
fmt.Printf("[worker] failed to ensure mongo indexes: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
runtime, err := worker.NewRuntime(
|
||||
dataStore,
|
||||
cfg.K8sNamespace,
|
||||
|
||||
@ -41,6 +41,8 @@
|
||||
- `users`
|
||||
- `settings`
|
||||
|
||||
API and worker startup both call `EnsureIndexes` on the platform MongoDB. Index creation is idempotent and covers the main lookup and dispatch paths such as run status queues, workflow/project run history, source-state checkpoints, audit queues, and singleton/settings lookups.
|
||||
|
||||
## Run Lifecycle
|
||||
|
||||
1. frontend calls `POST /api/workflows/:id/run`
|
||||
@ -60,7 +62,7 @@ Run the full verification loop:
|
||||
npm run verify
|
||||
```
|
||||
|
||||
This includes TypeScript/Go linting, Go tests, Python operator-runner tests, frontend node tests, production build, `npm audit --audit-level=moderate`, and Kubernetes manifest dry-run validation.
|
||||
This includes TypeScript/Go linting, frontend Prettier formatting checks, Go tests, Python operator-runner tests, frontend node tests, production build, `npm audit --audit-level=moderate`, and Kubernetes manifest dry-run validation.
|
||||
|
||||
## Runtime Metrics
|
||||
|
||||
|
||||
97
internal/store/mongo_indexes.go
Normal file
97
internal/store/mongo_indexes.go
Normal file
@ -0,0 +1,97 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func uniqueIndex(name string, keys bson.D) mongo.IndexModel {
|
||||
return mongo.IndexModel{
|
||||
Keys: keys,
|
||||
Options: options.Index().SetName(name).SetUnique(true),
|
||||
}
|
||||
}
|
||||
|
||||
func index(name string, keys bson.D) mongo.IndexModel {
|
||||
return mongo.IndexModel{
|
||||
Keys: keys,
|
||||
Options: options.Index().SetName(name),
|
||||
}
|
||||
}
|
||||
|
||||
func ensureCollectionIndexes(ctx context.Context, collection *mongo.Collection, models []mongo.IndexModel) error {
|
||||
if len(models) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err := collection.Indexes().CreateMany(ctx, models)
|
||||
return err
|
||||
}
|
||||
|
||||
func (store *MongoStore) EnsureIndexes(ctx context.Context) error {
|
||||
indexesByCollection := map[*mongo.Collection][]mongo.IndexModel{
|
||||
store.projects: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("status_createdAt", bson.D{{Key: "status", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
},
|
||||
store.operators: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("category_name", bson.D{{Key: "category", Value: 1}, {Key: "name", Value: 1}}),
|
||||
},
|
||||
store.builtinOperatorDeletions: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
},
|
||||
store.workflows: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("projectId_createdAt", bson.D{{Key: "projectId", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
index("type_status_lastRunAt", bson.D{{Key: "type", Value: 1}, {Key: "status", Value: 1}, {Key: "lastRunAt", Value: -1}}),
|
||||
},
|
||||
store.templates: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("createdAt", bson.D{{Key: "createdAt", Value: -1}}),
|
||||
},
|
||||
store.runs: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("status_availableAt_createdAt", bson.D{{Key: "status", Value: 1}, {Key: "availableAt", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
index("workflowId_createdAt", bson.D{{Key: "workflowId", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
index("projectId_createdAt", bson.D{{Key: "projectId", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
},
|
||||
store.sourceStates: {
|
||||
uniqueIndex("workflow_node_fingerprint_unique", bson.D{{Key: "workflowId", Value: 1}, {Key: "nodeId", Value: 1}, {Key: "sourceFingerprint", Value: 1}}),
|
||||
index("workflowId_nodeId", bson.D{{Key: "workflowId", Value: 1}, {Key: "nodeId", Value: 1}}),
|
||||
},
|
||||
store.auditTasks: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("status_createdAt", bson.D{{Key: "status", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
index("runId_nodeId", bson.D{{Key: "runId", Value: 1}, {Key: "nodeId", Value: 1}}),
|
||||
index("workflowId_createdAt", bson.D{{Key: "workflowId", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
},
|
||||
store.samplingTasks: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("status_createdAt", bson.D{{Key: "status", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
index("workflowId_createdAt", bson.D{{Key: "workflowId", Value: 1}, {Key: "createdAt", Value: -1}}),
|
||||
},
|
||||
store.users: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
},
|
||||
store.storageConnections: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("name", bson.D{{Key: "name", Value: 1}}),
|
||||
},
|
||||
store.mongoConnections: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
index("name", bson.D{{Key: "name", Value: 1}}),
|
||||
},
|
||||
store.settings: {
|
||||
uniqueIndex("id_unique", bson.D{{Key: "id", Value: 1}}),
|
||||
},
|
||||
}
|
||||
for collection, models := range indexesByCollection {
|
||||
if err := ensureCollectionIndexes(ctx, collection, models); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@ -28,6 +28,7 @@
|
||||
"autoprefixer": "^10.4.21",
|
||||
"concurrently": "^10.0.3",
|
||||
"playwright": "^1.59.1",
|
||||
"prettier": "^3.8.4",
|
||||
"tailwindcss": "^4.1.14",
|
||||
"typescript": "~5.8.2",
|
||||
"vite": "^8.0.16"
|
||||
@ -2531,6 +2532,22 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.8.4",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.4.tgz",
|
||||
"integrity": "sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.2.4",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",
|
||||
|
||||
@ -21,11 +21,13 @@
|
||||
"lint": "npm run lint:web && npm run lint:go",
|
||||
"lint:web": "tsc --noEmit",
|
||||
"lint:go": "bash -lc 'test -z \"$(gofmt -l cmd internal)\"'",
|
||||
"format": "prettier --write \"src/**/*.{ts,tsx,css}\" \"tests/frontend/**/*.mjs\"",
|
||||
"format:check": "prettier --check \"src/**/*.{ts,tsx,css}\" \"tests/frontend/**/*.mjs\"",
|
||||
"test": "go test ./...",
|
||||
"test:python": "python3 -m pytest backend/operator-runner tests/backend",
|
||||
"test:frontend": "node --test tests/frontend/*.test.mjs",
|
||||
"audit:moderate": "npm audit --audit-level=moderate",
|
||||
"verify": "npm run lint && npm test && npm run test:python && npm run test:frontend && npm run build && npm run audit:moderate && npm run k8s:validate",
|
||||
"verify": "npm run lint && npm run format:check && npm test && npm run test:python && npm run test:frontend && npm run build && npm run audit:moderate && npm run k8s:validate",
|
||||
"docker:build:api": "docker build -f Dockerfile.api -t droboticflow-api:local .",
|
||||
"docker:build:worker": "docker build -f Dockerfile.worker -t droboticflow-worker:local .",
|
||||
"docker:build:operator-runner": "docker build -f Dockerfile.operator-runner -t droboticflow-operator-runner:local .",
|
||||
@ -56,6 +58,7 @@
|
||||
"autoprefixer": "^10.4.21",
|
||||
"concurrently": "^10.0.3",
|
||||
"playwright": "^1.59.1",
|
||||
"prettier": "^3.8.4",
|
||||
"tailwindcss": "^4.1.14",
|
||||
"typescript": "~5.8.2",
|
||||
"vite": "^8.0.16"
|
||||
|
||||
25
src/App.tsx
25
src/App.tsx
@ -22,17 +22,11 @@ const Audit = lazy(() => import("./pages/Audit"));
|
||||
const DataAssets = lazy(() => import("./pages/DataAssets"));
|
||||
const DatabaseBrowser = lazy(() => import("./pages/DatabaseBrowser"));
|
||||
const ObjectStorageBrowser = lazy(() => import("./pages/ObjectStorageBrowser"));
|
||||
const LegacyDataAssetsRedirect = lazy(
|
||||
() => import("./pages/LegacyDataAssetsRedirect"),
|
||||
);
|
||||
const LegacyDataAssetsRedirect = lazy(() => import("./pages/LegacyDataAssetsRedirect"));
|
||||
const Sampling = lazy(() => import("./pages/Sampling"));
|
||||
|
||||
function RouteFallback() {
|
||||
return (
|
||||
<div className="flex min-h-[320px] items-center justify-center text-sm text-slate-400">
|
||||
正在加载页面...
|
||||
</div>
|
||||
);
|
||||
return <div className="flex min-h-[320px] items-center justify-center text-sm text-slate-400">正在加载页面...</div>;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
@ -50,18 +44,9 @@ export default function App() {
|
||||
<Route path="/workflow/:id" element={<WorkflowEditor />} />
|
||||
<Route path="/data-assets" element={<DataAssets />} />
|
||||
<Route path="/database" element={<DatabaseBrowser />} />
|
||||
<Route
|
||||
path="/object-storage"
|
||||
element={<ObjectStorageBrowser />}
|
||||
/>
|
||||
<Route
|
||||
path="/source-data"
|
||||
element={<LegacyDataAssetsRedirect />}
|
||||
/>
|
||||
<Route
|
||||
path="/packages"
|
||||
element={<LegacyDataAssetsRedirect />}
|
||||
/>
|
||||
<Route path="/object-storage" element={<ObjectStorageBrowser />} />
|
||||
<Route path="/source-data" element={<LegacyDataAssetsRedirect />} />
|
||||
<Route path="/packages" element={<LegacyDataAssetsRedirect />} />
|
||||
<Route path="/sampling" element={<Sampling />} />
|
||||
<Route path="/monitoring" element={<Monitoring />} />
|
||||
<Route path="/audit" element={<Audit />} />
|
||||
|
||||
@ -23,11 +23,14 @@ export default function AIGenerateModal({ isOpen, onClose, onGenerate }: AIGener
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
operatorsApi.list().then(setAvailableOperators).catch((err) => {
|
||||
console.error("Failed to load operators for AI generation", err);
|
||||
setAvailableOperators([]);
|
||||
setError("无法加载真实算子列表,暂时不能生成工作流。");
|
||||
});
|
||||
operatorsApi
|
||||
.list()
|
||||
.then(setAvailableOperators)
|
||||
.catch((err) => {
|
||||
console.error("Failed to load operators for AI generation", err);
|
||||
setAvailableOperators([]);
|
||||
setError("无法加载真实算子列表,暂时不能生成工作流。");
|
||||
});
|
||||
}, [isOpen]);
|
||||
|
||||
const handleGenerate = async () => {
|
||||
@ -65,11 +68,11 @@ export default function AIGenerateModal({ isOpen, onClose, onGenerate }: AIGener
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="space-y-3">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">描述您的需求</label>
|
||||
<textarea
|
||||
<textarea
|
||||
placeholder="例如:帮我建立一个工作流,从 OSS 下载视频,进行预处理,然后运行 YOLO 模型检测目标,最后将结果上传回 OSS。"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-xl px-4 py-3 text-sm h-40 focus:outline-none focus:border-blue-500 transition-all resize-none leading-relaxed"
|
||||
value={description}
|
||||
onChange={e => setDescription(e.target.value)}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
disabled={isGenerating}
|
||||
/>
|
||||
<p className="text-[10px] text-gray-500 italic">
|
||||
@ -100,19 +103,20 @@ export default function AIGenerateModal({ isOpen, onClose, onGenerate }: AIGener
|
||||
</div>
|
||||
|
||||
<div className="p-6 border-t border-[#2a2b2f] flex justify-end gap-3 bg-[#0a0a0a]/50">
|
||||
<button
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="px-4 py-2 text-sm font-medium text-gray-400 hover:text-white transition-colors"
|
||||
disabled={isGenerating}
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
onClick={handleGenerate}
|
||||
disabled={!aiStatus.enabled || !description.trim() || isGenerating || availableOperators.length === 0}
|
||||
className={cn(
|
||||
"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-all flex items-center gap-2",
|
||||
(!aiStatus.enabled || !description.trim() || isGenerating || availableOperators.length === 0) && "opacity-50 cursor-not-allowed"
|
||||
(!aiStatus.enabled || !description.trim() || isGenerating || availableOperators.length === 0) &&
|
||||
"opacity-50 cursor-not-allowed",
|
||||
)}
|
||||
>
|
||||
{isGenerating ? (
|
||||
|
||||
@ -10,9 +10,7 @@ const artifactExtension = (item: ExecutionData) => {
|
||||
|
||||
const rawPreviewPayload = (item: ExecutionData) => {
|
||||
const preview = item.data?.preview;
|
||||
return preview && typeof preview === "object"
|
||||
? (preview as Record<string, any>)
|
||||
: null;
|
||||
return preview && typeof preview === "object" ? (preview as Record<string, any>) : null;
|
||||
};
|
||||
|
||||
const derivedPreview = (item: ExecutionData) => {
|
||||
@ -54,10 +52,7 @@ export function ArtifactPreviewPanel({ item }: { item: ExecutionData | null }) {
|
||||
const [mediaError, setMediaError] = React.useState(false);
|
||||
const preview = item ? derivedPreview(item) : null;
|
||||
const previewURL = item && preview ? artifactPreviewURL(item, preview) : "";
|
||||
const playablePreviewURL =
|
||||
preview?.kind === "video"
|
||||
? buildBrowserPlayableVideoURL(previewURL)
|
||||
: previewURL;
|
||||
const playablePreviewURL = preview?.kind === "video" ? buildBrowserPlayableVideoURL(previewURL) : previewURL;
|
||||
|
||||
React.useEffect(() => {
|
||||
setMediaError(false);
|
||||
@ -86,7 +81,8 @@ export function ArtifactPreviewPanel({ item }: { item: ExecutionData | null }) {
|
||||
<div className="rounded-lg border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-100">
|
||||
<div className="font-medium">浏览器预览生成失败</div>
|
||||
<div className="mt-2 leading-6 text-amber-100/80">
|
||||
系统已经尝试自动将原始视频转为浏览器可播放的 H.264 预览,但本次预览仍然失败。你仍可直接打开原始文件,或稍后重试。
|
||||
系统已经尝试自动将原始视频转为浏览器可播放的 H.264
|
||||
预览,但本次预览仍然失败。你仍可直接打开原始文件,或稍后重试。
|
||||
</div>
|
||||
<a
|
||||
href={previewURL}
|
||||
@ -134,7 +130,10 @@ export function ArtifactPreviewPanel({ item }: { item: ExecutionData | null }) {
|
||||
<thead className="sticky top-0 bg-[#16181c]">
|
||||
<tr>
|
||||
{columns.map((column: string) => (
|
||||
<th key={column} className="px-3 py-2 text-left text-xs text-gray-400 font-medium border-b border-[#2a2b2f]">
|
||||
<th
|
||||
key={column}
|
||||
className="px-3 py-2 text-left text-xs text-gray-400 font-medium border-b border-[#2a2b2f]"
|
||||
>
|
||||
{column}
|
||||
</th>
|
||||
))}
|
||||
@ -168,7 +167,7 @@ export function ArtifactPreviewPanel({ item }: { item: ExecutionData | null }) {
|
||||
}
|
||||
|
||||
if (preview.kind === "json" || item.type === "json") {
|
||||
const jsonValue = preview.kind === "json" ? preview.value ?? item.data : item.data;
|
||||
const jsonValue = preview.kind === "json" ? (preview.value ?? item.data) : item.data;
|
||||
return (
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#0f1012] p-4">
|
||||
<pre className="text-xs text-gray-200 whitespace-pre-wrap break-all leading-6 max-h-[460px] overflow-auto">
|
||||
|
||||
@ -16,46 +16,44 @@ export function Logo({ className, size = "md", showText = false }: LogoProps) {
|
||||
|
||||
return (
|
||||
<div className={cn("flex items-center gap-3", className)}>
|
||||
<div className={cn(
|
||||
"relative bg-blue-600 rounded-lg flex items-center justify-center overflow-hidden shadow-lg shadow-blue-600/20",
|
||||
sizeClasses[size]
|
||||
)}>
|
||||
<div
|
||||
className={cn(
|
||||
"relative bg-blue-600 rounded-lg flex items-center justify-center overflow-hidden shadow-lg shadow-blue-600/20",
|
||||
sizeClasses[size],
|
||||
)}
|
||||
>
|
||||
{/* Stylized "D" + Robot + Flow */}
|
||||
<svg
|
||||
viewBox="0 0 100 100"
|
||||
className="w-[70%] h-[70%] fill-none stroke-white stroke-[8] stroke-round"
|
||||
>
|
||||
<svg viewBox="0 0 100 100" className="w-[70%] h-[70%] fill-none stroke-white stroke-[8] stroke-round">
|
||||
{/* The "D" shape / Robot Head */}
|
||||
<path
|
||||
d="M30 25 H60 C80 25 80 75 60 75 H30 V25 Z"
|
||||
className="stroke-white"
|
||||
/>
|
||||
|
||||
<path d="M30 25 H60 C80 25 80 75 60 75 H30 V25 Z" className="stroke-white" />
|
||||
|
||||
{/* Antenna */}
|
||||
<path d="M50 25 V15" className="stroke-white/40 stroke-[4]" />
|
||||
<circle cx="50" cy="12" r="3" fill="white" className="opacity-40" />
|
||||
|
||||
|
||||
{/* Robot Eyes */}
|
||||
<rect x="42" cy="40" width="8" height="8" rx="2" fill="white" stroke="none" />
|
||||
<rect x="62" cy="40" width="8" height="8" rx="2" fill="white" stroke="none" />
|
||||
|
||||
|
||||
{/* Flow Lines inside D */}
|
||||
<path d="M30 55 H55" className="stroke-white/30 stroke-[4]" />
|
||||
<path d="M30 65 H45" className="stroke-white/30 stroke-[4]" />
|
||||
|
||||
|
||||
{/* External Flow Nodes */}
|
||||
<circle cx="20" cy="50" r="6" fill="white" stroke="none" className="opacity-80" />
|
||||
<path d="M20 50 L30 50" className="stroke-white/80 stroke-[4]" />
|
||||
</svg>
|
||||
|
||||
|
||||
{/* Subtle Glow Effect */}
|
||||
<div className="absolute inset-0 bg-gradient-to-tr from-white/10 to-transparent pointer-events-none" />
|
||||
</div>
|
||||
|
||||
|
||||
{showText && (
|
||||
<div className="flex flex-col leading-none">
|
||||
<span className="text-white font-bold text-lg tracking-tight">Drobodata</span>
|
||||
<span className="text-[10px] text-blue-400 font-mono uppercase tracking-widest mt-0.5">Embodied Data Workflows</span>
|
||||
<span className="text-[10px] text-blue-400 font-mono uppercase tracking-widest mt-0.5">
|
||||
Embodied Data Workflows
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -51,16 +51,7 @@ export function Sidebar({ isCollapsed, onToggle }: SidebarProps) {
|
||||
const [isProfileModalOpen, setIsProfileModalOpen] = useState(false);
|
||||
const [profileDraft, setProfileDraft] = useState<ProfileDraft | null>(null);
|
||||
const [isSavingProfile, setIsSavingProfile] = useState(false);
|
||||
const {
|
||||
currentUser,
|
||||
users,
|
||||
role,
|
||||
name,
|
||||
email,
|
||||
selectUser,
|
||||
updateCurrentUser,
|
||||
logout,
|
||||
} = useUser();
|
||||
const { currentUser, users, role, name, email, selectUser, updateCurrentUser, logout } = useUser();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isProfileModalOpen || !currentUser) {
|
||||
@ -171,7 +162,10 @@ export function Sidebar({ isCollapsed, onToggle }: SidebarProps) {
|
||||
<User className="w-5 h-5 text-blue-500" />
|
||||
当前用户
|
||||
</h2>
|
||||
<button onClick={() => setIsProfileModalOpen(false)} className="text-gray-500 hover:text-white transition-colors">
|
||||
<button
|
||||
onClick={() => setIsProfileModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white transition-colors"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
@ -211,7 +205,11 @@ export function Sidebar({ isCollapsed, onToggle }: SidebarProps) {
|
||||
type="text"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
value={profileDraft.name}
|
||||
onChange={(event) => setProfileDraft((previous) => (previous ? { ...previous, name: event.target.value } : previous))}
|
||||
onChange={(event) =>
|
||||
setProfileDraft((previous) =>
|
||||
previous ? { ...previous, name: event.target.value } : previous,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -223,7 +221,11 @@ export function Sidebar({ isCollapsed, onToggle }: SidebarProps) {
|
||||
type="email"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
value={profileDraft.email}
|
||||
onChange={(event) => setProfileDraft((previous) => (previous ? { ...previous, email: event.target.value } : previous))}
|
||||
onChange={(event) =>
|
||||
setProfileDraft((previous) =>
|
||||
previous ? { ...previous, email: event.target.value } : previous,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@ -139,7 +139,9 @@ export function UserBootstrapPanel() {
|
||||
</label>
|
||||
<select
|
||||
value={form.role}
|
||||
onChange={(event) => setForm((previous) => ({ ...previous, role: event.target.value as UserRole | "" }))}
|
||||
onChange={(event) =>
|
||||
setForm((previous) => ({ ...previous, role: event.target.value as UserRole | "" }))
|
||||
}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0a0a0a] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
>
|
||||
<option value="">请选择角色</option>
|
||||
|
||||
@ -1,11 +1,4 @@
|
||||
import React, {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
||||
import { settingsApi } from "../services/api/settings";
|
||||
import { resolveTimeZone } from "../lib/datetime";
|
||||
|
||||
@ -18,9 +11,7 @@ type TimeZoneContextValue = {
|
||||
const TimeZoneContext = createContext<TimeZoneContextValue | null>(null);
|
||||
|
||||
export function TimeZoneProvider({ children }: { children: React.ReactNode }) {
|
||||
const [timeZone, setTimeZoneState] = useState(() =>
|
||||
resolveTimeZone(undefined),
|
||||
);
|
||||
const [timeZone, setTimeZoneState] = useState(() => resolveTimeZone(undefined));
|
||||
|
||||
const refreshTimeZone = useCallback(async () => {
|
||||
try {
|
||||
@ -38,18 +29,13 @@ export function TimeZoneProvider({ children }: { children: React.ReactNode }) {
|
||||
const value = useMemo<TimeZoneContextValue>(
|
||||
() => ({
|
||||
timeZone,
|
||||
setTimeZone: (nextTimeZone: string) =>
|
||||
setTimeZoneState(resolveTimeZone(nextTimeZone)),
|
||||
setTimeZone: (nextTimeZone: string) => setTimeZoneState(resolveTimeZone(nextTimeZone)),
|
||||
refreshTimeZone,
|
||||
}),
|
||||
[refreshTimeZone, timeZone],
|
||||
);
|
||||
|
||||
return (
|
||||
<TimeZoneContext.Provider value={value}>
|
||||
{children}
|
||||
</TimeZoneContext.Provider>
|
||||
);
|
||||
return <TimeZoneContext.Provider value={value}>{children}</TimeZoneContext.Provider>;
|
||||
}
|
||||
|
||||
export function useTimeZone() {
|
||||
|
||||
@ -13,7 +13,8 @@ export function useAIStatus() {
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
aiApi.status()
|
||||
aiApi
|
||||
.status()
|
||||
.then((result) => {
|
||||
if (!cancelled) {
|
||||
setStatus(result);
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@keyframes node-flash {
|
||||
0%, 100% { border-color: #3b82f6; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
|
||||
50% { border-color: #60a5fa; box-shadow: 0 0 20px 5px rgba(59, 130, 246, 0.5); }
|
||||
0%,
|
||||
100% {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
|
||||
}
|
||||
50% {
|
||||
border-color: #60a5fa;
|
||||
box-shadow: 0 0 20px 5px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-node-flash {
|
||||
|
||||
@ -47,11 +47,7 @@ export function resolveTimeZone(value: string | undefined) {
|
||||
return FALLBACK_TIME_ZONE;
|
||||
}
|
||||
|
||||
function formatterParts(
|
||||
value: string,
|
||||
timeZone: string,
|
||||
options: Intl.DateTimeFormatOptions,
|
||||
) {
|
||||
function formatterParts(value: string, timeZone: string, options: Intl.DateTimeFormatOptions) {
|
||||
const formatter = new Intl.DateTimeFormat(DEFAULT_LOCALE, {
|
||||
timeZone: resolveTimeZone(timeZone),
|
||||
hour12: false,
|
||||
@ -63,9 +59,7 @@ function formatterParts(
|
||||
}
|
||||
const parts = formatter.formatToParts(parsed);
|
||||
return Object.fromEntries(
|
||||
parts
|
||||
.filter((part) => part.type !== "literal")
|
||||
.map((part) => [part.type, part.value]),
|
||||
parts.filter((part) => part.type !== "literal").map((part) => [part.type, part.value]),
|
||||
) as Record<string, string>;
|
||||
}
|
||||
|
||||
@ -88,11 +82,7 @@ function parseDateValue(value: string | undefined) {
|
||||
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
||||
}
|
||||
|
||||
export function formatDateTime(
|
||||
value: string | undefined,
|
||||
timeZone: string | undefined,
|
||||
fallback = "--",
|
||||
) {
|
||||
export function formatDateTime(value: string | undefined, timeZone: string | undefined, fallback = "--") {
|
||||
if (!isValidDate(value)) {
|
||||
return value || fallback;
|
||||
}
|
||||
@ -107,11 +97,7 @@ export function formatDateTime(
|
||||
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}:${parts.second}`;
|
||||
}
|
||||
|
||||
export function formatCompactDateTime(
|
||||
value: string | undefined,
|
||||
timeZone: string | undefined,
|
||||
fallback = "--",
|
||||
) {
|
||||
export function formatCompactDateTime(value: string | undefined, timeZone: string | undefined, fallback = "--") {
|
||||
if (!isValidDate(value)) {
|
||||
return value || fallback;
|
||||
}
|
||||
@ -125,11 +111,7 @@ export function formatCompactDateTime(
|
||||
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}`;
|
||||
}
|
||||
|
||||
export function formatClockTime(
|
||||
value: string | undefined,
|
||||
timeZone: string | undefined,
|
||||
fallback = "--",
|
||||
) {
|
||||
export function formatClockTime(value: string | undefined, timeZone: string | undefined, fallback = "--") {
|
||||
if (!isValidDate(value)) {
|
||||
return value || fallback;
|
||||
}
|
||||
|
||||
10
src/main.tsx
10
src/main.tsx
@ -1,9 +1,9 @@
|
||||
import {StrictMode} from 'react';
|
||||
import {createRoot} from 'react-dom/client';
|
||||
import App from './App.tsx';
|
||||
import './index.css';
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App.tsx";
|
||||
import "./index.css";
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
|
||||
@ -1,16 +1,6 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {
|
||||
ClipboardCheck,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
Eye,
|
||||
Clock,
|
||||
User,
|
||||
ExternalLink,
|
||||
Info,
|
||||
AlertCircle,
|
||||
} from "lucide-react";
|
||||
import { ClipboardCheck, CheckCircle2, XCircle, Eye, Clock, User, ExternalLink, Info, AlertCircle } from "lucide-react";
|
||||
import { cn } from "../lib/utils";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import type { AuditTask } from "../types";
|
||||
@ -23,9 +13,7 @@ export default function Audit() {
|
||||
const { timeZone } = useTimeZone();
|
||||
const [tasks, setTasks] = useState<AuditTask[]>([]);
|
||||
const [selectedTask, setSelectedTask] = useState<AuditTask | null>(null);
|
||||
const [filter, setFilter] = useState<"all" | "pending" | "completed">(
|
||||
"pending",
|
||||
);
|
||||
const [filter, setFilter] = useState<"all" | "pending" | "completed">("pending");
|
||||
|
||||
useEffect(() => {
|
||||
auditApi
|
||||
@ -43,10 +31,7 @@ export default function Audit() {
|
||||
});
|
||||
|
||||
const handleAction = (taskId: string, action: "approved" | "rejected") => {
|
||||
const request =
|
||||
action === "approved"
|
||||
? auditApi.approve(taskId)
|
||||
: auditApi.reject(taskId);
|
||||
const request = action === "approved" ? auditApi.approve(taskId) : auditApi.reject(taskId);
|
||||
request
|
||||
.then((updated) => {
|
||||
setTasks(tasks.map((task) => (task.id === taskId ? updated : task)));
|
||||
@ -63,9 +48,7 @@ export default function Audit() {
|
||||
<ClipboardCheck className="w-8 h-8 text-blue-500" />
|
||||
任务审核 (Task Audit)
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
处理工作流中需要人工介入的审核请求。
|
||||
</p>
|
||||
<p className="text-gray-500 mt-1">处理工作流中需要人工介入的审核请求。</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
@ -74,9 +57,7 @@ export default function Audit() {
|
||||
onClick={() => setFilter("pending")}
|
||||
className={cn(
|
||||
"px-4 py-1.5 text-xs font-medium rounded-md transition-all",
|
||||
filter === "pending"
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "text-gray-400 hover:text-white",
|
||||
filter === "pending" ? "bg-blue-600 text-white shadow-lg" : "text-gray-400 hover:text-white",
|
||||
)}
|
||||
>
|
||||
待审核 ({tasks.filter((t) => t.status === "pending").length})
|
||||
@ -85,9 +66,7 @@ export default function Audit() {
|
||||
onClick={() => setFilter("completed")}
|
||||
className={cn(
|
||||
"px-4 py-1.5 text-xs font-medium rounded-md transition-all",
|
||||
filter === "completed"
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "text-gray-400 hover:text-white",
|
||||
filter === "completed" ? "bg-blue-600 text-white shadow-lg" : "text-gray-400 hover:text-white",
|
||||
)}
|
||||
>
|
||||
已处理
|
||||
@ -96,9 +75,7 @@ export default function Audit() {
|
||||
onClick={() => setFilter("all")}
|
||||
className={cn(
|
||||
"px-4 py-1.5 text-xs font-medium rounded-md transition-all",
|
||||
filter === "all"
|
||||
? "bg-blue-600 text-white shadow-lg"
|
||||
: "text-gray-400 hover:text-white",
|
||||
filter === "all" ? "bg-blue-600 text-white shadow-lg" : "text-gray-400 hover:text-white",
|
||||
)}
|
||||
>
|
||||
全部
|
||||
@ -133,9 +110,7 @@ export default function Audit() {
|
||||
<span className="text-[10px] font-mono text-blue-400 bg-blue-400/10 px-2 py-0.5 rounded uppercase tracking-wider">
|
||||
{task.projectName}
|
||||
</span>
|
||||
<span className="text-[10px] font-mono text-gray-500 uppercase tracking-widest">
|
||||
ID: {task.id}
|
||||
</span>
|
||||
<span className="text-[10px] font-mono text-gray-500 uppercase tracking-widest">ID: {task.id}</span>
|
||||
</div>
|
||||
<span
|
||||
className={cn(
|
||||
@ -147,11 +122,7 @@ export default function Audit() {
|
||||
: "bg-red-500/10 text-red-500 border-red-500/20",
|
||||
)}
|
||||
>
|
||||
{task.status === "pending"
|
||||
? "待审核"
|
||||
: task.status === "approved"
|
||||
? "已通过"
|
||||
: "已拒绝"}
|
||||
{task.status === "pending" ? "待审核" : task.status === "approved" ? "已通过" : "已拒绝"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -159,8 +130,7 @@ export default function Audit() {
|
||||
{task.workflowName}
|
||||
</h3>
|
||||
<p className="text-xs text-gray-500 mb-4 flex items-center gap-1.5">
|
||||
<Clock className="w-3 h-3" />{" "}
|
||||
{formatCompactDateTime(task.createdAt, timeZone)}
|
||||
<Clock className="w-3 h-3" /> {formatCompactDateTime(task.createdAt, timeZone)}
|
||||
</p>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
@ -195,11 +165,7 @@ export default function Audit() {
|
||||
<h2 className="text-lg font-bold text-white">审核详情</h2>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() =>
|
||||
navigate(
|
||||
`/monitoring?runId=${encodeURIComponent(selectedTask.runId)}`,
|
||||
)
|
||||
}
|
||||
onClick={() => navigate(`/monitoring?runId=${encodeURIComponent(selectedTask.runId)}`)}
|
||||
className="p-2 hover:bg-white/5 rounded-md text-gray-500 hover:text-white transition-colors"
|
||||
title="查看对应执行监控"
|
||||
>
|
||||
@ -211,21 +177,15 @@ export default function Audit() {
|
||||
<div className="space-y-3">
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-gray-500">所属项目</span>
|
||||
<span className="text-gray-300 font-medium">
|
||||
{selectedTask.projectName}
|
||||
</span>
|
||||
<span className="text-gray-300 font-medium">{selectedTask.projectName}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-gray-500">工作流</span>
|
||||
<span className="text-gray-300 font-medium">
|
||||
{selectedTask.workflowName}
|
||||
</span>
|
||||
<span className="text-gray-300 font-medium">{selectedTask.workflowName}</span>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs">
|
||||
<span className="text-gray-500">触发算子</span>
|
||||
<span className="text-blue-400 font-medium">
|
||||
{selectedTask.operatorName}
|
||||
</span>
|
||||
<span className="text-blue-400 font-medium">{selectedTask.operatorName}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -246,8 +206,7 @@ export default function Audit() {
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-black/60 to-transparent flex flex-col justify-end p-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="px-2 py-0.5 bg-blue-600 text-white text-[10px] font-bold rounded">
|
||||
置信度:{" "}
|
||||
{(selectedTask.data.confidence * 100).toFixed(0)}%
|
||||
置信度: {(selectedTask.data.confidence * 100).toFixed(0)}%
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -259,12 +218,8 @@ export default function Audit() {
|
||||
<div className="flex items-start gap-3">
|
||||
<AlertCircle className="w-5 h-5 text-blue-500 shrink-0 mt-0.5" />
|
||||
<div>
|
||||
<h4 className="text-sm font-bold text-blue-400 mb-1">
|
||||
审核原因
|
||||
</h4>
|
||||
<p className="text-xs text-gray-400 leading-relaxed">
|
||||
{selectedTask.data.reason}
|
||||
</p>
|
||||
<h4 className="text-sm font-bold text-blue-400 mb-1">审核原因</h4>
|
||||
<p className="text-xs text-gray-400 leading-relaxed">{selectedTask.data.reason}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -275,16 +230,14 @@ export default function Audit() {
|
||||
<Info className="w-3 h-3" /> 检测结果 (AI)
|
||||
</label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{selectedTask.data.detectedObjects.map(
|
||||
(obj: string, i: number) => (
|
||||
<span
|
||||
key={i}
|
||||
className="px-3 py-1 bg-[#1a1b1e] border border-[#2a2b2f] rounded-full text-xs text-gray-300"
|
||||
>
|
||||
{obj}
|
||||
</span>
|
||||
),
|
||||
)}
|
||||
{selectedTask.data.detectedObjects.map((obj: string, i: number) => (
|
||||
<span
|
||||
key={i}
|
||||
className="px-3 py-1 bg-[#1a1b1e] border border-[#2a2b2f] rounded-full text-xs text-gray-300"
|
||||
>
|
||||
{obj}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -316,12 +269,8 @@ export default function Audit() {
|
||||
<div className="w-16 h-16 bg-[#1a1b1e] border border-[#2a2b2f] rounded-2xl flex items-center justify-center mb-6">
|
||||
<ClipboardCheck className="w-8 h-8 opacity-20" />
|
||||
</div>
|
||||
<h3 className="text-white font-bold mb-2">
|
||||
选择一个任务开始审核
|
||||
</h3>
|
||||
<p className="text-xs leading-relaxed">
|
||||
点击左侧列表中的待审核任务,查看详细数据并进行人工确认。
|
||||
</p>
|
||||
<h3 className="text-white font-bold mb-2">选择一个任务开始审核</h3>
|
||||
<p className="text-xs leading-relaxed">点击左侧列表中的待审核任务,查看详细数据并进行人工确认。</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -8,9 +8,12 @@ export default function Dashboard() {
|
||||
const { currentUser } = useUser();
|
||||
|
||||
useEffect(() => {
|
||||
dashboardApi.getSummary().then(setSummary).catch((error) => {
|
||||
console.error("Failed to load dashboard summary", error);
|
||||
});
|
||||
dashboardApi
|
||||
.getSummary()
|
||||
.then(setSummary)
|
||||
.catch((error) => {
|
||||
console.error("Failed to load dashboard summary", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -18,10 +21,12 @@ export default function Dashboard() {
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">Drobodata 仪表盘</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
{currentUser ? `欢迎回来,${currentUser.name}。这里是当前平台的真实执行概览。` : "这里是当前平台的真实执行概览。"}
|
||||
{currentUser
|
||||
? `欢迎回来,${currentUser.name}。这里是当前平台的真实执行概览。`
|
||||
: "这里是当前平台的真实执行概览。"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div className="bg-gradient-to-br from-blue-600 to-blue-800 p-6 rounded-2xl shadow-xl shadow-blue-900/20">
|
||||
<h3 className="text-blue-100 text-sm font-medium uppercase tracking-wider mb-1">活跃项目</h3>
|
||||
|
||||
@ -45,12 +45,7 @@ const formatBytes = (value?: number) => {
|
||||
return `${current.toFixed(current >= 10 || unit === 0 ? 0 : 1)} ${units[unit]}`;
|
||||
};
|
||||
|
||||
const collectionLabel = (
|
||||
item: Pick<
|
||||
SourceCollection,
|
||||
"collectionName" | "relativePath" | "meta" | "collectionId"
|
||||
>,
|
||||
) =>
|
||||
const collectionLabel = (item: Pick<SourceCollection, "collectionName" | "relativePath" | "meta" | "collectionId">) =>
|
||||
item.meta?.project_id ||
|
||||
item.collectionName ||
|
||||
item.relativePath.split("/").filter(Boolean).at(-1) ||
|
||||
@ -160,10 +155,7 @@ const StorageLocationPanel = ({
|
||||
</div>
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2">
|
||||
{rows.map(([label, value]) => (
|
||||
<div
|
||||
key={label}
|
||||
className="rounded-lg border border-[#2a2b2f] bg-[#16181c] p-3"
|
||||
>
|
||||
<div key={label} className="rounded-lg border border-[#2a2b2f] bg-[#16181c] p-3">
|
||||
<div className="text-gray-500">{label}</div>
|
||||
<div className="mt-1 break-all text-gray-200">{value}</div>
|
||||
</div>
|
||||
@ -177,10 +169,7 @@ export default function DataAssets() {
|
||||
const navigate = useNavigate();
|
||||
const { timeZone } = useTimeZone();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const activeTab = parseDataAssetsTab(
|
||||
searchParams.get("tab"),
|
||||
DATA_ASSET_SOURCE_TAB,
|
||||
);
|
||||
const activeTab = parseDataAssetsTab(searchParams.get("tab"), DATA_ASSET_SOURCE_TAB);
|
||||
const scope = useMemo(
|
||||
() => ({
|
||||
projectId: searchParams.get("projectId")?.trim() || "",
|
||||
@ -197,22 +186,16 @@ export default function DataAssets() {
|
||||
const [collections, setCollections] = useState<SourceCollection[]>([]);
|
||||
const [collectionsLoading, setCollectionsLoading] = useState(true);
|
||||
const [collectionsError, setCollectionsError] = useState("");
|
||||
const [selectedCollection, setSelectedCollection] =
|
||||
useState<SourceCollection | null>(null);
|
||||
const [collectionDetail, setCollectionDetail] =
|
||||
useState<SourceCollectionDetail | null>(null);
|
||||
const [selectedSourceArtifact, setSelectedSourceArtifact] =
|
||||
useState<ExecutionData | null>(null);
|
||||
const [selectedCollection, setSelectedCollection] = useState<SourceCollection | null>(null);
|
||||
const [collectionDetail, setCollectionDetail] = useState<SourceCollectionDetail | null>(null);
|
||||
const [selectedSourceArtifact, setSelectedSourceArtifact] = useState<ExecutionData | null>(null);
|
||||
|
||||
const [packages, setPackages] = useState<PackageRecord[]>([]);
|
||||
const [packagesLoading, setPackagesLoading] = useState(true);
|
||||
const [packagesError, setPackagesError] = useState("");
|
||||
const [selectedPackage, setSelectedPackage] = useState<PackageRecord | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedPackage, setSelectedPackage] = useState<PackageRecord | null>(null);
|
||||
const [packageDetail, setPackageDetail] = useState<PackageDetail | null>(null);
|
||||
const [selectedPackageArtifact, setSelectedPackageArtifact] =
|
||||
useState<ExecutionData | null>(null);
|
||||
const [selectedPackageArtifact, setSelectedPackageArtifact] = useState<ExecutionData | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
@ -232,9 +215,7 @@ export default function DataAssets() {
|
||||
}
|
||||
console.error("Failed to load source collections", error);
|
||||
setCollections([]);
|
||||
setCollectionsError(
|
||||
error instanceof Error ? error.message : "加载源数据失败",
|
||||
);
|
||||
setCollectionsError(error instanceof Error ? error.message : "加载源数据失败");
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) {
|
||||
@ -264,9 +245,7 @@ export default function DataAssets() {
|
||||
}
|
||||
console.error("Failed to load packages", error);
|
||||
setPackages([]);
|
||||
setPackagesError(
|
||||
error instanceof Error ? error.message : "加载成品数据失败",
|
||||
);
|
||||
setPackagesError(error instanceof Error ? error.message : "加载成品数据失败");
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) {
|
||||
@ -307,13 +286,7 @@ export default function DataAssets() {
|
||||
if (!query) {
|
||||
return true;
|
||||
}
|
||||
return [
|
||||
item.packageName,
|
||||
item.sourceVideo,
|
||||
item.projectName,
|
||||
item.workflowName,
|
||||
item.clipId,
|
||||
]
|
||||
return [item.packageName, item.sourceVideo, item.projectName, item.workflowName, item.clipId]
|
||||
.filter(Boolean)
|
||||
.some((value) => String(value).toLowerCase().includes(query));
|
||||
});
|
||||
@ -325,9 +298,7 @@ export default function DataAssets() {
|
||||
return;
|
||||
}
|
||||
const stillVisible = filteredCollections.find(
|
||||
(item) =>
|
||||
item.runId === selectedCollection.runId &&
|
||||
item.collectionId === selectedCollection.collectionId,
|
||||
(item) => item.runId === selectedCollection.runId && item.collectionId === selectedCollection.collectionId,
|
||||
);
|
||||
if (!stillVisible) {
|
||||
setSelectedCollection(filteredCollections[0] || null);
|
||||
@ -340,9 +311,7 @@ export default function DataAssets() {
|
||||
return;
|
||||
}
|
||||
const stillVisible = filteredPackages.find(
|
||||
(item) =>
|
||||
item.runId === selectedPackage.runId &&
|
||||
item.packageName === selectedPackage.packageName,
|
||||
(item) => item.runId === selectedPackage.runId && item.packageName === selectedPackage.packageName,
|
||||
);
|
||||
if (!stillVisible) {
|
||||
setSelectedPackage(filteredPackages[0] || null);
|
||||
@ -363,9 +332,7 @@ export default function DataAssets() {
|
||||
return;
|
||||
}
|
||||
setCollectionDetail(loaded);
|
||||
const firstFile = loaded.entries.find(
|
||||
(entry) => entry.kind !== "directory" && entry.artifact,
|
||||
);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedSourceArtifact(firstFile?.artifact || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -395,9 +362,7 @@ export default function DataAssets() {
|
||||
return;
|
||||
}
|
||||
setPackageDetail(loaded);
|
||||
setSelectedPackageArtifact(
|
||||
loaded.package.previewArtifact || loaded.files[0] || null,
|
||||
);
|
||||
setSelectedPackageArtifact(loaded.package.previewArtifact || loaded.files[0] || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (cancelled) {
|
||||
@ -415,16 +380,10 @@ export default function DataAssets() {
|
||||
const openSourcePrefix = (prefix: string) => {
|
||||
if (!selectedCollection) return;
|
||||
dataPlatformApi
|
||||
.getSourceCollectionEntries(
|
||||
selectedCollection.runId,
|
||||
selectedCollection.collectionId,
|
||||
prefix,
|
||||
)
|
||||
.getSourceCollectionEntries(selectedCollection.runId, selectedCollection.collectionId, prefix)
|
||||
.then((loaded) => {
|
||||
setCollectionDetail(loaded);
|
||||
const firstFile = loaded.entries.find(
|
||||
(entry) => entry.kind !== "directory" && entry.artifact,
|
||||
);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedSourceArtifact(firstFile?.artifact || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
@ -446,11 +405,7 @@ export default function DataAssets() {
|
||||
navigate(`/project/${projectId}`);
|
||||
};
|
||||
|
||||
const openRelatedWorkflow = (
|
||||
workflowId: string,
|
||||
projectId: string,
|
||||
runId = "",
|
||||
) => {
|
||||
const openRelatedWorkflow = (workflowId: string, projectId: string, runId = "") => {
|
||||
const params = new URLSearchParams({
|
||||
projectId,
|
||||
readOnly: "true",
|
||||
@ -465,43 +420,26 @@ export default function DataAssets() {
|
||||
navigate(`/monitoring?runId=${encodeURIComponent(runId)}`);
|
||||
};
|
||||
|
||||
const sourceBreadcrumbParts = (collectionDetail?.prefix || "")
|
||||
.split("/")
|
||||
.filter(Boolean);
|
||||
const scopeLabel =
|
||||
scope.workflowName ||
|
||||
scope.projectName ||
|
||||
scope.workflowId ||
|
||||
scope.projectId ||
|
||||
"";
|
||||
const sourceBreadcrumbParts = (collectionDetail?.prefix || "").split("/").filter(Boolean);
|
||||
const scopeLabel = scope.workflowName || scope.projectName || scope.workflowId || scope.projectId || "";
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col gap-3 xl:flex-row xl:items-end xl:justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
数据资产
|
||||
</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">数据资产</h1>
|
||||
<p className="mt-1 text-gray-500">
|
||||
用一个入口查看源数据和成品数据,并按项目、工作流、运行记录回溯真实资产链路。
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#151619] px-4 py-3">
|
||||
<div className="text-xs uppercase tracking-[0.22em] text-gray-500">
|
||||
源数据
|
||||
</div>
|
||||
<div className="mt-2 text-2xl font-semibold text-white">
|
||||
{filteredCollections.length}
|
||||
</div>
|
||||
<div className="text-xs uppercase tracking-[0.22em] text-gray-500">源数据</div>
|
||||
<div className="mt-2 text-2xl font-semibold text-white">{filteredCollections.length}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#151619] px-4 py-3">
|
||||
<div className="text-xs uppercase tracking-[0.22em] text-gray-500">
|
||||
成品数据
|
||||
</div>
|
||||
<div className="mt-2 text-2xl font-semibold text-white">
|
||||
{filteredPackages.length}
|
||||
</div>
|
||||
<div className="text-xs uppercase tracking-[0.22em] text-gray-500">成品数据</div>
|
||||
<div className="mt-2 text-2xl font-semibold text-white">{filteredPackages.length}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -509,9 +447,7 @@ export default function DataAssets() {
|
||||
{(scope.projectId || scope.workflowId || scope.runId) && (
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-blue-500/20 bg-blue-500/5 px-4 py-3">
|
||||
<div className="space-y-1">
|
||||
<div className="text-sm font-medium text-blue-300">
|
||||
当前仅显示 {scopeLabel || "指定范围"} 的数据资产
|
||||
</div>
|
||||
<div className="text-sm font-medium text-blue-300">当前仅显示 {scopeLabel || "指定范围"} 的数据资产</div>
|
||||
<div className="flex flex-wrap gap-2 text-xs text-blue-100/80">
|
||||
{scope.projectId && (
|
||||
<span className="rounded-full border border-blue-400/20 px-2.5 py-1">
|
||||
@ -524,9 +460,7 @@ export default function DataAssets() {
|
||||
</span>
|
||||
)}
|
||||
{scope.runId && (
|
||||
<span className="rounded-full border border-blue-400/20 px-2.5 py-1">
|
||||
Run {scope.runId}
|
||||
</span>
|
||||
<span className="rounded-full border border-blue-400/20 px-2.5 py-1">Run {scope.runId}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@ -568,23 +502,16 @@ export default function DataAssets() {
|
||||
)}
|
||||
>
|
||||
<tab.icon
|
||||
className={cn(
|
||||
"mt-0.5 h-4 w-4 shrink-0",
|
||||
activeTab === tab.key ? "text-blue-400" : "text-gray-500",
|
||||
)}
|
||||
className={cn("mt-0.5 h-4 w-4 shrink-0", activeTab === tab.key ? "text-blue-400" : "text-gray-500")}
|
||||
/>
|
||||
<div className="min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm font-semibold text-white">
|
||||
{tab.label}
|
||||
</span>
|
||||
<span className="text-sm font-semibold text-white">{tab.label}</span>
|
||||
<span className="rounded-full border border-[#2a2b2f] px-2 py-0.5 text-[11px] text-gray-300">
|
||||
{tab.count}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{tab.description}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">{tab.description}</div>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
@ -599,9 +526,7 @@ export default function DataAssets() {
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
placeholder={
|
||||
activeTab === DATA_ASSET_SOURCE_TAB
|
||||
? "搜索目录、元数据、工作流..."
|
||||
: "搜索数据包、来源视频、工作流..."
|
||||
activeTab === DATA_ASSET_SOURCE_TAB ? "搜索目录、元数据、工作流..." : "搜索数据包、来源视频、工作流..."
|
||||
}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] py-2 pl-10 pr-4 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
/>
|
||||
@ -649,68 +574,55 @@ export default function DataAssets() {
|
||||
onClick={() => setSelectedCollection(item)}
|
||||
className={cn(
|
||||
"w-full rounded-2xl border p-5 text-left transition",
|
||||
selectedCollection?.runId === item.runId &&
|
||||
selectedCollection?.collectionId === item.collectionId
|
||||
selectedCollection?.runId === item.runId && selectedCollection?.collectionId === item.collectionId
|
||||
? "border-blue-500 bg-blue-500/5"
|
||||
: "border-[#2a2b2f] bg-[#151619] hover:border-blue-500/30",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-base font-semibold text-white">
|
||||
{collectionLabel(item)}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-500">
|
||||
{item.relativePath || item.workflowName}
|
||||
</div>
|
||||
<div className="mt-2 inline-flex items-center gap-2 text-xs text-gray-400">
|
||||
<span className="rounded-full border border-[#2a2b2f] px-2 py-0.5 text-[10px] text-gray-300">
|
||||
{storageProviderLabel(item.storage?.provider)}
|
||||
</span>
|
||||
<span className="truncate">{storageSummary(item.storage)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-base font-semibold text-white">{collectionLabel(item)}</div>
|
||||
<div className="mt-1 text-sm text-gray-500">{item.relativePath || item.workflowName}</div>
|
||||
<div className="mt-2 inline-flex items-center gap-2 text-xs text-gray-400">
|
||||
<span className="rounded-full border border-[#2a2b2f] px-2 py-0.5 text-[10px] text-gray-300">
|
||||
{storageProviderLabel(item.storage?.provider)}
|
||||
</span>
|
||||
<span className="truncate">{storageSummary(item.storage)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
className={cn(
|
||||
"rounded-full px-2 py-1 text-xs font-medium",
|
||||
item.valid
|
||||
? "bg-green-500/10 text-green-400"
|
||||
: "bg-red-500/10 text-red-400",
|
||||
item.valid ? "bg-green-500/10 text-green-400" : "bg-red-500/10 text-red-400",
|
||||
)}
|
||||
>
|
||||
{item.valid ? "有效" : "缺文件"}
|
||||
</span>
|
||||
</div>
|
||||
<AssetLineage
|
||||
projectName={item.projectName}
|
||||
workflowName={item.workflowName}
|
||||
runId={item.runId}
|
||||
compact
|
||||
/>
|
||||
<div className="mt-4 grid grid-cols-2 gap-3 text-xs text-gray-400">
|
||||
{item.valid ? "有效" : "缺文件"}
|
||||
</span>
|
||||
</div>
|
||||
<AssetLineage
|
||||
projectName={item.projectName}
|
||||
workflowName={item.workflowName}
|
||||
runId={item.runId}
|
||||
compact
|
||||
/>
|
||||
<div className="mt-4 grid grid-cols-2 gap-3 text-xs text-gray-400">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-gray-500">视频数</div>
|
||||
<div className="mt-1 text-gray-200">{item.videoCount}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-gray-500">总大小</div>
|
||||
<div className="mt-1 text-gray-200">
|
||||
{formatBytes(item.totalBytes)}
|
||||
</div>
|
||||
<div className="mt-1 text-gray-200">{formatBytes(item.totalBytes)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 text-xs text-gray-500">
|
||||
{formatCompactDateTime(item.createdAt, timeZone)}
|
||||
</div>
|
||||
<div className="mt-4 text-xs text-gray-500">{formatCompactDateTime(item.createdAt, timeZone)}</div>
|
||||
</button>
|
||||
))}
|
||||
{!collectionsLoading &&
|
||||
!collectionsError &&
|
||||
filteredCollections.length === 0 && (
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#151619] p-6 text-sm text-gray-500">
|
||||
当前筛选条件下没有源数据。
|
||||
</div>
|
||||
)}
|
||||
{!collectionsLoading && !collectionsError && filteredCollections.length === 0 && (
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#151619] p-6 text-sm text-gray-500">
|
||||
当前筛选条件下没有源数据。
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#151619] p-6">
|
||||
@ -723,15 +635,12 @@ export default function DataAssets() {
|
||||
{collectionLabel(collectionDetail.collection)}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-500">
|
||||
{collectionDetail.collection.meta?.project_id ||
|
||||
collectionDetail.collection.relativePath}
|
||||
{collectionDetail.collection.meta?.project_id || collectionDetail.collection.relativePath}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={() =>
|
||||
openRelatedProject(collectionDetail.collection.projectId)
|
||||
}
|
||||
onClick={() => openRelatedProject(collectionDetail.collection.projectId)}
|
||||
className="rounded-md border border-[#2a2b2f] px-3 py-2 text-xs text-gray-300 hover:bg-white/5"
|
||||
>
|
||||
项目
|
||||
@ -762,8 +671,7 @@ export default function DataAssets() {
|
||||
projectId: collectionDetail.collection.projectId,
|
||||
projectName: collectionDetail.collection.projectName,
|
||||
workflowId: collectionDetail.collection.workflowId,
|
||||
workflowName:
|
||||
collectionDetail.collection.workflowName,
|
||||
workflowName: collectionDetail.collection.workflowName,
|
||||
}),
|
||||
)
|
||||
}
|
||||
@ -773,15 +681,15 @@ export default function DataAssets() {
|
||||
查看相关成品
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AssetLineage
|
||||
projectName={collectionDetail.collection.projectName}
|
||||
workflowName={collectionDetail.collection.workflowName}
|
||||
runId={collectionDetail.collection.runId}
|
||||
/>
|
||||
<AssetLineage
|
||||
projectName={collectionDetail.collection.projectName}
|
||||
workflowName={collectionDetail.collection.workflowName}
|
||||
runId={collectionDetail.collection.runId}
|
||||
/>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs">
|
||||
<div className="flex flex-wrap items-center gap-2 text-xs">
|
||||
<button
|
||||
onClick={() => openSourcePrefix("")}
|
||||
className="rounded-full border border-[#2a2b2f] px-3 py-1 text-gray-300 hover:bg-white/5"
|
||||
@ -789,9 +697,7 @@ export default function DataAssets() {
|
||||
根目录
|
||||
</button>
|
||||
{sourceBreadcrumbParts.map((part, index) => {
|
||||
const prefix = sourceBreadcrumbParts
|
||||
.slice(0, index + 1)
|
||||
.join("/");
|
||||
const prefix = sourceBreadcrumbParts.slice(0, index + 1).join("/");
|
||||
return (
|
||||
<button
|
||||
key={prefix}
|
||||
@ -806,118 +712,99 @@ export default function DataAssets() {
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114]">
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3 text-sm font-medium text-white">
|
||||
目录内容
|
||||
</div>
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3 text-sm font-medium text-white">目录内容</div>
|
||||
<div className="max-h-[520px] overflow-auto">
|
||||
{collectionDetail.entries.map((entry) => {
|
||||
const isSelected =
|
||||
entry.kind !== "directory" &&
|
||||
selectedSourceArtifact?.id === entry.artifact?.id;
|
||||
entry.kind !== "directory" && selectedSourceArtifact?.id === entry.artifact?.id;
|
||||
return (
|
||||
<button
|
||||
key={entry.path}
|
||||
onClick={() => {
|
||||
if (entry.kind === "directory") {
|
||||
openSourcePrefix(entry.path);
|
||||
return;
|
||||
}
|
||||
setSelectedSourceArtifact(entry.artifact || null);
|
||||
}}
|
||||
className={cn(
|
||||
"flex w-full items-start gap-3 border-b border-[#202227] px-4 py-3 text-left transition",
|
||||
entry.kind === "directory"
|
||||
? "hover:bg-white/5"
|
||||
: isSelected
|
||||
? "bg-blue-500/10"
|
||||
: "hover:bg-white/5",
|
||||
)}
|
||||
>
|
||||
<div className="mt-0.5 text-blue-400">
|
||||
{entry.kind === "directory" ? (
|
||||
<Folder className="h-4 w-4" />
|
||||
) : entry.kind === "video" ? (
|
||||
<FileVideo className="h-4 w-4" />
|
||||
) : (
|
||||
<FileJson className="h-4 w-4" />
|
||||
<button
|
||||
key={entry.path}
|
||||
onClick={() => {
|
||||
if (entry.kind === "directory") {
|
||||
openSourcePrefix(entry.path);
|
||||
return;
|
||||
}
|
||||
setSelectedSourceArtifact(entry.artifact || null);
|
||||
}}
|
||||
className={cn(
|
||||
"flex w-full items-start gap-3 border-b border-[#202227] px-4 py-3 text-left transition",
|
||||
entry.kind === "directory"
|
||||
? "hover:bg-white/5"
|
||||
: isSelected
|
||||
? "bg-blue-500/10"
|
||||
: "hover:bg-white/5",
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-sm text-white">
|
||||
{entry.name}
|
||||
>
|
||||
<div className="mt-0.5 text-blue-400">
|
||||
{entry.kind === "directory" ? (
|
||||
<Folder className="h-4 w-4" />
|
||||
) : entry.kind === "video" ? (
|
||||
<FileVideo className="h-4 w-4" />
|
||||
) : (
|
||||
<FileJson className="h-4 w-4" />
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{entry.kind === "directory"
|
||||
? "文件夹"
|
||||
: [
|
||||
entry.codec,
|
||||
entry.resolution,
|
||||
entry.frameRate
|
||||
? `${entry.frameRate}fps`
|
||||
: "",
|
||||
entry.duration ? `${entry.duration}s` : "",
|
||||
formatBytes(entry.sizeBytes),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-sm text-white">{entry.name}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{entry.kind === "directory"
|
||||
? "文件夹"
|
||||
: [
|
||||
entry.codec,
|
||||
entry.resolution,
|
||||
entry.frameRate ? `${entry.frameRate}fps` : "",
|
||||
entry.duration ? `${entry.duration}s` : "",
|
||||
formatBytes(entry.sizeBytes),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
)})}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2 xl:grid-cols-4">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">文件数</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{collectionDetail.collection.fileCount}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">视频数</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{collectionDetail.collection.videoCount}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">总大小</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{formatBytes(collectionDetail.collection.totalBytes)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2 xl:grid-cols-4">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">文件数</div>
|
||||
<div className="mt-2 text-gray-100">{collectionDetail.collection.fileCount}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">视频数</div>
|
||||
<div className="mt-2 text-gray-100">{collectionDetail.collection.videoCount}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">总大小</div>
|
||||
<div className="mt-2 text-gray-100">{formatBytes(collectionDetail.collection.totalBytes)}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">来源工作流</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{collectionDetail.collection.workflowName}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-2 text-gray-100">{collectionDetail.collection.workflowName}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<StorageLocationPanel
|
||||
<StorageLocationPanel
|
||||
title="源数据存储位置"
|
||||
storage={collectionDetail.collection.storage}
|
||||
pathLabel="当前采集目录"
|
||||
/>
|
||||
|
||||
{collectionDetail.collection.meta &&
|
||||
Object.keys(collectionDetail.collection.meta).length > 0 && (
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="mb-3 text-sm font-medium text-white">
|
||||
meta.json 元数据
|
||||
</div>
|
||||
<pre className="max-h-56 overflow-auto whitespace-pre-wrap break-all text-xs leading-6 text-gray-300">
|
||||
{JSON.stringify(collectionDetail.collection.meta, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="mb-3 text-sm font-medium text-white">
|
||||
文件预览
|
||||
{collectionDetail.collection.meta && Object.keys(collectionDetail.collection.meta).length > 0 && (
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="mb-3 text-sm font-medium text-white">meta.json 元数据</div>
|
||||
<pre className="max-h-56 overflow-auto whitespace-pre-wrap break-all text-xs leading-6 text-gray-300">
|
||||
{JSON.stringify(collectionDetail.collection.meta, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="mb-3 text-sm font-medium text-white">文件预览</div>
|
||||
<ArtifactPreviewPanel item={selectedSourceArtifact} />
|
||||
</div>
|
||||
</div>
|
||||
@ -950,20 +837,15 @@ export default function DataAssets() {
|
||||
onClick={() => setSelectedPackage(item)}
|
||||
className={cn(
|
||||
"w-full rounded-2xl border p-5 text-left transition",
|
||||
selectedPackage?.runId === item.runId &&
|
||||
selectedPackage?.packageName === item.packageName
|
||||
selectedPackage?.runId === item.runId && selectedPackage?.packageName === item.packageName
|
||||
? "border-blue-500 bg-blue-500/5"
|
||||
: "border-[#2a2b2f] bg-[#151619] hover:border-blue-500/30",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-base font-semibold text-white">
|
||||
{item.packageName}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-500">
|
||||
{item.sourceVideo}
|
||||
</div>
|
||||
<div className="text-base font-semibold text-white">{item.packageName}</div>
|
||||
<div className="mt-1 text-sm text-gray-500">{item.sourceVideo}</div>
|
||||
<div className="mt-2 inline-flex items-center gap-2 text-xs text-gray-400">
|
||||
<span className="rounded-full border border-[#2a2b2f] px-2 py-0.5 text-[10px] text-gray-300">
|
||||
{storageProviderLabel(item.storage?.provider)}
|
||||
@ -975,26 +857,24 @@ export default function DataAssets() {
|
||||
{item.fileCount} 文件
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
{item.pipelineTags.map((tag) => (
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
{item.pipelineTags.map((tag) => (
|
||||
<span
|
||||
key={tag}
|
||||
className="inline-flex items-center gap-1 rounded-full border border-[#2a2b2f] px-2.5 py-1 text-xs text-gray-300"
|
||||
>
|
||||
<Boxes className="h-3 w-3 text-gray-500" />
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<AssetLineage
|
||||
projectName={item.projectName}
|
||||
workflowName={item.workflowName}
|
||||
runId={item.runId}
|
||||
compact
|
||||
/>
|
||||
<div className="mt-4 text-xs text-gray-500">
|
||||
{formatCompactDateTime(item.createdAt, timeZone)}
|
||||
</div>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<AssetLineage
|
||||
projectName={item.projectName}
|
||||
workflowName={item.workflowName}
|
||||
runId={item.runId}
|
||||
compact
|
||||
/>
|
||||
<div className="mt-4 text-xs text-gray-500">{formatCompactDateTime(item.createdAt, timeZone)}</div>
|
||||
</button>
|
||||
))}
|
||||
{!packagesLoading && !packagesError && filteredPackages.length === 0 && (
|
||||
@ -1010,18 +890,12 @@ export default function DataAssets() {
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-lg font-semibold text-white">
|
||||
{packageDetail.package.packageName}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-500">
|
||||
{storageSummary(packageDetail.package.storage)}
|
||||
</div>
|
||||
<div className="text-lg font-semibold text-white">{packageDetail.package.packageName}</div>
|
||||
<div className="mt-1 text-sm text-gray-500">{storageSummary(packageDetail.package.storage)}</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={() =>
|
||||
openRelatedProject(packageDetail.package.projectId)
|
||||
}
|
||||
onClick={() => openRelatedProject(packageDetail.package.projectId)}
|
||||
className="rounded-md border border-[#2a2b2f] px-3 py-2 text-xs text-gray-300 hover:bg-white/5"
|
||||
>
|
||||
项目
|
||||
@ -1061,27 +935,23 @@ export default function DataAssets() {
|
||||
<ArrowRightLeft className="h-3.5 w-3.5" />
|
||||
查看相关源数据
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AssetLineage
|
||||
projectName={packageDetail.package.projectName}
|
||||
workflowName={packageDetail.package.workflowName}
|
||||
runId={packageDetail.package.runId}
|
||||
/>
|
||||
<AssetLineage
|
||||
projectName={packageDetail.package.projectName}
|
||||
workflowName={packageDetail.package.workflowName}
|
||||
runId={packageDetail.package.runId}
|
||||
/>
|
||||
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2">
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">来源视频</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{packageDetail.package.sourceVideo}
|
||||
</div>
|
||||
<div className="mt-2 text-gray-100">{packageDetail.package.sourceVideo}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">片段时长</div>
|
||||
<div className="mt-2 text-gray-100">
|
||||
{packageDetail.package.clipDuration || 0}s
|
||||
</div>
|
||||
<div className="mt-2 text-gray-100">{packageDetail.package.clipDuration || 0}s</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1092,39 +962,36 @@ export default function DataAssets() {
|
||||
/>
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114]">
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3 text-sm font-medium text-white">
|
||||
数据包文件
|
||||
</div>
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3 text-sm font-medium text-white">数据包文件</div>
|
||||
<div className="max-h-[520px] overflow-auto">
|
||||
{packageDetail.files.map((file) => {
|
||||
const isSelected = selectedPackageArtifact?.id === file.id;
|
||||
return (
|
||||
<button
|
||||
key={`${file.path}:${file.name}`}
|
||||
onClick={() => setSelectedPackageArtifact(file)}
|
||||
className={cn(
|
||||
"flex w-full items-center justify-between border-b border-[#202227] px-4 py-3 text-left transition",
|
||||
isSelected ? "bg-blue-500/10" : "hover:bg-white/5",
|
||||
)}
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm text-white">
|
||||
{file.path}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{file.size} · {file.metadata?.mimeType || file.type}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{previewURLFromArtifact(file) && (
|
||||
<span className="rounded-full border border-blue-500/20 bg-blue-500/10 px-2 py-0.5 text-[10px] text-blue-300">
|
||||
可预览
|
||||
</span>
|
||||
<button
|
||||
key={`${file.path}:${file.name}`}
|
||||
onClick={() => setSelectedPackageArtifact(file)}
|
||||
className={cn(
|
||||
"flex w-full items-center justify-between border-b border-[#202227] px-4 py-3 text-left transition",
|
||||
isSelected ? "bg-blue-500/10" : "hover:bg-white/5",
|
||||
)}
|
||||
<ExternalLink className="h-4 w-4 text-gray-500" />
|
||||
</div>
|
||||
</button>
|
||||
)})}
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm text-white">{file.path}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{file.size} · {file.metadata?.mimeType || file.type}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{previewURLFromArtifact(file) && (
|
||||
<span className="rounded-full border border-blue-500/20 bg-blue-500/10 px-2 py-0.5 text-[10px] text-blue-300">
|
||||
可预览
|
||||
</span>
|
||||
)}
|
||||
<ExternalLink className="h-4 w-4 text-gray-500" />
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1140,18 +1007,12 @@ export default function DataAssets() {
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">标注结果</div>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-gray-100">
|
||||
{JSON.stringify(
|
||||
packageDetail.package.annotation || {},
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
{JSON.stringify(packageDetail.package.annotation || {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="mb-3 text-sm font-medium text-white">
|
||||
文件预览
|
||||
</div>
|
||||
<div className="mb-3 text-sm font-medium text-white">文件预览</div>
|
||||
<ArtifactPreviewPanel item={selectedPackageArtifact} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -29,10 +29,7 @@ import type {
|
||||
MongoConnection,
|
||||
} from "../types";
|
||||
import { databaseApi } from "../services/api/database";
|
||||
import {
|
||||
externalBusinessWriteApi,
|
||||
scopeForConnection,
|
||||
} from "../services/api/external-business-db";
|
||||
import { externalBusinessWriteApi, scopeForConnection } from "../services/api/external-business-db";
|
||||
import { mongoConnectionsApi } from "../services/api/mongo-connections";
|
||||
|
||||
const DEFAULT_FILTER = "{}";
|
||||
@ -49,11 +46,7 @@ function renderCellValue(value: unknown) {
|
||||
if (value === null || value === undefined) {
|
||||
return "-";
|
||||
}
|
||||
if (
|
||||
typeof value === "string" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "boolean"
|
||||
) {
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
return String(value);
|
||||
}
|
||||
return safeJSONStringify(value);
|
||||
@ -104,8 +97,7 @@ export default function DatabaseBrowser() {
|
||||
const [overviewLoading, setOverviewLoading] = useState(false);
|
||||
const [overviewError, setOverviewError] = useState("");
|
||||
const [collectionSearch, setCollectionSearch] = useState("");
|
||||
const [selectedCollection, setSelectedCollection] =
|
||||
useState<DatabaseCollectionSummary | null>(null);
|
||||
const [selectedCollection, setSelectedCollection] = useState<DatabaseCollectionSummary | null>(null);
|
||||
const [queryResult, setQueryResult] = useState<DatabaseQueryResult | null>(null);
|
||||
const [queryLoading, setQueryLoading] = useState(false);
|
||||
const [queryError, setQueryError] = useState("");
|
||||
@ -128,9 +120,7 @@ export default function DatabaseBrowser() {
|
||||
const [documentActionError, setDocumentActionError] = useState("");
|
||||
const [documentActionLoading, setDocumentActionLoading] = useState(false);
|
||||
const [isNewDocumentMode, setIsNewDocumentMode] = useState(false);
|
||||
const [externalTokens, setExternalTokens] = useState<ExternalBusinessWriteToken[]>(
|
||||
[],
|
||||
);
|
||||
const [externalTokens, setExternalTokens] = useState<ExternalBusinessWriteToken[]>([]);
|
||||
const [externalTokensLoading, setExternalTokensLoading] = useState(false);
|
||||
const [externalTokensError, setExternalTokensError] = useState("");
|
||||
const [selectedTokenId, setSelectedTokenId] = useState("");
|
||||
@ -155,10 +145,7 @@ export default function DatabaseBrowser() {
|
||||
const items = await mongoConnectionsApi.list();
|
||||
setConnections(items);
|
||||
setSelectedConnectionId((current) => {
|
||||
if (
|
||||
preferredConnectionId &&
|
||||
items.some((item) => item.id === preferredConnectionId)
|
||||
) {
|
||||
if (preferredConnectionId && items.some((item) => item.id === preferredConnectionId)) {
|
||||
return preferredConnectionId;
|
||||
}
|
||||
if (current && items.some((item) => item.id === current)) {
|
||||
@ -170,9 +157,7 @@ export default function DatabaseBrowser() {
|
||||
console.error("Failed to load mongo connections", error);
|
||||
setConnections([]);
|
||||
setSelectedConnectionId("");
|
||||
setConnectionsError(
|
||||
error instanceof Error ? error.message : "加载业务 MongoDB 连接失败",
|
||||
);
|
||||
setConnectionsError(error instanceof Error ? error.message : "加载业务 MongoDB 连接失败");
|
||||
} finally {
|
||||
setConnectionsLoading(false);
|
||||
}
|
||||
@ -197,9 +182,7 @@ export default function DatabaseBrowser() {
|
||||
console.error("Failed to load external business write tokens", error);
|
||||
setExternalTokens([]);
|
||||
setSelectedTokenId("");
|
||||
setExternalTokensError(
|
||||
error instanceof Error ? error.message : "加载第三方写入 Token 失败",
|
||||
);
|
||||
setExternalTokensError(error instanceof Error ? error.message : "加载第三方写入 Token 失败");
|
||||
} finally {
|
||||
setExternalTokensLoading(false);
|
||||
}
|
||||
@ -225,9 +208,7 @@ export default function DatabaseBrowser() {
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Failed to reveal external business write token", error);
|
||||
setTokenActionError(
|
||||
error instanceof Error ? error.message : "查看完整 Token 失败",
|
||||
);
|
||||
setTokenActionError(error instanceof Error ? error.message : "查看完整 Token 失败");
|
||||
} finally {
|
||||
setRevealingTokenId("");
|
||||
}
|
||||
@ -258,11 +239,7 @@ export default function DatabaseBrowser() {
|
||||
setOverview(item);
|
||||
setSelectedCollection((current) => {
|
||||
if (current && item.collections.some((entry) => entry.name === current.name)) {
|
||||
return (
|
||||
item.collections.find((entry) => entry.name === current.name) ||
|
||||
item.collections[0] ||
|
||||
null
|
||||
);
|
||||
return item.collections.find((entry) => entry.name === current.name) || item.collections[0] || null;
|
||||
}
|
||||
return item.collections[0] || null;
|
||||
});
|
||||
@ -274,9 +251,7 @@ export default function DatabaseBrowser() {
|
||||
console.error("Failed to load database overview", error);
|
||||
setOverview(null);
|
||||
setSelectedCollection(null);
|
||||
setOverviewError(
|
||||
error instanceof Error ? error.message : "加载数据库概览失败",
|
||||
);
|
||||
setOverviewError(error instanceof Error ? error.message : "加载数据库概览失败");
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) {
|
||||
@ -354,9 +329,7 @@ export default function DatabaseBrowser() {
|
||||
}
|
||||
console.error("Failed to load indexes", error);
|
||||
setIndexes([]);
|
||||
setIndexesError(
|
||||
error instanceof Error ? error.message : "加载索引失败",
|
||||
);
|
||||
setIndexesError(error instanceof Error ? error.message : "加载索引失败");
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) {
|
||||
@ -368,27 +341,18 @@ export default function DatabaseBrowser() {
|
||||
};
|
||||
}, [selectedCollection?.name, selectedConnectionId]);
|
||||
|
||||
const selectedConnection = connections.find(
|
||||
(item) => item.id === selectedConnectionId,
|
||||
);
|
||||
const selectedToken =
|
||||
externalTokens.find((item) => item.id === selectedTokenId) || null;
|
||||
const selectedConnection = connections.find((item) => item.id === selectedConnectionId);
|
||||
const selectedToken = externalTokens.find((item) => item.id === selectedTokenId) || null;
|
||||
const scopedTokens = useMemo(() => {
|
||||
if (!selectedConnectionId) {
|
||||
return [];
|
||||
}
|
||||
return externalTokens.filter((item) =>
|
||||
item.scopes.some((scope) => scope.connectionId === selectedConnectionId),
|
||||
);
|
||||
return externalTokens.filter((item) => item.scopes.some((scope) => scope.connectionId === selectedConnectionId));
|
||||
}, [externalTokens, selectedConnectionId]);
|
||||
|
||||
const selectedDocument =
|
||||
queryResult?.documents?.[
|
||||
Math.min(
|
||||
selectedDocumentIndex,
|
||||
Math.max((queryResult?.documents?.length || 1) - 1, 0),
|
||||
)
|
||||
] || null;
|
||||
queryResult?.documents?.[Math.min(selectedDocumentIndex, Math.max((queryResult?.documents?.length || 1) - 1, 0))] ||
|
||||
null;
|
||||
|
||||
useEffect(() => {
|
||||
setRenameCollectionName(selectedCollection?.name || "");
|
||||
@ -448,9 +412,7 @@ export default function DatabaseBrowser() {
|
||||
}, [externalTokens, selectedConnectionId]);
|
||||
|
||||
const resultColumns = (
|
||||
queryResult?.sampleFields?.length
|
||||
? queryResult.sampleFields
|
||||
: selectedCollection?.sampleFields || []
|
||||
queryResult?.sampleFields?.length ? queryResult.sampleFields : selectedCollection?.sampleFields || []
|
||||
).slice(0, 6);
|
||||
|
||||
const reloadOverview = async (preferredCollectionName = "") => {
|
||||
@ -466,9 +428,7 @@ export default function DatabaseBrowser() {
|
||||
setOverview(item);
|
||||
setSelectedCollection((current) => {
|
||||
const preferred =
|
||||
(preferredCollectionName &&
|
||||
item.collections.find((entry) => entry.name === preferredCollectionName)) ||
|
||||
null;
|
||||
(preferredCollectionName && item.collections.find((entry) => entry.name === preferredCollectionName)) || null;
|
||||
if (preferred) {
|
||||
return preferred;
|
||||
}
|
||||
@ -482,9 +442,7 @@ export default function DatabaseBrowser() {
|
||||
console.error("Failed to reload database overview", error);
|
||||
setOverview(null);
|
||||
setSelectedCollection(null);
|
||||
setOverviewError(
|
||||
error instanceof Error ? error.message : "加载数据库概览失败",
|
||||
);
|
||||
setOverviewError(error instanceof Error ? error.message : "加载数据库概览失败");
|
||||
return null;
|
||||
} finally {
|
||||
setOverviewLoading(false);
|
||||
@ -515,9 +473,7 @@ export default function DatabaseBrowser() {
|
||||
await loadConnections(created.id);
|
||||
} catch (error) {
|
||||
console.error("Failed to create mongo connection", error);
|
||||
setConnectionsError(
|
||||
error instanceof Error ? error.message : "创建业务 MongoDB 连接失败",
|
||||
);
|
||||
setConnectionsError(error instanceof Error ? error.message : "创建业务 MongoDB 连接失败");
|
||||
} finally {
|
||||
setIsSavingConnection(false);
|
||||
}
|
||||
@ -535,14 +491,10 @@ export default function DatabaseBrowser() {
|
||||
setConnectionActionMessage("");
|
||||
try {
|
||||
const result = await mongoConnectionsApi.test({ uri, database });
|
||||
setConnectionActionMessage(
|
||||
`连接成功,数据库 ${result.database},发现 ${result.collections.length} 个集合。`,
|
||||
);
|
||||
setConnectionActionMessage(`连接成功,数据库 ${result.database},发现 ${result.collections.length} 个集合。`);
|
||||
} catch (error) {
|
||||
console.error("Failed to test draft mongo connection", error);
|
||||
setConnectionActionError(
|
||||
error instanceof Error ? error.message : "测试连接失败",
|
||||
);
|
||||
setConnectionActionError(error instanceof Error ? error.message : "测试连接失败");
|
||||
} finally {
|
||||
setConnectionActionLoading(false);
|
||||
}
|
||||
@ -558,15 +510,11 @@ export default function DatabaseBrowser() {
|
||||
setConnectionActionMessage("");
|
||||
try {
|
||||
const result = await mongoConnectionsApi.test({ id: selectedConnectionId });
|
||||
setConnectionActionMessage(
|
||||
`连接成功,数据库 ${result.database},发现 ${result.collections.length} 个集合。`,
|
||||
);
|
||||
setConnectionActionMessage(`连接成功,数据库 ${result.database},发现 ${result.collections.length} 个集合。`);
|
||||
await reloadOverview(selectedCollection?.name || "");
|
||||
} catch (error) {
|
||||
console.error("Failed to test selected mongo connection", error);
|
||||
setConnectionActionError(
|
||||
error instanceof Error ? error.message : "测试连接失败",
|
||||
);
|
||||
setConnectionActionError(error instanceof Error ? error.message : "测试连接失败");
|
||||
} finally {
|
||||
setConnectionActionLoading(false);
|
||||
}
|
||||
@ -593,9 +541,7 @@ export default function DatabaseBrowser() {
|
||||
setConnectionActionMessage("连接已删除。");
|
||||
} catch (error) {
|
||||
console.error("Failed to delete mongo connection", error);
|
||||
setConnectionActionError(
|
||||
error instanceof Error ? error.message : "删除连接失败",
|
||||
);
|
||||
setConnectionActionError(error instanceof Error ? error.message : "删除连接失败");
|
||||
} finally {
|
||||
setConnectionActionLoading(false);
|
||||
}
|
||||
@ -669,9 +615,7 @@ export default function DatabaseBrowser() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to save external business write token", error);
|
||||
setTokenActionError(
|
||||
error instanceof Error ? error.message : "保存第三方写入 Token 失败",
|
||||
);
|
||||
setTokenActionError(error instanceof Error ? error.message : "保存第三方写入 Token 失败");
|
||||
} finally {
|
||||
setTokenActionLoading(false);
|
||||
}
|
||||
@ -690,9 +634,7 @@ export default function DatabaseBrowser() {
|
||||
await loadExternalTokens(result.token.id);
|
||||
} catch (error) {
|
||||
console.error("Failed to rotate external business write token", error);
|
||||
setTokenActionError(
|
||||
error instanceof Error ? error.message : "轮换 API Key 失败",
|
||||
);
|
||||
setTokenActionError(error instanceof Error ? error.message : "轮换 API Key 失败");
|
||||
} finally {
|
||||
setTokenActionLoading(false);
|
||||
}
|
||||
@ -716,9 +658,7 @@ export default function DatabaseBrowser() {
|
||||
await loadExternalTokens();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete external business write token", error);
|
||||
setTokenActionError(
|
||||
error instanceof Error ? error.message : "删除第三方写入 Token 失败",
|
||||
);
|
||||
setTokenActionError(error instanceof Error ? error.message : "删除第三方写入 Token 失败");
|
||||
} finally {
|
||||
setTokenActionLoading(false);
|
||||
}
|
||||
@ -757,9 +697,7 @@ export default function DatabaseBrowser() {
|
||||
await reloadOverview(result.collection);
|
||||
} catch (error) {
|
||||
console.error("Failed to create collection", error);
|
||||
setCollectionActionError(
|
||||
error instanceof Error ? error.message : "创建集合失败",
|
||||
);
|
||||
setCollectionActionError(error instanceof Error ? error.message : "创建集合失败");
|
||||
} finally {
|
||||
setCollectionActionLoading(false);
|
||||
}
|
||||
@ -784,9 +722,7 @@ export default function DatabaseBrowser() {
|
||||
await reloadOverview(result.collection);
|
||||
} catch (error) {
|
||||
console.error("Failed to rename collection", error);
|
||||
setCollectionActionError(
|
||||
error instanceof Error ? error.message : "重命名集合失败",
|
||||
);
|
||||
setCollectionActionError(error instanceof Error ? error.message : "重命名集合失败");
|
||||
} finally {
|
||||
setCollectionActionLoading(false);
|
||||
}
|
||||
@ -813,9 +749,7 @@ export default function DatabaseBrowser() {
|
||||
await reloadOverview();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete collection", error);
|
||||
setCollectionActionError(
|
||||
error instanceof Error ? error.message : "删除集合失败",
|
||||
);
|
||||
setCollectionActionError(error instanceof Error ? error.message : "删除集合失败");
|
||||
} finally {
|
||||
setCollectionActionLoading(false);
|
||||
}
|
||||
@ -839,21 +773,16 @@ export default function DatabaseBrowser() {
|
||||
const currentDocumentId = documentIdValue(selectedDocument);
|
||||
const result =
|
||||
!isNewDocumentMode && currentDocumentId
|
||||
? await databaseApi.replaceDocument(
|
||||
selectedCollection.name,
|
||||
currentDocumentId,
|
||||
document,
|
||||
{ connectionId: selectedConnectionId },
|
||||
)
|
||||
? await databaseApi.replaceDocument(selectedCollection.name, currentDocumentId, document, {
|
||||
connectionId: selectedConnectionId,
|
||||
})
|
||||
: await databaseApi.createDocument(selectedCollection.name, document, {
|
||||
connectionId: selectedConnectionId,
|
||||
});
|
||||
const refreshed = await queryCollection(selectedCollection);
|
||||
const nextDocumentId = documentIdValue(result.document);
|
||||
if (refreshed && nextDocumentId) {
|
||||
const nextIndex = refreshed.documents.findIndex(
|
||||
(item) => documentIdValue(item) === nextDocumentId,
|
||||
);
|
||||
const nextIndex = refreshed.documents.findIndex((item) => documentIdValue(item) === nextDocumentId);
|
||||
setSelectedDocumentIndex(nextIndex >= 0 ? nextIndex : 0);
|
||||
} else {
|
||||
setSelectedDocumentIndex(0);
|
||||
@ -862,9 +791,7 @@ export default function DatabaseBrowser() {
|
||||
setDocumentEditorText(safeJSONStringify(result.document));
|
||||
} catch (error) {
|
||||
console.error("Failed to save document", error);
|
||||
setDocumentActionError(
|
||||
error instanceof Error ? error.message : "保存记录失败",
|
||||
);
|
||||
setDocumentActionError(error instanceof Error ? error.message : "保存记录失败");
|
||||
} finally {
|
||||
setDocumentActionLoading(false);
|
||||
}
|
||||
@ -964,9 +891,7 @@ export default function DatabaseBrowser() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to delete document", error);
|
||||
setDocumentActionError(
|
||||
error instanceof Error ? error.message : "删除记录失败",
|
||||
);
|
||||
setDocumentActionError(error instanceof Error ? error.message : "删除记录失败");
|
||||
} finally {
|
||||
setDocumentActionLoading(false);
|
||||
}
|
||||
@ -976,12 +901,8 @@ export default function DatabaseBrowser() {
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
业务数据库
|
||||
</h1>
|
||||
<p className="mt-1 text-gray-500">
|
||||
管理用户自定义的业务 MongoDB 连接,并维护其集合、索引和记录。
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">业务数据库</h1>
|
||||
<p className="mt-1 text-gray-500">管理用户自定义的业务 MongoDB 连接,并维护其集合、索引和记录。</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
@ -1006,9 +927,7 @@ export default function DatabaseBrowser() {
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-sm font-medium text-white">MongoDB 连接</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
业务库与平台系统库分离;这里只管理工作流可写入的业务连接。
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">业务库与平台系统库分离;这里只管理工作流可写入的业务连接。</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
@ -1024,18 +943,14 @@ export default function DatabaseBrowser() {
|
||||
|
||||
<div className="mt-4 grid gap-4 md:grid-cols-[minmax(0,1fr)_200px]">
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
当前连接
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">当前连接</label>
|
||||
<select
|
||||
value={selectedConnectionId}
|
||||
onChange={(event) => setSelectedConnectionId(event.target.value)}
|
||||
disabled={connectionsLoading}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-sm text-white outline-none transition-colors focus:border-blue-500 disabled:opacity-60"
|
||||
>
|
||||
<option value="">
|
||||
{connectionsLoading ? "加载中..." : "请选择业务 MongoDB 连接"}
|
||||
</option>
|
||||
<option value="">{connectionsLoading ? "加载中..." : "请选择业务 MongoDB 连接"}</option>
|
||||
{connections.map((connection) => (
|
||||
<option key={connection.id} value={connection.id}>
|
||||
{connection.name}
|
||||
@ -1094,9 +1009,7 @@ export default function DatabaseBrowser() {
|
||||
{isConnectionFormOpen ? (
|
||||
<div className="mt-4 grid gap-3 rounded-xl border border-[#2a2b2f] bg-[#101114] p-4 md:grid-cols-2">
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
连接名称
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">连接名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={connectionDraft.name}
|
||||
@ -1110,9 +1023,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
数据库名
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">数据库名</label>
|
||||
<input
|
||||
type="text"
|
||||
value={connectionDraft.database}
|
||||
@ -1126,9 +1037,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1 md:col-span-2">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
Mongo URI
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">Mongo URI</label>
|
||||
<input
|
||||
type="password"
|
||||
value={connectionDraft.uri}
|
||||
@ -1142,9 +1051,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1 md:col-span-2">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
描述
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">描述</label>
|
||||
<input
|
||||
type="text"
|
||||
value={connectionDraft.description}
|
||||
@ -1238,11 +1145,7 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-0.5 shrink-0 rounded-md border border-[#2a2b2f] bg-[#101114] p-2 text-gray-300">
|
||||
{isExternalWritePanelOpen ? (
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
) : (
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
)}
|
||||
{isExternalWritePanelOpen ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
@ -1257,17 +1160,13 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
<div className="mt-2 text-xs leading-6 text-gray-500">
|
||||
这里直接配置当前业务库对外开放的写入 Token。每个 Token 只允许写入白名单集合,调用时使用
|
||||
<code className="mx-1 rounded bg-[#0a0a0a] px-1.5 py-0.5 text-[11px] text-blue-200">
|
||||
X-API-Key
|
||||
</code>
|
||||
<code className="mx-1 rounded bg-[#0a0a0a] px-1.5 py-0.5 text-[11px] text-blue-200">X-API-Key</code>
|
||||
请求头。
|
||||
</div>
|
||||
<div className="mt-4 grid gap-3">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs text-gray-500">当前连接</div>
|
||||
<div className="mt-1 text-sm text-gray-100">
|
||||
{selectedConnection?.name || "--"}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-100">{selectedConnection?.name || "--"}</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs text-gray-500">connectionId</div>
|
||||
@ -1294,9 +1193,7 @@ export default function DatabaseBrowser() {
|
||||
<KeyRound className="h-4 w-4 text-blue-400" />
|
||||
Token 配置
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
当前表单只编辑当前业务库的 collection 白名单。
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">当前表单只编辑当前业务库的 collection 白名单。</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@ -1310,9 +1207,7 @@ export default function DatabaseBrowser() {
|
||||
|
||||
<div className="mt-4 space-y-3">
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
Token 名称
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">Token 名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={tokenDraft.name}
|
||||
@ -1327,9 +1222,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
描述
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">描述</label>
|
||||
<input
|
||||
type="text"
|
||||
value={tokenDraft.description}
|
||||
@ -1359,9 +1252,7 @@ export default function DatabaseBrowser() {
|
||||
placeholder={"orders\ncustomers"}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 font-mono text-xs text-white outline-none transition-colors focus:border-blue-500"
|
||||
/>
|
||||
<div className="text-[11px] text-gray-500">
|
||||
每行一个集合,或使用英文逗号分隔。
|
||||
</div>
|
||||
<div className="text-[11px] text-gray-500">每行一个集合,或使用英文逗号分隔。</div>
|
||||
</div>
|
||||
<label className="flex items-center gap-2 text-sm text-gray-200">
|
||||
<input
|
||||
@ -1423,12 +1314,8 @@ export default function DatabaseBrowser() {
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-sm font-medium text-white">
|
||||
当前业务库 Token 列表
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
这里只显示对当前 connection 生效的 Token。
|
||||
</div>
|
||||
<div className="text-sm font-medium text-white">当前业务库 Token 列表</div>
|
||||
<div className="mt-1 text-xs text-gray-500">这里只显示对当前 connection 生效的 Token。</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@ -1469,9 +1356,7 @@ export default function DatabaseBrowser() {
|
||||
key={token.id}
|
||||
className={cn(
|
||||
"rounded-xl border p-4 transition-colors",
|
||||
isSelected
|
||||
? "border-blue-500 bg-blue-500/10"
|
||||
: "border-[#2a2b2f] bg-[#101114]",
|
||||
isSelected ? "border-blue-500 bg-blue-500/10" : "border-[#2a2b2f] bg-[#101114]",
|
||||
)}
|
||||
>
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
@ -1496,15 +1381,11 @@ export default function DatabaseBrowser() {
|
||||
</span>
|
||||
</div>
|
||||
{token.description ? (
|
||||
<div className="mt-1 text-sm text-gray-400">
|
||||
{token.description}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-400">{token.description}</div>
|
||||
) : null}
|
||||
<div className="mt-3 grid gap-2 md:grid-cols-2">
|
||||
<div>
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">
|
||||
Token 预览
|
||||
</div>
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">Token 预览</div>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<div className="font-mono text-xs text-gray-200">
|
||||
{revealedTokenValues[token.id] || token.tokenPreview || "--"}
|
||||
@ -1527,18 +1408,14 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">
|
||||
最近使用
|
||||
</div>
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">最近使用</div>
|
||||
<div className="mt-1 text-xs text-gray-200">
|
||||
{formatCompactDateTime(token.lastUsedAt, "Asia/Shanghai", "未使用")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-3">
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">
|
||||
当前业务库白名单
|
||||
</div>
|
||||
<div className="text-[11px] uppercase tracking-wider text-gray-500">当前业务库白名单</div>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{(scope?.collections || []).map((collection) => (
|
||||
<span
|
||||
@ -1612,9 +1489,7 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs text-gray-500">访问模式</div>
|
||||
<div className="mt-1 text-sm text-gray-100">
|
||||
{overview?.readOnly ? "只读" : "可写"}
|
||||
</div>
|
||||
<div className="mt-1 text-sm text-gray-100">{overview?.readOnly ? "只读" : "可写"}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="relative mt-4">
|
||||
@ -1628,9 +1503,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4 space-y-3 rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
集合操作
|
||||
</div>
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">集合操作</div>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
@ -1694,10 +1567,7 @@ export default function DatabaseBrowser() {
|
||||
正在加载集合...
|
||||
</div>
|
||||
) : null}
|
||||
{!connectionsLoading &&
|
||||
!overviewLoading &&
|
||||
selectedConnectionId &&
|
||||
filteredCollections.length === 0 ? (
|
||||
{!connectionsLoading && !overviewLoading && selectedConnectionId && filteredCollections.length === 0 ? (
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] px-4 py-3 text-sm text-gray-400">
|
||||
没有匹配的集合。
|
||||
</div>
|
||||
@ -1716,12 +1586,8 @@ export default function DatabaseBrowser() {
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-medium text-white">
|
||||
{collection.name}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{collection.documentCount} 条记录
|
||||
</div>
|
||||
<div className="truncate text-sm font-medium text-white">{collection.name}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">{collection.documentCount} 条记录</div>
|
||||
</div>
|
||||
<FileJson className="h-4 w-4 shrink-0 text-gray-500" />
|
||||
</div>
|
||||
@ -1747,9 +1613,7 @@ export default function DatabaseBrowser() {
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-sm font-medium text-white">
|
||||
{selectedCollection
|
||||
? `${selectedCollection.name} 查询`
|
||||
: "选择集合"}
|
||||
{selectedCollection ? `${selectedCollection.name} 查询` : "选择集合"}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
使用 Mongo JSON 过滤条件查看记录,敏感字段只做掩码展示。
|
||||
@ -1774,9 +1638,7 @@ export default function DatabaseBrowser() {
|
||||
|
||||
<div className="mt-4 grid gap-3 md:grid-cols-[minmax(0,1fr)_120px_120px]">
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
Filter
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">Filter</label>
|
||||
<textarea
|
||||
value={filterText}
|
||||
onChange={(event) => setFilterText(event.target.value)}
|
||||
@ -1785,9 +1647,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
Limit
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">Limit</label>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
@ -1798,9 +1658,7 @@ export default function DatabaseBrowser() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
Skip
|
||||
</label>
|
||||
<label className="text-xs font-medium uppercase tracking-wider text-gray-400">Skip</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
@ -1824,9 +1682,7 @@ export default function DatabaseBrowser() {
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-sm font-medium text-white">索引管理</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
为当前业务集合创建或删除 MongoDB 索引。
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">为当前业务集合创建或删除 MongoDB 索引。</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
@ -1842,9 +1698,7 @@ export default function DatabaseBrowser() {
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to refresh indexes", error);
|
||||
setIndexesError(
|
||||
error instanceof Error ? error.message : "刷新索引失败",
|
||||
);
|
||||
setIndexesError(error instanceof Error ? error.message : "刷新索引失败");
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
@ -1867,9 +1721,7 @@ export default function DatabaseBrowser() {
|
||||
|
||||
<div className="mt-4 grid gap-4 xl:grid-cols-[minmax(0,1fr)_320px]">
|
||||
<div className="space-y-3 rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
当前索引
|
||||
</div>
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">当前索引</div>
|
||||
{!selectedCollection ? (
|
||||
<div className="rounded-lg border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-sm text-gray-500">
|
||||
请先选择集合。
|
||||
@ -1881,18 +1733,11 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
) : null}
|
||||
{indexes.map((index) => (
|
||||
<div
|
||||
key={index.name}
|
||||
className="rounded-lg border border-[#2a2b2f] bg-[#0a0a0a] p-3"
|
||||
>
|
||||
<div key={index.name} className="rounded-lg border border-[#2a2b2f] bg-[#0a0a0a] p-3">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-medium text-white">
|
||||
{index.name}
|
||||
</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{safeJSONStringify(index.keys)}
|
||||
</div>
|
||||
<div className="truncate text-sm font-medium text-white">{index.name}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">{safeJSONStringify(index.keys)}</div>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{index.unique ? (
|
||||
<span className="rounded border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] text-emerald-200">
|
||||
@ -1921,9 +1766,7 @@ export default function DatabaseBrowser() {
|
||||
</div>
|
||||
|
||||
<div className="space-y-3 rounded-xl border border-[#2a2b2f] bg-[#101114] p-3">
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">
|
||||
新建索引
|
||||
</div>
|
||||
<div className="text-xs font-medium uppercase tracking-wider text-gray-400">新建索引</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-xs text-gray-500">索引名称</label>
|
||||
<input
|
||||
@ -1986,9 +1829,7 @@ export default function DatabaseBrowser() {
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="text-sm font-medium text-white">记录列表</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{queryResult ? `${queryResult.total} 条记录` : "--"}
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">{queryResult ? `${queryResult.total} 条记录` : "--"}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-auto">
|
||||
@ -2012,24 +1853,17 @@ export default function DatabaseBrowser() {
|
||||
onClick={() => setSelectedDocumentIndex(index)}
|
||||
className={cn(
|
||||
"cursor-pointer transition-colors",
|
||||
index === selectedDocumentIndex
|
||||
? "bg-blue-500/10"
|
||||
: "hover:bg-[#17191d]",
|
||||
index === selectedDocumentIndex ? "bg-blue-500/10" : "hover:bg-[#17191d]",
|
||||
)}
|
||||
>
|
||||
{(resultColumns.length ? resultColumns : ["_id"]).map((column) => (
|
||||
<td
|
||||
key={column}
|
||||
className="max-w-[260px] truncate px-4 py-3 text-gray-200"
|
||||
>
|
||||
<td key={column} className="max-w-[260px] truncate px-4 py-3 text-gray-200">
|
||||
{renderCellValue(document[column])}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
{!queryLoading &&
|
||||
selectedConnectionId &&
|
||||
(!queryResult || queryResult.documents.length === 0) ? (
|
||||
{!queryLoading && selectedConnectionId && (!queryResult || queryResult.documents.length === 0) ? (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={Math.max(resultColumns.length, 1)}
|
||||
@ -2047,9 +1881,7 @@ export default function DatabaseBrowser() {
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#151619]">
|
||||
<div className="border-b border-[#2a2b2f] px-4 py-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="text-sm font-medium text-white">
|
||||
{isNewDocumentMode ? "新建记录" : "记录编辑器"}
|
||||
</div>
|
||||
<div className="text-sm font-medium text-white">{isNewDocumentMode ? "新建记录" : "记录编辑器"}</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import React, { useState, useMemo, useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTimeZone } from "../context/TimeZoneContext";
|
||||
import {
|
||||
formatClockTime,
|
||||
formatCompactDateTime,
|
||||
formatDateTime,
|
||||
} from "../lib/datetime";
|
||||
import { formatClockTime, formatCompactDateTime, formatDateTime } from "../lib/datetime";
|
||||
import { copyText } from "../lib/clipboard.js";
|
||||
import { buildBrowserPlayableVideoURL } from "../lib/video-preview.js";
|
||||
import {
|
||||
@ -27,24 +23,9 @@ import {
|
||||
FileText,
|
||||
} from "lucide-react";
|
||||
import { cn } from "../lib/utils";
|
||||
import {
|
||||
monitoringApi,
|
||||
LogEntry,
|
||||
ResourceUsage,
|
||||
ExecutionData,
|
||||
} from "../services/api/monitoring";
|
||||
import { monitoringApi, LogEntry, ResourceUsage, ExecutionData } from "../services/api/monitoring";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import {
|
||||
LineChart,
|
||||
Line,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
Tooltip,
|
||||
ResponsiveContainer,
|
||||
AreaChart,
|
||||
Area,
|
||||
} from "recharts";
|
||||
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, AreaChart, Area } from "recharts";
|
||||
|
||||
const formatDuration = (durationMs?: number) => {
|
||||
if (!durationMs) return "进行中";
|
||||
@ -54,8 +35,7 @@ const formatDuration = (durationMs?: number) => {
|
||||
return `${minutes}m ${seconds}s`;
|
||||
};
|
||||
|
||||
const hasDirectArtifactURL = (item: ExecutionData) =>
|
||||
/^https?:\/\//i.test(item.path);
|
||||
const hasDirectArtifactURL = (item: ExecutionData) => /^https?:\/\//i.test(item.path);
|
||||
|
||||
const artifactExtension = (item: ExecutionData) => {
|
||||
const source = item.name || item.path || "";
|
||||
@ -65,9 +45,7 @@ const artifactExtension = (item: ExecutionData) => {
|
||||
|
||||
const rawPreviewPayload = (item: ExecutionData) => {
|
||||
const preview = item.data?.preview;
|
||||
return preview && typeof preview === "object"
|
||||
? (preview as Record<string, any>)
|
||||
: null;
|
||||
return preview && typeof preview === "object" ? (preview as Record<string, any>) : null;
|
||||
};
|
||||
|
||||
const derivedPreview = (item: ExecutionData) => {
|
||||
@ -169,9 +147,7 @@ export default function Monitoring() {
|
||||
const [runs, setRuns] = useState<any[]>([]);
|
||||
|
||||
// Modal states
|
||||
const [activeModal, setActiveModal] = useState<
|
||||
"logs" | "resources" | "data" | null
|
||||
>(null);
|
||||
const [activeModal, setActiveModal] = useState<"logs" | "resources" | "data" | null>(null);
|
||||
const [selectedRun, setSelectedRun] = useState<any>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [modalData, setModalData] = useState<{
|
||||
@ -179,9 +155,7 @@ export default function Monitoring() {
|
||||
resources?: ResourceUsage[];
|
||||
data?: ExecutionData[];
|
||||
}>({});
|
||||
const [selectedArtifact, setSelectedArtifact] = useState<ExecutionData | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedArtifact, setSelectedArtifact] = useState<ExecutionData | null>(null);
|
||||
const [runActionPendingId, setRunActionPendingId] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
@ -215,8 +189,7 @@ export default function Monitoring() {
|
||||
run.projectName.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
run.id.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
|
||||
const matchesStatus =
|
||||
statusFilter === "all" || run.status === statusFilter;
|
||||
const matchesStatus = statusFilter === "all" || run.status === statusFilter;
|
||||
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
@ -270,9 +243,7 @@ export default function Monitoring() {
|
||||
setRunActionPendingId(runId);
|
||||
try {
|
||||
const updated = await monitoringApi.stopRun(runId);
|
||||
setRuns((previous) =>
|
||||
previous.map((item) => (item.id === runId ? updated : item)),
|
||||
);
|
||||
setRuns((previous) => previous.map((item) => (item.id === runId ? updated : item)));
|
||||
} catch (error) {
|
||||
console.error("Failed to stop run", error);
|
||||
} finally {
|
||||
@ -287,9 +258,7 @@ export default function Monitoring() {
|
||||
setRunActionPendingId(runId);
|
||||
try {
|
||||
const updated = await monitoringApi.forceStopRun(runId);
|
||||
setRuns((previous) =>
|
||||
previous.map((item) => (item.id === runId ? updated : item)),
|
||||
);
|
||||
setRuns((previous) => previous.map((item) => (item.id === runId ? updated : item)));
|
||||
} catch (error) {
|
||||
console.error("Failed to force stop run", error);
|
||||
} finally {
|
||||
@ -300,22 +269,14 @@ export default function Monitoring() {
|
||||
const renderArtifactPreview = (item: ExecutionData) => {
|
||||
const preview = derivedPreview(item);
|
||||
const directURL = hasDirectArtifactURL(item) ? item.path : "";
|
||||
const previewURL =
|
||||
typeof preview.url === "string" && preview.url ? preview.url : directURL;
|
||||
const playablePreviewURL =
|
||||
preview.kind === "video"
|
||||
? buildBrowserPlayableVideoURL(previewURL)
|
||||
: previewURL;
|
||||
const previewURL = typeof preview.url === "string" && preview.url ? preview.url : directURL;
|
||||
const playablePreviewURL = preview.kind === "video" ? buildBrowserPlayableVideoURL(previewURL) : previewURL;
|
||||
|
||||
if (preview.kind === "image" && previewURL) {
|
||||
return (
|
||||
<div className="flex-1 flex flex-col gap-4">
|
||||
<div className="min-h-[280px] bg-black rounded-lg overflow-hidden border border-[#2a2b2f] flex items-center justify-center">
|
||||
<img
|
||||
src={previewURL}
|
||||
alt={item.name}
|
||||
className="max-h-[420px] w-auto max-w-full object-contain"
|
||||
/>
|
||||
<img src={previewURL} alt={item.name} className="max-h-[420px] w-auto max-w-full object-contain" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@ -361,10 +322,7 @@ export default function Monitoring() {
|
||||
<thead className="bg-[#111214] sticky top-0">
|
||||
<tr>
|
||||
{columns.map((column) => (
|
||||
<th
|
||||
key={column}
|
||||
className="px-3 py-2 text-left text-gray-400 font-mono border-b border-[#2a2b2f]"
|
||||
>
|
||||
<th key={column} className="px-3 py-2 text-left text-gray-400 font-mono border-b border-[#2a2b2f]">
|
||||
{column}
|
||||
</th>
|
||||
))}
|
||||
@ -375,9 +333,7 @@ export default function Monitoring() {
|
||||
<tr key={index} className="border-b border-[#1f2024] last:border-b-0">
|
||||
{columns.map((column) => (
|
||||
<td key={`${index}-${column}`} className="px-3 py-2 text-gray-200 align-top">
|
||||
<div className="max-w-[240px] break-all">
|
||||
{String(row?.[column] ?? "")}
|
||||
</div>
|
||||
<div className="max-w-[240px] break-all">{String(row?.[column] ?? "")}</div>
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
@ -404,7 +360,7 @@ export default function Monitoring() {
|
||||
}
|
||||
|
||||
if (preview.kind === "json" || item.type === "json") {
|
||||
const jsonValue = preview.kind === "json" ? preview.value ?? item.data : item.data;
|
||||
const jsonValue = preview.kind === "json" ? (preview.value ?? item.data) : item.data;
|
||||
return (
|
||||
<pre className="flex-1 min-h-[420px] bg-black rounded-lg border border-[#2a2b2f] p-4 text-xs text-gray-200 overflow-auto whitespace-pre-wrap break-all">
|
||||
{JSON.stringify(jsonValue ?? {}, null, 2)}
|
||||
@ -494,9 +450,7 @@ export default function Monitoring() {
|
||||
{loading ? (
|
||||
<div className="h-64 flex flex-col items-center justify-center gap-3">
|
||||
<Loader2 className="w-8 h-8 text-blue-500 animate-spin" />
|
||||
<p className="text-xs text-gray-500 animate-pulse">
|
||||
正在获取实时数据...
|
||||
</p>
|
||||
<p className="text-xs text-gray-500 animate-pulse">正在获取实时数据...</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
@ -521,12 +475,8 @@ export default function Monitoring() {
|
||||
>
|
||||
{log.level}
|
||||
</span>
|
||||
<span className="text-gray-500 shrink-0 italic">
|
||||
[{log.operator}]
|
||||
</span>
|
||||
<span className="text-gray-300 break-all">
|
||||
{log.message}
|
||||
</span>
|
||||
<span className="text-gray-500 shrink-0 italic">[{log.operator}]</span>
|
||||
<span className="text-gray-300 break-all">{log.message}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@ -552,18 +502,9 @@ export default function Monitoring() {
|
||||
color: "text-purple-500",
|
||||
},
|
||||
].map((stat) => (
|
||||
<div
|
||||
key={stat.label}
|
||||
className="bg-[#0a0a0a] border border-[#2a2b2f] p-4 rounded-xl"
|
||||
>
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">
|
||||
{stat.label}
|
||||
</div>
|
||||
<div
|
||||
className={cn("text-xl font-bold", stat.color)}
|
||||
>
|
||||
{stat.value}
|
||||
</div>
|
||||
<div key={stat.label} className="bg-[#0a0a0a] border border-[#2a2b2f] p-4 rounded-xl">
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">{stat.label}</div>
|
||||
<div className={cn("text-xl font-bold", stat.color)}>{stat.value}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@ -572,46 +513,21 @@ export default function Monitoring() {
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<AreaChart data={modalData.resources}>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="colorCpu"
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="0"
|
||||
y2="1"
|
||||
>
|
||||
<stop
|
||||
offset="5%"
|
||||
stopColor="#3b82f6"
|
||||
stopOpacity={0.3}
|
||||
/>
|
||||
<stop
|
||||
offset="95%"
|
||||
stopColor="#3b82f6"
|
||||
stopOpacity={0}
|
||||
/>
|
||||
<linearGradient id="colorCpu" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="5%" stopColor="#3b82f6" stopOpacity={0.3} />
|
||||
<stop offset="95%" stopColor="#3b82f6" stopOpacity={0} />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<CartesianGrid
|
||||
strokeDasharray="3 3"
|
||||
stroke="#1a1b1e"
|
||||
vertical={false}
|
||||
/>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#1a1b1e" vertical={false} />
|
||||
<XAxis
|
||||
dataKey="timestamp"
|
||||
stroke="#4b5563"
|
||||
fontSize={10}
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickFormatter={(value) =>
|
||||
formatClockTime(String(value), timeZone)
|
||||
}
|
||||
/>
|
||||
<YAxis
|
||||
stroke="#4b5563"
|
||||
fontSize={10}
|
||||
tickLine={false}
|
||||
axisLine={false}
|
||||
tickFormatter={(value) => formatClockTime(String(value), timeZone)}
|
||||
/>
|
||||
<YAxis stroke="#4b5563" fontSize={10} tickLine={false} axisLine={false} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
backgroundColor: "#151619",
|
||||
@ -620,9 +536,7 @@ export default function Monitoring() {
|
||||
fontSize: "12px",
|
||||
}}
|
||||
itemStyle={{ color: "#fff" }}
|
||||
labelFormatter={(value) =>
|
||||
formatDateTime(String(value), timeZone)
|
||||
}
|
||||
labelFormatter={(value) => formatDateTime(String(value), timeZone)}
|
||||
/>
|
||||
<Area
|
||||
type="monotone"
|
||||
@ -650,9 +564,7 @@ export default function Monitoring() {
|
||||
{activeModal === "data" && (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="space-y-3">
|
||||
<h4 className="text-xs font-medium text-gray-500 uppercase tracking-wider mb-2">
|
||||
文件列表
|
||||
</h4>
|
||||
<h4 className="text-xs font-medium text-gray-500 uppercase tracking-wider mb-2">文件列表</h4>
|
||||
{modalData.data?.map((item) => (
|
||||
<div
|
||||
key={item.id}
|
||||
@ -669,9 +581,7 @@ export default function Monitoring() {
|
||||
{renderArtifactIcon(item)}
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-sm font-bold text-white truncate max-w-[180px]">
|
||||
{item.name}
|
||||
</div>
|
||||
<div className="text-sm font-bold text-white truncate max-w-[180px]">{item.name}</div>
|
||||
<div className="text-[10px] text-gray-500 font-mono mt-0.5">
|
||||
{item.size} • {artifactSecondaryLabel(item)}
|
||||
</div>
|
||||
@ -700,11 +610,7 @@ export default function Monitoring() {
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
window.open(
|
||||
item.path,
|
||||
"_blank",
|
||||
"noopener,noreferrer",
|
||||
);
|
||||
window.open(item.path, "_blank", "noopener,noreferrer");
|
||||
}}
|
||||
className="p-2 hover:bg-white/5 rounded-lg text-gray-400 hover:text-white transition-colors"
|
||||
title="打开真实资源"
|
||||
@ -718,52 +624,38 @@ export default function Monitoring() {
|
||||
</div>
|
||||
|
||||
<div className="bg-[#0a0a0a] border border-[#2a2b2f] rounded-xl p-4 flex flex-col min-h-[400px]">
|
||||
<h4 className="text-xs font-medium text-gray-500 uppercase tracking-wider mb-4">
|
||||
预览面板
|
||||
</h4>
|
||||
<h4 className="text-xs font-medium text-gray-500 uppercase tracking-wider mb-4">预览面板</h4>
|
||||
{selectedArtifact ? (
|
||||
<div className="flex-1 flex flex-col">
|
||||
{renderArtifactPreview(selectedArtifact)}
|
||||
<div className="mt-4 space-y-4">
|
||||
<div>
|
||||
<div className="text-sm font-bold text-white">
|
||||
{selectedArtifact.name}
|
||||
</div>
|
||||
<div className="text-sm font-bold text-white">{selectedArtifact.name}</div>
|
||||
<div className="text-xs text-gray-500 font-mono mt-1 break-all bg-white/5 p-2 rounded border border-[#2a2b2f]">
|
||||
{selectedArtifact.path}
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="bg-white/5 p-3 rounded-lg border border-[#2a2b2f]">
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">
|
||||
类型
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">类型</div>
|
||||
<div className="text-sm font-bold text-white">
|
||||
{artifactKindLabel(selectedArtifact)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-white/5 p-3 rounded-lg border border-[#2a2b2f]">
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">
|
||||
文件大小
|
||||
</div>
|
||||
<div className="text-sm font-bold text-white">
|
||||
{selectedArtifact.size}
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">文件大小</div>
|
||||
<div className="text-sm font-bold text-white">{selectedArtifact.size}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="bg-white/5 p-3 rounded-lg border border-[#2a2b2f]">
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">
|
||||
MIME
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">MIME</div>
|
||||
<div className="text-sm font-bold text-white break-all">
|
||||
{selectedArtifact.metadata?.mimeType || "--"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-white/5 p-3 rounded-lg border border-[#2a2b2f]">
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">
|
||||
SHA256
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-500 uppercase font-mono mb-1">SHA256</div>
|
||||
<div className="text-sm font-bold text-white break-all">
|
||||
{selectedArtifact.metadata?.sha256?.slice(0, 16) || "--"}
|
||||
</div>
|
||||
@ -771,13 +663,7 @@ export default function Monitoring() {
|
||||
</div>
|
||||
{hasDirectArtifactURL(selectedArtifact) ? (
|
||||
<button
|
||||
onClick={() =>
|
||||
window.open(
|
||||
selectedArtifact.path,
|
||||
"_blank",
|
||||
"noopener,noreferrer",
|
||||
)
|
||||
}
|
||||
onClick={() => window.open(selectedArtifact.path, "_blank", "noopener,noreferrer")}
|
||||
className="w-full py-3 bg-blue-600 hover:bg-blue-500 text-white rounded-xl text-sm font-bold transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
@ -785,9 +671,7 @@ export default function Monitoring() {
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={() =>
|
||||
copyToClipboard(selectedArtifact.path)
|
||||
}
|
||||
onClick={() => copyToClipboard(selectedArtifact.path)}
|
||||
className="w-full py-3 bg-white/5 hover:bg-white/10 text-white rounded-xl text-sm font-bold transition-all flex items-center justify-center gap-2 border border-[#2a2b2f]"
|
||||
>
|
||||
<Database className="w-4 h-4" />
|
||||
@ -801,9 +685,7 @@ export default function Monitoring() {
|
||||
<div className="w-16 h-16 bg-white/5 rounded-full flex items-center justify-center text-gray-600 mb-4">
|
||||
<FileText className="w-8 h-8" />
|
||||
</div>
|
||||
<h5 className="text-sm font-bold text-gray-400">
|
||||
未选择预览内容
|
||||
</h5>
|
||||
<h5 className="text-sm font-bold text-gray-400">未选择预览内容</h5>
|
||||
<p className="text-xs text-gray-500 mt-2">
|
||||
点击左侧任一产物,即可查看对应的结构化预览、媒体预览或真实元数据。
|
||||
</p>
|
||||
@ -830,12 +712,8 @@ export default function Monitoring() {
|
||||
)}
|
||||
</AnimatePresence>
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
执行监控
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
实时查看 K8s Job 运行状态与算子执行日志
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">执行监控</h1>
|
||||
<p className="text-gray-500 mt-1">实时查看 K8s Job 运行状态与算子执行日志</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
@ -863,24 +741,15 @@ export default function Monitoring() {
|
||||
value: formatDuration(
|
||||
runs
|
||||
.filter((run) => typeof run.durationMs === "number")
|
||||
.reduce(
|
||||
(sum, run, _, all) =>
|
||||
sum + (run.durationMs || 0) / Math.max(all.length, 1),
|
||||
0,
|
||||
),
|
||||
.reduce((sum, run, _, all) => sum + (run.durationMs || 0) / Math.max(all.length, 1), 0),
|
||||
),
|
||||
icon: Clock,
|
||||
color: "text-purple-500",
|
||||
},
|
||||
].map((stat) => (
|
||||
<div
|
||||
key={stat.label}
|
||||
className="bg-[#151619] border border-[#2a2b2f] p-6 rounded-xl"
|
||||
>
|
||||
<div key={stat.label} className="bg-[#151619] border border-[#2a2b2f] p-6 rounded-xl">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||
{stat.label}
|
||||
</span>
|
||||
<span className="text-xs font-medium text-gray-500 uppercase tracking-wider">{stat.label}</span>
|
||||
<stat.icon className={cn("w-4 h-4", stat.color)} />
|
||||
</div>
|
||||
<div className="text-2xl font-bold text-white">{stat.value}</div>
|
||||
@ -918,9 +787,7 @@ export default function Monitoring() {
|
||||
|
||||
<div className="bg-[#151619] border border-[#2a2b2f] rounded-xl overflow-hidden">
|
||||
<div className="px-6 py-4 border-b border-[#2a2b2f] flex items-center justify-between">
|
||||
<h3 className="font-bold text-white">
|
||||
执行历史 ({filteredExecutions.length})
|
||||
</h3>
|
||||
<h3 className="font-bold text-white">执行历史 ({filteredExecutions.length})</h3>
|
||||
<button
|
||||
className="text-xs text-blue-500 hover:underline"
|
||||
onClick={() => {
|
||||
@ -954,16 +821,10 @@ export default function Monitoring() {
|
||||
}
|
||||
className="hover:bg-white/5 transition-colors group cursor-pointer"
|
||||
>
|
||||
<td className="px-6 py-4 font-mono text-xs text-gray-400">
|
||||
{run.id}
|
||||
</td>
|
||||
<td className="px-6 py-4 font-mono text-xs text-gray-400">{run.id}</td>
|
||||
<td className="px-6 py-4">
|
||||
<div className="font-medium text-white">
|
||||
{run.workflowName}
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{run.projectName}
|
||||
</div>
|
||||
<div className="font-medium text-white">{run.workflowName}</div>
|
||||
<div className="text-xs text-gray-500">{run.projectName}</div>
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<div
|
||||
@ -973,11 +834,11 @@ export default function Monitoring() {
|
||||
? "bg-blue-500/10 text-blue-500 border border-blue-500/20"
|
||||
: run.status === "stopping"
|
||||
? "bg-amber-500/10 text-amber-400 border border-amber-500/20"
|
||||
: run.status === "completed"
|
||||
? "bg-green-500/10 text-green-500 border border-green-500/20"
|
||||
: run.status === "cancelled"
|
||||
? "bg-slate-500/10 text-slate-300 border border-slate-500/20"
|
||||
: "bg-red-500/10 text-red-500 border border-red-500/20",
|
||||
: run.status === "completed"
|
||||
? "bg-green-500/10 text-green-500 border border-green-500/20"
|
||||
: run.status === "cancelled"
|
||||
? "bg-slate-500/10 text-slate-300 border border-slate-500/20"
|
||||
: "bg-red-500/10 text-red-500 border border-red-500/20",
|
||||
)}
|
||||
>
|
||||
{(run.status === "running" || run.status === "stopping") && (
|
||||
@ -987,14 +848,9 @@ export default function Monitoring() {
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-6 py-4 text-gray-400">
|
||||
{formatCompactDateTime(
|
||||
run.startedAt || run.createdAt,
|
||||
timeZone,
|
||||
)}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-gray-400">
|
||||
{formatDuration(run.durationMs)}
|
||||
{formatCompactDateTime(run.startedAt || run.createdAt, timeZone)}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-gray-400">{formatDuration(run.durationMs)}</td>
|
||||
<td className="px-6 py-4 text-right">
|
||||
<div className="flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<button
|
||||
@ -1028,7 +884,9 @@ export default function Monitoring() {
|
||||
<Clock className="w-4 h-4" />
|
||||
</button>
|
||||
)}
|
||||
{(run.status === "running" || run.status === "stopping" || run.status === "waiting_for_audit") && (
|
||||
{(run.status === "running" ||
|
||||
run.status === "stopping" ||
|
||||
run.status === "waiting_for_audit") && (
|
||||
<button
|
||||
className="p-1.5 hover:bg-red-500/10 rounded text-red-300 hover:text-red-100 disabled:opacity-50"
|
||||
title="强制停止"
|
||||
@ -1044,10 +902,7 @@ export default function Monitoring() {
|
||||
))}
|
||||
{filteredExecutions.length === 0 && (
|
||||
<tr>
|
||||
<td
|
||||
colSpan={6}
|
||||
className="px-6 py-12 text-center text-gray-500"
|
||||
>
|
||||
<td colSpan={6} className="px-6 py-12 text-center text-gray-500">
|
||||
没有找到匹配的执行记录
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -20,19 +20,12 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useTimeZone } from "../context/TimeZoneContext";
|
||||
import { formatCompactDateTime } from "../lib/datetime";
|
||||
import {
|
||||
isObjectStorageEditorLocked,
|
||||
shouldSyncObjectStoragePreviewToEditor,
|
||||
} from "../lib/object-storage-preview.js";
|
||||
import { isObjectStorageEditorLocked, shouldSyncObjectStoragePreviewToEditor } from "../lib/object-storage-preview.js";
|
||||
import { buildBrowserPlayableVideoURL } from "../lib/video-preview.js";
|
||||
import { cn } from "../lib/utils";
|
||||
import { objectStorageApi } from "../services/api/object-storage";
|
||||
import { storageConnectionsApi } from "../services/api/storage-connections";
|
||||
import type {
|
||||
ObjectStorageObjectSummary,
|
||||
ObjectStorageOverview,
|
||||
StorageConnection,
|
||||
} from "../types";
|
||||
import type { ObjectStorageObjectSummary, ObjectStorageOverview, StorageConnection } from "../types";
|
||||
|
||||
const formatBytes = (value?: number) => {
|
||||
if (!value) return "-";
|
||||
@ -201,9 +194,7 @@ export default function ObjectStorageBrowser() {
|
||||
: "";
|
||||
|
||||
const playablePreviewURL =
|
||||
previewKind(selectedItem) === "video"
|
||||
? buildBrowserPlayableVideoURL(previewURL)
|
||||
: previewURL;
|
||||
previewKind(selectedItem) === "video" ? buildBrowserPlayableVideoURL(previewURL) : previewURL;
|
||||
|
||||
const filteredItems = useMemo(() => {
|
||||
const keyword = objectSearch.trim().toLowerCase();
|
||||
@ -212,9 +203,7 @@ export default function ObjectStorageBrowser() {
|
||||
return sorted;
|
||||
}
|
||||
return sorted.filter((item) => {
|
||||
const haystack = [item.name, item.key, item.contentType || "", item.kind]
|
||||
.join(" ")
|
||||
.toLowerCase();
|
||||
const haystack = [item.name, item.key, item.contentType || "", item.kind].join(" ").toLowerCase();
|
||||
return haystack.includes(keyword);
|
||||
});
|
||||
}, [items, objectSearch]);
|
||||
@ -238,10 +227,7 @@ export default function ObjectStorageBrowser() {
|
||||
const items = await storageConnectionsApi.list();
|
||||
setConnections(items);
|
||||
setSelectedConnectionId((current) => {
|
||||
if (
|
||||
preferredConnectionId &&
|
||||
items.some((item) => item.id === preferredConnectionId)
|
||||
) {
|
||||
if (preferredConnectionId && items.some((item) => item.id === preferredConnectionId)) {
|
||||
return preferredConnectionId;
|
||||
}
|
||||
if (current && items.some((item) => item.id === current)) {
|
||||
@ -253,9 +239,7 @@ export default function ObjectStorageBrowser() {
|
||||
console.error("Failed to load storage connections", error);
|
||||
setConnections([]);
|
||||
setSelectedConnectionId("");
|
||||
setConnectionsError(
|
||||
error instanceof Error ? error.message : "加载对象存储连接失败",
|
||||
);
|
||||
setConnectionsError(error instanceof Error ? error.message : "加载对象存储连接失败");
|
||||
} finally {
|
||||
setConnectionsLoading(false);
|
||||
}
|
||||
@ -285,8 +269,7 @@ export default function ObjectStorageBrowser() {
|
||||
setOverview(result);
|
||||
setSelectedBucket((current) => {
|
||||
const resolvedBucket = result.bucket || result.buckets[0]?.name || "";
|
||||
const nextPreferred =
|
||||
preferredBucket && preferredBucket === resolvedBucket ? preferredBucket : "";
|
||||
const nextPreferred = preferredBucket && preferredBucket === resolvedBucket ? preferredBucket : "";
|
||||
if (nextPreferred) return nextPreferred;
|
||||
if (current && current === resolvedBucket) {
|
||||
return current;
|
||||
@ -301,9 +284,7 @@ export default function ObjectStorageBrowser() {
|
||||
console.error("Failed to load object storage overview", error);
|
||||
setOverview(null);
|
||||
setSelectedBucket("");
|
||||
setOverviewError(
|
||||
error instanceof Error ? error.message : "加载对象存储概览失败",
|
||||
);
|
||||
setOverviewError(error instanceof Error ? error.message : "加载对象存储概览失败");
|
||||
return null;
|
||||
} finally {
|
||||
if (overviewRequestIdRef.current === requestId) {
|
||||
@ -363,9 +344,7 @@ export default function ObjectStorageBrowser() {
|
||||
console.error("Failed to load object storage items", error);
|
||||
setItems([]);
|
||||
setSelectedItem(null);
|
||||
setObjectsError(
|
||||
error instanceof Error ? error.message : "加载对象列表失败",
|
||||
);
|
||||
setObjectsError(error instanceof Error ? error.message : "加载对象列表失败");
|
||||
return null;
|
||||
} finally {
|
||||
if (objectsRequestIdRef.current === requestId) {
|
||||
@ -426,9 +405,7 @@ export default function ObjectStorageBrowser() {
|
||||
setPreviewReturnedSizeBytes(undefined);
|
||||
if (!isNewObjectMode) {
|
||||
setObjectDraftKey(selectedItem.key);
|
||||
setObjectContentType(
|
||||
selectedItem.contentType || guessContentType(selectedItem.key),
|
||||
);
|
||||
setObjectContentType(selectedItem.contentType || guessContentType(selectedItem.key));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -445,9 +422,7 @@ export default function ObjectStorageBrowser() {
|
||||
if (cancelled) return;
|
||||
setPreviewText(result.content);
|
||||
setPreviewTruncated(result.truncated);
|
||||
setPreviewOriginalSizeBytes(
|
||||
result.originalSizeBytes || selectedItem.sizeBytes,
|
||||
);
|
||||
setPreviewOriginalSizeBytes(result.originalSizeBytes || selectedItem.sizeBytes);
|
||||
setPreviewReturnedSizeBytes(result.returnedSizeBytes);
|
||||
if (
|
||||
!isNewObjectMode &&
|
||||
@ -458,24 +433,18 @@ export default function ObjectStorageBrowser() {
|
||||
) {
|
||||
setObjectDraftKey(selectedItem.key);
|
||||
setObjectEditorText(result.content);
|
||||
setObjectContentType(
|
||||
selectedItem.contentType || guessContentType(selectedItem.key),
|
||||
);
|
||||
setObjectContentType(selectedItem.contentType || guessContentType(selectedItem.key));
|
||||
} else if (!isNewObjectMode) {
|
||||
setObjectDraftKey(selectedItem.key);
|
||||
setObjectEditorText("");
|
||||
setObjectContentType(
|
||||
selectedItem.contentType || guessContentType(selectedItem.key),
|
||||
);
|
||||
setObjectContentType(selectedItem.contentType || guessContentType(selectedItem.key));
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
if (cancelled) return;
|
||||
console.error("Failed to read object content", error);
|
||||
setPreviewText("");
|
||||
setPreviewError(
|
||||
error instanceof Error ? error.message : "读取对象内容失败",
|
||||
);
|
||||
setPreviewError(error instanceof Error ? error.message : "读取对象内容失败");
|
||||
setPreviewTruncated(false);
|
||||
setPreviewOriginalSizeBytes(undefined);
|
||||
setPreviewReturnedSizeBytes(undefined);
|
||||
@ -510,14 +479,14 @@ export default function ObjectStorageBrowser() {
|
||||
return;
|
||||
}
|
||||
setConnectionFormMode("edit");
|
||||
setConnectionDraft({
|
||||
name: selectedConnection.name || "",
|
||||
description: selectedConnection.description || "",
|
||||
endpoint: selectedConnection.endpoint || "",
|
||||
bucket: selectedConnection.bucket || "",
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
});
|
||||
setConnectionDraft({
|
||||
name: selectedConnection.name || "",
|
||||
description: selectedConnection.description || "",
|
||||
endpoint: selectedConnection.endpoint || "",
|
||||
bucket: selectedConnection.bucket || "",
|
||||
accessKeyId: "",
|
||||
secretAccessKey: "",
|
||||
});
|
||||
setConnectionActionMessage("");
|
||||
setConnectionActionError("");
|
||||
setIsConnectionFormOpen(true);
|
||||
@ -563,14 +532,10 @@ export default function ObjectStorageBrowser() {
|
||||
}
|
||||
setIsConnectionFormOpen(false);
|
||||
setConnectionDraft(EMPTY_CONNECTION_DRAFT);
|
||||
setConnectionActionMessage(
|
||||
connectionFormMode === "create" ? "连接已创建。" : "连接已更新。",
|
||||
);
|
||||
setConnectionActionMessage(connectionFormMode === "create" ? "连接已创建。" : "连接已更新。");
|
||||
} catch (error) {
|
||||
console.error("Failed to save storage connection", error);
|
||||
setConnectionActionError(
|
||||
error instanceof Error ? error.message : "保存对象存储连接失败",
|
||||
);
|
||||
setConnectionActionError(error instanceof Error ? error.message : "保存对象存储连接失败");
|
||||
} finally {
|
||||
setConnectionActionLoading(false);
|
||||
}
|
||||
@ -598,9 +563,7 @@ export default function ObjectStorageBrowser() {
|
||||
setConnectionActionMessage("连接已删除。");
|
||||
} catch (error) {
|
||||
console.error("Failed to delete storage connection", error);
|
||||
setConnectionActionError(
|
||||
error instanceof Error ? error.message : "删除对象存储连接失败",
|
||||
);
|
||||
setConnectionActionError(error instanceof Error ? error.message : "删除对象存储连接失败");
|
||||
} finally {
|
||||
setConnectionActionLoading(false);
|
||||
}
|
||||
@ -648,9 +611,7 @@ export default function ObjectStorageBrowser() {
|
||||
setSelectedItem(result.object);
|
||||
} catch (error) {
|
||||
console.error("Failed to save object", error);
|
||||
setObjectActionError(
|
||||
error instanceof Error ? error.message : "保存对象失败",
|
||||
);
|
||||
setObjectActionError(error instanceof Error ? error.message : "保存对象失败");
|
||||
} finally {
|
||||
setObjectActionLoading(false);
|
||||
}
|
||||
@ -681,9 +642,7 @@ export default function ObjectStorageBrowser() {
|
||||
setSelectedItem(result.object);
|
||||
} catch (error) {
|
||||
console.error("Failed to rename object", error);
|
||||
setObjectActionError(
|
||||
error instanceof Error ? error.message : "重命名对象失败",
|
||||
);
|
||||
setObjectActionError(error instanceof Error ? error.message : "重命名对象失败");
|
||||
} finally {
|
||||
setObjectActionLoading(false);
|
||||
}
|
||||
@ -716,9 +675,7 @@ export default function ObjectStorageBrowser() {
|
||||
await reloadObjects();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete object", error);
|
||||
setObjectActionError(
|
||||
error instanceof Error ? error.message : isDirectory ? "删除目录失败" : "删除对象失败",
|
||||
);
|
||||
setObjectActionError(error instanceof Error ? error.message : isDirectory ? "删除目录失败" : "删除对象失败");
|
||||
} finally {
|
||||
setObjectActionLoading(false);
|
||||
}
|
||||
@ -753,9 +710,7 @@ export default function ObjectStorageBrowser() {
|
||||
setSelectedItem(result.object);
|
||||
} catch (error) {
|
||||
console.error("Failed to upload object", error);
|
||||
setObjectActionError(
|
||||
error instanceof Error ? error.message : "上传对象失败",
|
||||
);
|
||||
setObjectActionError(error instanceof Error ? error.message : "上传对象失败");
|
||||
} finally {
|
||||
setObjectActionLoading(false);
|
||||
}
|
||||
@ -781,9 +736,7 @@ export default function ObjectStorageBrowser() {
|
||||
return (
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#111317] p-5 text-sm text-gray-300">
|
||||
当前选中目录 ` {selectedItem.key} `
|
||||
<div className="mt-3 text-xs text-gray-500">
|
||||
双击或点击列表中的目录即可进入下一级前缀。
|
||||
</div>
|
||||
<div className="mt-3 text-xs text-gray-500">双击或点击列表中的目录即可进入下一级前缀。</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -791,11 +744,7 @@ export default function ObjectStorageBrowser() {
|
||||
if (kind === "image" && previewURL) {
|
||||
return (
|
||||
<div className="rounded-2xl border border-[#2a2b2f] bg-[#111317] p-3">
|
||||
<img
|
||||
src={previewURL}
|
||||
alt={selectedItem.name}
|
||||
className="max-h-[420px] w-full rounded-xl object-contain"
|
||||
/>
|
||||
<img src={previewURL} alt={selectedItem.name} className="max-h-[420px] w-full rounded-xl object-contain" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -877,9 +826,7 @@ export default function ObjectStorageBrowser() {
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-white">对象存储</h1>
|
||||
<p className="mt-2 text-gray-400">
|
||||
管理真实 OSS/BOS 连接、绑定 bucket、对象目录,并直接在页面内预览与操作。
|
||||
</p>
|
||||
<p className="mt-2 text-gray-400">管理真实 OSS/BOS 连接、绑定 bucket、对象目录,并直接在页面内预览与操作。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -965,9 +912,7 @@ export default function ObjectStorageBrowser() {
|
||||
<label className="text-xs uppercase tracking-[0.2em] text-gray-500">连接名称</label>
|
||||
<input
|
||||
value={connectionDraft.name}
|
||||
onChange={(event) =>
|
||||
setConnectionDraft((previous) => ({ ...previous, name: event.target.value }))
|
||||
}
|
||||
onChange={(event) => setConnectionDraft((previous) => ({ ...previous, name: event.target.value }))}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0b0c10] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
placeholder="例如:BOS 测试环境"
|
||||
/>
|
||||
@ -976,9 +921,7 @@ export default function ObjectStorageBrowser() {
|
||||
<label className="text-xs uppercase tracking-[0.2em] text-gray-500">Endpoint</label>
|
||||
<input
|
||||
value={connectionDraft.endpoint}
|
||||
onChange={(event) =>
|
||||
setConnectionDraft((previous) => ({ ...previous, endpoint: event.target.value }))
|
||||
}
|
||||
onChange={(event) => setConnectionDraft((previous) => ({ ...previous, endpoint: event.target.value }))}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0b0c10] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
placeholder="留空则使用 BOS 默认 endpoint"
|
||||
/>
|
||||
@ -988,9 +931,7 @@ export default function ObjectStorageBrowser() {
|
||||
<input
|
||||
data-testid="connection-bucket-input"
|
||||
value={connectionDraft.bucket}
|
||||
onChange={(event) =>
|
||||
setConnectionDraft((previous) => ({ ...previous, bucket: event.target.value }))
|
||||
}
|
||||
onChange={(event) => setConnectionDraft((previous) => ({ ...previous, bucket: event.target.value }))}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0b0c10] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
placeholder="例如:datastorage"
|
||||
/>
|
||||
@ -1063,11 +1004,7 @@ export default function ObjectStorageBrowser() {
|
||||
disabled={connectionActionLoading}
|
||||
className="inline-flex items-center gap-2 rounded-xl bg-blue-600 px-4 py-3 text-sm font-medium text-white hover:bg-blue-500 disabled:opacity-60"
|
||||
>
|
||||
{connectionActionLoading ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Save className="h-4 w-4" />
|
||||
)}
|
||||
{connectionActionLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : <Save className="h-4 w-4" />}
|
||||
{connectionFormMode === "create" ? "创建连接" : "保存连接"}
|
||||
</button>
|
||||
</div>
|
||||
@ -1115,10 +1052,7 @@ export default function ObjectStorageBrowser() {
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-xs uppercase tracking-[0.2em] text-gray-500">绑定 Bucket</div>
|
||||
<div
|
||||
data-testid="bound-bucket-name"
|
||||
className="mt-2 break-all text-sm font-medium text-white"
|
||||
>
|
||||
<div data-testid="bound-bucket-name" className="mt-2 break-all text-sm font-medium text-white">
|
||||
{selectedBucket || selectedConnection.bucket || "未绑定 bucket"}
|
||||
</div>
|
||||
</div>
|
||||
@ -1264,9 +1198,7 @@ export default function ObjectStorageBrowser() {
|
||||
</div>
|
||||
<div className="mt-3 flex flex-wrap gap-3 text-xs text-gray-500">
|
||||
<span>{formatBytes(item.sizeBytes)}</span>
|
||||
{item.lastModified && (
|
||||
<span>{formatCompactDateTime(item.lastModified, timeZone)}</span>
|
||||
)}
|
||||
{item.lastModified && <span>{formatCompactDateTime(item.lastModified, timeZone)}</span>}
|
||||
{item.contentType && <span>{item.contentType}</span>}
|
||||
</div>
|
||||
</button>
|
||||
@ -1346,9 +1278,9 @@ export default function ObjectStorageBrowser() {
|
||||
<div className="grid gap-4 md:grid-cols-[1fr_160px]">
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs uppercase tracking-[0.2em] text-gray-500">对象 key</label>
|
||||
<input
|
||||
data-testid="object-key-input"
|
||||
value={objectDraftKey}
|
||||
<input
|
||||
data-testid="object-key-input"
|
||||
value={objectDraftKey}
|
||||
onChange={(event) => setObjectDraftKey(event.target.value)}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0b0c10] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
placeholder="例如:demo/output.json"
|
||||
@ -1356,9 +1288,9 @@ export default function ObjectStorageBrowser() {
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs uppercase tracking-[0.2em] text-gray-500">Content-Type</label>
|
||||
<input
|
||||
data-testid="object-content-type-input"
|
||||
value={objectContentType}
|
||||
<input
|
||||
data-testid="object-content-type-input"
|
||||
value={objectContentType}
|
||||
onChange={(event) => setObjectContentType(event.target.value)}
|
||||
className="w-full rounded-xl border border-[#2a2b2f] bg-[#0b0c10] px-4 py-3 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
/>
|
||||
@ -1391,11 +1323,7 @@ export default function ObjectStorageBrowser() {
|
||||
disabled={objectActionLoading || objectEditorLocked}
|
||||
className="inline-flex items-center gap-2 rounded-xl bg-blue-600 px-4 py-3 text-sm font-medium text-white hover:bg-blue-500 disabled:opacity-60"
|
||||
>
|
||||
{objectActionLoading ? (
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
<Save className="h-4 w-4" />
|
||||
)}
|
||||
{objectActionLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : <Save className="h-4 w-4" />}
|
||||
保存对象
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Cpu, Plus, Search, Code, Box, X, Info, Layers, Edit3, Trash2, Sparkles, Loader2, AlertCircle } from "lucide-react";
|
||||
import {
|
||||
Cpu,
|
||||
Plus,
|
||||
Search,
|
||||
Code,
|
||||
Box,
|
||||
X,
|
||||
Info,
|
||||
Layers,
|
||||
Edit3,
|
||||
Trash2,
|
||||
Sparkles,
|
||||
Loader2,
|
||||
AlertCircle,
|
||||
} from "lucide-react";
|
||||
import { useUser } from "../context/UserContext";
|
||||
import { cn } from "../lib/utils";
|
||||
import { Operator, PortDefinition } from "../types";
|
||||
@ -37,39 +51,42 @@ export default function Operators() {
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
hyperparams: [],
|
||||
skillDefinition: ""
|
||||
skillDefinition: "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
operatorsApi.list().then(setOperators).catch((error) => {
|
||||
console.error("Failed to load operators", error);
|
||||
});
|
||||
operatorsApi
|
||||
.list()
|
||||
.then(setOperators)
|
||||
.catch((error) => {
|
||||
console.error("Failed to load operators", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleAddHyperParam = () => {
|
||||
const hp = {
|
||||
key: `PARAM_${(newOp.hyperparams?.length || 0) + 1}`,
|
||||
value: "",
|
||||
description: ""
|
||||
description: "",
|
||||
};
|
||||
setNewOp({ ...newOp, hyperparams: [...(newOp.hyperparams || []), hp] });
|
||||
};
|
||||
|
||||
const handleAddPort = (type: 'inputs' | 'outputs') => {
|
||||
const handleAddPort = (type: "inputs" | "outputs") => {
|
||||
setNewOp((current) => {
|
||||
const nextIndex = (current[type]?.length ?? 0) + 1;
|
||||
const port: PortDefinition = {
|
||||
id: createPortID(),
|
||||
name: `端口 ${nextIndex}`,
|
||||
type: "json",
|
||||
transmission: "bus"
|
||||
transmission: "bus",
|
||||
};
|
||||
return { ...current, [type]: [...(current[type] || []), port] };
|
||||
});
|
||||
};
|
||||
|
||||
const updatePort = (
|
||||
type: 'inputs' | 'outputs',
|
||||
type: "inputs" | "outputs",
|
||||
index: number,
|
||||
updater: Partial<PortDefinition> | ((current: PortDefinition) => PortDefinition),
|
||||
) => {
|
||||
@ -84,7 +101,7 @@ export default function Operators() {
|
||||
});
|
||||
};
|
||||
|
||||
const removePort = (type: 'inputs' | 'outputs', index: number) => {
|
||||
const removePort = (type: "inputs" | "outputs", index: number) => {
|
||||
setNewOp((current) => ({
|
||||
...current,
|
||||
[type]: (current[type] || []).filter((_, portIndex) => portIndex !== index),
|
||||
@ -96,9 +113,7 @@ export default function Operators() {
|
||||
if (editingOpId) {
|
||||
operatorsApi
|
||||
.update(editingOpId, newOp)
|
||||
.then((updated) =>
|
||||
setOperators(operators.map((op) => (op.id === editingOpId ? updated : op))),
|
||||
)
|
||||
.then((updated) => setOperators(operators.map((op) => (op.id === editingOpId ? updated : op))))
|
||||
.catch((error) => console.error("Failed to update operator", error));
|
||||
} else {
|
||||
operatorsApi
|
||||
@ -141,10 +156,10 @@ export default function Operators() {
|
||||
name: generated.name,
|
||||
category: generated.category as any,
|
||||
description: generated.description,
|
||||
inputs: generated.inputs.map(i => ({ id: createPortID(), ...i })) as any,
|
||||
outputs: generated.outputs.map(o => ({ id: createPortID(), ...o })) as any,
|
||||
inputs: generated.inputs.map((i) => ({ id: createPortID(), ...i })) as any,
|
||||
outputs: generated.outputs.map((o) => ({ id: createPortID(), ...o })) as any,
|
||||
hyperparams: generated.hyperparams || [],
|
||||
skillDefinition: generated.skillDefinition
|
||||
skillDefinition: generated.skillDefinition,
|
||||
});
|
||||
setIsAIModalOpen(false);
|
||||
setIsModalOpen(true);
|
||||
@ -183,14 +198,18 @@ export default function Operators() {
|
||||
</div>
|
||||
{canManage && (
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
<button
|
||||
onClick={() => {
|
||||
setAiDescription("");
|
||||
setAiError(null);
|
||||
setIsAIModalOpen(true);
|
||||
}}
|
||||
disabled={!aiStatus.enabled}
|
||||
title={aiStatus.enabled ? `使用 ${aiStatus.model || "glm-5"} 辅助生成算子定义` : (aiStatus.reason || "当前服务端未配置 AI 服务")}
|
||||
title={
|
||||
aiStatus.enabled
|
||||
? `使用 ${aiStatus.model || "glm-5"} 辅助生成算子定义`
|
||||
: aiStatus.reason || "当前服务端未配置 AI 服务"
|
||||
}
|
||||
className={cn(
|
||||
"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors border border-blue-500/20",
|
||||
aiStatus.enabled
|
||||
@ -201,7 +220,7 @@ export default function Operators() {
|
||||
<Sparkles className="w-4 h-4" />
|
||||
AI 辅助注册
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
onClick={() => {
|
||||
setEditingOpId(null);
|
||||
setNewOp({ type: "custom", category: "CV", inputs: [], outputs: [], skillDefinition: "" });
|
||||
@ -219,9 +238,9 @@ export default function Operators() {
|
||||
<div className="flex items-center gap-4 bg-[#151619] p-4 rounded-lg border border-[#2a2b2f]">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索算子..."
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索算子..."
|
||||
value={searchQuery}
|
||||
onChange={(event) => setSearchQuery(event.target.value)}
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md pl-10 pr-4 py-2 text-sm focus:outline-none focus:border-blue-500 transition-colors"
|
||||
@ -231,39 +250,51 @@ export default function Operators() {
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredOperators.map((op) => (
|
||||
<div
|
||||
key={op.id}
|
||||
<div
|
||||
key={op.id}
|
||||
data-testid="operator-card"
|
||||
onDoubleClick={() => canManage && handleEdit(op)}
|
||||
className={cn(
|
||||
"bg-[#151619] border border-[#2a2b2f] rounded-xl p-6 hover:bg-[#1a1b1e] transition-all group relative",
|
||||
canManage && "cursor-pointer"
|
||||
canManage && "cursor-pointer",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<div className={cn(
|
||||
"w-12 h-12 rounded-lg flex items-center justify-center",
|
||||
op.type === "builtin" ? "bg-blue-500/10 text-blue-500" : "bg-purple-500/10 text-purple-500"
|
||||
)}>
|
||||
<div
|
||||
className={cn(
|
||||
"w-12 h-12 rounded-lg flex items-center justify-center",
|
||||
op.type === "builtin" ? "bg-blue-500/10 text-blue-500" : "bg-purple-500/10 text-purple-500",
|
||||
)}
|
||||
>
|
||||
{op.category === "IO" ? <Box className="w-6 h-6" /> : <Code className="w-6 h-6" />}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{canManage && (
|
||||
<>
|
||||
{op.type === "custom" && (
|
||||
<button onClick={() => handleEdit(op)} className="p-1.5 hover:bg-white/5 rounded text-gray-500 hover:text-blue-400 transition-colors">
|
||||
<button
|
||||
onClick={() => handleEdit(op)}
|
||||
className="p-1.5 hover:bg-white/5 rounded text-gray-500 hover:text-blue-400 transition-colors"
|
||||
>
|
||||
<Edit3 className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
<button onClick={() => handleDelete(op.id)} className="p-1.5 hover:bg-white/5 rounded text-gray-500 hover:text-red-400 transition-colors">
|
||||
<button
|
||||
onClick={() => handleDelete(op.id)}
|
||||
className="p-1.5 hover:bg-white/5 rounded text-gray-500 hover:text-red-400 transition-colors"
|
||||
>
|
||||
<Trash2 className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<span className={cn(
|
||||
"text-[10px] px-2 py-0.5 rounded-full font-mono uppercase tracking-wider",
|
||||
op.type === "builtin" ? "bg-blue-500/10 text-blue-500 border border-blue-500/20" : "bg-purple-500/10 text-purple-500 border border-purple-500/20"
|
||||
)}>
|
||||
<span
|
||||
className={cn(
|
||||
"text-[10px] px-2 py-0.5 rounded-full font-mono uppercase tracking-wider",
|
||||
op.type === "builtin"
|
||||
? "bg-blue-500/10 text-blue-500 border border-blue-500/20"
|
||||
: "bg-purple-500/10 text-purple-500 border border-purple-500/20",
|
||||
)}
|
||||
>
|
||||
{op.type === "builtin" ? "Built-in" : "Custom"}
|
||||
</span>
|
||||
{op.skillDefinition && (
|
||||
@ -274,10 +305,10 @@ export default function Operators() {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h3 className="text-lg font-bold text-white mb-1">{op.name}</h3>
|
||||
<p className="text-sm text-gray-500 mb-6 h-10 line-clamp-2">{op.description}</p>
|
||||
|
||||
|
||||
{/* Contract / Ports Display */}
|
||||
<div className="space-y-3 mb-6">
|
||||
<div className="flex items-center gap-2 text-[10px] text-gray-600 uppercase font-mono tracking-widest">
|
||||
@ -285,17 +316,25 @@ export default function Operators() {
|
||||
契约定义 (Ports)
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{op.inputs?.map(port => (
|
||||
<span key={port.id} className="px-2 py-1 bg-blue-500/5 border border-blue-500/20 rounded text-[10px] text-blue-400">
|
||||
{op.inputs?.map((port) => (
|
||||
<span
|
||||
key={port.id}
|
||||
className="px-2 py-1 bg-blue-500/5 border border-blue-500/20 rounded text-[10px] text-blue-400"
|
||||
>
|
||||
IN: {port.name} ({port.type})
|
||||
</span>
|
||||
))}
|
||||
{op.outputs?.map(port => (
|
||||
<span key={port.id} className="px-2 py-1 bg-green-500/5 border border-green-500/20 rounded text-[10px] text-green-400">
|
||||
{op.outputs?.map((port) => (
|
||||
<span
|
||||
key={port.id}
|
||||
className="px-2 py-1 bg-green-500/5 border border-green-500/20 rounded text-[10px] text-green-400"
|
||||
>
|
||||
OUT: {port.name} ({port.type})
|
||||
</span>
|
||||
))}
|
||||
{(!op.inputs?.length && !op.outputs?.length) && <span className="text-[10px] text-gray-700 italic">无端口定义</span>}
|
||||
{!op.inputs?.length && !op.outputs?.length && (
|
||||
<span className="text-[10px] text-gray-700 italic">无端口定义</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -307,8 +346,11 @@ export default function Operators() {
|
||||
超参配置 (Hyperparams)
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{op.hyperparams.map(hp => (
|
||||
<span key={hp.key} className="px-2 py-1 bg-orange-500/5 border border-orange-500/20 rounded text-[10px] text-orange-400 font-mono">
|
||||
{op.hyperparams.map((hp) => (
|
||||
<span
|
||||
key={hp.key}
|
||||
className="px-2 py-1 bg-orange-500/5 border border-orange-500/20 rounded text-[10px] text-orange-400 font-mono"
|
||||
>
|
||||
{hp.key}={hp.value}
|
||||
</span>
|
||||
))}
|
||||
@ -318,7 +360,7 @@ export default function Operators() {
|
||||
|
||||
<div className="flex items-center justify-between pt-4 border-t border-[#2a2b2f]">
|
||||
<span className="text-[10px] text-gray-600 font-mono uppercase tracking-widest">{op.category}</span>
|
||||
<button
|
||||
<button
|
||||
onClick={() => handleEdit(op)}
|
||||
className="text-xs text-blue-500 hover:underline flex items-center gap-1"
|
||||
>
|
||||
@ -353,7 +395,9 @@ export default function Operators() {
|
||||
onClick={() => setActiveTab("basic")}
|
||||
className={cn(
|
||||
"px-4 py-3 text-xs font-bold uppercase tracking-widest transition-all border-b-2",
|
||||
activeTab === "basic" ? "text-blue-500 border-blue-500" : "text-gray-500 border-transparent hover:text-gray-300"
|
||||
activeTab === "basic"
|
||||
? "text-blue-500 border-blue-500"
|
||||
: "text-gray-500 border-transparent hover:text-gray-300",
|
||||
)}
|
||||
>
|
||||
基础配置
|
||||
@ -363,7 +407,9 @@ export default function Operators() {
|
||||
onClick={() => setActiveTab("ports")}
|
||||
className={cn(
|
||||
"px-4 py-3 text-xs font-bold uppercase tracking-widest transition-all border-b-2",
|
||||
activeTab === "ports" ? "text-blue-500 border-blue-500" : "text-gray-500 border-transparent hover:text-gray-300"
|
||||
activeTab === "ports"
|
||||
? "text-blue-500 border-blue-500"
|
||||
: "text-gray-500 border-transparent hover:text-gray-300",
|
||||
)}
|
||||
>
|
||||
端口定义
|
||||
@ -373,7 +419,9 @@ export default function Operators() {
|
||||
onClick={() => setActiveTab("hyperparams")}
|
||||
className={cn(
|
||||
"px-4 py-3 text-xs font-bold uppercase tracking-widest transition-all border-b-2",
|
||||
activeTab === "hyperparams" ? "text-blue-500 border-blue-500" : "text-gray-500 border-transparent hover:text-gray-300"
|
||||
activeTab === "hyperparams"
|
||||
? "text-blue-500 border-blue-500"
|
||||
: "text-gray-500 border-transparent hover:text-gray-300",
|
||||
)}
|
||||
>
|
||||
超参配置
|
||||
@ -383,33 +431,35 @@ export default function Operators() {
|
||||
onClick={() => setActiveTab("skill")}
|
||||
className={cn(
|
||||
"px-4 py-3 text-xs font-bold uppercase tracking-widest transition-all border-b-2",
|
||||
activeTab === "skill" ? "text-blue-500 border-blue-500" : "text-gray-500 border-transparent hover:text-gray-300"
|
||||
activeTab === "skill"
|
||||
? "text-blue-500 border-blue-500"
|
||||
: "text-gray-500 border-transparent hover:text-gray-300",
|
||||
)}
|
||||
>
|
||||
AI Skill 描述
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-6 overflow-y-auto flex-1 space-y-6">
|
||||
{activeTab === "basic" && (
|
||||
<div className="space-y-6">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">算子名称</label>
|
||||
<input
|
||||
type="text"
|
||||
<input
|
||||
type="text"
|
||||
placeholder="例如: 图像锐化"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
value={newOp.name || ""}
|
||||
onChange={e => setNewOp({...newOp, name: e.target.value})}
|
||||
onChange={(e) => setNewOp({ ...newOp, name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">分类</label>
|
||||
<select
|
||||
<select
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
value={newOp.category || "CV"}
|
||||
onChange={e => setNewOp({...newOp, category: e.target.value})}
|
||||
onChange={(e) => setNewOp({ ...newOp, category: e.target.value })}
|
||||
>
|
||||
<option value="CV">计算机视觉 (CV)</option>
|
||||
<option value="AI">人工智能 (AI)</option>
|
||||
@ -421,22 +471,24 @@ export default function Operators() {
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">描述</label>
|
||||
<textarea
|
||||
<textarea
|
||||
placeholder="描述该算子的功能与用途..."
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm h-20 focus:outline-none focus:border-blue-500"
|
||||
value={newOp.description || ""}
|
||||
onChange={e => setNewOp({...newOp, description: e.target.value})}
|
||||
onChange={(e) => setNewOp({ ...newOp, description: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">Docker 镜像地址</label>
|
||||
<input
|
||||
type="text"
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
Docker 镜像地址
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="registry.flowai.io/operators/sharpen:v1.0"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
value={newOp.image || ""}
|
||||
onChange={e => setNewOp({...newOp, image: e.target.value})}
|
||||
onChange={(e) => setNewOp({ ...newOp, image: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -446,35 +498,40 @@ export default function Operators() {
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-3 min-w-0">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">输入端口 (Inputs)</label>
|
||||
<button type="button" onClick={() => handleAddPort('inputs')} className="text-blue-500 hover:text-blue-400 text-xs flex items-center gap-1">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
输入端口 (Inputs)
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleAddPort("inputs")}
|
||||
className="text-blue-500 hover:text-blue-400 text-xs flex items-center gap-1"
|
||||
>
|
||||
<Plus className="w-3 h-3" /> 添加
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{newOp.inputs?.map((port, idx) => (
|
||||
<div key={port.id} className="grid grid-cols-[minmax(0,1fr)_5.5rem_5rem_auto] gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="名称"
|
||||
<div
|
||||
key={port.id}
|
||||
className="grid grid-cols-[minmax(0,1fr)_5.5rem_5rem_auto] gap-2 items-center"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="名称"
|
||||
className="min-w-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-xs"
|
||||
value={port.name}
|
||||
onChange={e => updatePort('inputs', idx, { name: e.target.value })}
|
||||
onChange={(e) => updatePort("inputs", idx, { name: e.target.value })}
|
||||
/>
|
||||
<select
|
||||
<select
|
||||
className="w-full shrink-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-xs"
|
||||
value={port.type}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
const type = e.target.value as any;
|
||||
updatePort('inputs', idx, (current) => ({
|
||||
updatePort("inputs", idx, (current) => ({
|
||||
...current,
|
||||
type,
|
||||
transmission:
|
||||
type === "video" || type === "file"
|
||||
? "oss"
|
||||
: type === "tensor"
|
||||
? "stream"
|
||||
: "bus",
|
||||
type === "video" || type === "file" ? "oss" : type === "tensor" ? "stream" : "bus",
|
||||
}));
|
||||
}}
|
||||
>
|
||||
@ -484,19 +541,19 @@ export default function Operators() {
|
||||
<option value="tensor">Tensor</option>
|
||||
<option value="file">File</option>
|
||||
</select>
|
||||
<select
|
||||
<select
|
||||
className="w-full shrink-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-[10px] text-blue-400"
|
||||
value={port.transmission}
|
||||
onChange={e => updatePort('inputs', idx, { transmission: e.target.value as any })}
|
||||
onChange={(e) => updatePort("inputs", idx, { transmission: e.target.value as any })}
|
||||
>
|
||||
<option value="bus">Bus</option>
|
||||
<option value="oss">OSS</option>
|
||||
<option value="shm">SHM</option>
|
||||
<option value="stream">Stream</option>
|
||||
</select>
|
||||
<button
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removePort('inputs', idx)}
|
||||
onClick={() => removePort("inputs", idx)}
|
||||
className="shrink-0 p-1.5 text-gray-600 hover:text-red-500"
|
||||
aria-label={`删除输入端口 ${port.name || idx + 1}`}
|
||||
>
|
||||
@ -509,35 +566,40 @@ export default function Operators() {
|
||||
|
||||
<div className="space-y-3 min-w-0">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">输出端口 (Outputs)</label>
|
||||
<button type="button" onClick={() => handleAddPort('outputs')} className="text-green-500 hover:text-green-400 text-xs flex items-center gap-1">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
输出端口 (Outputs)
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleAddPort("outputs")}
|
||||
className="text-green-500 hover:text-green-400 text-xs flex items-center gap-1"
|
||||
>
|
||||
<Plus className="w-3 h-3" /> 添加
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{newOp.outputs?.map((port, idx) => (
|
||||
<div key={port.id} className="grid grid-cols-[minmax(0,1fr)_5.5rem_5rem_auto] gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="名称"
|
||||
<div
|
||||
key={port.id}
|
||||
className="grid grid-cols-[minmax(0,1fr)_5.5rem_5rem_auto] gap-2 items-center"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="名称"
|
||||
className="min-w-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-xs"
|
||||
value={port.name}
|
||||
onChange={e => updatePort('outputs', idx, { name: e.target.value })}
|
||||
onChange={(e) => updatePort("outputs", idx, { name: e.target.value })}
|
||||
/>
|
||||
<select
|
||||
<select
|
||||
className="w-full shrink-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-xs"
|
||||
value={port.type}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
const type = e.target.value as any;
|
||||
updatePort('outputs', idx, (current) => ({
|
||||
updatePort("outputs", idx, (current) => ({
|
||||
...current,
|
||||
type,
|
||||
transmission:
|
||||
type === "video" || type === "file"
|
||||
? "oss"
|
||||
: type === "tensor"
|
||||
? "stream"
|
||||
: "bus",
|
||||
type === "video" || type === "file" ? "oss" : type === "tensor" ? "stream" : "bus",
|
||||
}));
|
||||
}}
|
||||
>
|
||||
@ -547,19 +609,19 @@ export default function Operators() {
|
||||
<option value="tensor">Tensor</option>
|
||||
<option value="file">File</option>
|
||||
</select>
|
||||
<select
|
||||
<select
|
||||
className="w-full shrink-0 bg-[#0a0a0a] border border-[#2a2b2f] rounded px-2 py-1 text-[10px] text-blue-400"
|
||||
value={port.transmission}
|
||||
onChange={e => updatePort('outputs', idx, { transmission: e.target.value as any })}
|
||||
onChange={(e) => updatePort("outputs", idx, { transmission: e.target.value as any })}
|
||||
>
|
||||
<option value="bus">Bus</option>
|
||||
<option value="oss">OSS</option>
|
||||
<option value="shm">SHM</option>
|
||||
<option value="stream">Stream</option>
|
||||
</select>
|
||||
<button
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => removePort('outputs', idx)}
|
||||
onClick={() => removePort("outputs", idx)}
|
||||
className="shrink-0 p-1.5 text-gray-600 hover:text-red-500"
|
||||
aria-label={`删除输出端口 ${port.name || idx + 1}`}
|
||||
>
|
||||
@ -587,69 +649,73 @@ export default function Operators() {
|
||||
<Plus className="w-3 h-3" /> 添加参数
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="p-4 bg-orange-500/5 border border-orange-500/20 rounded-lg flex items-start gap-3 mb-4">
|
||||
<Info className="w-4 h-4 text-orange-500 mt-0.5" />
|
||||
<p className="text-[10px] text-gray-500 leading-relaxed">
|
||||
超参将作为环境变量注入到算子的 K8s Job 中。
|
||||
例如:设置 <code>CONFIDENCE_THRESHOLD</code> 为 <code>0.5</code>,
|
||||
算子代码中可以通过 <code>os.environ.get('CONFIDENCE_THRESHOLD')</code> 获取。
|
||||
超参将作为环境变量注入到算子的 K8s Job 中。 例如:设置 <code>CONFIDENCE_THRESHOLD</code> 为{" "}
|
||||
<code>0.5</code>, 算子代码中可以通过 <code>os.environ.get('CONFIDENCE_THRESHOLD')</code> 获取。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
{newOp.hyperparams?.map((hp, idx) => (
|
||||
<div key={idx} className="bg-[#0a0a0a] border border-[#2a2b2f] rounded-lg p-4 space-y-3 relative group">
|
||||
<div
|
||||
key={idx}
|
||||
className="bg-[#0a0a0a] border border-[#2a2b2f] rounded-lg p-4 space-y-3 relative group"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
const hyperparams = newOp.hyperparams?.filter((_, i) => i !== idx);
|
||||
setNewOp({...newOp, hyperparams});
|
||||
setNewOp({ ...newOp, hyperparams });
|
||||
}}
|
||||
className="absolute top-2 right-2 text-gray-600 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="space-y-1">
|
||||
<label className="text-[10px] text-gray-500 uppercase font-mono">变量名 (Key)</label>
|
||||
<input
|
||||
type="text"
|
||||
<input
|
||||
type="text"
|
||||
className="w-full bg-[#151619] border border-[#2a2b2f] rounded px-3 py-1.5 text-xs focus:outline-none focus:border-blue-500 font-mono"
|
||||
value={hp.key}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
const hyperparams = [...(newOp.hyperparams || [])];
|
||||
hyperparams[idx].key = e.target.value.toUpperCase().replace(/\s+/g, '_');
|
||||
setNewOp({...newOp, hyperparams});
|
||||
hyperparams[idx].key = e.target.value.toUpperCase().replace(/\s+/g, "_");
|
||||
setNewOp({ ...newOp, hyperparams });
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-[10px] text-gray-500 uppercase font-mono">默认值 (Default Value)</label>
|
||||
<input
|
||||
type="text"
|
||||
<label className="text-[10px] text-gray-500 uppercase font-mono">
|
||||
默认值 (Default Value)
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="w-full bg-[#151619] border border-[#2a2b2f] rounded px-3 py-1.5 text-xs focus:outline-none focus:border-blue-500"
|
||||
value={hp.value}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
const hyperparams = [...(newOp.hyperparams || [])];
|
||||
hyperparams[idx].value = e.target.value;
|
||||
setNewOp({...newOp, hyperparams});
|
||||
setNewOp({ ...newOp, hyperparams });
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-[10px] text-gray-500 uppercase font-mono">描述 (Description)</label>
|
||||
<input
|
||||
type="text"
|
||||
<input
|
||||
type="text"
|
||||
placeholder="说明该参数的作用..."
|
||||
className="w-full bg-[#151619] border border-[#2a2b2f] rounded px-3 py-1.5 text-xs focus:outline-none focus:border-blue-500"
|
||||
value={hp.description}
|
||||
onChange={e => {
|
||||
onChange={(e) => {
|
||||
const hyperparams = [...(newOp.hyperparams || [])];
|
||||
hyperparams[idx].description = e.target.value;
|
||||
setNewOp({...newOp, hyperparams});
|
||||
setNewOp({ ...newOp, hyperparams });
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -669,17 +735,19 @@ export default function Operators() {
|
||||
<div className="p-4 bg-blue-500/5 border border-blue-500/20 rounded-lg flex items-start gap-3">
|
||||
<Info className="w-4 h-4 text-blue-500 mt-0.5" />
|
||||
<p className="text-[10px] text-gray-500 leading-relaxed">
|
||||
AI Skill 描述用于向 AI 助手描述该算子的功能、输入输出要求以及使用场景。
|
||||
良好的描述能帮助 AI 更准确地在自动化工作流生成中使用该算子。
|
||||
AI Skill 描述用于向 AI 助手描述该算子的功能、输入输出要求以及使用场景。 良好的描述能帮助 AI
|
||||
更准确地在自动化工作流生成中使用该算子。
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">Skill 定义 (Markdown)</label>
|
||||
<textarea
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
Skill 定义 (Markdown)
|
||||
</label>
|
||||
<textarea
|
||||
placeholder="### 算子名称\n描述算子的核心功能...\n\n#### 使用场景\n在什么情况下应该使用该算子...\n\n#### 限制条件\n输入数据的特殊要求..."
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm h-64 font-mono focus:outline-none focus:border-blue-500"
|
||||
value={newOp.skillDefinition || ""}
|
||||
onChange={e => setNewOp({...newOp, skillDefinition: e.target.value})}
|
||||
onChange={(e) => setNewOp({ ...newOp, skillDefinition: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -715,7 +783,10 @@ export default function Operators() {
|
||||
<Sparkles className="w-5 h-5 text-blue-500" />
|
||||
<h2 className="text-xl font-bold text-white">AI 辅助注册算子</h2>
|
||||
</div>
|
||||
<button onClick={() => setIsAIModalOpen(false)} className="text-gray-500 hover:text-white transition-colors">
|
||||
<button
|
||||
onClick={() => setIsAIModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white transition-colors"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
@ -723,11 +794,11 @@ export default function Operators() {
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="space-y-3">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">描述您的算子</label>
|
||||
<textarea
|
||||
<textarea
|
||||
placeholder="例如:帮我注册一个算子,用于对输入的视频进行锐化处理。它应该接受一个视频输入,输出一个处理后的视频。它属于 CV 类别。"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-xl px-4 py-3 text-sm h-40 focus:outline-none focus:border-blue-500 transition-all resize-none leading-relaxed"
|
||||
value={aiDescription}
|
||||
onChange={e => setAiDescription(e.target.value)}
|
||||
onChange={(e) => setAiDescription(e.target.value)}
|
||||
disabled={isGenerating}
|
||||
/>
|
||||
<p className="text-[10px] text-gray-500 italic">
|
||||
@ -758,19 +829,19 @@ export default function Operators() {
|
||||
</div>
|
||||
|
||||
<div className="p-6 border-t border-[#2a2b2f] flex justify-end gap-3 bg-[#0a0a0a]/50">
|
||||
<button
|
||||
<button
|
||||
onClick={() => setIsAIModalOpen(false)}
|
||||
className="px-4 py-2 text-sm font-medium text-gray-400 hover:text-white transition-colors"
|
||||
disabled={isGenerating}
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
onClick={handleAIGenerate}
|
||||
disabled={!aiStatus.enabled || !aiDescription.trim() || isGenerating}
|
||||
className={cn(
|
||||
"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-all flex items-center gap-2",
|
||||
(!aiStatus.enabled || !aiDescription.trim() || isGenerating) && "opacity-50 cursor-not-allowed"
|
||||
(!aiStatus.enabled || !aiDescription.trim() || isGenerating) && "opacity-50 cursor-not-allowed",
|
||||
)}
|
||||
>
|
||||
{isGenerating ? (
|
||||
|
||||
@ -15,22 +15,28 @@ export default function Packages() {
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
dataPlatformApi.listPackages().then((loaded) => {
|
||||
setItems(loaded);
|
||||
if (loaded[0]) setSelected(loaded[0]);
|
||||
}).catch((error) => {
|
||||
console.error("Failed to load packages", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.listPackages()
|
||||
.then((loaded) => {
|
||||
setItems(loaded);
|
||||
if (loaded[0]) setSelected(loaded[0]);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load packages", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selected) return;
|
||||
dataPlatformApi.getPackage(selected.runId, selected.packageName).then((loaded) => {
|
||||
setDetail(loaded);
|
||||
setSelectedArtifact(loaded.package.previewArtifact || loaded.files[0] || null);
|
||||
}).catch((error) => {
|
||||
console.error("Failed to load package detail", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.getPackage(selected.runId, selected.packageName)
|
||||
.then((loaded) => {
|
||||
setDetail(loaded);
|
||||
setSelectedArtifact(loaded.package.previewArtifact || loaded.files[0] || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load package detail", error);
|
||||
});
|
||||
}, [selected]);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
@ -47,7 +53,9 @@ export default function Packages() {
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">成品数据</h1>
|
||||
<p className="mt-1 text-gray-500">直接基于真实 package run artifacts 聚合,保留来源 workflow 与 run 可追溯性。</p>
|
||||
<p className="mt-1 text-gray-500">
|
||||
直接基于真实 package run artifacts 聚合,保留来源 workflow 与 run 可追溯性。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#151619] p-4">
|
||||
@ -81,14 +89,19 @@ export default function Packages() {
|
||||
</div>
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
{item.pipelineTags.map((tag) => (
|
||||
<span key={tag} className="inline-flex items-center gap-1 rounded-full border border-[#2a2b2f] px-2.5 py-1 text-xs text-gray-300">
|
||||
<span
|
||||
key={tag}
|
||||
className="inline-flex items-center gap-1 rounded-full border border-[#2a2b2f] px-2.5 py-1 text-xs text-gray-300"
|
||||
>
|
||||
<Tag className="h-3 w-3 text-gray-500" />
|
||||
{tag}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<div className="mt-4 flex items-center justify-between text-xs text-gray-500">
|
||||
<span>{item.projectName} / {item.workflowName}</span>
|
||||
<span>
|
||||
{item.projectName} / {item.workflowName}
|
||||
</span>
|
||||
<span>{formatCompactDateTime(item.createdAt, timeZone)}</span>
|
||||
</div>
|
||||
</button>
|
||||
@ -126,7 +139,9 @@ export default function Packages() {
|
||||
>
|
||||
<div>
|
||||
<div className="text-sm text-white">{file.path}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">{file.size} · {file.metadata?.mimeType || file.type}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{file.size} · {file.metadata?.mimeType || file.type}
|
||||
</div>
|
||||
</div>
|
||||
<Boxes className="h-4 w-4 text-gray-500" />
|
||||
</button>
|
||||
@ -139,11 +154,15 @@ export default function Packages() {
|
||||
<div className="grid gap-3 text-xs md:grid-cols-2">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">质检结果</div>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-gray-100">{JSON.stringify(detail.package.quality || {}, null, 2)}</pre>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-gray-100">
|
||||
{JSON.stringify(detail.package.quality || {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-gray-500">标注结果</div>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-gray-100">{JSON.stringify(detail.package.annotation || {}, null, 2)}</pre>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-gray-100">
|
||||
{JSON.stringify(detail.package.annotation || {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
|
||||
@ -27,10 +27,7 @@ import {
|
||||
import { cn } from "../lib/utils";
|
||||
import { buildDataAssetsPath, DATA_ASSET_PACKAGES_TAB } from "../lib/data-assets.js";
|
||||
import { formatCompactDateTime } from "../lib/datetime";
|
||||
import {
|
||||
buildTemplatePayload,
|
||||
buildWorkflowCopyPayload,
|
||||
} from "../lib/templates.js";
|
||||
import { buildTemplatePayload, buildWorkflowCopyPayload } from "../lib/templates.js";
|
||||
import { buildWorkflowEditorPath } from "../lib/scan-workflows.js";
|
||||
import { countWorkflowOperators } from "../lib/workflow";
|
||||
import { Project, Workflow as WorkflowRecord } from "../types";
|
||||
@ -55,9 +52,7 @@ export default function ProjectDetail() {
|
||||
const [isAIModalOpen, setIsAIModalOpen] = useState(false);
|
||||
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
||||
const [isSaveTemplateModalOpen, setIsSaveTemplateModalOpen] = useState(false);
|
||||
const [editingWorkflow, setEditingWorkflow] = useState<WorkflowRecord | null>(
|
||||
null,
|
||||
);
|
||||
const [editingWorkflow, setEditingWorkflow] = useState<WorkflowRecord | null>(null);
|
||||
const [workflows, setWorkflows] = useState<WorkflowRecord[]>([]);
|
||||
const [newWfData, setNewWfData] = useState({
|
||||
name: "",
|
||||
@ -81,9 +76,7 @@ export default function ProjectDetail() {
|
||||
console.error("Failed to load project detail", error);
|
||||
setProject(null);
|
||||
setWorkflows([]);
|
||||
setLoadError(
|
||||
error instanceof Error ? error.message : "加载项目详情失败",
|
||||
);
|
||||
setLoadError(error instanceof Error ? error.message : "加载项目详情失败");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
@ -127,11 +120,7 @@ export default function ProjectDetail() {
|
||||
return status !== "running" && status !== "completed";
|
||||
};
|
||||
|
||||
const handleAIGenerate = (
|
||||
workflow: GeneratedWorkflow,
|
||||
name: string,
|
||||
description: string,
|
||||
) => {
|
||||
const handleAIGenerate = (workflow: GeneratedWorkflow, name: string, description: string) => {
|
||||
if (!id) return;
|
||||
projectsApi
|
||||
.createWorkflow(id, {
|
||||
@ -172,9 +161,7 @@ export default function ProjectDetail() {
|
||||
const handleDeleteWorkflow = (wfId: string) => {
|
||||
workflowsApi
|
||||
.remove(wfId)
|
||||
.then(() =>
|
||||
setWorkflows(workflows.filter((workflow) => workflow.id !== wfId)),
|
||||
)
|
||||
.then(() => setWorkflows(workflows.filter((workflow) => workflow.id !== wfId)))
|
||||
.catch((error) => console.error("Failed to delete workflow", error));
|
||||
};
|
||||
|
||||
@ -201,11 +188,7 @@ export default function ProjectDetail() {
|
||||
workflowsApi
|
||||
.update(editingWorkflow.id, editingWorkflow)
|
||||
.then((updated) => {
|
||||
setWorkflows(
|
||||
workflows.map((workflow) =>
|
||||
workflow.id === updated.id ? updated : workflow,
|
||||
),
|
||||
);
|
||||
setWorkflows(workflows.map((workflow) => (workflow.id === updated.id ? updated : workflow)));
|
||||
setIsEditModalOpen(false);
|
||||
setEditingWorkflow(null);
|
||||
})
|
||||
@ -221,8 +204,7 @@ export default function ProjectDetail() {
|
||||
setTemplateDraft({
|
||||
workflowId: defaultWorkflow.id,
|
||||
name: `${defaultWorkflow.name} 模板`,
|
||||
description:
|
||||
defaultWorkflow.description || `${project.name} 导出的工作流模板`,
|
||||
description: defaultWorkflow.description || `${project.name} 导出的工作流模板`,
|
||||
});
|
||||
setIsSaveTemplateModalOpen(true);
|
||||
};
|
||||
@ -237,9 +219,7 @@ export default function ProjectDetail() {
|
||||
};
|
||||
|
||||
const handleSaveTemplate = () => {
|
||||
const sourceWorkflow = workflows.find(
|
||||
(workflow) => workflow.id === templateDraft.workflowId,
|
||||
);
|
||||
const sourceWorkflow = workflows.find((workflow) => workflow.id === templateDraft.workflowId);
|
||||
if (!sourceWorkflow || !templateDraft.name.trim()) {
|
||||
return;
|
||||
}
|
||||
@ -254,9 +234,7 @@ export default function ProjectDetail() {
|
||||
setIsSaveTemplateModalOpen(false);
|
||||
navigate(`/workflow/${created.id}?type=template`);
|
||||
})
|
||||
.catch((error) =>
|
||||
console.error("Failed to save workflow as template", error),
|
||||
);
|
||||
.catch((error) => console.error("Failed to save workflow as template", error));
|
||||
};
|
||||
|
||||
return (
|
||||
@ -270,9 +248,7 @@ export default function ProjectDetail() {
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
</button>
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
{project.name}
|
||||
</h1>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">{project.name}</h1>
|
||||
<p className="text-gray-500 mt-1">{project.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -340,183 +316,177 @@ export default function ProjectDetail() {
|
||||
onClick={() =>
|
||||
navigate(
|
||||
(() => {
|
||||
const params = new URLSearchParams({
|
||||
projectId: project.id,
|
||||
readOnly: String(!isEditable(wf.status)),
|
||||
});
|
||||
if (wf.status === "running" && wf.lastRunId) {
|
||||
params.set("runId", wf.lastRunId);
|
||||
}
|
||||
return `/workflow/${wf.id}?${params.toString()}`;
|
||||
const params = new URLSearchParams({
|
||||
projectId: project.id,
|
||||
readOnly: String(!isEditable(wf.status)),
|
||||
});
|
||||
if (wf.status === "running" && wf.lastRunId) {
|
||||
params.set("runId", wf.lastRunId);
|
||||
}
|
||||
return `/workflow/${wf.id}?${params.toString()}`;
|
||||
})(),
|
||||
)
|
||||
}
|
||||
className="group bg-[#151619] border border-[#2a2b2f] rounded-xl p-5 hover:border-blue-500/50 transition-all cursor-pointer flex items-center gap-6"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"w-12 h-12 rounded-lg flex items-center justify-center shrink-0",
|
||||
wf.status === "completed"
|
||||
? "bg-green-500/10 text-green-500"
|
||||
: wf.status === "running"
|
||||
? "bg-blue-500/10 text-blue-500"
|
||||
: wf.status === "failed"
|
||||
? "bg-red-500/10 text-red-500"
|
||||
: "bg-gray-500/10 text-gray-500",
|
||||
)}
|
||||
>
|
||||
{wf.status === "completed" ? (
|
||||
<CheckCircle2 className="w-6 h-6" />
|
||||
) : wf.status === "running" ? (
|
||||
wf.type === "streaming" ? (
|
||||
<RefreshCw className="w-6 h-6 animate-spin" />
|
||||
) : (
|
||||
<Play className="w-6 h-6 animate-pulse" />
|
||||
)
|
||||
) : wf.status === "failed" ? (
|
||||
<XCircle className="w-6 h-6" />
|
||||
) : (
|
||||
<WorkflowIcon className="w-6 h-6" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h3 className="text-lg font-bold text-white truncate group-hover:text-blue-400 transition-colors">
|
||||
{wf.name}
|
||||
</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
wf.status === "running"
|
||||
? "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
||||
: wf.status === "completed"
|
||||
? "bg-green-500/10 text-green-500 border-green-500/20"
|
||||
: wf.status === "failed"
|
||||
? "bg-red-500/10 text-red-500 border-red-500/20"
|
||||
: "bg-gray-500/10 text-gray-500 border-gray-500/20",
|
||||
)}
|
||||
>
|
||||
{wf.status}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
wf.type === "streaming"
|
||||
? "bg-purple-500/10 text-purple-500 border-purple-500/20"
|
||||
: "bg-gray-500/10 text-gray-400 border-gray-500/20",
|
||||
)}
|
||||
>
|
||||
{wf.type === "streaming" ? "周期执行" : "手动执行"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-gray-500 truncate">{wf.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-8 shrink-0">
|
||||
<div className="text-right">
|
||||
<div className="text-xs text-gray-600 uppercase font-mono tracking-widest mb-1">
|
||||
算子数
|
||||
</div>
|
||||
<div className="inline-flex items-center gap-1.5 rounded-full border border-blue-500/20 bg-blue-500/10 px-2.5 py-1 text-sm font-medium text-blue-300">
|
||||
<Cpu className="w-3.5 h-3.5" />
|
||||
{operatorCount}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-xs text-gray-600 uppercase font-mono tracking-widest mb-1">
|
||||
最后运行
|
||||
</div>
|
||||
<div className="text-sm text-gray-400 flex items-center gap-2 justify-end">
|
||||
<Clock className="w-3.5 h-3.5" />
|
||||
{wf.lastRunAt
|
||||
? formatCompactDateTime(wf.lastRunAt, timeZone)
|
||||
: wf.lastRun || "未运行"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all",
|
||||
isEditable(wf.status) && canManage
|
||||
? "bg-blue-600/10 text-blue-500"
|
||||
: "bg-gray-600/10 text-gray-500",
|
||||
)}
|
||||
>
|
||||
{isEditable(wf.status) && canManage ? (
|
||||
<>
|
||||
<Edit3 className="w-4 h-4" />
|
||||
编辑
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Eye className="w-4 h-4" />
|
||||
查看
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{canManage && (
|
||||
<>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(
|
||||
buildDataAssetsPath({
|
||||
tab: DATA_ASSET_PACKAGES_TAB,
|
||||
projectId: project.id,
|
||||
projectName: project.name,
|
||||
workflowId: wf.id,
|
||||
workflowName: wf.name,
|
||||
runId: wf.lastRunId || "",
|
||||
}),
|
||||
);
|
||||
}}
|
||||
title="查看相关数据资产"
|
||||
>
|
||||
<Database className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleEditInfo(wf);
|
||||
}}
|
||||
title="编辑基本信息"
|
||||
>
|
||||
<Settings2 className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleCopyWorkflow(wf);
|
||||
}}
|
||||
title="复制工作流"
|
||||
>
|
||||
<Copy className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-red-500/10 rounded-md text-gray-500 hover:text-red-500 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleDeleteWorkflow(wf.id);
|
||||
}}
|
||||
title="删除工作流"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
</>
|
||||
<div
|
||||
className={cn(
|
||||
"w-12 h-12 rounded-lg flex items-center justify-center shrink-0",
|
||||
wf.status === "completed"
|
||||
? "bg-green-500/10 text-green-500"
|
||||
: wf.status === "running"
|
||||
? "bg-blue-500/10 text-blue-500"
|
||||
: wf.status === "failed"
|
||||
? "bg-red-500/10 text-red-500"
|
||||
: "bg-gray-500/10 text-gray-500",
|
||||
)}
|
||||
<div className="w-8 h-8 flex items-center justify-center text-blue-500 opacity-0 group-hover:opacity-100 group-hover:translate-x-1 transition-all">
|
||||
<ArrowRight className="w-5 h-5" />
|
||||
>
|
||||
{wf.status === "completed" ? (
|
||||
<CheckCircle2 className="w-6 h-6" />
|
||||
) : wf.status === "running" ? (
|
||||
wf.type === "streaming" ? (
|
||||
<RefreshCw className="w-6 h-6 animate-spin" />
|
||||
) : (
|
||||
<Play className="w-6 h-6 animate-pulse" />
|
||||
)
|
||||
) : wf.status === "failed" ? (
|
||||
<XCircle className="w-6 h-6" />
|
||||
) : (
|
||||
<WorkflowIcon className="w-6 h-6" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h3 className="text-lg font-bold text-white truncate group-hover:text-blue-400 transition-colors">
|
||||
{wf.name}
|
||||
</h3>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
wf.status === "running"
|
||||
? "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
||||
: wf.status === "completed"
|
||||
? "bg-green-500/10 text-green-500 border-green-500/20"
|
||||
: wf.status === "failed"
|
||||
? "bg-red-500/10 text-red-500 border-red-500/20"
|
||||
: "bg-gray-500/10 text-gray-500 border-gray-500/20",
|
||||
)}
|
||||
>
|
||||
{wf.status}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
wf.type === "streaming"
|
||||
? "bg-purple-500/10 text-purple-500 border-purple-500/20"
|
||||
: "bg-gray-500/10 text-gray-400 border-gray-500/20",
|
||||
)}
|
||||
>
|
||||
{wf.type === "streaming" ? "周期执行" : "手动执行"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-gray-500 truncate">{wf.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-8 shrink-0">
|
||||
<div className="text-right">
|
||||
<div className="text-xs text-gray-600 uppercase font-mono tracking-widest mb-1">算子数</div>
|
||||
<div className="inline-flex items-center gap-1.5 rounded-full border border-blue-500/20 bg-blue-500/10 px-2.5 py-1 text-sm font-medium text-blue-300">
|
||||
<Cpu className="w-3.5 h-3.5" />
|
||||
{operatorCount}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-xs text-gray-600 uppercase font-mono tracking-widest mb-1">最后运行</div>
|
||||
<div className="text-sm text-gray-400 flex items-center gap-2 justify-end">
|
||||
<Clock className="w-3.5 h-3.5" />
|
||||
{wf.lastRunAt ? formatCompactDateTime(wf.lastRunAt, timeZone) : wf.lastRun || "未运行"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all",
|
||||
isEditable(wf.status) && canManage
|
||||
? "bg-blue-600/10 text-blue-500"
|
||||
: "bg-gray-600/10 text-gray-500",
|
||||
)}
|
||||
>
|
||||
{isEditable(wf.status) && canManage ? (
|
||||
<>
|
||||
<Edit3 className="w-4 h-4" />
|
||||
编辑
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Eye className="w-4 h-4" />
|
||||
查看
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{canManage && (
|
||||
<>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(
|
||||
buildDataAssetsPath({
|
||||
tab: DATA_ASSET_PACKAGES_TAB,
|
||||
projectId: project.id,
|
||||
projectName: project.name,
|
||||
workflowId: wf.id,
|
||||
workflowName: wf.name,
|
||||
runId: wf.lastRunId || "",
|
||||
}),
|
||||
);
|
||||
}}
|
||||
title="查看相关数据资产"
|
||||
>
|
||||
<Database className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleEditInfo(wf);
|
||||
}}
|
||||
title="编辑基本信息"
|
||||
>
|
||||
<Settings2 className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-blue-500/10 rounded-md text-gray-500 hover:text-blue-400 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleCopyWorkflow(wf);
|
||||
}}
|
||||
title="复制工作流"
|
||||
>
|
||||
<Copy className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
className="p-2 hover:bg-red-500/10 rounded-md text-gray-500 hover:text-red-500 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleDeleteWorkflow(wf.id);
|
||||
}}
|
||||
title="删除工作流"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
<div className="w-8 h-8 flex items-center justify-center text-blue-500 opacity-0 group-hover:opacity-100 group-hover:translate-x-1 transition-all">
|
||||
<ArrowRight className="w-5 h-5" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{workflows.length === 0 && (
|
||||
@ -531,13 +501,8 @@ export default function ProjectDetail() {
|
||||
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm">
|
||||
<div className="bg-[#151619] border border-[#2a2b2f] rounded-2xl w-full max-w-md shadow-2xl">
|
||||
<div className="px-6 py-4 border-b border-[#2a2b2f] flex items-center justify-between">
|
||||
<h2 className="text-xl font-bold text-white">
|
||||
创建新工作流
|
||||
</h2>
|
||||
<button
|
||||
onClick={() => setIsNewWorkflowModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white"
|
||||
>
|
||||
<h2 className="text-xl font-bold text-white">创建新工作流</h2>
|
||||
<button onClick={() => setIsNewWorkflowModalOpen(false)} className="text-gray-500 hover:text-white">
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
@ -556,19 +521,15 @@ export default function ProjectDetail() {
|
||||
placeholder="例如: 实时障碍物检测"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
value={newWfData.name}
|
||||
onChange={(e) =>
|
||||
setNewWfData({ ...newWfData, name: e.target.value })
|
||||
}
|
||||
onChange={(e) => setNewWfData({ ...newWfData, name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#0a0a0a] px-4 py-3">
|
||||
<div className="text-sm font-medium text-white">
|
||||
默认先创建普通工作流
|
||||
</div>
|
||||
<div className="text-sm font-medium text-white">默认先创建普通工作流</div>
|
||||
<div className="mt-1 text-[11px] text-gray-500">
|
||||
创建后请在“工作流配置”里设置触发方式。如果流程需要源数据扫描,
|
||||
直接把“BOS 增量扫描”算子拖到画布;FULL/INCREMENTAL、连接信息和扫描路径都在该节点中配置。
|
||||
创建后请在“工作流配置”里设置触发方式。如果流程需要源数据扫描, 直接把“BOS
|
||||
增量扫描”算子拖到画布;FULL/INCREMENTAL、连接信息和扫描路径都在该节点中配置。
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -594,11 +555,7 @@ export default function ProjectDetail() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<AIGenerateModal
|
||||
isOpen={isAIModalOpen}
|
||||
onClose={() => setIsAIModalOpen(false)}
|
||||
onGenerate={handleAIGenerate}
|
||||
/>
|
||||
<AIGenerateModal isOpen={isAIModalOpen} onClose={() => setIsAIModalOpen(false)} onGenerate={handleAIGenerate} />
|
||||
|
||||
{isSaveTemplateModalOpen && (
|
||||
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm">
|
||||
@ -617,14 +574,10 @@ export default function ProjectDetail() {
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
来源工作流
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">来源工作流</label>
|
||||
<select
|
||||
value={templateDraft.workflowId}
|
||||
onChange={(event) =>
|
||||
handleTemplateWorkflowChange(event.target.value)
|
||||
}
|
||||
onChange={(event) => handleTemplateWorkflowChange(event.target.value)}
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
>
|
||||
{workflows.map((workflow) => (
|
||||
@ -635,9 +588,7 @@ export default function ProjectDetail() {
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
模板名称
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">模板名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={templateDraft.name}
|
||||
@ -651,9 +602,7 @@ export default function ProjectDetail() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
模板描述
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">模板描述</label>
|
||||
<textarea
|
||||
rows={4}
|
||||
value={templateDraft.description}
|
||||
@ -676,13 +625,10 @@ export default function ProjectDetail() {
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSaveTemplate}
|
||||
disabled={
|
||||
!templateDraft.workflowId || !templateDraft.name.trim()
|
||||
}
|
||||
disabled={!templateDraft.workflowId || !templateDraft.name.trim()}
|
||||
className={cn(
|
||||
"px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors",
|
||||
(!templateDraft.workflowId || !templateDraft.name.trim()) &&
|
||||
"opacity-50 cursor-not-allowed",
|
||||
(!templateDraft.workflowId || !templateDraft.name.trim()) && "opacity-50 cursor-not-allowed",
|
||||
)}
|
||||
>
|
||||
保存模板
|
||||
@ -698,18 +644,13 @@ export default function ProjectDetail() {
|
||||
<div className="bg-[#151619] border border-[#2a2b2f] rounded-2xl w-full max-w-md shadow-2xl">
|
||||
<div className="px-6 py-4 border-b border-[#2a2b2f] flex items-center justify-between">
|
||||
<h2 className="text-xl font-bold text-white">编辑工作流信息</h2>
|
||||
<button
|
||||
onClick={() => setIsEditModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white"
|
||||
>
|
||||
<button onClick={() => setIsEditModalOpen(false)} className="text-gray-500 hover:text-white">
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
工作流名称
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">工作流名称</label>
|
||||
<input
|
||||
type="text"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
@ -723,9 +664,7 @@ export default function ProjectDetail() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
描述
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">描述</label>
|
||||
<textarea
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm h-24 focus:outline-none focus:border-blue-500 text-white resize-none"
|
||||
value={editingWorkflow.description}
|
||||
|
||||
@ -27,9 +27,7 @@ export default function Projects() {
|
||||
const { role } = useUser();
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [statusFilter, setStatusFilter] = useState<
|
||||
"all" | "active" | "archived"
|
||||
>("all");
|
||||
const [statusFilter, setStatusFilter] = useState<"all" | "active" | "archived">("all");
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const [modalMode, setModalMode] = useState<"create" | "edit">("create");
|
||||
@ -103,8 +101,7 @@ export default function Projects() {
|
||||
.filter(Boolean)
|
||||
.some((value) => value.toLowerCase().includes(normalizedSearch));
|
||||
const projectStatus = project.status || "active";
|
||||
const matchesStatus =
|
||||
statusFilter === "all" || projectStatus === statusFilter;
|
||||
const matchesStatus = statusFilter === "all" || projectStatus === statusFilter;
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
|
||||
@ -122,13 +119,7 @@ export default function Projects() {
|
||||
} else {
|
||||
projectsApi
|
||||
.update(currentProject.id as string, currentProject)
|
||||
.then((updated) =>
|
||||
setProjects(
|
||||
projects.map((project) =>
|
||||
project.id === updated.id ? updated : project,
|
||||
),
|
||||
),
|
||||
)
|
||||
.then((updated) => setProjects(projects.map((project) => (project.id === updated.id ? updated : project))))
|
||||
.catch((error) => console.error("Failed to update project", error));
|
||||
}
|
||||
setIsModalOpen(false);
|
||||
@ -138,12 +129,8 @@ export default function Projects() {
|
||||
<div className="space-y-8 relative">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
项目管理
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
在 Drobodata 中管理您的具身智能数据处理项目
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">项目管理</h1>
|
||||
<p className="text-gray-500 mt-1">在 Drobodata 中管理您的具身智能数据处理项目</p>
|
||||
</div>
|
||||
{canManage && (
|
||||
<button
|
||||
@ -169,9 +156,7 @@ export default function Projects() {
|
||||
</div>
|
||||
<select
|
||||
value={statusFilter}
|
||||
onChange={(event) =>
|
||||
setStatusFilter(event.target.value as typeof statusFilter)
|
||||
}
|
||||
onChange={(event) => setStatusFilter(event.target.value as typeof statusFilter)}
|
||||
className="bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
>
|
||||
<option value="all">所有状态</option>
|
||||
@ -197,9 +182,7 @@ export default function Projects() {
|
||||
className="text-gray-500 hover:text-white p-1 rounded-md hover:bg-white/5 transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setOpenMenuId(
|
||||
openMenuId === project.id ? null : project.id,
|
||||
);
|
||||
setOpenMenuId(openMenuId === project.id ? null : project.id);
|
||||
}}
|
||||
>
|
||||
<MoreVertical className="w-5 h-5" />
|
||||
@ -243,12 +226,8 @@ export default function Projects() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<h3 className="text-lg font-bold text-white mb-2">
|
||||
{project.name}
|
||||
</h3>
|
||||
<p className="text-gray-400 text-sm line-clamp-2 mb-6">
|
||||
{project.description}
|
||||
</p>
|
||||
<h3 className="text-lg font-bold text-white mb-2">{project.name}</h3>
|
||||
<p className="text-gray-400 text-sm line-clamp-2 mb-6">{project.description}</p>
|
||||
<div className="mb-5 flex items-center gap-2">
|
||||
<span className="inline-flex items-center gap-1 rounded-full border border-blue-500/20 bg-blue-500/10 px-2.5 py-1 text-xs font-medium text-blue-300">
|
||||
<WorkflowIcon className="w-3.5 h-3.5" />
|
||||
@ -270,9 +249,7 @@ export default function Projects() {
|
||||
))}
|
||||
{filteredProjects.length === 0 && (
|
||||
<div className="col-span-full bg-[#151619] border border-[#2a2b2f] rounded-xl p-12 text-center text-gray-500">
|
||||
{projects.length === 0
|
||||
? "当前还没有项目,请先创建真实项目。"
|
||||
: "没有匹配的项目,请调整筛选条件。"}
|
||||
{projects.length === 0 ? "当前还没有项目,请先创建真实项目。" : "没有匹配的项目,请调整筛选条件。"}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@ -299,9 +276,7 @@ export default function Projects() {
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
项目名称
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">项目名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={currentProject.name}
|
||||
@ -317,9 +292,7 @@ export default function Projects() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
项目描述
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">项目描述</label>
|
||||
<textarea
|
||||
rows={4}
|
||||
value={currentProject.description}
|
||||
@ -366,9 +339,7 @@ export default function Projects() {
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-white">确认删除项目?</h2>
|
||||
<p className="text-sm text-gray-500 mt-2">
|
||||
此操作不可撤销。该项目及其关联的所有工作流都将被永久删除。
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 mt-2">此操作不可撤销。该项目及其关联的所有工作流都将被永久删除。</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-6 border-t border-[#2a2b2f] flex gap-3 bg-[#0a0a0a]/50">
|
||||
|
||||
@ -23,15 +23,18 @@ export default function Sampling() {
|
||||
const [review, setReview] = useState(emptyReview);
|
||||
|
||||
const loadTasks = () => {
|
||||
dataPlatformApi.listSamplingTasks().then((loaded) => {
|
||||
setTasks(loaded);
|
||||
if (loaded[0]) {
|
||||
setSelectedTask(loaded[0]);
|
||||
setSelectedItem(loaded[0].items.find((item) => item.status === "pending") || loaded[0].items[0] || null);
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error("Failed to load sampling tasks", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.listSamplingTasks()
|
||||
.then((loaded) => {
|
||||
setTasks(loaded);
|
||||
if (loaded[0]) {
|
||||
setSelectedTask(loaded[0]);
|
||||
setSelectedItem(loaded[0].items.find((item) => item.status === "pending") || loaded[0].items[0] || null);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load sampling tasks", error);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@ -40,10 +43,11 @@ export default function Sampling() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedTask) return;
|
||||
const nextItem = selectedTask.items.find((item) => item.id === selectedItem?.id)
|
||||
|| selectedTask.items.find((item) => item.status === "pending")
|
||||
|| selectedTask.items[0]
|
||||
|| null;
|
||||
const nextItem =
|
||||
selectedTask.items.find((item) => item.id === selectedItem?.id) ||
|
||||
selectedTask.items.find((item) => item.status === "pending") ||
|
||||
selectedTask.items[0] ||
|
||||
null;
|
||||
setSelectedItem(nextItem);
|
||||
}, [selectedTask]);
|
||||
|
||||
@ -63,7 +67,11 @@ export default function Sampling() {
|
||||
const updated = await dataPlatformApi.reviewSamplingItem(selectedItem.id, review);
|
||||
setTasks((current) => current.map((task) => (task.id === updated.id ? updated : task)));
|
||||
setSelectedTask(updated);
|
||||
setSelectedItem(updated.items.find((item) => item.status === "pending") || updated.items.find((item) => item.id === selectedItem.id) || null);
|
||||
setSelectedItem(
|
||||
updated.items.find((item) => item.status === "pending") ||
|
||||
updated.items.find((item) => item.id === selectedItem.id) ||
|
||||
null,
|
||||
);
|
||||
setReview(emptyReview);
|
||||
} catch (error) {
|
||||
console.error("Failed to review sampling item", error);
|
||||
@ -74,7 +82,9 @@ export default function Sampling() {
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">抽检任务</h1>
|
||||
<p className="mt-1 text-gray-500">基于真实 `audit-samples.json` 自动生成的人工抽检任务,评审结果会持久化保存。</p>
|
||||
<p className="mt-1 text-gray-500">
|
||||
基于真实 `audit-samples.json` 自动生成的人工抽检任务,评审结果会持久化保存。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#151619] p-4">
|
||||
@ -100,14 +110,20 @@ export default function Sampling() {
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-base font-semibold text-white">{task.name}</div>
|
||||
<div className="mt-1 truncate text-sm text-gray-500">{task.projectName} / {task.workflowName}</div>
|
||||
<div className="mt-1 truncate text-sm text-gray-500">
|
||||
{task.projectName} / {task.workflowName}
|
||||
</div>
|
||||
</div>
|
||||
<span className={`rounded-full px-2 py-1 text-xs ${task.status === "completed" ? "bg-green-500/10 text-green-400" : "bg-orange-500/10 text-orange-400"}`}>
|
||||
<span
|
||||
className={`rounded-full px-2 py-1 text-xs ${task.status === "completed" ? "bg-green-500/10 text-green-400" : "bg-orange-500/10 text-orange-400"}`}
|
||||
>
|
||||
{task.status === "completed" ? "已完成" : "待处理"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center justify-between text-xs text-gray-500">
|
||||
<span>{task.items.filter((item) => item.status === "completed").length}/{task.items.length} 已评审</span>
|
||||
<span>
|
||||
{task.items.filter((item) => item.status === "completed").length}/{task.items.length} 已评审
|
||||
</span>
|
||||
<span>{formatCompactDateTime(task.createdAt, timeZone)}</span>
|
||||
</div>
|
||||
</button>
|
||||
@ -126,9 +142,13 @@ export default function Sampling() {
|
||||
<ClipboardList className="mt-0.5 h-4 w-4 text-blue-400" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-sm text-white">{item.packageName}</div>
|
||||
<div className="mt-1 truncate text-xs text-gray-500">{item.sourceVideo} · 规则 {item.sampleRuleId || "-"}</div>
|
||||
<div className="mt-1 truncate text-xs text-gray-500">
|
||||
{item.sourceVideo} · 规则 {item.sampleRuleId || "-"}
|
||||
</div>
|
||||
</div>
|
||||
<span className={`rounded-full px-2 py-1 text-[10px] ${item.status === "completed" ? "bg-green-500/10 text-green-400" : "bg-orange-500/10 text-orange-400"}`}>
|
||||
<span
|
||||
className={`rounded-full px-2 py-1 text-[10px] ${item.status === "completed" ? "bg-green-500/10 text-green-400" : "bg-orange-500/10 text-orange-400"}`}
|
||||
>
|
||||
{item.status === "completed" ? "已评审" : "待评审"}
|
||||
</span>
|
||||
</button>
|
||||
@ -158,43 +178,76 @@ export default function Sampling() {
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-xs uppercase tracking-wider text-gray-500">质检</div>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-xs text-gray-100">{JSON.stringify(selectedItem.quality || {}, null, 2)}</pre>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-xs text-gray-100">
|
||||
{JSON.stringify(selectedItem.quality || {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
<div className="rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="text-xs uppercase tracking-wider text-gray-500">标注</div>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-xs text-gray-100">{JSON.stringify(selectedItem.annotation || {}, null, 2)}</pre>
|
||||
<pre className="mt-2 whitespace-pre-wrap break-all text-xs text-gray-100">
|
||||
{JSON.stringify(selectedItem.annotation || {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{selectedItem.status === "completed" && selectedItem.review ? (
|
||||
<div className="rounded-xl border border-green-500/20 bg-green-500/5 p-4 text-sm text-green-200">
|
||||
已评审:{selectedItem.review.overallGrade} · {selectedItem.review.videoQuality} / {selectedItem.review.annotationAccuracy} / {selectedItem.review.annotationCompleteness}
|
||||
已评审:{selectedItem.review.overallGrade} · {selectedItem.review.videoQuality} /{" "}
|
||||
{selectedItem.review.annotationAccuracy} / {selectedItem.review.annotationCompleteness}
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-4 rounded-xl border border-[#2a2b2f] bg-[#101114] p-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<label className="space-y-2 text-sm">
|
||||
<span className="text-gray-400">视频质量</span>
|
||||
<select value={review.videoQuality} onChange={(event) => setReview((current) => ({ ...current, videoQuality: event.target.value }))} className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white">
|
||||
{["合格", "不合格"].map((option) => <option key={option}>{option}</option>)}
|
||||
<select
|
||||
value={review.videoQuality}
|
||||
onChange={(event) => setReview((current) => ({ ...current, videoQuality: event.target.value }))}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white"
|
||||
>
|
||||
{["合格", "不合格"].map((option) => (
|
||||
<option key={option}>{option}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-2 text-sm">
|
||||
<span className="text-gray-400">标注准确性</span>
|
||||
<select value={review.annotationAccuracy} onChange={(event) => setReview((current) => ({ ...current, annotationAccuracy: event.target.value }))} className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white">
|
||||
{["正确", "不正确"].map((option) => <option key={option}>{option}</option>)}
|
||||
<select
|
||||
value={review.annotationAccuracy}
|
||||
onChange={(event) =>
|
||||
setReview((current) => ({ ...current, annotationAccuracy: event.target.value }))
|
||||
}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white"
|
||||
>
|
||||
{["正确", "不正确"].map((option) => (
|
||||
<option key={option}>{option}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-2 text-sm">
|
||||
<span className="text-gray-400">标注完整性</span>
|
||||
<select value={review.annotationCompleteness} onChange={(event) => setReview((current) => ({ ...current, annotationCompleteness: event.target.value }))} className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white">
|
||||
{["完整", "不完整"].map((option) => <option key={option}>{option}</option>)}
|
||||
<select
|
||||
value={review.annotationCompleteness}
|
||||
onChange={(event) =>
|
||||
setReview((current) => ({ ...current, annotationCompleteness: event.target.value }))
|
||||
}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white"
|
||||
>
|
||||
{["完整", "不完整"].map((option) => (
|
||||
<option key={option}>{option}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="space-y-2 text-sm">
|
||||
<span className="text-gray-400">总体评价</span>
|
||||
<select value={review.overallGrade} onChange={(event) => setReview((current) => ({ ...current, overallGrade: event.target.value }))} className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white">
|
||||
{["A", "B", "C", "D"].map((option) => <option key={option}>{option}</option>)}
|
||||
<select
|
||||
value={review.overallGrade}
|
||||
onChange={(event) => setReview((current) => ({ ...current, overallGrade: event.target.value }))}
|
||||
className="w-full rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-white"
|
||||
>
|
||||
{["A", "B", "C", "D"].map((option) => (
|
||||
<option key={option}>{option}</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
@ -208,7 +261,10 @@ export default function Sampling() {
|
||||
/>
|
||||
</label>
|
||||
<div className="flex justify-end">
|
||||
<button onClick={submitReview} className="inline-flex items-center gap-2 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700">
|
||||
<button
|
||||
onClick={submitReview}
|
||||
className="inline-flex items-center gap-2 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700"
|
||||
>
|
||||
<Send className="h-4 w-4" />
|
||||
提交抽检结果
|
||||
</button>
|
||||
|
||||
@ -1,21 +1,7 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
AlertCircle,
|
||||
Bot,
|
||||
CheckCircle2,
|
||||
Clock3,
|
||||
Cpu,
|
||||
Loader2,
|
||||
Save,
|
||||
Server,
|
||||
} from "lucide-react";
|
||||
import { AlertCircle, Bot, CheckCircle2, Clock3, Cpu, Loader2, Save, Server } from "lucide-react";
|
||||
import { useTimeZone } from "../context/TimeZoneContext";
|
||||
import {
|
||||
COMMON_TIME_ZONES,
|
||||
formatCompactDateTime,
|
||||
formatDateTime,
|
||||
resolveTimeZone,
|
||||
} from "../lib/datetime";
|
||||
import { COMMON_TIME_ZONES, formatCompactDateTime, formatDateTime, resolveTimeZone } from "../lib/datetime";
|
||||
import { buildSettingsUpdatePayload } from "../lib/settings.js";
|
||||
import { settingsApi } from "../services/api/settings";
|
||||
import type { SystemConfig } from "../types";
|
||||
@ -41,9 +27,7 @@ export default function Settings() {
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load settings", error);
|
||||
setErrorMessage(
|
||||
error instanceof Error ? error.message : "加载系统配置失败",
|
||||
);
|
||||
setErrorMessage(error instanceof Error ? error.message : "加载系统配置失败");
|
||||
});
|
||||
}, []);
|
||||
|
||||
@ -66,9 +50,7 @@ export default function Settings() {
|
||||
} catch (error) {
|
||||
console.error("Failed to save settings", error);
|
||||
setSaveState("error");
|
||||
setErrorMessage(
|
||||
error instanceof Error ? error.message : "保存系统配置失败",
|
||||
);
|
||||
setErrorMessage(error instanceof Error ? error.message : "保存系统配置失败");
|
||||
}
|
||||
};
|
||||
|
||||
@ -76,12 +58,8 @@ export default function Settings() {
|
||||
return (
|
||||
<div className="max-w-4xl space-y-6">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
系统配置
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
配置 Kubernetes 集群、Worker 调度、显示时区、AI 生成服务及默认资源限制
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">系统配置</h1>
|
||||
<p className="text-gray-500 mt-1">配置 Kubernetes 集群、Worker 调度、显示时区、AI 生成服务及默认资源限制</p>
|
||||
</div>
|
||||
<div className="bg-[#151619] border border-[#2a2b2f] rounded-xl p-8 flex items-center gap-3 text-gray-400">
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
@ -97,24 +75,17 @@ export default function Settings() {
|
||||
);
|
||||
}
|
||||
|
||||
const savedAIKeyExists =
|
||||
Boolean(config.ai.hasAPIKey) &&
|
||||
!(config.ai.apiKey && config.ai.apiKey.trim().length > 0);
|
||||
const savedAIKeyExists = Boolean(config.ai.hasAPIKey) && !(config.ai.apiKey && config.ai.apiKey.trim().length > 0);
|
||||
const savedKubeconfigExists =
|
||||
Boolean(config.k8s.hasKubeconfig) &&
|
||||
!(config.k8s.kubeconfig && config.k8s.kubeconfig.trim().length > 0);
|
||||
Boolean(config.k8s.hasKubeconfig) && !(config.k8s.kubeconfig && config.k8s.kubeconfig.trim().length > 0);
|
||||
const savedAIKeyPreview = config.ai.apiKeyPreview?.trim() || "";
|
||||
const savedKubeconfigPreview = config.k8s.kubeconfigPreview?.trim() || "";
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl space-y-8">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
系统配置
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
配置 Kubernetes 集群、Worker 调度、显示时区、AI 生成服务及默认资源限制
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">系统配置</h1>
|
||||
<p className="text-gray-500 mt-1">配置 Kubernetes 集群、Worker 调度、显示时区、AI 生成服务及默认资源限制</p>
|
||||
</div>
|
||||
|
||||
{errorMessage && (
|
||||
@ -142,9 +113,7 @@ export default function Settings() {
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
集群 Endpoint
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">集群 Endpoint</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.k8s.endpoint || ""}
|
||||
@ -165,9 +134,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
默认命名空间
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">默认命名空间</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.k8s.namespace}
|
||||
@ -188,9 +155,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
默认 GPU 数量
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">默认 GPU 数量</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.defaults.gpuLimit || ""}
|
||||
@ -214,9 +179,7 @@ export default function Settings() {
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
共享 PVC 名称
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">共享 PVC 名称</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.k8s.workspacePVCName || ""}
|
||||
@ -237,9 +200,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
共享挂载路径
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">共享挂载路径</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.k8s.workspaceMountPath || ""}
|
||||
@ -270,12 +231,8 @@ export default function Settings() {
|
||||
</label>
|
||||
{savedKubeconfigPreview ? (
|
||||
<div className="rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-4 py-3">
|
||||
<p className="text-[11px] uppercase tracking-wider text-gray-500">
|
||||
仅回显前后缀
|
||||
</p>
|
||||
<p className="mt-2 break-all text-xs font-mono text-gray-200">
|
||||
{savedKubeconfigPreview}
|
||||
</p>
|
||||
<p className="text-[11px] uppercase tracking-wider text-gray-500">仅回显前后缀</p>
|
||||
<p className="mt-2 break-all text-xs font-mono text-gray-200">{savedKubeconfigPreview}</p>
|
||||
</div>
|
||||
) : null}
|
||||
<p className="text-[11px] font-medium text-gray-500 uppercase tracking-wider">
|
||||
@ -292,9 +249,7 @@ export default function Settings() {
|
||||
k8s: {
|
||||
...current.k8s,
|
||||
kubeconfig: event.target.value,
|
||||
hasKubeconfig:
|
||||
current.k8s.hasKubeconfig ||
|
||||
event.target.value.trim().length > 0,
|
||||
hasKubeconfig: current.k8s.hasKubeconfig || event.target.value.trim().length > 0,
|
||||
},
|
||||
}
|
||||
: current,
|
||||
@ -324,9 +279,7 @@ export default function Settings() {
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
轮询间隔 (ms)
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">轮询间隔 (ms)</label>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
@ -338,9 +291,7 @@ export default function Settings() {
|
||||
...current,
|
||||
worker: {
|
||||
...current.worker,
|
||||
pollIntervalMs:
|
||||
Number(event.target.value) ||
|
||||
current.worker.pollIntervalMs,
|
||||
pollIntervalMs: Number(event.target.value) || current.worker.pollIntervalMs,
|
||||
},
|
||||
}
|
||||
: current,
|
||||
@ -350,9 +301,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
默认最大并发数
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">默认最大并发数</label>
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
@ -364,9 +313,7 @@ export default function Settings() {
|
||||
...current,
|
||||
worker: {
|
||||
...current.worker,
|
||||
maxConcurrentRuns:
|
||||
Number(event.target.value) ||
|
||||
current.worker.maxConcurrentRuns,
|
||||
maxConcurrentRuns: Number(event.target.value) || current.worker.maxConcurrentRuns,
|
||||
},
|
||||
}
|
||||
: current,
|
||||
@ -480,19 +427,13 @@ export default function Settings() {
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
IANA 时区
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">IANA 时区</label>
|
||||
<input
|
||||
list="system-timezone-options"
|
||||
type="text"
|
||||
value={config.timezone}
|
||||
onChange={(event) =>
|
||||
setConfig((current) =>
|
||||
current
|
||||
? { ...current, timezone: event.target.value }
|
||||
: current,
|
||||
)
|
||||
setConfig((current) => (current ? { ...current, timezone: event.target.value } : current))
|
||||
}
|
||||
placeholder="例如 Asia/Shanghai"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-amber-400"
|
||||
@ -517,9 +458,7 @@ export default function Settings() {
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
Provider
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">Provider</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.ai.provider}
|
||||
@ -537,9 +476,7 @@ export default function Settings() {
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
模型
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">模型</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.ai.model}
|
||||
@ -558,9 +495,7 @@ export default function Settings() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
OpenAI 兼容 Base URL
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">OpenAI 兼容 Base URL</label>
|
||||
<input
|
||||
type="text"
|
||||
value={config.ai.baseURL}
|
||||
@ -583,12 +518,8 @@ export default function Settings() {
|
||||
</label>
|
||||
{savedAIKeyPreview ? (
|
||||
<div className="rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-4 py-3">
|
||||
<p className="text-[11px] uppercase tracking-wider text-gray-500">
|
||||
仅回显前后缀
|
||||
</p>
|
||||
<p className="mt-2 break-all font-mono text-sm text-gray-200">
|
||||
{savedAIKeyPreview}
|
||||
</p>
|
||||
<p className="text-[11px] uppercase tracking-wider text-gray-500">仅回显前后缀</p>
|
||||
<p className="mt-2 break-all font-mono text-sm text-gray-200">{savedAIKeyPreview}</p>
|
||||
</div>
|
||||
) : null}
|
||||
<p className="text-[11px] font-medium text-gray-500 uppercase tracking-wider">
|
||||
@ -597,11 +528,7 @@ export default function Settings() {
|
||||
<input
|
||||
type="password"
|
||||
value={config.ai.apiKey || ""}
|
||||
placeholder={
|
||||
savedAIKeyExists
|
||||
? "输入新 Key;留空表示保持不变"
|
||||
: "输入服务端 AI Key"
|
||||
}
|
||||
placeholder={savedAIKeyExists ? "输入新 Key;留空表示保持不变" : "输入服务端 AI Key"}
|
||||
onChange={(event) =>
|
||||
setConfig((current) =>
|
||||
current
|
||||
@ -610,9 +537,7 @@ export default function Settings() {
|
||||
ai: {
|
||||
...current.ai,
|
||||
apiKey: event.target.value,
|
||||
hasAPIKey:
|
||||
current.ai.hasAPIKey ||
|
||||
event.target.value.trim().length > 0,
|
||||
hasAPIKey: current.ai.hasAPIKey || event.target.value.trim().length > 0,
|
||||
},
|
||||
}
|
||||
: current,
|
||||
@ -632,23 +557,14 @@ export default function Settings() {
|
||||
|
||||
<div className="flex items-center justify-between pt-4">
|
||||
<p className="text-xs text-gray-500">
|
||||
最近更新时间:{" "}
|
||||
{formatCompactDateTime(
|
||||
config.updatedAt,
|
||||
config.timezone,
|
||||
"尚未保存",
|
||||
)}
|
||||
最近更新时间: {formatCompactDateTime(config.updatedAt, config.timezone, "尚未保存")}
|
||||
</p>
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={saveState === "saving"}
|
||||
className="flex items-center gap-2 bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md text-sm font-medium transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
>
|
||||
{saveState === "saving" ? (
|
||||
<Loader2 className="w-4 h-4 animate-spin" />
|
||||
) : (
|
||||
<Save className="w-4 h-4" />
|
||||
)}
|
||||
{saveState === "saving" ? <Loader2 className="w-4 h-4 animate-spin" /> : <Save className="w-4 h-4" />}
|
||||
{saveState === "saving" ? "正在保存..." : "保存配置"}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
ChevronRight,
|
||||
FileJson,
|
||||
FileVideo,
|
||||
Folder,
|
||||
HardDrive,
|
||||
Search,
|
||||
} from "lucide-react";
|
||||
import { ChevronRight, FileJson, FileVideo, Folder, HardDrive, Search } from "lucide-react";
|
||||
import { useTimeZone } from "../context/TimeZoneContext";
|
||||
import { formatCompactDateTime } from "../lib/datetime";
|
||||
import type { ExecutionData, SourceCollection, SourceCollectionDetail, SourceCollectionEntry } from "../types";
|
||||
@ -25,12 +18,11 @@ const formatBytes = (value?: number) => {
|
||||
return `${current.toFixed(current >= 10 || unit === 0 ? 0 : 1)} ${units[unit]}`;
|
||||
};
|
||||
|
||||
const collectionLabel = (item: Pick<SourceCollection, "collectionName" | "relativePath" | "meta" | "collectionId">) => (
|
||||
item.meta?.project_id
|
||||
|| item.collectionName
|
||||
|| item.relativePath.split("/").filter(Boolean).at(-1)
|
||||
|| item.collectionId
|
||||
);
|
||||
const collectionLabel = (item: Pick<SourceCollection, "collectionName" | "relativePath" | "meta" | "collectionId">) =>
|
||||
item.meta?.project_id ||
|
||||
item.collectionName ||
|
||||
item.relativePath.split("/").filter(Boolean).at(-1) ||
|
||||
item.collectionId;
|
||||
|
||||
export default function SourceData() {
|
||||
const { timeZone } = useTimeZone();
|
||||
@ -43,25 +35,31 @@ export default function SourceData() {
|
||||
const [placeFilter, setPlaceFilter] = useState("all");
|
||||
|
||||
useEffect(() => {
|
||||
dataPlatformApi.listSourceCollections().then((items) => {
|
||||
setCollections(items);
|
||||
if (items[0]) {
|
||||
setSelectedCollection(items[0]);
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error("Failed to load source collections", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.listSourceCollections()
|
||||
.then((items) => {
|
||||
setCollections(items);
|
||||
if (items[0]) {
|
||||
setSelectedCollection(items[0]);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load source collections", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedCollection) return;
|
||||
dataPlatformApi.getSourceCollection(selectedCollection.runId, selectedCollection.collectionId).then((loaded) => {
|
||||
setDetail(loaded);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedArtifact(firstFile?.artifact || null);
|
||||
}).catch((error) => {
|
||||
console.error("Failed to load source collection detail", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.getSourceCollection(selectedCollection.runId, selectedCollection.collectionId)
|
||||
.then((loaded) => {
|
||||
setDetail(loaded);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedArtifact(firstFile?.artifact || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to load source collection detail", error);
|
||||
});
|
||||
}, [selectedCollection]);
|
||||
|
||||
const typeOptions = useMemo(
|
||||
@ -78,7 +76,14 @@ export default function SourceData() {
|
||||
return collections.filter((item) => {
|
||||
const matchesSearch =
|
||||
!query ||
|
||||
[item.collectionId, item.collectionName, item.relativePath, item.meta?.place, item.meta?.type, item.meta?.project_id]
|
||||
[
|
||||
item.collectionId,
|
||||
item.collectionName,
|
||||
item.relativePath,
|
||||
item.meta?.place,
|
||||
item.meta?.type,
|
||||
item.meta?.project_id,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.some((value) => String(value).toLowerCase().includes(query));
|
||||
const matchesType = typeFilter === "all" || item.meta?.type === typeFilter;
|
||||
@ -89,13 +94,16 @@ export default function SourceData() {
|
||||
|
||||
const openPrefix = (prefix: string) => {
|
||||
if (!selectedCollection) return;
|
||||
dataPlatformApi.getSourceCollectionEntries(selectedCollection.runId, selectedCollection.collectionId, prefix).then((loaded) => {
|
||||
setDetail(loaded);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedArtifact(firstFile?.artifact || null);
|
||||
}).catch((error) => {
|
||||
console.error("Failed to browse source entries", error);
|
||||
});
|
||||
dataPlatformApi
|
||||
.getSourceCollectionEntries(selectedCollection.runId, selectedCollection.collectionId, prefix)
|
||||
.then((loaded) => {
|
||||
setDetail(loaded);
|
||||
const firstFile = loaded.entries.find((entry) => entry.kind !== "directory" && entry.artifact);
|
||||
setSelectedArtifact(firstFile?.artifact || null);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Failed to browse source entries", error);
|
||||
});
|
||||
};
|
||||
|
||||
const breadcrumbParts = (detail?.prefix || "").split("/").filter(Boolean);
|
||||
@ -123,7 +131,9 @@ export default function SourceData() {
|
||||
className="rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
>
|
||||
{typeOptions.map((item) => (
|
||||
<option key={item} value={item}>{item === "all" ? "全部场景" : item}</option>
|
||||
<option key={item} value={item}>
|
||||
{item === "all" ? "全部场景" : item}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select
|
||||
@ -132,7 +142,9 @@ export default function SourceData() {
|
||||
className="rounded-md border border-[#2a2b2f] bg-[#0a0a0a] px-3 py-2 text-sm text-white focus:border-blue-500 focus:outline-none"
|
||||
>
|
||||
{placeOptions.map((item) => (
|
||||
<option key={item} value={item}>{item === "all" ? "全部地点" : item}</option>
|
||||
<option key={item} value={item}>
|
||||
{item === "all" ? "全部地点" : item}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
@ -148,9 +160,13 @@ export default function SourceData() {
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-base font-semibold text-white">{collectionLabel(item)}</div>
|
||||
<div className="mt-1 text-sm text-gray-500">{item.meta?.place || "未知地点"} · {item.meta?.type || "未知场景"}</div>
|
||||
<div className="mt-1 text-sm text-gray-500">
|
||||
{item.meta?.place || "未知地点"} · {item.meta?.type || "未知场景"}
|
||||
</div>
|
||||
</div>
|
||||
<span className={`rounded-full px-2 py-1 text-xs font-medium ${item.valid ? "bg-green-500/10 text-green-400" : "bg-red-500/10 text-red-400"}`}>
|
||||
<span
|
||||
className={`rounded-full px-2 py-1 text-xs font-medium ${item.valid ? "bg-green-500/10 text-green-400" : "bg-red-500/10 text-red-400"}`}
|
||||
>
|
||||
{item.valid ? "有效" : "缺文件"}
|
||||
</span>
|
||||
</div>
|
||||
@ -221,14 +237,26 @@ export default function SourceData() {
|
||||
className="flex w-full items-start gap-3 border-b border-[#202227] px-4 py-3 text-left hover:bg-white/5"
|
||||
>
|
||||
<div className="mt-0.5 text-blue-400">
|
||||
{entry.kind === "directory" ? <Folder className="h-4 w-4" /> : entry.kind === "video" ? <FileVideo className="h-4 w-4" /> : <FileJson className="h-4 w-4" />}
|
||||
{entry.kind === "directory" ? (
|
||||
<Folder className="h-4 w-4" />
|
||||
) : entry.kind === "video" ? (
|
||||
<FileVideo className="h-4 w-4" />
|
||||
) : (
|
||||
<FileJson className="h-4 w-4" />
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-sm text-white">{entry.name}</div>
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{entry.kind === "directory"
|
||||
? "文件夹"
|
||||
: [entry.codec, entry.resolution, entry.frameRate ? `${entry.frameRate}fps` : "", entry.duration ? `${entry.duration}s` : "", formatBytes(entry.sizeBytes)]
|
||||
: [
|
||||
entry.codec,
|
||||
entry.resolution,
|
||||
entry.frameRate ? `${entry.frameRate}fps` : "",
|
||||
entry.duration ? `${entry.duration}s` : "",
|
||||
formatBytes(entry.sizeBytes),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</div>
|
||||
@ -269,7 +297,9 @@ export default function SourceData() {
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex min-h-[420px] items-center justify-center text-sm text-gray-500">请选择左侧采集目录</div>
|
||||
<div className="flex min-h-[420px] items-center justify-center text-sm text-gray-500">
|
||||
请选择左侧采集目录
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -17,10 +17,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { useTimeZone } from "../context/TimeZoneContext";
|
||||
import { useUser } from "../context/UserContext";
|
||||
import { formatCompactDateTime } from "../lib/datetime";
|
||||
import {
|
||||
buildTemplatePayload,
|
||||
buildWorkflowFromTemplate,
|
||||
} from "../lib/templates.js";
|
||||
import { buildTemplatePayload, buildWorkflowFromTemplate } from "../lib/templates.js";
|
||||
import { countWorkflowOperators } from "../lib/workflow";
|
||||
import { cn } from "../lib/utils";
|
||||
import AIGenerateModal from "../components/AIGenerateModal";
|
||||
@ -41,9 +38,7 @@ export default function Templates() {
|
||||
const [isAIModalOpen, setIsAIModalOpen] = useState(false);
|
||||
const [isProjectSelectOpen, setIsProjectSelectOpen] = useState(false);
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<any>(null);
|
||||
const [selectedProjectId, setSelectedProjectId] = useState<string | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedProjectId, setSelectedProjectId] = useState<string | null>(null);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [newTpl, setNewTpl] = useState({ name: "", description: "" });
|
||||
|
||||
@ -78,11 +73,7 @@ export default function Templates() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleAIGenerate = (
|
||||
workflow: GeneratedWorkflow,
|
||||
name: string,
|
||||
description: string,
|
||||
) => {
|
||||
const handleAIGenerate = (workflow: GeneratedWorkflow, name: string, description: string) => {
|
||||
templatesApi
|
||||
.create(
|
||||
buildTemplatePayload(
|
||||
@ -117,9 +108,7 @@ export default function Templates() {
|
||||
const handleDelete = (id: string) => {
|
||||
templatesApi
|
||||
.remove(id)
|
||||
.then(() =>
|
||||
setTemplates(templates.filter((template) => template.id !== id)),
|
||||
)
|
||||
.then(() => setTemplates(templates.filter((template) => template.id !== id)))
|
||||
.catch((error) => console.error("Failed to delete template", error));
|
||||
};
|
||||
|
||||
@ -147,18 +136,13 @@ export default function Templates() {
|
||||
const confirmUseTemplate = () => {
|
||||
if (selectedTemplate && selectedProjectId) {
|
||||
projectsApi
|
||||
.createWorkflow(
|
||||
selectedProjectId,
|
||||
buildWorkflowFromTemplate(selectedTemplate),
|
||||
)
|
||||
.createWorkflow(selectedProjectId, buildWorkflowFromTemplate(selectedTemplate))
|
||||
.then((created) => {
|
||||
setIsProjectSelectOpen(false);
|
||||
setSelectedProjectId(null);
|
||||
navigate(`/workflow/${created.id}?projectId=${selectedProjectId}`);
|
||||
})
|
||||
.catch((error) =>
|
||||
console.error("Failed to instantiate template workflow", error),
|
||||
);
|
||||
.catch((error) => console.error("Failed to instantiate template workflow", error));
|
||||
}
|
||||
};
|
||||
|
||||
@ -166,12 +150,8 @@ export default function Templates() {
|
||||
<div className="space-y-8">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">
|
||||
工作流模板
|
||||
</h1>
|
||||
<p className="text-gray-500 mt-1">
|
||||
复用经过验证的数据处理流程,加速开发效率
|
||||
</p>
|
||||
<h1 className="text-3xl font-bold tracking-tight text-white">工作流模板</h1>
|
||||
<p className="text-gray-500 mt-1">复用经过验证的数据处理流程,加速开发效率</p>
|
||||
</div>
|
||||
{canManage && (
|
||||
<div className="flex gap-3">
|
||||
@ -266,9 +246,7 @@ export default function Templates() {
|
||||
</div>
|
||||
|
||||
<h3 className="text-lg font-bold text-white mb-1">{tpl.name}</h3>
|
||||
<p className="text-sm text-gray-500 mb-6 flex-1 line-clamp-2">
|
||||
{tpl.description}
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 mb-6 flex-1 line-clamp-2">{tpl.description}</p>
|
||||
<div className="mb-5 flex items-center gap-2">
|
||||
<span className="inline-flex items-center gap-1 rounded-full border border-blue-500/20 bg-blue-500/10 px-2.5 py-1 text-xs font-medium text-blue-300">
|
||||
<Cpu className="w-3.5 h-3.5" />
|
||||
@ -320,37 +298,26 @@ export default function Templates() {
|
||||
<div className="bg-[#151619] border border-[#2a2b2f] rounded-2xl w-full max-w-md shadow-2xl">
|
||||
<div className="px-6 py-4 border-b border-[#2a2b2f] flex items-center justify-between">
|
||||
<h2 className="text-xl font-bold text-white">创建新模板</h2>
|
||||
<button
|
||||
onClick={() => setIsModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white"
|
||||
>
|
||||
<button onClick={() => setIsModalOpen(false)} className="text-gray-500 hover:text-white">
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
模板名称
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">模板名称</label>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="例如: 基础视觉处理"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500"
|
||||
onChange={(e) =>
|
||||
setNewTpl({ ...newTpl, name: e.target.value })
|
||||
}
|
||||
onChange={(e) => setNewTpl({ ...newTpl, name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">
|
||||
描述
|
||||
</label>
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider">描述</label>
|
||||
<textarea
|
||||
placeholder="简要描述模板的用途..."
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm h-24 focus:outline-none focus:border-blue-500"
|
||||
onChange={(e) =>
|
||||
setNewTpl({ ...newTpl, description: e.target.value })
|
||||
}
|
||||
onChange={(e) => setNewTpl({ ...newTpl, description: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -372,11 +339,7 @@ export default function Templates() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<AIGenerateModal
|
||||
isOpen={isAIModalOpen}
|
||||
onClose={() => setIsAIModalOpen(false)}
|
||||
onGenerate={handleAIGenerate}
|
||||
/>
|
||||
<AIGenerateModal isOpen={isAIModalOpen} onClose={() => setIsAIModalOpen(false)} onGenerate={handleAIGenerate} />
|
||||
|
||||
{/* Project Selection Modal */}
|
||||
{isProjectSelectOpen && (
|
||||
@ -395,9 +358,7 @@ export default function Templates() {
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-6 space-y-4">
|
||||
<p className="text-sm text-gray-400">
|
||||
请选择要将此模板应用到的项目:
|
||||
</p>
|
||||
<p className="text-sm text-gray-400">请选择要将此模板应用到的项目:</p>
|
||||
<div className="space-y-2 max-h-60 overflow-y-auto pr-2 custom-scrollbar">
|
||||
{projects.length === 0 ? (
|
||||
<div className="rounded-xl border border-dashed border-[#2a2b2f] bg-[#0a0a0a] px-4 py-6 text-sm text-gray-500">
|
||||
@ -419,9 +380,7 @@ export default function Templates() {
|
||||
<div className="w-2 h-2 rounded-full bg-blue-500" />
|
||||
<span className="font-medium">{project.name}</span>
|
||||
</div>
|
||||
{selectedProjectId === project.id && (
|
||||
<Check className="w-4 h-4 text-blue-500" />
|
||||
)}
|
||||
{selectedProjectId === project.id && <Check className="w-4 h-4 text-blue-500" />}
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
|
||||
@ -13,9 +13,11 @@ export default function Users() {
|
||||
const [modalMode, setModalMode] = useState<"create" | "edit">("edit");
|
||||
|
||||
useEffect(() => {
|
||||
refreshUsers({ silent: true }).then(setUsers).catch((error) => {
|
||||
console.error("Failed to load users", error);
|
||||
});
|
||||
refreshUsers({ silent: true })
|
||||
.then(setUsers)
|
||||
.catch((error) => {
|
||||
console.error("Failed to load users", error);
|
||||
});
|
||||
}, [refreshUsers]);
|
||||
|
||||
const handleEdit = (user: UserData) => {
|
||||
@ -98,18 +100,22 @@ export default function Users() {
|
||||
<td className="px-6 py-4 font-medium text-white">{u.name}</td>
|
||||
<td className="px-6 py-4 text-gray-400">{u.email}</td>
|
||||
<td className="px-6 py-4">
|
||||
<span className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
u.role === "admin" ? "bg-red-500/10 text-red-500 border-red-500/20" :
|
||||
u.role === "auditor" ? "bg-blue-500/10 text-blue-500 border-blue-500/20" :
|
||||
"bg-gray-500/10 text-gray-500 border-gray-500/20"
|
||||
)}>
|
||||
<span
|
||||
className={cn(
|
||||
"px-2 py-0.5 rounded-full text-[10px] font-medium uppercase tracking-wider border",
|
||||
u.role === "admin"
|
||||
? "bg-red-500/10 text-red-500 border-red-500/20"
|
||||
: u.role === "auditor"
|
||||
? "bg-blue-500/10 text-blue-500 border-blue-500/20"
|
||||
: "bg-gray-500/10 text-gray-500 border-gray-500/20",
|
||||
)}
|
||||
>
|
||||
{u.role}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-6 py-4 text-right">
|
||||
<div className="inline-flex items-center gap-3">
|
||||
<button
|
||||
<button
|
||||
onClick={() => handleEdit(u)}
|
||||
className="text-xs text-blue-500 hover:text-blue-400 font-medium transition-colors"
|
||||
>
|
||||
@ -139,7 +145,10 @@ export default function Users() {
|
||||
<User className="w-5 h-5 text-blue-500" />
|
||||
{modalMode === "create" ? "创建用户" : "编辑用户信息"}
|
||||
</h2>
|
||||
<button onClick={() => setIsModalOpen(false)} className="text-gray-500 hover:text-white transition-colors">
|
||||
<button
|
||||
onClick={() => setIsModalOpen(false)}
|
||||
className="text-gray-500 hover:text-white transition-colors"
|
||||
>
|
||||
<X className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
@ -148,32 +157,32 @@ export default function Users() {
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider flex items-center gap-1.5">
|
||||
<User className="w-3 h-3" /> 用户名
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
<input
|
||||
type="text"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
value={editingUser.name}
|
||||
onChange={e => setEditingUser({...editingUser, name: e.target.value})}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, name: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider flex items-center gap-1.5">
|
||||
<Mail className="w-3 h-3" /> 邮箱地址
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
<input
|
||||
type="email"
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
value={editingUser.email}
|
||||
onChange={e => setEditingUser({...editingUser, email: e.target.value})}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, email: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-xs font-medium text-gray-400 uppercase tracking-wider flex items-center gap-1.5">
|
||||
<Shield className="w-3 h-3" /> 角色权限
|
||||
</label>
|
||||
<select
|
||||
<select
|
||||
className="w-full bg-[#0a0a0a] border border-[#2a2b2f] rounded-md px-4 py-2 text-sm focus:outline-none focus:border-blue-500 text-white"
|
||||
value={editingUser.role}
|
||||
onChange={e => setEditingUser({...editingUser, role: e.target.value as UserData["role"]})}
|
||||
onChange={(e) => setEditingUser({ ...editingUser, role: e.target.value as UserData["role"] })}
|
||||
>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="auditor">Auditor</option>
|
||||
@ -182,13 +191,13 @@ export default function Users() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-6 border-t border-[#2a2b2f] flex justify-end gap-3 bg-[#0a0a0a]/50">
|
||||
<button
|
||||
<button
|
||||
onClick={() => setIsModalOpen(false)}
|
||||
className="px-4 py-2 text-sm font-medium text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
onClick={handleSave}
|
||||
className="px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-all"
|
||||
>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,4 @@
|
||||
import {
|
||||
aiApi,
|
||||
type AIStatus,
|
||||
type GeneratedOperator,
|
||||
type GeneratedWorkflow,
|
||||
} from "./api/ai";
|
||||
import { aiApi, type AIStatus, type GeneratedOperator, type GeneratedWorkflow } from "./api/ai";
|
||||
|
||||
export type { AIStatus, GeneratedOperator, GeneratedWorkflow };
|
||||
|
||||
|
||||
@ -35,14 +35,16 @@ async function loadStatus(force = false) {
|
||||
if (!force && statusPromise) {
|
||||
return statusPromise;
|
||||
}
|
||||
statusPromise = apiRequest<AIStatus>("/api/ai/status").then((status) => {
|
||||
statusCache = status;
|
||||
statusPromise = null;
|
||||
return status;
|
||||
}).catch((error) => {
|
||||
statusPromise = null;
|
||||
throw error;
|
||||
});
|
||||
statusPromise = apiRequest<AIStatus>("/api/ai/status")
|
||||
.then((status) => {
|
||||
statusCache = status;
|
||||
statusPromise = null;
|
||||
return status;
|
||||
})
|
||||
.catch((error) => {
|
||||
statusPromise = null;
|
||||
throw error;
|
||||
});
|
||||
return statusPromise;
|
||||
}
|
||||
|
||||
|
||||
@ -1,43 +1,24 @@
|
||||
import type {
|
||||
PackageDetail,
|
||||
PackageRecord,
|
||||
SamplingTask,
|
||||
SourceCollection,
|
||||
SourceCollectionDetail,
|
||||
} from "../../types";
|
||||
import type { PackageDetail, PackageRecord, SamplingTask, SourceCollection, SourceCollectionDetail } from "../../types";
|
||||
import { apiRequest } from "./client";
|
||||
|
||||
export const dataPlatformApi = {
|
||||
listSourceCollections: async () =>
|
||||
(
|
||||
await apiRequest<{ items: SourceCollection[] }>(
|
||||
"/api/source-data/collections",
|
||||
)
|
||||
).items,
|
||||
(await apiRequest<{ items: SourceCollection[] }>("/api/source-data/collections")).items,
|
||||
getSourceCollection: (runId: string, collectionId: string) =>
|
||||
apiRequest<SourceCollectionDetail>(
|
||||
`/api/source-data/collections/${encodeURIComponent(runId)}/${encodeURIComponent(collectionId)}`,
|
||||
),
|
||||
getSourceCollectionEntries: (
|
||||
runId: string,
|
||||
collectionId: string,
|
||||
prefix = "",
|
||||
) =>
|
||||
getSourceCollectionEntries: (runId: string, collectionId: string, prefix = "") =>
|
||||
apiRequest<SourceCollectionDetail>(
|
||||
`/api/source-data/collections/${encodeURIComponent(runId)}/${encodeURIComponent(collectionId)}/entries?prefix=${encodeURIComponent(prefix)}`,
|
||||
),
|
||||
|
||||
listPackages: async () =>
|
||||
(await apiRequest<{ items: PackageRecord[] }>("/api/packages")).items,
|
||||
listPackages: async () => (await apiRequest<{ items: PackageRecord[] }>("/api/packages")).items,
|
||||
getPackage: (runId: string, packageName: string) =>
|
||||
apiRequest<PackageDetail>(
|
||||
`/api/packages/${encodeURIComponent(runId)}/${encodeURIComponent(packageName)}`,
|
||||
),
|
||||
apiRequest<PackageDetail>(`/api/packages/${encodeURIComponent(runId)}/${encodeURIComponent(packageName)}`),
|
||||
|
||||
listSamplingTasks: async () =>
|
||||
(await apiRequest<{ items: SamplingTask[] }>("/api/sampling-tasks")).items,
|
||||
getSamplingTask: (id: string) =>
|
||||
apiRequest<SamplingTask>(`/api/sampling-tasks/${id}`),
|
||||
listSamplingTasks: async () => (await apiRequest<{ items: SamplingTask[] }>("/api/sampling-tasks")).items,
|
||||
getSamplingTask: (id: string) => apiRequest<SamplingTask>(`/api/sampling-tasks/${id}`),
|
||||
reviewSamplingItem: (
|
||||
id: string,
|
||||
payload: {
|
||||
@ -47,10 +28,5 @@ export const dataPlatformApi = {
|
||||
overallGrade: string;
|
||||
notes?: string;
|
||||
},
|
||||
) =>
|
||||
apiRequest<SamplingTask>(
|
||||
`/api/sampling-items/${id}/review`,
|
||||
{ method: "POST" },
|
||||
payload,
|
||||
),
|
||||
) => apiRequest<SamplingTask>(`/api/sampling-items/${id}/review`, { method: "POST" }, payload),
|
||||
};
|
||||
|
||||
@ -11,7 +11,13 @@ import type {
|
||||
} from "../../types";
|
||||
import { apiRequest } from "./client";
|
||||
|
||||
function buildDatabaseParams(options?: { target?: "platform" | "business"; connectionId?: string; filter?: string; limit?: number; skip?: number }) {
|
||||
function buildDatabaseParams(options?: {
|
||||
target?: "platform" | "business";
|
||||
connectionId?: string;
|
||||
filter?: string;
|
||||
limit?: number;
|
||||
skip?: number;
|
||||
}) {
|
||||
const params = new URLSearchParams();
|
||||
if (options?.target) {
|
||||
params.set("target", options.target);
|
||||
@ -38,7 +44,13 @@ export const databaseApi = {
|
||||
},
|
||||
queryCollection: (
|
||||
collection: string,
|
||||
options?: { target?: "platform" | "business"; connectionId?: string; filter?: string; limit?: number; skip?: number },
|
||||
options?: {
|
||||
target?: "platform" | "business";
|
||||
connectionId?: string;
|
||||
filter?: string;
|
||||
limit?: number;
|
||||
skip?: number;
|
||||
},
|
||||
) => {
|
||||
return apiRequest<DatabaseQueryResult>(
|
||||
`/api/database/collections/${encodeURIComponent(collection)}/documents${buildDatabaseParams(options)}`,
|
||||
|
||||
@ -49,9 +49,6 @@ export const externalBusinessWriteApi = {
|
||||
}),
|
||||
};
|
||||
|
||||
export function scopeForConnection(
|
||||
token: ExternalBusinessWriteToken | null | undefined,
|
||||
connectionId: string,
|
||||
) {
|
||||
export function scopeForConnection(token: ExternalBusinessWriteToken | null | undefined, connectionId: string) {
|
||||
return token?.scopes?.find((scope) => scope.connectionId === connectionId) || null;
|
||||
}
|
||||
|
||||
@ -9,16 +9,13 @@ type MongoConnectionPayload = {
|
||||
};
|
||||
|
||||
export const mongoConnectionsApi = {
|
||||
list: async () =>
|
||||
(await apiRequest<{ items: MongoConnection[] }>("/api/mongo/connections"))
|
||||
.items,
|
||||
list: async () => (await apiRequest<{ items: MongoConnection[] }>("/api/mongo/connections")).items,
|
||||
get: (id: string) => apiRequest<MongoConnection>(`/api/mongo/connections/${id}`),
|
||||
create: (payload: MongoConnectionPayload) =>
|
||||
apiRequest<MongoConnection>("/api/mongo/connections", { method: "POST" }, payload),
|
||||
update: (id: string, payload: Partial<MongoConnectionPayload>) =>
|
||||
apiRequest<MongoConnection>(`/api/mongo/connections/${id}`, { method: "PUT" }, payload),
|
||||
remove: (id: string) =>
|
||||
apiRequest<void>(`/api/mongo/connections/${id}`, { method: "DELETE" }),
|
||||
remove: (id: string) => apiRequest<void>(`/api/mongo/connections/${id}`, { method: "DELETE" }),
|
||||
test: (payload: { id?: string; uri?: string; database?: string }) =>
|
||||
apiRequest<MongoConnectionTestResult>("/api/mongo/connections/test", { method: "POST" }, payload),
|
||||
};
|
||||
|
||||
@ -1,10 +1,4 @@
|
||||
import type {
|
||||
ExecutionData,
|
||||
ExecutionRun,
|
||||
ExecutionRunSummary,
|
||||
LogEntry,
|
||||
ResourceUsage,
|
||||
} from "../../types";
|
||||
import type { ExecutionData, ExecutionRun, ExecutionRunSummary, LogEntry, ResourceUsage } from "../../types";
|
||||
import { apiRequest } from "./client";
|
||||
|
||||
export { type ExecutionData, type LogEntry, type ResourceUsage };
|
||||
@ -15,29 +9,18 @@ type StorageBrowseTarget = {
|
||||
};
|
||||
|
||||
export const monitoringApi = {
|
||||
listRuns: async () =>
|
||||
(await apiRequest<{ items: ExecutionRunSummary[] }>("/api/runs")).items,
|
||||
listRuns: async () => (await apiRequest<{ items: ExecutionRunSummary[] }>("/api/runs")).items,
|
||||
getRun: (runId: string) => apiRequest<ExecutionRun>(`/api/runs/${runId}`),
|
||||
rerunSubtree: (runId: string, nodeId: string) =>
|
||||
apiRequest<ExecutionRun>(`/api/runs/${runId}/rerun-subtree`, { method: "POST" }, { nodeId }),
|
||||
stopRun: (runId: string) =>
|
||||
apiRequest<ExecutionRun>(`/api/runs/${runId}/stop`, { method: "POST" }),
|
||||
forceStopRun: (runId: string) =>
|
||||
apiRequest<ExecutionRun>(`/api/runs/${runId}/force-stop`, { method: "POST" }),
|
||||
stopRun: (runId: string) => apiRequest<ExecutionRun>(`/api/runs/${runId}/stop`, { method: "POST" }),
|
||||
forceStopRun: (runId: string) => apiRequest<ExecutionRun>(`/api/runs/${runId}/force-stop`, { method: "POST" }),
|
||||
getLogs: async (runId: string): Promise<LogEntry[]> =>
|
||||
(await apiRequest<{ items: LogEntry[] }>(`/api/runs/${runId}/logs`)).items,
|
||||
getResourceUsage: async (runId: string): Promise<ResourceUsage[]> =>
|
||||
(
|
||||
await apiRequest<{ items: ResourceUsage[] }>(
|
||||
`/api/runs/${runId}/resources`,
|
||||
)
|
||||
).items,
|
||||
(await apiRequest<{ items: ResourceUsage[] }>(`/api/runs/${runId}/resources`)).items,
|
||||
getExecutionData: async (runId: string): Promise<ExecutionData[]> =>
|
||||
(
|
||||
await apiRequest<{ items: ExecutionData[] }>(
|
||||
`/api/runs/${runId}/artifacts`,
|
||||
)
|
||||
).items,
|
||||
(await apiRequest<{ items: ExecutionData[] }>(`/api/runs/${runId}/artifacts`)).items,
|
||||
listOssBuckets: async ({ sourcePath = "", connectionId = "" }: StorageBrowseTarget): Promise<string[]> => {
|
||||
const query = new URLSearchParams();
|
||||
if (connectionId.trim()) {
|
||||
@ -46,11 +29,7 @@ export const monitoringApi = {
|
||||
if (sourcePath.trim()) {
|
||||
query.set("sourcePath", sourcePath.trim());
|
||||
}
|
||||
return (
|
||||
await apiRequest<{ items: string[] }>(
|
||||
`/api/storage/buckets?${query.toString()}`,
|
||||
)
|
||||
).items;
|
||||
return (await apiRequest<{ items: string[] }>(`/api/storage/buckets?${query.toString()}`)).items;
|
||||
},
|
||||
listOssObjects: async (
|
||||
{ sourcePath = "", connectionId = "" }: StorageBrowseTarget,
|
||||
@ -66,10 +45,6 @@ export const monitoringApi = {
|
||||
}
|
||||
query.set("bucket", bucket);
|
||||
query.set("prefix", prefix);
|
||||
return (
|
||||
await apiRequest<{ items: string[] }>(
|
||||
`/api/storage/objects?${query.toString()}`,
|
||||
)
|
||||
).items;
|
||||
return (await apiRequest<{ items: string[] }>(`/api/storage/objects?${query.toString()}`)).items;
|
||||
},
|
||||
};
|
||||
|
||||
@ -52,10 +52,8 @@ function buildObjectStorageParams(options?: {
|
||||
}
|
||||
|
||||
const OBJECT_STORAGE_PREVIEW_TRUNCATED_HEADER = "X-Drobodata-Preview-Truncated";
|
||||
const OBJECT_STORAGE_PREVIEW_ORIGINAL_SIZE_HEADER =
|
||||
"X-Drobodata-Preview-Original-Bytes";
|
||||
const OBJECT_STORAGE_PREVIEW_RETURNED_SIZE_HEADER =
|
||||
"X-Drobodata-Preview-Returned-Bytes";
|
||||
const OBJECT_STORAGE_PREVIEW_ORIGINAL_SIZE_HEADER = "X-Drobodata-Preview-Original-Bytes";
|
||||
const OBJECT_STORAGE_PREVIEW_RETURNED_SIZE_HEADER = "X-Drobodata-Preview-Returned-Bytes";
|
||||
|
||||
export interface ObjectStorageTextPreviewResult {
|
||||
content: string;
|
||||
@ -78,13 +76,9 @@ async function uploadWithFormData<T>(path: string, formData: FormData) {
|
||||
|
||||
export const objectStorageApi = {
|
||||
getOverview: (options?: { connectionId?: string }) =>
|
||||
apiRequest<ObjectStorageOverview>(
|
||||
`/api/object-storage${buildObjectStorageParams(options)}`,
|
||||
),
|
||||
apiRequest<ObjectStorageOverview>(`/api/object-storage${buildObjectStorageParams(options)}`),
|
||||
listObjects: (options: { connectionId: string; bucket?: string; prefix?: string }) =>
|
||||
apiRequest<ObjectStorageBrowseResult>(
|
||||
`/api/object-storage/objects${buildObjectStorageParams(options)}`,
|
||||
),
|
||||
apiRequest<ObjectStorageBrowseResult>(`/api/object-storage/objects${buildObjectStorageParams(options)}`),
|
||||
putObject: (
|
||||
payload: { bucket?: string; key: string; content: string; contentType?: string },
|
||||
options: { connectionId: string },
|
||||
@ -105,28 +99,18 @@ export const objectStorageApi = {
|
||||
formData,
|
||||
);
|
||||
},
|
||||
renameObject: (
|
||||
payload: { bucket?: string; key: string; newKey: string },
|
||||
options: { connectionId: string },
|
||||
) =>
|
||||
renameObject: (payload: { bucket?: string; key: string; newKey: string }, options: { connectionId: string }) =>
|
||||
apiRequest<ObjectStorageObjectMutationResult>(
|
||||
`/api/object-storage/objects${buildObjectStorageParams(options)}`,
|
||||
{ method: "PATCH" },
|
||||
payload,
|
||||
),
|
||||
deleteObject: (
|
||||
options: { connectionId: string; bucket?: string; key: string; recursive?: boolean },
|
||||
) =>
|
||||
apiRequest<ObjectStorageObjectDeleteResult>(
|
||||
`/api/object-storage/objects${buildObjectStorageParams(options)}`,
|
||||
{ method: "DELETE" },
|
||||
),
|
||||
buildContentURL: (options: {
|
||||
connectionId: string;
|
||||
bucket?: string;
|
||||
key: string;
|
||||
transcode?: string;
|
||||
}) => `/api/object-storage/content${buildObjectStorageParams(options)}`,
|
||||
deleteObject: (options: { connectionId: string; bucket?: string; key: string; recursive?: boolean }) =>
|
||||
apiRequest<ObjectStorageObjectDeleteResult>(`/api/object-storage/objects${buildObjectStorageParams(options)}`, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
buildContentURL: (options: { connectionId: string; bucket?: string; key: string; transcode?: string }) =>
|
||||
`/api/object-storage/content${buildObjectStorageParams(options)}`,
|
||||
readObjectTextPreview: async (options: {
|
||||
connectionId: string;
|
||||
bucket?: string;
|
||||
@ -153,14 +137,9 @@ export const objectStorageApi = {
|
||||
};
|
||||
return {
|
||||
content,
|
||||
truncated:
|
||||
response.headers.get(OBJECT_STORAGE_PREVIEW_TRUNCATED_HEADER) === "true",
|
||||
originalSizeBytes: parseBytesHeader(
|
||||
OBJECT_STORAGE_PREVIEW_ORIGINAL_SIZE_HEADER,
|
||||
),
|
||||
returnedSizeBytes: parseBytesHeader(
|
||||
OBJECT_STORAGE_PREVIEW_RETURNED_SIZE_HEADER,
|
||||
),
|
||||
truncated: response.headers.get(OBJECT_STORAGE_PREVIEW_TRUNCATED_HEADER) === "true",
|
||||
originalSizeBytes: parseBytesHeader(OBJECT_STORAGE_PREVIEW_ORIGINAL_SIZE_HEADER),
|
||||
returnedSizeBytes: parseBytesHeader(OBJECT_STORAGE_PREVIEW_RETURNED_SIZE_HEADER),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@ -3,8 +3,7 @@ import { apiRequest } from "./client";
|
||||
|
||||
export const operatorsApi = {
|
||||
list: async () => (await apiRequest<{ items: Operator[] }>("/api/operators")).items,
|
||||
create: (payload: Partial<Operator>) =>
|
||||
apiRequest<Operator>("/api/operators", { method: "POST" }, payload),
|
||||
create: (payload: Partial<Operator>) => apiRequest<Operator>("/api/operators", { method: "POST" }, payload),
|
||||
update: (id: string, payload: Partial<Operator>) =>
|
||||
apiRequest<Operator>(`/api/operators/${id}`, { method: "PUT" }, payload),
|
||||
remove: (id: string) => apiRequest<void>(`/api/operators/${id}`, { method: "DELETE" }),
|
||||
|
||||
@ -9,11 +9,7 @@ export const projectsApi = {
|
||||
update: (id: string, payload: Partial<Project>) =>
|
||||
apiRequest<Project>(`/api/projects/${id}`, { method: "PUT" }, payload),
|
||||
listStoragePathFavorites: async (id: string) =>
|
||||
(
|
||||
await apiRequest<{ items: StoragePathFavorite[] }>(
|
||||
`/api/projects/${id}/storage-path-favorites`,
|
||||
)
|
||||
).items,
|
||||
(await apiRequest<{ items: StoragePathFavorite[] }>(`/api/projects/${id}/storage-path-favorites`)).items,
|
||||
updateStoragePathFavorites: (id: string, items: StoragePathFavorite[]) =>
|
||||
apiRequest<{ items: StoragePathFavorite[] }>(
|
||||
`/api/projects/${id}/storage-path-favorites`,
|
||||
|
||||
@ -3,6 +3,5 @@ import { apiRequest } from "./client";
|
||||
|
||||
export const settingsApi = {
|
||||
get: () => apiRequest<SystemConfig>("/api/settings"),
|
||||
update: (payload: Partial<SystemConfig>) =>
|
||||
apiRequest<SystemConfig>("/api/settings", { method: "PUT" }, payload),
|
||||
update: (payload: Partial<SystemConfig>) => apiRequest<SystemConfig>("/api/settings", { method: "PUT" }, payload),
|
||||
};
|
||||
|
||||
@ -12,23 +12,11 @@ type StorageConnectionPayload = {
|
||||
};
|
||||
|
||||
export const storageConnectionsApi = {
|
||||
list: async () =>
|
||||
(await apiRequest<{ items: StorageConnection[] }>("/api/storage/connections"))
|
||||
.items,
|
||||
get: (id: string) =>
|
||||
apiRequest<StorageConnection>(`/api/storage/connections/${id}`),
|
||||
list: async () => (await apiRequest<{ items: StorageConnection[] }>("/api/storage/connections")).items,
|
||||
get: (id: string) => apiRequest<StorageConnection>(`/api/storage/connections/${id}`),
|
||||
create: (payload: StorageConnectionPayload) =>
|
||||
apiRequest<StorageConnection>(
|
||||
"/api/storage/connections",
|
||||
{ method: "POST" },
|
||||
payload,
|
||||
),
|
||||
apiRequest<StorageConnection>("/api/storage/connections", { method: "POST" }, payload),
|
||||
update: (id: string, payload: Partial<StorageConnectionPayload>) =>
|
||||
apiRequest<StorageConnection>(
|
||||
`/api/storage/connections/${id}`,
|
||||
{ method: "PUT" },
|
||||
payload,
|
||||
),
|
||||
remove: (id: string) =>
|
||||
apiRequest<void>(`/api/storage/connections/${id}`, { method: "DELETE" }),
|
||||
apiRequest<StorageConnection>(`/api/storage/connections/${id}`, { method: "PUT" }, payload),
|
||||
remove: (id: string) => apiRequest<void>(`/api/storage/connections/${id}`, { method: "DELETE" }),
|
||||
};
|
||||
|
||||
@ -5,14 +5,9 @@ export const usersApi = {
|
||||
list: async () => (await apiRequest<{ items: User[] }>("/api/users")).items,
|
||||
create: (payload: Pick<User, "name" | "email" | "role">) =>
|
||||
apiRequest<User>("/api/users", { method: "POST" }, payload),
|
||||
update: (id: string, payload: Partial<User>) =>
|
||||
apiRequest<User>(`/api/users/${id}`, { method: "PUT" }, payload),
|
||||
update: (id: string, payload: Partial<User>) => apiRequest<User>(`/api/users/${id}`, { method: "PUT" }, payload),
|
||||
listStoragePathFavorites: async (id: string) =>
|
||||
(
|
||||
await apiRequest<{ items: StoragePathFavorite[] }>(
|
||||
`/api/users/${id}/storage-path-favorites`,
|
||||
)
|
||||
).items,
|
||||
(await apiRequest<{ items: StoragePathFavorite[] }>(`/api/users/${id}/storage-path-favorites`)).items,
|
||||
updateStoragePathFavorites: (id: string, items: StoragePathFavorite[]) =>
|
||||
apiRequest<{ items: StoragePathFavorite[] }>(
|
||||
`/api/users/${id}/storage-path-favorites`,
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
import type {
|
||||
ExecutionRun,
|
||||
ExecutionRunSummary,
|
||||
Workflow,
|
||||
WorkflowNodeSourceState,
|
||||
} from "../../types";
|
||||
import type { ExecutionRun, ExecutionRunSummary, Workflow, WorkflowNodeSourceState } from "../../types";
|
||||
import { apiRequest } from "./client";
|
||||
|
||||
export const workflowsApi = {
|
||||
|
||||
26
src/types.ts
26
src/types.ts
@ -608,13 +608,7 @@ export interface SamplingTask {
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type NodeExecutionStatus =
|
||||
| "queued"
|
||||
| "running"
|
||||
| "cancelled"
|
||||
| "waiting_for_audit"
|
||||
| "completed"
|
||||
| "failed";
|
||||
export type NodeExecutionStatus = "queued" | "running" | "cancelled" | "waiting_for_audit" | "completed" | "failed";
|
||||
|
||||
export interface NodeExecution {
|
||||
nodeId: string;
|
||||
@ -639,14 +633,7 @@ export interface ExecutionRun {
|
||||
parentRunId?: string;
|
||||
restartFromNodeId?: string;
|
||||
availableAt?: string;
|
||||
status:
|
||||
| "queued"
|
||||
| "running"
|
||||
| "stopping"
|
||||
| "waiting_for_audit"
|
||||
| "completed"
|
||||
| "failed"
|
||||
| "cancelled";
|
||||
status: "queued" | "running" | "stopping" | "waiting_for_audit" | "completed" | "failed" | "cancelled";
|
||||
stopMode?: "graceful" | "force";
|
||||
stopRequestedAt?: string;
|
||||
previousRunAt?: string;
|
||||
@ -675,14 +662,7 @@ export interface ExecutionRunSummary {
|
||||
parentRunId?: string;
|
||||
restartFromNodeId?: string;
|
||||
availableAt?: string;
|
||||
status:
|
||||
| "queued"
|
||||
| "running"
|
||||
| "stopping"
|
||||
| "waiting_for_audit"
|
||||
| "completed"
|
||||
| "failed"
|
||||
| "cancelled";
|
||||
status: "queued" | "running" | "stopping" | "waiting_for_audit" | "completed" | "failed" | "cancelled";
|
||||
stopMode?: "graceful" | "force";
|
||||
stopRequestedAt?: string;
|
||||
startedAt?: string;
|
||||
|
||||
@ -45,10 +45,7 @@ test("data asset scope matching supports project workflow and run filtering", ()
|
||||
assert.equal(matchesDataAssetScope(item, { projectId: "project-1" }), true);
|
||||
assert.equal(matchesDataAssetScope(item, { workflowId: "workflow-1" }), true);
|
||||
assert.equal(matchesDataAssetScope(item, { runId: "run-1" }), true);
|
||||
assert.equal(
|
||||
matchesDataAssetScope(item, { projectId: "project-1", workflowId: "workflow-1" }),
|
||||
true,
|
||||
);
|
||||
assert.equal(matchesDataAssetScope(item, { projectId: "project-1", workflowId: "workflow-1" }), true);
|
||||
assert.equal(matchesDataAssetScope(item, { projectId: "project-2" }), false);
|
||||
assert.equal(matchesDataAssetScope(item, { workflowId: "workflow-2" }), false);
|
||||
assert.equal(matchesDataAssetScope(item, { runId: "run-2" }), false);
|
||||
|
||||
@ -130,18 +130,9 @@ test("scan workflow config payload falls back to incremental source node when wo
|
||||
});
|
||||
|
||||
test("workflow schedule helpers support hourly and daily modes", () => {
|
||||
assert.equal(
|
||||
effectiveWorkflowScheduleMode({ mode: "every_hours", intervalHours: 4 }),
|
||||
"every_hours",
|
||||
);
|
||||
assert.equal(
|
||||
effectiveWorkflowScheduleMode({ dayInterval: 2, timeOfDay: "18:30" }),
|
||||
"every_days_at_time",
|
||||
);
|
||||
assert.equal(
|
||||
isWorkflowScheduleEnabled({ mode: "every_hours", intervalHours: 4 }),
|
||||
true,
|
||||
);
|
||||
assert.equal(effectiveWorkflowScheduleMode({ mode: "every_hours", intervalHours: 4 }), "every_hours");
|
||||
assert.equal(effectiveWorkflowScheduleMode({ dayInterval: 2, timeOfDay: "18:30" }), "every_days_at_time");
|
||||
assert.equal(isWorkflowScheduleEnabled({ mode: "every_hours", intervalHours: 4 }), true);
|
||||
assert.equal(
|
||||
isWorkflowScheduleEnabled({
|
||||
mode: "every_days_at_time",
|
||||
@ -245,22 +236,13 @@ test("scan config patch keeps workflow config, schedule, type, and source node d
|
||||
assert.equal(updated.nodes[0].data.bucket, "datastorage");
|
||||
assert.equal(updated.nodes[0].data.prefix, "algo/X-platform-test");
|
||||
assert.equal(updated.nodes[0].data.label, "BOS 增量扫描");
|
||||
assert.equal(
|
||||
updated.nodes[0].data.hyperparams.find((item) => item.key === "DATA_SOURCE")?.value,
|
||||
"BOS",
|
||||
);
|
||||
assert.equal(updated.nodes[0].data.hyperparams.find((item) => item.key === "DATA_SOURCE")?.value, "BOS");
|
||||
assert.equal(
|
||||
updated.nodes[0].data.hyperparams.find((item) => item.key === "SOURCE_PATH")?.value,
|
||||
"bos://datastorage/algo/X-platform-test",
|
||||
);
|
||||
assert.equal(
|
||||
updated.nodes[0].data.hyperparams.find((item) => item.key === "SCAN_MODE")?.value,
|
||||
"FULL",
|
||||
);
|
||||
assert.equal(
|
||||
updated.nodes[0].data.hyperparams.find((item) => item.key === "INCREMENTAL_UNIT")?.value,
|
||||
"DIRECTORY",
|
||||
);
|
||||
assert.equal(updated.nodes[0].data.hyperparams.find((item) => item.key === "SCAN_MODE")?.value, "FULL");
|
||||
assert.equal(updated.nodes[0].data.hyperparams.find((item) => item.key === "INCREMENTAL_UNIT")?.value, "DIRECTORY");
|
||||
assert.equal(
|
||||
updated.nodes[0].data.hyperparams.find((item) => item.key === "INCREMENTAL_DIRECTORY_DEPTH")?.value,
|
||||
"2",
|
||||
|
||||
@ -51,11 +51,7 @@ test("rememberStoragePath deduplicates and keeps newest entries first", () => {
|
||||
|
||||
rememberStoragePath(target, { bucket: "datastorage", prefix: "algo/a" }, storage);
|
||||
rememberStoragePath(target, { bucket: "datastorage", prefix: "algo/b" }, storage);
|
||||
const items = rememberStoragePath(
|
||||
target,
|
||||
{ bucket: "datastorage", prefix: "algo/a" },
|
||||
storage,
|
||||
);
|
||||
const items = rememberStoragePath(target, { bucket: "datastorage", prefix: "algo/a" }, storage);
|
||||
|
||||
assert.deepEqual(items, [
|
||||
{
|
||||
@ -77,11 +73,7 @@ test("listRecentStoragePaths isolates scopes and caps the history length", () =>
|
||||
const targetB = { connectionId: "conn-b" };
|
||||
|
||||
for (let index = 0; index < MAX_RECENT_STORAGE_PATHS + 2; index += 1) {
|
||||
rememberStoragePath(
|
||||
targetA,
|
||||
{ bucket: "datastorage", prefix: `algo/run-${index}` },
|
||||
storage,
|
||||
);
|
||||
rememberStoragePath(targetA, { bucket: "datastorage", prefix: `algo/run-${index}` }, storage);
|
||||
}
|
||||
rememberStoragePath(targetB, { bucket: "other", prefix: "root" }, storage);
|
||||
|
||||
@ -114,11 +106,7 @@ test("toggleFavoriteStoragePath pins and unpins scoped favorites", () => {
|
||||
const storage = createMemoryStorage();
|
||||
const target = { connectionId: "conn-1" };
|
||||
|
||||
let items = toggleFavoriteStoragePath(
|
||||
target,
|
||||
{ bucket: "datastorage", prefix: "algo/a" },
|
||||
storage,
|
||||
);
|
||||
let items = toggleFavoriteStoragePath(target, { bucket: "datastorage", prefix: "algo/a" }, storage);
|
||||
assert.deepEqual(items, [
|
||||
{
|
||||
bucket: "datastorage",
|
||||
@ -127,11 +115,7 @@ test("toggleFavoriteStoragePath pins and unpins scoped favorites", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
items = toggleFavoriteStoragePath(
|
||||
target,
|
||||
{ bucket: "datastorage", prefix: "algo/a" },
|
||||
storage,
|
||||
);
|
||||
items = toggleFavoriteStoragePath(target, { bucket: "datastorage", prefix: "algo/a" }, storage);
|
||||
assert.deepEqual(items, []);
|
||||
});
|
||||
|
||||
@ -141,17 +125,9 @@ test("favorite storage paths are isolated by scope and capped independently", ()
|
||||
const targetB = { sourcePath: "bos://other/root" };
|
||||
|
||||
for (let index = 0; index < MAX_FAVORITE_STORAGE_PATHS + 3; index += 1) {
|
||||
toggleFavoriteStoragePath(
|
||||
targetA,
|
||||
{ bucket: "datastorage", prefix: `algo/favorite-${index}` },
|
||||
storage,
|
||||
);
|
||||
toggleFavoriteStoragePath(targetA, { bucket: "datastorage", prefix: `algo/favorite-${index}` }, storage);
|
||||
}
|
||||
toggleFavoriteStoragePath(
|
||||
targetB,
|
||||
{ bucket: "other", prefix: "root" },
|
||||
storage,
|
||||
);
|
||||
toggleFavoriteStoragePath(targetB, { bucket: "other", prefix: "root" }, storage);
|
||||
|
||||
const itemsA = listFavoriteStoragePaths(targetA, storage);
|
||||
const itemsB = listFavoriteStoragePaths(targetB, storage);
|
||||
@ -175,16 +151,8 @@ test("favorites and recents are stored independently", () => {
|
||||
const storage = createMemoryStorage();
|
||||
const target = { connectionId: "conn-1" };
|
||||
|
||||
rememberStoragePath(
|
||||
target,
|
||||
{ bucket: "datastorage", prefix: "algo/recent-only" },
|
||||
storage,
|
||||
);
|
||||
toggleFavoriteStoragePath(
|
||||
target,
|
||||
{ bucket: "datastorage", prefix: "algo/favorite-only" },
|
||||
storage,
|
||||
);
|
||||
rememberStoragePath(target, { bucket: "datastorage", prefix: "algo/recent-only" }, storage);
|
||||
toggleFavoriteStoragePath(target, { bucket: "datastorage", prefix: "algo/favorite-only" }, storage);
|
||||
|
||||
assert.deepEqual(listRecentStoragePaths(target, storage), [
|
||||
{
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
buildTemplatePayload,
|
||||
buildWorkflowFromTemplate,
|
||||
} from "../../src/lib/templates.js";
|
||||
import { buildTemplatePayload, buildWorkflowFromTemplate } from "../../src/lib/templates.js";
|
||||
|
||||
test("buildWorkflowFromTemplate preserves workflow-level execution config", () => {
|
||||
const payload = buildWorkflowFromTemplate({
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
buildTemplatePayload,
|
||||
buildWorkflowCopyPayload,
|
||||
buildWorkflowFromTemplate,
|
||||
} from "../../src/lib/templates.js";
|
||||
import { buildTemplatePayload, buildWorkflowCopyPayload, buildWorkflowFromTemplate } from "../../src/lib/templates.js";
|
||||
|
||||
test("buildTemplatePayload keeps scan config and execution settings", () => {
|
||||
const workflow = {
|
||||
@ -92,7 +88,9 @@ test("buildWorkflowCopyPayload keeps all workflow-level fields", () => {
|
||||
maxRetryAttempts: 4,
|
||||
retryBackoffSeconds: 30,
|
||||
schedule: { interval: 600, sourcePath: "bos://wjzh-data-migration/wjzh-0330-Data-migration" },
|
||||
nodes: [{ id: "n1", data: { label: "BOS 增量扫描", hyperparams: [{ key: "BOS_SECRET_ACCESS_KEY", value: "secret" }] } }],
|
||||
nodes: [
|
||||
{ id: "n1", data: { label: "BOS 增量扫描", hyperparams: [{ key: "BOS_SECRET_ACCESS_KEY", value: "secret" }] } },
|
||||
],
|
||||
edges: [{ id: "e1", source: "n1", target: "n2" }],
|
||||
};
|
||||
|
||||
|
||||
@ -71,8 +71,5 @@ test("does not duplicate browser transcode flag", () => {
|
||||
});
|
||||
|
||||
test("leaves non source data urls untouched", () => {
|
||||
assert.equal(
|
||||
buildBrowserPlayableVideoURL("https://example.com/preview.mp4"),
|
||||
"https://example.com/preview.mp4",
|
||||
);
|
||||
assert.equal(buildBrowserPlayableVideoURL("https://example.com/preview.mp4"), "https://example.com/preview.mp4");
|
||||
});
|
||||
|
||||
@ -120,7 +120,5 @@ test("removing selected edges leaves nodes intact", () => {
|
||||
|
||||
assert.deepEqual(result.removedEdgeIds, ["edge-a"]);
|
||||
assert.equal(result.nodes.length, 2);
|
||||
assert.deepEqual(result.edges, [
|
||||
{ id: "edge-b", source: "node-b", target: "node-a", selected: false },
|
||||
]);
|
||||
assert.deepEqual(result.edges, [{ id: "edge-b", source: "node-b", target: "node-a", selected: false }]);
|
||||
});
|
||||
|
||||
@ -173,14 +173,9 @@ test("resolves edge output artifacts by source handle and source port definition
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(
|
||||
getEdgeOutputArtifacts(
|
||||
{ id: "edge-1", source: "source", sourceHandle: "out-1" },
|
||||
run,
|
||||
graphNodes,
|
||||
),
|
||||
[run.nodeExecutions[0].artifacts[0]],
|
||||
);
|
||||
assert.deepEqual(getEdgeOutputArtifacts({ id: "edge-1", source: "source", sourceHandle: "out-1" }, run, graphNodes), [
|
||||
run.nodeExecutions[0].artifacts[0],
|
||||
]);
|
||||
});
|
||||
|
||||
test("resolves edge output artifacts by port name when the run payload lacks port ids", () => {
|
||||
@ -212,11 +207,7 @@ test("resolves edge output artifacts by port name when the run payload lacks por
|
||||
];
|
||||
|
||||
assert.deepEqual(
|
||||
getEdgeOutputArtifacts(
|
||||
{ id: "edge-1", source: "source", sourceHandle: "approved" },
|
||||
run,
|
||||
graphNodes,
|
||||
),
|
||||
getEdgeOutputArtifacts({ id: "edge-1", source: "source", sourceHandle: "approved" }, run, graphNodes),
|
||||
[run.nodeExecutions[0].artifacts[0]],
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,16 +1,10 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
buildWorkflowSystemEnvVarsPreview,
|
||||
toWorkflowEnvDateTime,
|
||||
} from "../../src/lib/workflow-system-env.js";
|
||||
import { buildWorkflowSystemEnvVarsPreview, toWorkflowEnvDateTime } from "../../src/lib/workflow-system-env.js";
|
||||
|
||||
test("converts ISO timestamps to Asia/Shanghai datetime strings", () => {
|
||||
assert.equal(
|
||||
toWorkflowEnvDateTime("2026-04-21T10:00:00Z"),
|
||||
"2026-04-21T18:00:00+08:00",
|
||||
);
|
||||
assert.equal(toWorkflowEnvDateTime("2026-04-21T10:00:00Z"), "2026-04-21T18:00:00+08:00");
|
||||
assert.equal(toWorkflowEnvDateTime(""), "");
|
||||
assert.equal(toWorkflowEnvDateTime("not-a-date"), "");
|
||||
});
|
||||
|
||||
@ -1,124 +0,0 @@
|
||||
const base = "http://114.111.24.223:30080";
|
||||
const stamp = Date.now();
|
||||
const projectName = `Business Mongo Validation ${stamp}`;
|
||||
const workflowName = `Business Mongo Write ${stamp}`;
|
||||
const doc = {
|
||||
runLabel: `business-mongo-${stamp}`,
|
||||
source: "workflow",
|
||||
value: 1,
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
|
||||
async function api(path, init = {}) {
|
||||
const response = await fetch(`${base}${path}`, {
|
||||
...init,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(init.headers || {}),
|
||||
},
|
||||
});
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(`${response.status} ${text}`);
|
||||
}
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const project = await api("/api/projects", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: projectName,
|
||||
description: "Validate business Mongo write operator",
|
||||
}),
|
||||
});
|
||||
|
||||
const workflow = await api(`/api/projects/${project.id}/workflows`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: workflowName,
|
||||
description: "Writes workflow output into business MongoDB",
|
||||
nodes: [
|
||||
{
|
||||
id: "node-source",
|
||||
type: "operator",
|
||||
position: { x: 120, y: 180 },
|
||||
data: {
|
||||
label: "真实数据源",
|
||||
category: "IO",
|
||||
description: "source",
|
||||
inputs: [],
|
||||
outputs: [{ id: "out-json", name: "output", type: "json" }],
|
||||
hyperparams: [{ key: "SOURCE_JSON", value: JSON.stringify([doc]) }],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "node-mongo",
|
||||
type: "operator",
|
||||
position: { x: 420, y: 180 },
|
||||
data: {
|
||||
label: "MongoDB 写入",
|
||||
category: "DATA",
|
||||
description: "write business data",
|
||||
inputs: [{ id: "input", name: "input", type: "json" }],
|
||||
outputs: [{ id: "result", name: "result", type: "json" }],
|
||||
hyperparams: [
|
||||
{ key: "MONGO_COLLECTION", value: "businessWriteValidation" },
|
||||
{ key: "MONGO_MODE", value: "insert_many" },
|
||||
{ key: "MONGO_TARGET", value: "business" },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
edges: [
|
||||
{
|
||||
id: "edge-source-mongo",
|
||||
source: "node-source",
|
||||
sourceHandle: "out-json",
|
||||
target: "node-mongo",
|
||||
targetHandle: "input",
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
const run = await api(`/api/workflows/${workflow.id}/run`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ trigger: "manual" }),
|
||||
});
|
||||
|
||||
let latest = null;
|
||||
for (let attempt = 0; attempt < 90; attempt += 1) {
|
||||
latest = await api(`/api/runs/${run.id}`);
|
||||
if (latest.status === "completed" || latest.status === "failed") {
|
||||
break;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
}
|
||||
|
||||
if (!latest || latest.status !== "completed") {
|
||||
console.log(JSON.stringify({ project, workflow, run: latest }, null, 2));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const filter = encodeURIComponent(JSON.stringify({ runLabel: doc.runLabel }));
|
||||
const query = await api(`/api/database/collections/businessWriteValidation/documents?filter=${filter}&limit=10`);
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
{
|
||||
projectId: project.id,
|
||||
workflowId: workflow.id,
|
||||
runId: run.id,
|
||||
runStatus: latest.status,
|
||||
query,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
@ -1,85 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
base='http://114.111.24.223:30080'
|
||||
stamp="$(date +%s)"
|
||||
connection_payload="$(jq -nc --arg name "Business Mongo ${stamp}" --arg description 'Validation business mongo connection' --arg uri 'mongodb://business-mongodb.droboticflow.svc.cluster.local:27017' --arg database 'business_data' '{name:$name,description:$description,uri:$uri,database:$database}')"
|
||||
connection="$(curl -fsS -X POST "$base/api/mongo/connections" -H 'Content-Type: application/json' --data-binary "$connection_payload")"
|
||||
connection_id="$(printf '%s' "$connection" | jq -r '.id')"
|
||||
draft_test="$(curl -fsS -X POST "$base/api/mongo/connections/test" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg uri 'mongodb://business-mongodb.droboticflow.svc.cluster.local:27017' --arg database 'business_data' '{uri:$uri,database:$database}')")"
|
||||
stored_test="$(curl -fsS -X POST "$base/api/mongo/connections/test" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg id "$connection_id" '{id:$id}')")"
|
||||
|
||||
project_payload="$(jq -nc --arg name "Business Mongo Validation ${stamp}" --arg description 'Validate business Mongo write operator' '{name:$name,description:$description}')"
|
||||
project="$(curl -fsS -X POST "$base/api/projects" -H 'Content-Type: application/json' --data-binary "$project_payload")"
|
||||
project_id="$(printf '%s' "$project" | jq -r '.id')"
|
||||
|
||||
doc="$(jq -nc --arg runLabel "business-mongo-${stamp}" --arg createdAt "$(date -u +%FT%TZ)" '{runLabel:$runLabel,source:"workflow",value:1,createdAt:$createdAt}')"
|
||||
source_json="$(jq -nc --argjson doc "$doc" '[ $doc ]')"
|
||||
workflow_payload="$(jq -nc \
|
||||
--arg name "Business Mongo Write ${stamp}" \
|
||||
--arg description 'Writes workflow output into business MongoDB' \
|
||||
--arg source_json "$source_json" \
|
||||
--arg connection_id "$connection_id" \
|
||||
'{name:$name,description:$description,nodes:[{id:"node-source",type:"operator",position:{x:120,y:180},data:{label:"真实数据源",category:"IO",description:"source",inputs:[],outputs:[{id:"out-json",name:"output",type:"json"}],hyperparams:[{key:"SOURCE_JSON",value:$source_json}]}},{id:"node-mongo",type:"operator",position:{x:420,y:180},data:{label:"MongoDB 写入",category:"DATA",description:"write business data",inputs:[{id:"input",name:"input",type:"json"}],outputs:[{id:"result",name:"result",type:"json"}],hyperparams:[{key:"MONGO_COLLECTION",value:"businessWriteValidation"},{key:"MONGO_MODE",value:"insert_many"},{key:"MONGO_CONNECTION_ID",value:$connection_id},{key:"MONGO_TARGET",value:"business"}]}}],edges:[{id:"edge-source-mongo",source:"node-source",sourceHandle:"out-json",target:"node-mongo",targetHandle:"input"}] }')"
|
||||
|
||||
workflow="$(curl -fsS -X POST "$base/api/projects/$project_id/workflows" -H 'Content-Type: application/json' --data-binary "$workflow_payload")"
|
||||
workflow_id="$(printf '%s' "$workflow" | jq -r '.id')"
|
||||
run="$(curl -fsS -X POST "$base/api/workflows/$workflow_id/run" -H 'Content-Type: application/json' --data-binary '{"trigger":"manual"}')"
|
||||
run_id="$(printf '%s' "$run" | jq -r '.id')"
|
||||
|
||||
run_state=''
|
||||
run_detail=''
|
||||
for _ in $(seq 1 90); do
|
||||
run_detail="$(curl -fsS "$base/api/runs/$run_id")"
|
||||
run_state="$(printf '%s' "$run_detail" | jq -r '.status')"
|
||||
if [[ "$run_state" == 'completed' || "$run_state" == 'failed' ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [[ "$run_state" != 'completed' ]]; then
|
||||
printf '%s\n' "$run_detail"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filter="$(python3 -c 'import json, urllib.parse, sys; print(urllib.parse.quote(json.dumps({"runLabel": sys.argv[1]})))' "business-mongo-${stamp}")"
|
||||
query="$(curl -fsS "$base/api/database/collections/businessWriteValidation/documents?connectionId=${connection_id}&filter=${filter}&limit=10")"
|
||||
crud_collection="crudValidation_${stamp}"
|
||||
crud_collection_renamed="crudValidationRenamed_${stamp}"
|
||||
|
||||
create_collection="$(curl -fsS -X POST "$base/api/database/collections?connectionId=${connection_id}" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg name "$crud_collection" '{name:$name}')")"
|
||||
create_document="$(curl -fsS -X POST "$base/api/database/collections/${crud_collection}/documents?connectionId=${connection_id}" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg recordKey "crud-${stamp}" '{document:{recordKey:$recordKey,status:"draft",amount:1}}')")"
|
||||
crud_document_id="$(printf '%s' "$create_document" | jq -r '.document._id."$oid" // .document._id')"
|
||||
crud_query_filter="$(python3 -c 'import json, urllib.parse, sys; print(urllib.parse.quote(json.dumps({"recordKey": sys.argv[1]})))' "crud-${stamp}")"
|
||||
crud_query_before="$(curl -fsS "$base/api/database/collections/${crud_collection}/documents?connectionId=${connection_id}&filter=${crud_query_filter}&limit=10")"
|
||||
update_document="$(curl -fsS -X PUT "$base/api/database/collections/${crud_collection}/documents/${crud_document_id}?connectionId=${connection_id}" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg recordKey "crud-${stamp}" '{document:{recordKey:$recordKey,status:"done",amount:2}}')")"
|
||||
rename_collection="$(curl -fsS -X PATCH "$base/api/database/collections/${crud_collection}?connectionId=${connection_id}" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg newName "$crud_collection_renamed" '{newName:$newName}')")"
|
||||
create_index="$(curl -fsS -X POST "$base/api/database/collections/${crud_collection_renamed}/indexes?connectionId=${connection_id}" -H 'Content-Type: application/json' --data-binary "$(jq -nc --arg name "idx_record_key_${stamp}" '{name:$name,keys:{recordKey:1},unique:true}')")"
|
||||
list_indexes="$(curl -fsS "$base/api/database/collections/${crud_collection_renamed}/indexes?connectionId=${connection_id}")"
|
||||
delete_index="$(curl -fsS -X DELETE "$base/api/database/collections/${crud_collection_renamed}/indexes/idx_record_key_${stamp}?connectionId=${connection_id}")"
|
||||
delete_document="$(curl -fsS -X DELETE "$base/api/database/collections/${crud_collection_renamed}/documents/${crud_document_id}?connectionId=${connection_id}")"
|
||||
delete_collection="$(curl -fsS -X DELETE "$base/api/database/collections/${crud_collection_renamed}?connectionId=${connection_id}")"
|
||||
crud_overview="$(curl -fsS "$base/api/database?connectionId=${connection_id}")"
|
||||
|
||||
jq -nc \
|
||||
--arg connectionId "$connection_id" \
|
||||
--arg projectId "$project_id" \
|
||||
--arg workflowId "$workflow_id" \
|
||||
--arg runId "$run_id" \
|
||||
--arg runStatus "$run_state" \
|
||||
--argjson draftTest "$draft_test" \
|
||||
--argjson storedTest "$stored_test" \
|
||||
--argjson query "$query" \
|
||||
--argjson createCollection "$create_collection" \
|
||||
--argjson createDocument "$create_document" \
|
||||
--argjson crudQueryBefore "$crud_query_before" \
|
||||
--argjson updateDocument "$update_document" \
|
||||
--argjson renameCollection "$rename_collection" \
|
||||
--argjson createIndex "$create_index" \
|
||||
--argjson listIndexes "$list_indexes" \
|
||||
--argjson deleteIndex "$delete_index" \
|
||||
--argjson deleteDocument "$delete_document" \
|
||||
--argjson deleteCollection "$delete_collection" \
|
||||
--argjson crudOverview "$crud_overview" \
|
||||
'{connectionId:$connectionId,projectId:$projectId,workflowId:$workflowId,runId:$runId,runStatus:$runStatus,tests:{draftConnection:$draftTest,storedConnection:$storedTest},query:$query,crud:{createCollection:$createCollection,createDocument:$createDocument,queryBefore:$crudQueryBefore,updateDocument:$updateDocument,renameCollection:$renameCollection,createIndex:$createIndex,listIndexes:$listIndexes,deleteIndex:$deleteIndex,deleteDocument:$deleteDocument,deleteCollection:$deleteCollection,overview:$crudOverview}}'
|
||||
@ -1,320 +0,0 @@
|
||||
const BASE = "http://114.111.24.223:30080";
|
||||
const SOURCE_PATH =
|
||||
"bos://datastorage/algo/X-platform-test/raw/BJ_001_0001_OsmoNano_2026-03-19_14-51-43";
|
||||
const CONNECTION_ID = "storage-d69ba0e9824a9abd216eced490f0aed3";
|
||||
const BUCKET = "datastorage";
|
||||
const PREFIX = "algo/X-platform-test/raw/BJ_001_0001_OsmoNano_2026-03-19_14-51-43";
|
||||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
async function request(method, path, payload, expected = [200, 201, 202, 204]) {
|
||||
let lastError;
|
||||
for (let attempt = 1; attempt <= 6; attempt += 1) {
|
||||
try {
|
||||
const response = await fetch(`${BASE}${path}`, {
|
||||
method,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: payload === undefined ? undefined : JSON.stringify(payload),
|
||||
});
|
||||
const text = await response.text();
|
||||
if (!expected.includes(response.status)) {
|
||||
throw new Error(`${method} ${path} failed ${response.status}: ${text}`);
|
||||
}
|
||||
return text ? JSON.parse(text) : null;
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
if (attempt === 6) {
|
||||
throw error;
|
||||
}
|
||||
await sleep(Math.min(attempt, 3) * 1000);
|
||||
}
|
||||
}
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
function buildNode(operator, nodeId, x, y, overrides = {}, extra = {}) {
|
||||
const hyper = (operator.hyperparams || []).map((item) => ({ ...item }));
|
||||
const seen = new Set();
|
||||
for (const item of hyper) {
|
||||
if (Object.prototype.hasOwnProperty.call(overrides, item.key)) {
|
||||
item.value = overrides[item.key];
|
||||
seen.add(item.key);
|
||||
}
|
||||
}
|
||||
for (const [key, value] of Object.entries(overrides)) {
|
||||
if (seen.has(key)) {
|
||||
continue;
|
||||
}
|
||||
hyper.push({ key, value });
|
||||
}
|
||||
return {
|
||||
id: nodeId,
|
||||
type: "operator",
|
||||
data: {
|
||||
label: operator.name,
|
||||
category: operator.category,
|
||||
description: operator.description,
|
||||
inputs: operator.inputs || [],
|
||||
outputs: operator.outputs || [],
|
||||
image: operator.image || "",
|
||||
skillDefinition: operator.skillDefinition || "",
|
||||
hyperparams: hyper,
|
||||
...extra,
|
||||
},
|
||||
position: { x, y },
|
||||
};
|
||||
}
|
||||
|
||||
const interestingArtifactNames = new Set([
|
||||
"source-manifest.json",
|
||||
"dataset-index.json",
|
||||
"dataset-validation.json",
|
||||
"quality-report.json",
|
||||
"filtered-videos.json",
|
||||
"clips-manifest.json",
|
||||
"annotations-manifest.json",
|
||||
"packages-manifest.json",
|
||||
"audit-samples.json",
|
||||
"uploaded-results.json",
|
||||
]);
|
||||
|
||||
async function cleanupAll() {
|
||||
const scanWorkflows = (await request("GET", "/api/scan-configs")).items;
|
||||
for (const workflow of scanWorkflows) {
|
||||
await request("DELETE", `/api/scan-configs/${encodeURIComponent(workflow.id)}`);
|
||||
}
|
||||
const projects = (await request("GET", "/api/projects")).items;
|
||||
for (const project of projects) {
|
||||
const workflows = (
|
||||
await request("GET", `/api/projects/${encodeURIComponent(project.id)}/workflows`)
|
||||
).items;
|
||||
for (const workflow of workflows) {
|
||||
await request("DELETE", `/api/workflows/${encodeURIComponent(workflow.id)}`);
|
||||
}
|
||||
await request("DELETE", `/api/projects/${encodeURIComponent(project.id)}`);
|
||||
}
|
||||
const templates = (await request("GET", "/api/templates")).items;
|
||||
for (const template of templates) {
|
||||
await request("DELETE", `/api/templates/${encodeURIComponent(template.id)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await cleanupAll();
|
||||
|
||||
const operators = (await request("GET", "/api/operators")).items;
|
||||
const byName = Object.fromEntries(operators.map((item) => [item.name, item]));
|
||||
const needed = [
|
||||
"BOS 增量扫描",
|
||||
"X 平台数据集索引",
|
||||
"采集目录校验",
|
||||
"视频质检",
|
||||
"数据过滤",
|
||||
"视频切片",
|
||||
"视频标注",
|
||||
"成品打包",
|
||||
"抽检采样",
|
||||
"结果上传",
|
||||
];
|
||||
for (const name of needed) {
|
||||
if (!byName[name]) {
|
||||
throw new Error(`missing operator: ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
const ts = new Date().toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
|
||||
const outputPrefix = `factory/output/xplatform-real-data/${ts}`;
|
||||
const outputPath = `bos://${BUCKET}/${outputPrefix}`;
|
||||
const project = await request("POST", "/api/projects", {
|
||||
name: `XPlatform Real Data ${ts}`,
|
||||
description: "真实 BOS 数据验收项目",
|
||||
});
|
||||
|
||||
const nodes = [
|
||||
buildNode(
|
||||
byName["BOS 增量扫描"],
|
||||
"source",
|
||||
0,
|
||||
0,
|
||||
{
|
||||
DATA_SOURCE: "BOS",
|
||||
SOURCE_PATH: SOURCE_PATH,
|
||||
SCAN_MODE: "FULL",
|
||||
},
|
||||
{ connectionId: CONNECTION_ID, bucket: BUCKET, prefix: PREFIX },
|
||||
),
|
||||
buildNode(byName["X 平台数据集索引"], "index", 260, 0),
|
||||
buildNode(byName["采集目录校验"], "validate", 520, 0, {
|
||||
REQUIRE_INTRINSICS: "false",
|
||||
}),
|
||||
buildNode(byName["视频质检"], "quality", 780, 0, {
|
||||
MIN_CLARITY: "0.8",
|
||||
MAX_SHAKE: "0.2",
|
||||
MAX_HAND_OCCLUSION: "0.2",
|
||||
CLARITY_SCALE: "35",
|
||||
}),
|
||||
buildNode(byName["数据过滤"], "filter", 1040, 0, {
|
||||
DATE_START: "2026-02-01",
|
||||
DATE_END: "2026-04-05",
|
||||
PLACE: "蓟门里小区",
|
||||
TYPE: "家庭",
|
||||
MIN_CLARITY: "0.8",
|
||||
MAX_SHAKE: "0.2",
|
||||
MAX_HAND_OCCLUSION: "0.2",
|
||||
}),
|
||||
buildNode(byName["视频切片"], "slice", 1300, 0, {
|
||||
SEGMENT_DURATION_SECONDS: "300",
|
||||
}),
|
||||
buildNode(byName["视频标注"], "annotate", 1560, 0, {
|
||||
FRAME_INTERVAL_SECONDS: "1.0",
|
||||
}),
|
||||
buildNode(byName["成品打包"], "package", 1820, 0),
|
||||
buildNode(byName["抽检采样"], "sample", 2080, -100, {
|
||||
RULES_JSON: JSON.stringify([
|
||||
{
|
||||
id: "clarity-check",
|
||||
field: "quality.clarity",
|
||||
operator: "lt",
|
||||
value: 1.0,
|
||||
samplePercent: 100,
|
||||
},
|
||||
]),
|
||||
}),
|
||||
buildNode(
|
||||
byName["结果上传"],
|
||||
"upload",
|
||||
2080,
|
||||
120,
|
||||
{
|
||||
DATA_SOURCE: "BOS",
|
||||
OUTPUT_PATH: outputPath,
|
||||
SOURCE_PATH: outputPath,
|
||||
},
|
||||
{ connectionId: CONNECTION_ID, bucket: BUCKET, prefix: outputPrefix },
|
||||
),
|
||||
];
|
||||
|
||||
const edges = [
|
||||
{
|
||||
id: "source-index",
|
||||
source: "source",
|
||||
sourceHandle: "out-1",
|
||||
target: "index",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "index-validate",
|
||||
source: "index",
|
||||
sourceHandle: "out-1",
|
||||
target: "validate",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "validate-quality",
|
||||
source: "validate",
|
||||
sourceHandle: "out-1",
|
||||
target: "quality",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "quality-filter",
|
||||
source: "quality",
|
||||
sourceHandle: "out-1",
|
||||
target: "filter",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "filter-slice",
|
||||
source: "filter",
|
||||
sourceHandle: "out-1",
|
||||
target: "slice",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "slice-annotate",
|
||||
source: "slice",
|
||||
sourceHandle: "out-1",
|
||||
target: "annotate",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "annotate-package",
|
||||
source: "annotate",
|
||||
sourceHandle: "out-1",
|
||||
target: "package",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "package-sample",
|
||||
source: "package",
|
||||
sourceHandle: "out-1",
|
||||
target: "sample",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
{
|
||||
id: "package-upload",
|
||||
source: "package",
|
||||
sourceHandle: "out-1",
|
||||
target: "upload",
|
||||
targetHandle: "in-1",
|
||||
},
|
||||
];
|
||||
|
||||
const workflow = await request(
|
||||
"POST",
|
||||
`/api/projects/${encodeURIComponent(project.id)}/workflows`,
|
||||
{
|
||||
name: `XPlatform Real Pipeline ${ts}`,
|
||||
description: "基于真实 BOS 数据的 X 平台处理流程",
|
||||
type: "batch",
|
||||
nodes,
|
||||
edges,
|
||||
},
|
||||
);
|
||||
const run = await request("POST", `/api/workflows/${encodeURIComponent(workflow.id)}/run`, {
|
||||
trigger: "manual",
|
||||
});
|
||||
|
||||
let terminal = null;
|
||||
for (let index = 0; index < 900; index += 1) {
|
||||
const current = await request("GET", `/api/runs/${encodeURIComponent(run.id)}`);
|
||||
if (["completed", "failed", "cancelled", "waiting_for_audit"].includes(current.status)) {
|
||||
terminal = current;
|
||||
break;
|
||||
}
|
||||
await sleep(2000);
|
||||
}
|
||||
if (!terminal) {
|
||||
throw new Error(`timeout waiting for run ${run.id}`);
|
||||
}
|
||||
|
||||
const artifacts = (await request("GET", `/api/runs/${encodeURIComponent(run.id)}/artifacts`))
|
||||
.items;
|
||||
const logs = (await request("GET", `/api/runs/${encodeURIComponent(run.id)}/logs`)).items;
|
||||
const interesting = {};
|
||||
for (const item of artifacts) {
|
||||
if (interestingArtifactNames.has(item.name)) {
|
||||
interesting[item.name] = item.data;
|
||||
}
|
||||
}
|
||||
|
||||
const summary = {
|
||||
projectId: project.id,
|
||||
projectName: project.name,
|
||||
workflowId: workflow.id,
|
||||
workflowName: workflow.name,
|
||||
runId: run.id,
|
||||
status: terminal.status,
|
||||
nodeStatuses: Object.fromEntries(
|
||||
(terminal.nodeExecutions || []).map((item) => [item.nodeId, item.status]),
|
||||
),
|
||||
interestingArtifacts: interesting,
|
||||
lastLogs: logs.slice(-20),
|
||||
};
|
||||
console.log(JSON.stringify(summary, null, 2));
|
||||
if (terminal.status !== "completed") {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
@ -1,65 +0,0 @@
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const base = "http://114.111.24.223:30080";
|
||||
const conn = "storage-d69ba0e9824a9abd216eced490f0aed3";
|
||||
const bucket = "droboticflow-debug-preview";
|
||||
const key = "preview.json";
|
||||
|
||||
async function requestJSON(url, init) {
|
||||
const response = await fetch(url, init);
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(text || `Request failed: ${response.status}`);
|
||||
}
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
await requestJSON(`${base}/api/object-storage/buckets?connectionId=${conn}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ name: bucket }),
|
||||
});
|
||||
} catch {}
|
||||
|
||||
await requestJSON(`${base}/api/object-storage/objects?connectionId=${conn}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
bucket,
|
||||
key,
|
||||
content: JSON.stringify({ hello: "world" }, null, 2),
|
||||
contentType: "application/json",
|
||||
}),
|
||||
});
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const page = await browser.newPage();
|
||||
await page.goto(`${base}/object-storage`, { waitUntil: "networkidle" });
|
||||
await page.selectOption('[data-testid="object-storage-connection-select"]', conn);
|
||||
await page.waitForSelector(`[data-bucket-name="${bucket}"]`);
|
||||
await page.click(`[data-bucket-name="${bucket}"]`);
|
||||
await page.waitForSelector(`[data-object-key="${key}"]`);
|
||||
await page.click(`[data-object-key="${key}"]`);
|
||||
await page.waitForTimeout(4000);
|
||||
|
||||
const preTexts = await page.locator("pre").allTextContents();
|
||||
const bodyText = await page.locator("body").innerText();
|
||||
console.log(JSON.stringify({ preTexts, bodyHasWorld: bodyText.includes("world") }, null, 2));
|
||||
await page.screenshot({ path: "/tmp/object-storage-debug.png", fullPage: true });
|
||||
await browser.close();
|
||||
} finally {
|
||||
try {
|
||||
await fetch(
|
||||
`${base}/api/object-storage/objects?connectionId=${conn}&bucket=${bucket}&key=${encodeURIComponent(key)}`,
|
||||
{ method: "DELETE" },
|
||||
);
|
||||
} catch {}
|
||||
try {
|
||||
await fetch(
|
||||
`${base}/api/object-storage/buckets/${bucket}?connectionId=${conn}`,
|
||||
{ method: "DELETE" },
|
||||
);
|
||||
} catch {}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
=== MongoDB 写入
|
||||
{"category": "DATA", "description": "将上游 JSON 数据写入用户配置的业务 MongoDB,支持批量插入和按键 upsert,并允许显式覆盖连接。", "inputs": [{"id": "input", "name": "input", "type": "json", "description": "待写入的 JSON 文档或 items 列表"}], "outputs": [{"id": "result", "name": "result", "type": "json", "description": "写入结果摘要"}], "hyperparams": [{"key": "MONGO_COLLECTION", "value": "", "description": "目标集合名称(禁止写系统保留集合)", "type": "string"}, {"key": "MONGO_MODE", "value": "insert_many", "description": "写入模式:insert_many 或 upsert", "type": "string"}, {"key": "MONGO_CONNECTION_ID", "value": "", "description": "业务 MongoDB 连接 ID;推荐优先配置", "type": "string"}, {"key": "MONGO_TARGET", "value": "business", "description": "兼容字段;默认 business。若显式传入 URI/DB,会优先使用显式连接", "type": "string"}, {"key": "UPSERT_KEY", "value": "_id", "description": "upsert 模式使用的唯一键", "type": "string"}, {"key": "DOCUMENT_PATH", "value": "", "description": "从输入 payload 中提取待写入文档的字段路径", "type": "string"}, {"key": "MONGO_DB", "value": "", "description": "可选数据库名;显式填写后会覆盖 business/platform 默认连接", "type": "string"}, {"key": "MONGO_URI", "value": "", "description": "可选 Mongo URI;显式填写后会覆盖 business/platform 默认连接", "type": "string"}]}
|
||||
=== BOS 增量扫描
|
||||
{"category": "IO", "description": "按 bucket/prefix 增量扫描 BOS,仅输出本次新增对象并提交 checkpoint 给 runtime。", "inputs": [], "outputs": [{"id": "out-1", "name": "manifest", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "DATA_SOURCE", "value": "BOS", "description": "固定为 BOS"}, {"key": "SOURCE_PATH", "value": "", "description": "完整 bos://bucket/prefix 路径"}, {"key": "BOS_ENDPOINT", "value": "https://bj.bcebos.com", "description": "BOS Endpoint"}, {"key": "BOS_ACCESS_KEY_ID", "value": "", "description": "BOS Access Key ID"}, {"key": "BOS_SECRET_ACCESS_KEY", "value": "", "description": "BOS Secret Access Key"}, {"key": "SCAN_MODE", "value": "INCREMENTAL", "description": "固定为 INCREMENTAL"}]}
|
||||
=== 抽检采样
|
||||
{"category": "QA", "description": "按质检和标注规则对成品数据执行真实抽检采样。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "samples", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "RULES_JSON", "value": "[]", "description": "抽检规则数组,包含 field/operator/value/samplePercent"}]}
|
||||
=== 成品打包
|
||||
{"category": "VIDEO", "description": "将切片视频、质检结果、标注结果和配置文件组装成成品数据包。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "packages", "type": "json", "transmission": "bus"}], "hyperparams": null}
|
||||
=== 视频标注
|
||||
{"category": "VIDEO", "description": "基于真实视频片段生成阶段划分、动作标签和对象提示。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "annotations", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "FRAME_INTERVAL_SECONDS", "value": "1.0", "description": "采样帧间隔秒数"}]}
|
||||
=== 视频切片
|
||||
{"category": "VIDEO", "description": "将真实视频按固定时长切分为多个 mp4 片段。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "clips", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SEGMENT_DURATION_SECONDS", "value": "300", "description": "每个切片的秒数"}]}
|
||||
=== 数据过滤
|
||||
{"category": "VIDEO", "description": "按日期、地点、场景和质检阈值过滤有效视频。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "filtered", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "DATE_START", "value": "", "description": "开始日期,支持 YYYY-MM-DD / YYYYMMDD"}, {"key": "DATE_END", "value": "", "description": "结束日期,支持 YYYY-MM-DD / YYYYMMDD"}, {"key": "PLACE", "value": "", "description": "采集地点"}, {"key": "TYPE", "value": "", "description": "采集场景类型"}, {"key": "MIN_CLARITY", "value": "0.8", "description": "清晰度最低阈值"}, {"key": "MAX_SHAKE", "value": "0.1", "description": "抖动度最高阈值"}, {"key": "MAX_HAND_OCCLUSION", "value": "0.1", "description": "无手率最高阈值"}]}
|
||||
=== 视频质检
|
||||
{"category": "VIDEO", "description": "基于真实视频帧计算清晰度、抖动度和无手率估计。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "quality", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "MIN_CLARITY", "value": "0.8", "description": "清晰度最低阈值"}, {"key": "MAX_SHAKE", "value": "0.1", "description": "抖动度最高阈值"}, {"key": "MAX_HAND_OCCLUSION", "value": "0.1", "description": "无手率最高阈值"}, {"key": "CLARITY_SCALE", "value": "35", "description": "清晰度归一化尺度"}]}
|
||||
=== 采集目录校验
|
||||
{"category": "DATASET", "description": "校验采集目录是否包含 meta.json、video_meta.json,以及可选 intrinsics.json。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "validated", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "REQUIRE_INTRINSICS", "value": "false", "description": "是否要求 intrinsics.json 必须存在"}]}
|
||||
=== X 平台数据集索引
|
||||
{"category": "DATASET", "description": "扫描 X-platform 采集目录,解析 meta.json、video_meta.json 和视频文件索引。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "dataset", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_PATH", "value": "", "description": "X-platform 根目录或单个采集目录"}]}
|
||||
=== Shell 命令执行
|
||||
{"category": "UTIL", "description": "在 operator-runner 容器中真实执行 shell 命令并收集输出文件。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "result", "type": "file", "transmission": "bus"}], "hyperparams": [{"key": "COMMAND", "value": "", "description": "容器内执行的命令"}, {"key": "SCRIPT", "value": "", "description": "可执行脚本内容"}]}
|
||||
=== ROSBag 数据概览
|
||||
{"category": "ROBOTICS", "description": "读取真实 rosbag1 / rosbag2 / mcap / db3 数据并输出概览。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "summary", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_PATH", "value": "", "description": "bag/db3/mcap 文件或 rosbag2 目录"}]}
|
||||
=== LeRobot 数据集概览
|
||||
{"category": "ROBOTICS", "description": "读取真实 LeRobot 数据集目录,输出 meta/tasks/parquet/videos 概览。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "summary", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_PATH", "value": "", "description": "LeRobot 数据集根目录"}]}
|
||||
=== 条件分流
|
||||
{"category": "LOGIC", "description": "按字段条件将输入拆分到 matched / unmatched 两个真实输出端口。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "matched", "name": "matched", "type": "json", "transmission": "bus"}, {"id": "unmatched", "name": "unmatched", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "FIELD_PATH", "value": "", "description": "待判断字段路径"}, {"key": "OPERATOR", "value": "eq", "description": "eq/ne/contains/gt/gte/lt/lte/exists/missing"}, {"key": "EXPECTED", "value": "", "description": "字符串比较值"}, {"key": "EXPECTED_JSON", "value": "", "description": "JSON 格式比较值,优先于 EXPECTED"}]}
|
||||
=== 文本模板渲染
|
||||
{"category": "UTIL", "description": "使用上游 JSON 上下文渲染真实文本模板文件。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "rendered", "type": "file", "transmission": "bus"}], "hyperparams": [{"key": "TEMPLATE_TEXT", "value": "", "description": "模板文本"}, {"key": "OUTPUT_NAME", "value": "rendered.txt", "description": "输出文件名"}]}
|
||||
=== JSON 映射重命名
|
||||
{"category": "DATA", "description": "按映射表批量重命名 JSON 字段。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "mapped", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "FIELD_MAP_JSON", "value": "{}", "description": "JSON 字段映射,例如 {\"old\":\"new\"}"}]}
|
||||
=== JSON 过滤
|
||||
{"category": "DATA", "description": "按字段条件过滤 JSON 列表。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "filtered", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "FIELD_PATH", "value": "", "description": "待判断字段路径"}, {"key": "OPERATOR", "value": "eq", "description": "eq/ne/contains/gt/gte/lt/lte/exists/missing"}, {"key": "EXPECTED", "value": "", "description": "字符串比较值"}, {"key": "EXPECTED_JSON", "value": "", "description": "JSON 格式比较值,优先于 EXPECTED"}]}
|
||||
=== JSON 字段提取
|
||||
{"category": "DATA", "description": "按字段路径从 JSON 输入中提取指定值。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "extracted", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "FIELD_PATH", "value": "", "description": "点分字段路径,例如 metrics.score"}]}
|
||||
=== JSON 转 CSV
|
||||
{"category": "DATA", "description": "将 JSON 行数据导出为真实 CSV 文件。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "csv", "type": "file", "transmission": "bus"}], "hyperparams": null}
|
||||
=== CSV 转 JSON
|
||||
{"category": "DATA", "description": "将真实 CSV/TSV 文件转换成结构化 JSON 行列表。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "table", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_PATH", "value": "", "description": "csv/tsv 文件路径"}]}
|
||||
=== 目录扫描
|
||||
{"category": "IO", "description": "对真实目录做文件统计、扩展名分布和样例文件扫描。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "summary", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_PATH", "value": "", "description": "待扫描目录"}]}
|
||||
=== 人工审核
|
||||
{"category": "HUMAN", "description": "将真实输入送入人工审核并等待审核动作恢复流程。", "inputs": [{"id": "in-1", "name": "candidate", "type": "json", "transmission": "bus"}], "outputs": [{"id": "approved", "name": "approved", "type": "json", "transmission": "bus"}, {"id": "rejected", "name": "rejected", "type": "json", "transmission": "bus"}], "hyperparams": null}
|
||||
=== 结果上传
|
||||
{"category": "IO", "description": "收集上游真实输出并生成上传结果清单。", "inputs": [{"id": "in-1", "name": "result", "type": "json", "transmission": "bus"}], "outputs": [], "hyperparams": null}
|
||||
=== 数据合并
|
||||
{"category": "MATH", "description": "将多个 JSON 输入合并成统一结果。", "inputs": [{"id": "in-1", "name": "left", "type": "json", "transmission": "bus"}, {"id": "in-2", "name": "right", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "merged", "type": "json", "transmission": "bus"}], "hyperparams": null}
|
||||
=== 模型推理
|
||||
{"category": "AI", "description": "执行真实节点输入汇总、命令调用或模型镜像推理。", "inputs": [{"id": "in-1", "name": "input", "type": "json", "transmission": "bus"}], "outputs": [{"id": "out-1", "name": "result", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "COMMAND", "value": "", "description": "容器内执行的命令"}, {"key": "SCRIPT", "value": "", "description": "可执行脚本内容"}]}
|
||||
=== 真实数据源
|
||||
{"category": "IO", "description": "从 SOURCE_TEXT、SOURCE_JSON、SOURCE_PATH 或上游输入生成真实源数据清单。", "inputs": [], "outputs": [{"id": "out-1", "name": "manifest", "type": "json", "transmission": "bus"}], "hyperparams": [{"key": "SOURCE_TEXT", "value": "", "description": "直接注入文本内容"}, {"key": "SOURCE_JSON", "value": "", "description": "直接注入 JSON 内容"}, {"key": "SOURCE_PATH", "value": "", "description": "从本地路径读取真实数据"}]}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 82 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 62 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 119 KiB |
Loading…
x
Reference in New Issue
Block a user