mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 23:45:48 +01:00
✨ Allow opening media requests links in external host (#824)
* Allow opening media requests links in external host * Removed useless translation files * Restored translations * 🌐 Add missing translation --------- Co-authored-by: Manuel <manuel.ruwe@bluewin.ch>
This commit is contained in:
@@ -3,7 +3,10 @@
|
|||||||
"name": "Media Requests",
|
"name": "Media Requests",
|
||||||
"description": "See a list of all media requests from your Overseerr or Jellyseerr instance",
|
"description": "See a list of all media requests from your Overseerr or Jellyseerr instance",
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Media requests list"
|
"title": "Media requests list",
|
||||||
|
"replaceLinksWithExternalHost": {
|
||||||
|
"label": "Replace links with external host"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"noRequests": "No requests found. Please ensure that you've configured your apps correctly.",
|
"noRequests": "No requests found. Please ensure that you've configured your apps correctly.",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { getConfig } from '../../../../tools/config/getConfig';
|
|||||||
|
|
||||||
import { MediaRequest } from '../../../../widgets/media-requests/media-request-types';
|
import { MediaRequest } from '../../../../widgets/media-requests/media-request-types';
|
||||||
import { ConfigAppType } from '../../../../types/app';
|
import { ConfigAppType } from '../../../../types/app';
|
||||||
|
import { MediaRequestListWidget } from '../../../../widgets/media-requests/MediaRequestListTile';
|
||||||
|
|
||||||
const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
||||||
const configName = getCookie('config-name', { req: request });
|
const configName = getCookie('config-name', { req: request });
|
||||||
@@ -24,6 +25,15 @@ const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
|||||||
})
|
})
|
||||||
.then(async (response) => {
|
.then(async (response) => {
|
||||||
const body = (await response.json()) as OverseerrResponse;
|
const body = (await response.json()) as OverseerrResponse;
|
||||||
|
const mediaWidget = config.widgets.find(
|
||||||
|
(x) => x.type === 'media-requests-list') as MediaRequestListWidget | undefined;
|
||||||
|
if (!mediaWidget) {
|
||||||
|
Consola.log('No media-requests-list found');
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
const appUrl = mediaWidget.properties.replaceLinksWithExternalHost
|
||||||
|
? app.behaviour.externalUrl
|
||||||
|
: app.url;
|
||||||
|
|
||||||
const requests = await Promise.all(
|
const requests = await Promise.all(
|
||||||
body.results.map(async (item): Promise<MediaRequest> => {
|
body.results.map(async (item): Promise<MediaRequest> => {
|
||||||
@@ -42,12 +52,12 @@ const Get = async (request: NextApiRequest, response: NextApiResponse) => {
|
|||||||
name: genericItem.name,
|
name: genericItem.name,
|
||||||
userName: item.requestedBy.displayName,
|
userName: item.requestedBy.displayName,
|
||||||
userProfilePicture: constructAvatarUrl(app, item),
|
userProfilePicture: constructAvatarUrl(app, item),
|
||||||
userLink: `${app.url}/users/${item.requestedBy.id}`,
|
userLink: `${appUrl}/users/${item.requestedBy.id}`,
|
||||||
airDate: genericItem.airDate,
|
airDate: genericItem.airDate,
|
||||||
status: item.status,
|
status: item.status,
|
||||||
backdropPath: `https://image.tmdb.org/t/p/original/${genericItem.backdropPath}`,
|
backdropPath: `https://image.tmdb.org/t/p/original/${genericItem.backdropPath}`,
|
||||||
posterPath: `https://image.tmdb.org/t/p/w600_and_h900_bestv2/${genericItem.posterPath}`,
|
posterPath: `https://image.tmdb.org/t/p/w600_and_h900_bestv2/${genericItem.posterPath}`,
|
||||||
href: `${app.behaviour.externalUrl}/movie/${item.media.tmdbId}`,
|
href: `${appUrl}/movie/${item.media.tmdbId}`,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ import { MediaRequest, MediaRequestStatus } from './media-request-types';
|
|||||||
const definition = defineWidget({
|
const definition = defineWidget({
|
||||||
id: 'media-requests-list',
|
id: 'media-requests-list',
|
||||||
icon: IconGitPullRequest,
|
icon: IconGitPullRequest,
|
||||||
options: {},
|
options: {
|
||||||
|
replaceLinksWithExternalHost: {
|
||||||
|
type: 'switch',
|
||||||
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
component: MediaRequestListTile,
|
component: MediaRequestListTile,
|
||||||
gridstack: {
|
gridstack: {
|
||||||
minWidth: 3,
|
minWidth: 3,
|
||||||
|
|||||||
Reference in New Issue
Block a user