Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard): change graphs from echarts to recharts #1591

Draft
wants to merge 50 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d976e8f
rebase of main
thewbuk Nov 1, 2024
1bb5040
fix model runs call
thewbuk Nov 1, 2024
562ed88
fix model runs
thewbuk Nov 1, 2024
191ee77
fix the columns in models
thewbuk Nov 1, 2024
da8f918
imports
thewbuk Nov 1, 2024
42105e8
formatting
thewbuk Nov 1, 2024
4d5ccdc
add placeholder
thewbuk Nov 1, 2024
c6c18ca
add invalidates
thewbuk Nov 1, 2024
b973742
change typo
thewbuk Nov 1, 2024
baf17b3
change image
thewbuk Nov 1, 2024
1493b7e
fix namespace switch
thewbuk Nov 1, 2024
33f6e33
formatting
thewbuk Nov 1, 2024
3e62766
fix pages
thewbuk Nov 1, 2024
3feb272
fix sort
thewbuk Nov 1, 2024
541bb55
fix namespace switch
thewbuk Nov 1, 2024
a427ffb
COMMENT
thewbuk Nov 3, 2024
7208cd4
PR fixes
thewbuk Nov 4, 2024
621d56f
pr fixes
thewbuk Nov 4, 2024
07833d9
pr fixes
thewbuk Nov 4, 2024
ddc9d0b
pr fixes
thewbuk Nov 4, 2024
eac714c
pr fixes
thewbuk Nov 4, 2024
930447f
pr fixes
thewbuk Nov 4, 2024
4762802
move static
thewbuk Nov 4, 2024
c3f6c6e
pr fixes
thewbuk Nov 4, 2024
451b512
pr fixes
thewbuk Nov 4, 2024
2d0e0f9
change credit owner
thewbuk Nov 4, 2024
7df4fc5
pr fixes
thewbuk Nov 4, 2024
4a7b8bb
pr fixes
thewbuk Nov 4, 2024
d0b6173
remove casting
thewbuk Nov 4, 2024
539c660
formatting
thewbuk Nov 4, 2024
04d0289
fix reload
thewbuk Nov 4, 2024
bf204e8
pr fixes
thewbuk Nov 4, 2024
97afbbe
change to runnerId
thewbuk Nov 4, 2024
568b6b2
fix x axis
thewbuk Nov 4, 2024
0f573d2
formatting
thewbuk Nov 4, 2024
71cf3c6
add missing api
thewbuk Nov 4, 2024
9235664
add truncate
thewbuk Nov 4, 2024
af1c750
add max w
thewbuk Nov 4, 2024
bf7b925
add time options to ttoltip
thewbuk Nov 4, 2024
ca68924
fix summary
thewbuk Nov 4, 2024
94e7acb
add const
thewbuk Nov 4, 2024
e153582
fix model summary
thewbuk Nov 4, 2024
dc90012
remove logs
thewbuk Nov 4, 2024
b3196a0
update summary
thewbuk Nov 4, 2024
5aa496a
fix: fix various style issue
EiffelFly Nov 5, 2024
9133028
chore: bump version
EiffelFly Nov 5, 2024
6a6076c
add truncate
thewbuk Nov 5, 2024
36fa1c9
puch recharts
thewbuk Nov 5, 2024
2ddf4e6
formatting
thewbuk Nov 5, 2024
e509334
add loading skeletons
thewbuk Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/console/src/app/[entity]/dashboard/activity/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Metadata } from "next";

import { generateNextMetaBase } from "@instill-ai/toolkit/server";

import ActivityRender from "./render";

export async function generateMetadata(): Promise<Metadata> {
return {
title: "Instill Core | Activity Dashboard",
metadataBase: generateNextMetaBase({
defaultBase: "http://localhost:3000",
}),
openGraph: {
images: ["/instill-open-graph.png"],
},
};
}

export default function ActivityPage() {
return <ActivityRender />;
}
29 changes: 29 additions & 0 deletions apps/console/src/app/[entity]/dashboard/activity/render.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import * as React from "react";

import {
AppTopbar,
DashboardActivityPageMainView,
NamespaceSwitch,
PageBase,
} from "@instill-ai/toolkit";

import { useAppAccessToken } from "~/lib/use-app-access-token";
import { useAppTrackToken } from "~/lib/useAppTrackToken";

export default function ActivityRender() {
useAppAccessToken();
useAppTrackToken({ enabled: true });

return (
<PageBase>
<AppTopbar namespaceSwitch={<NamespaceSwitch />} />
<PageBase.Container>
<PageBase.Content contentPadding="p-8">
<DashboardActivityPageMainView />
</PageBase.Content>
</PageBase.Container>
</PageBase>
);
}
21 changes: 21 additions & 0 deletions apps/console/src/app/[entity]/dashboard/cost/model/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Metadata } from "next";

import { generateNextMetaBase } from "@instill-ai/toolkit/server";

import CostPipelineRender from "./render";

export async function generateMetadata(): Promise<Metadata> {
return {
title: "Instill Core | Pipeline Cost Dashboard",
metadataBase: generateNextMetaBase({
defaultBase: "http://localhost:3000",
}),
openGraph: {
images: ["/instill-open-graph.png"],
},
};
}

export default function CostPipelinePage() {
return <CostPipelineRender />;
}
29 changes: 29 additions & 0 deletions apps/console/src/app/[entity]/dashboard/cost/model/render.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import * as React from "react";

import {
AppTopbar,
DashboardCostModelPageMainView,
NamespaceSwitch,
PageBase,
} from "@instill-ai/toolkit";

import { useAppAccessToken } from "~/lib/use-app-access-token";
import { useAppTrackToken } from "~/lib/useAppTrackToken";

export default function CostModelRender() {
useAppAccessToken();
useAppTrackToken({ enabled: true });

return (
<PageBase>
<AppTopbar namespaceSwitch={<NamespaceSwitch />} />
<PageBase.Container>
<PageBase.Content contentPadding="p-8">
<DashboardCostModelPageMainView />
</PageBase.Content>
</PageBase.Container>
</PageBase>
);
}
15 changes: 15 additions & 0 deletions apps/console/src/app/[entity]/dashboard/cost/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { redirect } from "next/navigation";

type RedirectionDashboardCostPageProps = {
params: { id: string; entity: string };
};

const RedirectionDashboardCostPage = ({
params,
}: RedirectionDashboardCostPageProps) => {
const { entity } = params;

return redirect(`/${entity}/dashboard/cost/pipeline`);
};

export default RedirectionDashboardCostPage;
21 changes: 21 additions & 0 deletions apps/console/src/app/[entity]/dashboard/cost/pipeline/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Metadata } from "next";

import { generateNextMetaBase } from "@instill-ai/toolkit/server";

import CostModelRender from "./render";

export async function generateMetadata(): Promise<Metadata> {
return {
title: "Instill Core | Model Cost Dashboard",
metadataBase: generateNextMetaBase({
defaultBase: "http://localhost:3000",
}),
openGraph: {
images: ["/instill-open-graph.png"],
},
};
}

export default function CostModelPage() {
return <CostModelRender />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client";

import * as React from "react";

import {
AppTopbar,
DashboardCostPipelinePageMainView,
NamespaceSwitch,
PageBase,
} from "@instill-ai/toolkit";

import { useAppAccessToken } from "~/lib/use-app-access-token";
import { useAppTrackToken } from "~/lib/useAppTrackToken";

export default function CostPipelineRender() {
useAppAccessToken();
useAppTrackToken({ enabled: true });

return (
<PageBase>
<AppTopbar namespaceSwitch={<NamespaceSwitch />} />
<PageBase.Container>
<PageBase.Content contentPadding="p-8">
<DashboardCostPipelinePageMainView />
</PageBase.Content>
</PageBase.Container>
</PageBase>
);
}
16 changes: 11 additions & 5 deletions apps/console/src/app/[entity]/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { redirect } from "next/navigation";

type Props = {
params: { entity: string };
type RedirectionDashboardPageProps = {
params: { id: string; entity: string };
};

export default async function Page({ params }: Props) {
redirect(`/${params.entity}/dashboard/pipeline`);
}
const RedirectionDashboardPage = ({
params,
}: RedirectionDashboardPageProps) => {
const { entity } = params;

return redirect(`/${entity}/dashboard/activity`);
};

export default RedirectionDashboardPage;
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instill-sdk",
"version": "0.11.0-rc.28",
"version": "0.11.0-rc.37",
"description": "Instill AI's Typescript SDK",
"repository": "https://github.com/instill-ai/typescript-sdk.git",
"bugs": "https://github.com/instill-ai/community/issues",
Expand Down
138 changes: 134 additions & 4 deletions packages/sdk/src/core/metric/MetricClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { getQueryString } from "../../helper";
import { getInstillAdditionalHeaders, getQueryString } from "../../helper";
import { APIResource } from "../../main/resource";
import { PipelineRun } from "../../vdp";
import {
ListCreditConsumptionChartRecordResponse,
ListModelTriggerCountRequest,
ListModelTriggerCountResponse,
ListModelTriggerMetricRequest,
ListModelTriggerMetricResponse,
ListPipelineRunsByRequesterRequest,
ListPipelineRunsByRequesterResponse,
ListPipelineTriggerComputationTimeChartsRequest,
ListPipelineTriggerComputationTimeChartsResponse,
ListPipelineTriggerMetricRequest,
Expand All @@ -15,20 +22,20 @@ import {

export class MetricClient extends APIResource {
async listInstillCreditConsumptionTimeChart({
owner,
namespaceId,
start,
stop,
aggregationWindow,
}: {
owner: string;
namespaceId: string;
start?: string;
stop?: string;
aggregationWindow?: string;
}) {
try {
const queryString = getQueryString({
baseURL: `/metrics/credit/charts`,
owner,
namespaceId,
start: start ?? undefined,
stop: stop ?? undefined,
aggregationWindow: aggregationWindow ?? undefined,
Expand All @@ -45,6 +52,129 @@ export class MetricClient extends APIResource {
}
}

async listModelTriggerMetric(
props: ListModelTriggerMetricRequest & {
enablePagination?: boolean;
},
) {
const {
pageSize,
page,
filter,
enablePagination,
requesterId,
requesterUid,
start,
} = props;
const additionalHeaders = getInstillAdditionalHeaders({
requesterUid,
});

try {
const queryString = getQueryString({
baseURL: `/model-runs/query-charts`,
pageSize,
page,
filter,
requesterId,
start,
});

const response = await this._client.get<ListModelTriggerMetricResponse>(
queryString,
{
additionalHeaders,
},
);

if (enablePagination) {
return Promise.resolve(response);
}

return Promise.resolve(response);
} catch (error) {
return Promise.reject(error);
}
}

async listModelTriggerCount(
request: ListModelTriggerCountRequest,
): Promise<ListModelTriggerCountResponse> {
const { requesterId, start, stop } = request;

if (!requesterId) {
return Promise.reject(new Error("requesterId is required"));
}

try {
const queryString = getQueryString({
baseURL: `/model-runs/count?`,
requesterId,
start: start ?? undefined,
stop: stop ?? undefined,
});

const data =
await this._client.get<ListModelTriggerCountResponse>(queryString);

return Promise.resolve(data);
} catch (error) {
return Promise.reject(error);
}
}

async listPipelineRunsByRequester(
props: ListPipelineRunsByRequesterRequest & { enablePagination: true },
): Promise<ListPipelineRunsByRequesterResponse>;

async listPipelineRunsByRequester(
props: ListPipelineRunsByRequesterRequest & { enablePagination: false },
): Promise<PipelineRun[]>;

async listPipelineRunsByRequester(
props: ListPipelineRunsByRequesterRequest & { enablePagination?: boolean },
): Promise<ListPipelineRunsByRequesterResponse | PipelineRun[]> {
const {
pageSize,
page,
orderBy,
enablePagination,
requesterUid,
requesterId,
start,
} = props;

const additionalHeaders = getInstillAdditionalHeaders({
requesterUid,
});

try {
const queryString = getQueryString({
baseURL: `/dashboard/pipelines/runs`,
pageSize,
page,
orderBy,
requesterId,
start,
});

const data = await this._client.get<ListPipelineRunsByRequesterResponse>(
queryString,
{
additionalHeaders,
},
);

if (enablePagination) {
return Promise.resolve(data);
}

return Promise.resolve(data.pipelineRuns);
} catch (error) {
return Promise.reject(error);
}
}

async listPipelineTriggers(
props: ListPipelineTriggerRequest & {
enablePagination: true;
Expand Down
Loading
Loading