-
Notifications
You must be signed in to change notification settings - Fork 0
feat(dashboard): add optional Grafana dashboard embedding on overview page #65
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
797b0b4
feat(dashboard): add optional Grafana dashboard embedding on overview…
pescn 334db75
feat(dashboard): add multi-dashboard support with env var override
pescn 3d49637
fix(dashboard): address PR review comments
pescn 99871d1
fix(grafana): enable anonymous auth for iframe embedding
pescn bf2856b
chore: update auto-generated routeTree.gen.ts
pescn f5e5305
refactor(dashboard): improve error handling and remove redundant vali…
pescn fa9bcf6
docs(grafana): add security note for anonymous auth settings
pescn 3122693
fix(dashboard): handle empty array env var as explicit override
pescn 62dead7
feat(dashboard): improve Grafana embed UX
pescn a8fa60e
feat(metrics): add cost analytics and enhanced Grafana dashboard
pescn c2f31b3
fix(metrics): address code review feedback
pescn 1342d9a
fix(dashboard): stabilize useEffect dependency for dashboard auto-red…
pescn fc27513
merge: resolve conflicts with main
pescn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { Elysia, t } from "elysia"; | ||
| import { | ||
| isEnvOverrideActive, | ||
| getGrafanaDashboards, | ||
| setGrafanaDashboards, | ||
| clearGrafanaDashboards, | ||
| EnvOverrideError, | ||
| } from "@/utils/dashboards"; | ||
|
|
||
| const dashboardSchema = t.Object({ | ||
| id: t.String(), | ||
| label: t.String(), | ||
| url: t.String({ format: "uri" }), | ||
| }); | ||
|
|
||
| const dashboardsArraySchema = t.Array(dashboardSchema); | ||
|
|
||
| export const adminDashboards = new Elysia().group("/dashboards", (app) => | ||
| app | ||
| .get( | ||
| "/", | ||
| async () => { | ||
| const dashboards = await getGrafanaDashboards(); | ||
| return { | ||
| dashboards, | ||
| envOverride: isEnvOverrideActive(), | ||
| }; | ||
| }, | ||
| { | ||
| detail: { | ||
| description: | ||
| "Get Grafana dashboards configuration. Returns envOverride=true if GRAFANA_DASHBOARDS env var is set.", | ||
| }, | ||
| }, | ||
| ) | ||
| .put( | ||
| "/", | ||
| async ({ body, status }) => { | ||
| try { | ||
| await setGrafanaDashboards(body.dashboards); | ||
| return { | ||
| dashboards: body.dashboards, | ||
| envOverride: false, | ||
| }; | ||
| } catch (error) { | ||
| if (error instanceof EnvOverrideError) { | ||
| return status(409, { error: error.message }); | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| { | ||
| body: t.Object({ | ||
| dashboards: dashboardsArraySchema, | ||
| }), | ||
| detail: { | ||
| description: | ||
| "Update Grafana dashboards configuration. Returns 409 if GRAFANA_DASHBOARDS env var is set.", | ||
| }, | ||
| }, | ||
| ) | ||
| .delete( | ||
| "/", | ||
| async ({ status }) => { | ||
| try { | ||
| await clearGrafanaDashboards(); | ||
| return { success: true }; | ||
| } catch (error) { | ||
| if (error instanceof EnvOverrideError) { | ||
| return status(409, { error: error.message }); | ||
| } | ||
| throw error; | ||
| } | ||
| }, | ||
| { | ||
| detail: { | ||
| description: | ||
| "Clear Grafana dashboards configuration. Returns 409 if GRAFANA_DASHBOARDS env var is set.", | ||
| }, | ||
| }, | ||
| ), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { Elysia, t } from "elysia"; | ||
| import { deleteSetting, getAllSettings, getSetting, upsertSetting } from "@/db"; | ||
|
|
||
| export const adminSettings = new Elysia().group("/settings", (app) => | ||
| app | ||
| .get( | ||
| "/", | ||
| async () => { | ||
| return await getAllSettings(); | ||
| }, | ||
| { | ||
| detail: { description: "List all settings" }, | ||
| }, | ||
| ) | ||
| .get( | ||
| "/:key", | ||
| async ({ params, status }) => { | ||
| const setting = await getSetting(params.key); | ||
| if (!setting) { | ||
| return status(404, "Setting not found"); | ||
| } | ||
| return setting; | ||
| }, | ||
| { | ||
| params: t.Object({ key: t.String() }), | ||
| detail: { description: "Get a setting by key" }, | ||
| }, | ||
| ) | ||
| .put( | ||
| "/:key", | ||
| async ({ params, body }) => { | ||
| const result = await upsertSetting({ | ||
| key: params.key, | ||
| value: body.value, | ||
| }); | ||
| return result; | ||
| }, | ||
| { | ||
| params: t.Object({ key: t.String() }), | ||
| body: t.Object({ value: t.Any() }), | ||
| detail: { description: "Create or update a setting" }, | ||
| }, | ||
| ) | ||
| .delete( | ||
| "/:key", | ||
| async ({ params, status }) => { | ||
| const result = await deleteSetting(params.key); | ||
| if (!result) { | ||
| return status(404, "Setting not found"); | ||
| } | ||
| return result; | ||
| }, | ||
| { | ||
| params: t.Object({ key: t.String() }), | ||
| detail: { description: "Delete a setting" }, | ||
| }, | ||
| ), | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.