mirror of
https://github.com/colanode/colanode.git
synced 2026-02-24 03:49:48 +01:00
Improve date informations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
TaskArtifactOutput,
|
||||
formatBytes,
|
||||
formatDate,
|
||||
formatMimeType,
|
||||
} from '@colanode/core';
|
||||
import { Download, Link } from 'lucide-react';
|
||||
@@ -35,7 +36,10 @@ export const TaskArtifacts = ({ artifacts }: TaskArtifactsProps) => {
|
||||
<div className="flex-grow">
|
||||
<div className="font-semibold text-base">{artifact.name}</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{formatMimeType(artifact.mimeType)} - {formatBytes(artifact.size)}
|
||||
{formatMimeType(artifact.mimeType)} - {formatBytes(artifact.size)}{' '}
|
||||
{artifact.expiresAt
|
||||
? `- Expires ${formatDate(artifact.expiresAt)}`
|
||||
: ''}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
@@ -16,8 +16,10 @@ interface TaskCardProps {
|
||||
|
||||
export const TaskCard = ({ task }: TaskCardProps) => {
|
||||
const layout = useLayout();
|
||||
const duration = formatDuration(task.createdAt, task.completedAt);
|
||||
const startedAgo = timeAgo(task.createdAt);
|
||||
const startedAgo = task.startedAt ? timeAgo(task.startedAt) : 'Pending';
|
||||
const duration = task.startedAt
|
||||
? formatDuration(task.startedAt, task.completedAt)
|
||||
: '0s';
|
||||
|
||||
return (
|
||||
<div className="flex flex-row items-center gap-4 rounded-lg border bg-card p-4 shadow-sm">
|
||||
|
||||
@@ -20,8 +20,10 @@ interface TaskDetailsProps {
|
||||
}
|
||||
|
||||
export const TaskDetails = ({ task, logs, artifacts }: TaskDetailsProps) => {
|
||||
const duration = formatDuration(task.createdAt, task.completedAt);
|
||||
const createdAtAgo = timeAgo(task.createdAt);
|
||||
const startedAgo = task.startedAt ? timeAgo(task.startedAt) : 'Pending';
|
||||
const duration = task.startedAt
|
||||
? formatDuration(task.startedAt, task.completedAt)
|
||||
: '0s';
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-5 gap-4">
|
||||
@@ -54,7 +56,7 @@ export const TaskDetails = ({ task, logs, artifacts }: TaskDetailsProps) => {
|
||||
<span className="text-xs text-muted-foreground">Started</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<Calendar className="size-4" />
|
||||
<span className="font-semibold">{createdAtAgo}</span>
|
||||
<span className="font-semibold">{startedAgo}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
|
||||
@@ -12,6 +12,8 @@ export const mapTaskOutput = (task: SelectTask): TaskOutput => {
|
||||
createdAt: task.created_at.toISOString(),
|
||||
createdBy: task.created_by,
|
||||
completedAt: task.completed_at?.toISOString(),
|
||||
startedAt: task.started_at?.toISOString(),
|
||||
activeAt: task.active_at?.toISOString(),
|
||||
attributes: task.attributes,
|
||||
};
|
||||
};
|
||||
@@ -35,5 +37,6 @@ export const mapTaskArtifactOutput = (
|
||||
size: artifact.size,
|
||||
mimeType: artifact.mime_type,
|
||||
createdAt: artifact.created_at.toISOString(),
|
||||
expiresAt: artifact.expires_at?.toISOString(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@ export class WorkspaceExport {
|
||||
private readonly exportDataZipKey: string;
|
||||
private readonly exportFilesZipPrefix: string;
|
||||
private readonly exportTempDirectory: string;
|
||||
private readonly artifactExpireDate: Date;
|
||||
|
||||
private readonly dataFileKeys: string[] = [];
|
||||
private readonly uploadFileKeys: string[][] = [];
|
||||
@@ -81,6 +82,7 @@ export class WorkspaceExport {
|
||||
this.exportDataZipKey = `${this.taskDir}/data.zip`;
|
||||
this.exportFilesZipPrefix = `${this.taskDir}/files`;
|
||||
this.exportTempDirectory = `${this.taskDir}/temp`;
|
||||
this.artifactExpireDate = new Date(Date.now() + 1000 * 60 * 60 * 24 * 30);
|
||||
}
|
||||
|
||||
public async export() {
|
||||
@@ -732,6 +734,7 @@ export class WorkspaceExport {
|
||||
size,
|
||||
path,
|
||||
created_at: new Date(),
|
||||
expires_at: this.artifactExpireDate,
|
||||
})
|
||||
.executeTakeFirst();
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ export const taskOutputSchema = z.object({
|
||||
workspaceId: z.string(),
|
||||
createdAt: z.string(),
|
||||
createdBy: z.string(),
|
||||
startedAt: z.string().optional(),
|
||||
activeAt: z.string().optional(),
|
||||
completedAt: z.string().optional(),
|
||||
});
|
||||
|
||||
@@ -69,6 +71,7 @@ export const taskArtifactOutputSchema = z.object({
|
||||
size: z.number(),
|
||||
mimeType: z.string(),
|
||||
createdAt: z.string(),
|
||||
expiresAt: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TaskArtifactOutput = z.infer<typeof taskArtifactOutputSchema>;
|
||||
|
||||
Reference in New Issue
Block a user