Skip to content

Commit 28eac25

Browse files
dinmukhamedmskull8888888nidhi-wa
authored
custom formatter and collapsable tree (#313)
* Merge pull request #311 from lmnr-ai/fix/dashboard-tooltip fix double conversion date in chart tooltip too * Collapsable trace tree (#312) * Add ability to rename projects (#306) * Add ability to rename projects * Added user feedback notifiaction and convert PUT to POST * change to router.refresh * add close dialog after rename * Custom-formatter (#305) --------- Co-authored-by: skull8888888 <skull8888888@gmail.com> Co-authored-by: Nidhi Singh <120259299+nidhi-wa@users.noreply.github.com>
2 parents b4092c2 + 8717078 commit 28eac25

File tree

32 files changed

+9702
-9348
lines changed

32 files changed

+9702
-9348
lines changed

app-server/src/features/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub enum Feature {
1010
Storage,
1111
/// Build all containers. If false, only lite part is used: app-server, postgres, frontend
1212
FullBuild,
13+
/// Machine manager to spin up and manage machines
14+
MachineManager,
1315
}
1416

1517
pub fn is_feature_enabled(feature: Feature) -> bool {
@@ -27,5 +29,6 @@ pub fn is_feature_enabled(feature: Feature) -> bool {
2729
.expect("ENVIRONMENT must be set")
2830
.as_str(),
2931
),
32+
Feature::MachineManager => env::var("MACHINE_MANAGER_URL_GRPC").is_ok(),
3033
}
3134
}

app-server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ fn main() -> anyhow::Result<()> {
293293
};
294294

295295
let machine_manager: Arc<dyn MachineManager> =
296-
if is_feature_enabled(Feature::FullBuild) {
296+
if is_feature_enabled(Feature::MachineManager) {
297297
let machine_manager_url_grpc = env::var("MACHINE_MANAGER_URL_GRPC")
298298
.expect("MACHINE_MANAGER_URL_GRPC must be set");
299299
let machine_manager_client = Arc::new(

frontend/app/api/projects/[projectId]/prompt-copilot/run/route.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

frontend/app/api/projects/[projectId]/queues/[queueId]/move/route.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ export async function POST(
6060
.limit(1);
6161

6262
if (nextItem.length === 0 || stats.length === 0) {
63-
return Response.json(null);
63+
return Response.json([]);
6464
}
6565

66-
return Response.json({
66+
return Response.json([{
6767
...nextItem[0],
6868
count: stats[0].count,
6969
position: stats[0].position
70-
});
70+
}]);
7171

7272
} else if (direction === 'prev') {
7373
// return the previous item in the queue before the refDataId
@@ -106,14 +106,14 @@ export async function POST(
106106
.limit(1);
107107

108108
if (prevItem.length === 0 || stats.length === 0) {
109-
return Response.json(null);
109+
return Response.json([]);
110110
}
111111

112-
return Response.json({
112+
return Response.json([{
113113
...prevItem[0],
114114
count: stats[0].count,
115115
position: stats[0].position
116-
});
116+
}]);
117117
}
118118

119119
return Response.json({ error: 'Invalid direction' }, { status: 400 });
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { and, eq } from "drizzle-orm";
2+
import { NextResponse } from "next/server";
3+
4+
import { db } from "@/lib/db/drizzle";
5+
import { renderTemplates } from "@/lib/db/migrations/schema";
6+
7+
export async function GET(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
8+
const { projectId, templateId } = params;
9+
const template = await db.query.renderTemplates.findFirst({
10+
where: and(
11+
eq(renderTemplates.id, templateId),
12+
eq(renderTemplates.projectId, projectId)
13+
)
14+
});
15+
16+
if (!template) {
17+
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
18+
}
19+
20+
return NextResponse.json(template);
21+
}
22+
23+
export async function POST(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
24+
const { projectId, templateId } = params;
25+
const body = await request.json();
26+
27+
const template = await db.update(renderTemplates).set({
28+
name: body.name,
29+
code: body.code
30+
})
31+
.where(and(eq(renderTemplates.id, templateId), eq(renderTemplates.projectId, projectId)))
32+
.returning();
33+
34+
if (!template.length) {
35+
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
36+
}
37+
38+
return NextResponse.json(template[0]);
39+
}
40+
41+
export async function DELETE(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
42+
const { projectId, templateId } = params;
43+
const template = await db.delete(renderTemplates)
44+
.where(and(
45+
eq(renderTemplates.id, templateId),
46+
eq(renderTemplates.projectId, projectId)
47+
))
48+
.returning();
49+
50+
if (!template) {
51+
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
52+
}
53+
54+
return NextResponse.json(template);
55+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { eq } from 'drizzle-orm';
2+
import { NextResponse } from 'next/server';
3+
4+
import { db } from '@/lib/db/drizzle';
5+
import { renderTemplates } from '@/lib/db/migrations/schema';
6+
7+
export async function GET(
8+
req: Request,
9+
{ params }: { params: { projectId: string } }
10+
): Promise<Response> {
11+
const projectId = params.projectId;
12+
13+
const templates = await db.query.renderTemplates.findMany({
14+
where: eq(renderTemplates.projectId, projectId),
15+
columns: {
16+
id: true,
17+
name: true,
18+
}
19+
});
20+
21+
return NextResponse.json(templates);
22+
}
23+
24+
25+
export async function POST(req: Request, { params }: { params: { projectId: string } }) {
26+
const projectId = params.projectId;
27+
const body = await req.json();
28+
29+
const result = await db.insert(renderTemplates).values({
30+
projectId,
31+
name: body.name,
32+
code: body.code
33+
}).returning();
34+
35+
if (!result) {
36+
return new Response('Failed to create template', { status: 500 });
37+
}
38+
39+
return new Response(JSON.stringify(result[0]));
40+
}

frontend/app/api/projects/[projectId]/route.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,43 @@
1+
import { eq } from 'drizzle-orm';
12
import { getServerSession } from 'next-auth';
23

34
import { authOptions } from '@/lib/auth';
5+
import { db } from '@/lib/db/drizzle';
6+
import { projects } from '@/lib/db/migrations/schema';
47
import { fetcher } from '@/lib/utils';
58

9+
export async function POST(
10+
req: Request,
11+
{ params }: { params: { projectId: string } }
12+
): Promise<Response> {
13+
const { projectId } = params;
14+
const { name } = await req.json();
15+
16+
if (!name) {
17+
return new Response(JSON.stringify({ error: 'Project name is required.' }), {
18+
status: 400,
19+
});
20+
}
21+
22+
try {
23+
const result = await db.update(projects).set({ name }).where(eq(projects.id, projectId));
24+
25+
if (result.count === 0) {
26+
return new Response(JSON.stringify({ error: 'Project not found.' }), {
27+
status: 404,
28+
});
29+
}
30+
31+
return new Response(JSON.stringify({ message: 'Project renamed successfully.' }), {
32+
status: 200,
33+
});
34+
} catch (error) {
35+
return new Response(JSON.stringify({ error: 'Internal server error.' }), {
36+
status: 500,
37+
});
38+
}
39+
}
40+
641
export async function DELETE(
742
req: Request,
843
{ params }: { params: { projectId: string } }
@@ -19,3 +54,4 @@ export async function DELETE(
1954
}
2055
});
2156
}
57+

frontend/app/api/projects/[projectId]/templates/route.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

frontend/components/dashboard/span-stat-chart.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { AggregationFunction } from '@/lib/clickhouse/utils';
1313
import {
1414
cn,
1515
formatTimestamp,
16+
formatTimestampFromSeconds,
1617
formatTimestampFromSecondsWithInterval,
1718
formatTimestampWithInterval,
1819
} from '@/lib/utils';
@@ -298,7 +299,9 @@ export function DefaultLineChart({
298299
<ChartTooltipContent
299300
labelKey={xAxisKey}
300301
labelFormatter={(_, p) =>
301-
formatTimestamp(`${p[0].payload[xAxisKey]}Z`)
302+
numericTimestamp
303+
? formatTimestampFromSeconds(p[0].payload[xAxisKey])
304+
: formatTimestamp(`${p[0].payload[xAxisKey]}Z`)
302305
}
303306
/>
304307
}

0 commit comments

Comments
 (0)