-
-
Notifications
You must be signed in to change notification settings - Fork 181
feat: Tracearr integration #5060
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
Open
StrandedTurtle
wants to merge
21
commits into
homarr-labs:dev
Choose a base branch
from
StrandedTurtle:tracearr-integration
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,095
−3
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d10b8ad
feat: inital integration working
StrandedTurtle 77c3ae4
feat: activitty and violations
StrandedTurtle 42ed6ea
feat better live view
StrandedTurtle 615f27d
feat: violations simple
StrandedTurtle 03b9512
Merge branch 'homarr-labs:dev' into tracearr-integration
StrandedTurtle ebfad85
fix: final changes and cleanup
StrandedTurtle 101837a
fix: prettier
StrandedTurtle bb90e1e
Merge branch 'dev' into tracearr-integration
StrandedTurtle 061922f
fix: PR suggestions
StrandedTurtle 111f6e4
Merge branch 'tracearr-integration' of https://github.com/StrandedTur…
StrandedTurtle 4f786e9
Merge branch 'homarr-labs:dev' into tracearr-integration
StrandedTurtle 77eb37b
Merge branch 'homarr-labs:dev' into tracearr-integration
StrandedTurtle f0ea20d
feat: fix cmments from PR
StrandedTurtle e6aa4ab
Merge branch 'dev' into tracearr-integration
StrandedTurtle b178fe0
fix: pr suggestions
StrandedTurtle 71c504b
Merge branch 'dev' of https://github.com/homarr-labs/homarr into trac…
StrandedTurtle cb8f185
Merge branch 'dev' of https://github.com/homarr-labs/homarr into trac…
StrandedTurtle 77c668e
fix: remove new item from mock integration
StrandedTurtle bacd322
Merge branch 'homarr-labs:dev' into tracearr-integration
StrandedTurtle be0c31b
fix: add back media monitoring
StrandedTurtle 3f49e7e
Merge branch 'dev' into tracearr-integration
StrandedTurtle 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
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,48 @@ | ||
| import { observable } from "@trpc/server/observable"; | ||
|
|
||
| import type { TracearrDashboardData } from "@homarr/integrations/types"; | ||
| import { tracearrRequestHandler } from "@homarr/request-handler/tracearr"; | ||
|
|
||
| import { createManyIntegrationMiddleware } from "../../middlewares/integration"; | ||
| import { createTRPCRouter, publicProcedure } from "../../trpc"; | ||
|
|
||
| export const tracearrRouter = createTRPCRouter({ | ||
| getDashboard: publicProcedure.concat(createManyIntegrationMiddleware("query", "tracearr")).query(async ({ ctx }) => { | ||
| const results = await Promise.all( | ||
| ctx.integrations.map(async (integration) => { | ||
| const innerHandler = tracearrRequestHandler.handler(integration, {}); | ||
| const { data, timestamp } = await innerHandler.getCachedOrUpdatedDataAsync({ forceUpdate: false }); | ||
|
|
||
| return { | ||
| integrationId: integration.id, | ||
| integrationName: integration.name, | ||
| integrationUrl: integration.url, | ||
| dashboard: data, | ||
| updatedAt: timestamp, | ||
| }; | ||
| }), | ||
| ); | ||
|
|
||
| return results; | ||
| }), | ||
| subscribeToDashboard: publicProcedure | ||
| .concat(createManyIntegrationMiddleware("query", "tracearr")) | ||
| .subscription(({ ctx }) => { | ||
| return observable<{ integrationId: string; dashboard: TracearrDashboardData; timestamp: Date }>((emit) => { | ||
| const unsubscribes = ctx.integrations.map((integration) => { | ||
| const innerHandler = tracearrRequestHandler.handler(integration, {}); | ||
| return innerHandler.subscribe((dashboard) => { | ||
| emit.next({ | ||
| integrationId: integration.id, | ||
| dashboard, | ||
| timestamp: new Date(), | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| return () => { | ||
| unsubscribes.forEach((unsubscribe) => unsubscribe()); | ||
| }; | ||
| }); | ||
| }), | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { EVERY_5_SECONDS } from "@homarr/cron-jobs-core/expressions"; | ||
| import { createRequestIntegrationJobHandler } from "@homarr/request-handler/lib/cached-request-integration-job-handler"; | ||
| import { tracearrRequestHandler } from "@homarr/request-handler/tracearr"; | ||
|
|
||
| import { createCronJob } from "../../lib"; | ||
|
|
||
| export const tracearrJob = createCronJob("tracearr", EVERY_5_SECONDS).withCallback( | ||
| createRequestIntegrationJobHandler(tracearrRequestHandler.handler, { | ||
| widgetKinds: ["tracearr"], | ||
| getInput: { | ||
| tracearr: () => ({}), | ||
| }, | ||
| }), | ||
| ); | ||
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
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.
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.