Skip to content

Commit

Permalink
custom formatter and collapsable tree (#313)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jan 10, 2025
2 parents b4092c2 + 8717078 commit 28eac25
Show file tree
Hide file tree
Showing 32 changed files with 9,702 additions and 9,348 deletions.
3 changes: 3 additions & 0 deletions app-server/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub enum Feature {
Storage,
/// Build all containers. If false, only lite part is used: app-server, postgres, frontend
FullBuild,
/// Machine manager to spin up and manage machines
MachineManager,
}

pub fn is_feature_enabled(feature: Feature) -> bool {
Expand All @@ -27,5 +29,6 @@ pub fn is_feature_enabled(feature: Feature) -> bool {
.expect("ENVIRONMENT must be set")
.as_str(),
),
Feature::MachineManager => env::var("MACHINE_MANAGER_URL_GRPC").is_ok(),
}
}
2 changes: 1 addition & 1 deletion app-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn main() -> anyhow::Result<()> {
};

let machine_manager: Arc<dyn MachineManager> =
if is_feature_enabled(Feature::FullBuild) {
if is_feature_enabled(Feature::MachineManager) {
let machine_manager_url_grpc = env::var("MACHINE_MANAGER_URL_GRPC")
.expect("MACHINE_MANAGER_URL_GRPC must be set");
let machine_manager_client = Arc::new(
Expand Down
34 changes: 0 additions & 34 deletions frontend/app/api/projects/[projectId]/prompt-copilot/run/route.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export async function POST(
.limit(1);

if (nextItem.length === 0 || stats.length === 0) {
return Response.json(null);
return Response.json([]);
}

return Response.json({
return Response.json([{
...nextItem[0],
count: stats[0].count,
position: stats[0].position
});
}]);

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

if (prevItem.length === 0 || stats.length === 0) {
return Response.json(null);
return Response.json([]);
}

return Response.json({
return Response.json([{
...prevItem[0],
count: stats[0].count,
position: stats[0].position
});
}]);
}

return Response.json({ error: 'Invalid direction' }, { status: 400 });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { and, eq } from "drizzle-orm";
import { NextResponse } from "next/server";

import { db } from "@/lib/db/drizzle";
import { renderTemplates } from "@/lib/db/migrations/schema";

export async function GET(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
const { projectId, templateId } = params;
const template = await db.query.renderTemplates.findFirst({
where: and(
eq(renderTemplates.id, templateId),
eq(renderTemplates.projectId, projectId)
)
});

if (!template) {
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
}

return NextResponse.json(template);
}

export async function POST(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
const { projectId, templateId } = params;
const body = await request.json();

const template = await db.update(renderTemplates).set({
name: body.name,
code: body.code
})
.where(and(eq(renderTemplates.id, templateId), eq(renderTemplates.projectId, projectId)))
.returning();

if (!template.length) {
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
}

return NextResponse.json(template[0]);
}

export async function DELETE(request: Request, { params }: { params: { projectId: string, templateId: string } }) {
const { projectId, templateId } = params;
const template = await db.delete(renderTemplates)
.where(and(
eq(renderTemplates.id, templateId),
eq(renderTemplates.projectId, projectId)
))
.returning();

if (!template) {
return NextResponse.json({ error: 'Template not found' }, { status: 404 });
}

return NextResponse.json(template);
}
40 changes: 40 additions & 0 deletions frontend/app/api/projects/[projectId]/render-templates/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { eq } from 'drizzle-orm';
import { NextResponse } from 'next/server';

import { db } from '@/lib/db/drizzle';
import { renderTemplates } from '@/lib/db/migrations/schema';

export async function GET(
req: Request,
{ params }: { params: { projectId: string } }
): Promise<Response> {
const projectId = params.projectId;

const templates = await db.query.renderTemplates.findMany({
where: eq(renderTemplates.projectId, projectId),
columns: {
id: true,
name: true,
}
});

return NextResponse.json(templates);
}


export async function POST(req: Request, { params }: { params: { projectId: string } }) {
const projectId = params.projectId;
const body = await req.json();

const result = await db.insert(renderTemplates).values({
projectId,
name: body.name,
code: body.code
}).returning();

if (!result) {
return new Response('Failed to create template', { status: 500 });
}

return new Response(JSON.stringify(result[0]));
}
36 changes: 36 additions & 0 deletions frontend/app/api/projects/[projectId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
import { eq } from 'drizzle-orm';
import { getServerSession } from 'next-auth';

import { authOptions } from '@/lib/auth';
import { db } from '@/lib/db/drizzle';
import { projects } from '@/lib/db/migrations/schema';
import { fetcher } from '@/lib/utils';

export async function POST(
req: Request,
{ params }: { params: { projectId: string } }
): Promise<Response> {
const { projectId } = params;
const { name } = await req.json();

if (!name) {
return new Response(JSON.stringify({ error: 'Project name is required.' }), {
status: 400,
});
}

try {
const result = await db.update(projects).set({ name }).where(eq(projects.id, projectId));

if (result.count === 0) {
return new Response(JSON.stringify({ error: 'Project not found.' }), {
status: 404,
});
}

return new Response(JSON.stringify({ message: 'Project renamed successfully.' }), {
status: 200,
});
} catch (error) {
return new Response(JSON.stringify({ error: 'Internal server error.' }), {
status: 500,
});
}
}

export async function DELETE(
req: Request,
{ params }: { params: { projectId: string } }
Expand All @@ -19,3 +54,4 @@ export async function DELETE(
}
});
}

21 changes: 0 additions & 21 deletions frontend/app/api/projects/[projectId]/templates/route.ts

This file was deleted.

5 changes: 4 additions & 1 deletion frontend/components/dashboard/span-stat-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AggregationFunction } from '@/lib/clickhouse/utils';
import {
cn,
formatTimestamp,
formatTimestampFromSeconds,
formatTimestampFromSecondsWithInterval,
formatTimestampWithInterval,
} from '@/lib/utils';
Expand Down Expand Up @@ -298,7 +299,9 @@ export function DefaultLineChart({
<ChartTooltipContent
labelKey={xAxisKey}
labelFormatter={(_, p) =>
formatTimestamp(`${p[0].payload[xAxisKey]}Z`)
numericTimestamp
? formatTimestampFromSeconds(p[0].payload[xAxisKey])
: formatTimestamp(`${p[0].payload[xAxisKey]}Z`)
}
/>
}
Expand Down
Loading

0 comments on commit 28eac25

Please sign in to comment.