-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Feature: Jellystat widget #5185
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
da9a423
Feature: Jellystat widget
Zlendy 4791561
Feature: Add "days" parameter to Jellystat widget
Zlendy 13518f5
Enhancement: Improve error detection in Jellystat widget
Zlendy 08a95de
Docs: Jellystat widget
Zlendy 8b7aef1
Refactor: Remove unnecessary fields length check
Zlendy 5c1b480
Refactor: Insert "days" variable in alphabetical (ish) order by widge…
Zlendy e32c904
Fix
shamoon 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,18 @@ | ||
| --- | ||
| title: Jellystat | ||
| description: Jellystat Widget Configuration | ||
| --- | ||
|
|
||
| Learn more about [Jellystat](https://github.com/CyferShepard/Jellystat). The widget supports (at least) Jellystat version 1.1.6 | ||
|
|
||
| You can create an API key from inside Jellystat at `Settings > API Key`. | ||
|
|
||
| Allowed fields: `["songs", "movies", "episodes", "other"]`. | ||
|
|
||
| ```yaml | ||
| widget: | ||
| type: jellystat | ||
| url: http://jellystat.host.or.ip | ||
| key: apikeyapikeyapikeyapikeyapikey | ||
| days: 30 # optional, defaults to 30 | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import Block from "components/services/widget/block"; | ||
| import Container from "components/services/widget/container"; | ||
|
|
||
| import useWidgetAPI from "utils/proxy/use-widget-api"; | ||
|
|
||
| export default function Component({ service }) { | ||
| const { widget } = service; | ||
|
|
||
| // Days validation | ||
| if (!(Number.isInteger(widget.days) && 0 < widget.days)) widget.days = 30; | ||
|
|
||
| if (!widget.fields) { | ||
| widget.fields = []; | ||
| } | ||
shamoon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const { data: viewsData, error: viewsError } = useWidgetAPI(widget, "getViewsByLibraryType", { days: widget.days }); | ||
|
|
||
| const error = viewsError || viewsData?.message; | ||
| if (error) { | ||
| return <Container service={service} error={error} />; | ||
| } | ||
|
|
||
| if (!viewsData) { | ||
| return ( | ||
| <Container service={service}> | ||
| <Block label="jellystat.songs" /> | ||
| <Block label="jellystat.movies" /> | ||
| <Block label="jellystat.episodes" /> | ||
| <Block label="jellystat.other" /> | ||
| </Container> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Container service={service}> | ||
| <Block label="jellystat.songs" value={viewsData.Audio} /> | ||
| <Block label="jellystat.movies" value={viewsData.Movie} /> | ||
| <Block label="jellystat.episodes" value={viewsData.Series} /> | ||
| <Block label="jellystat.other" value={viewsData.Other} /> | ||
| </Container> | ||
| ); | ||
| } | ||
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,15 @@ | ||
| import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; | ||
|
|
||
| const widget = { | ||
| api: "{url}/{endpoint}", | ||
| proxyHandler: credentialedProxyHandler, | ||
|
|
||
| mappings: { | ||
| getViewsByLibraryType: { | ||
| endpoint: "stats/getViewsByLibraryType", | ||
| params: ["days"], | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default widget; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be inserted alphabetical (ish) by widget name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to apply this suggestion, but honestly there are far too many widgets in the wrong order to be sure this is what you meant.
833db71b8770678c3c3efffe62286bef034c632e