feat(manage slideover): show more request override details (#2772)

* feat(manage slideover): show the language profile if request is for a show

* feat(manage slideover): show name of profiles instead of id
pull/2777/head
Danshil Kokil Mungur 3 years ago committed by GitHub
parent 14519ef555
commit 90095bb185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,7 @@ const messages = defineMessages({
server: 'Destination Server', server: 'Destination Server',
profilechanged: 'Quality Profile', profilechanged: 'Quality Profile',
rootfolder: 'Root Folder', rootfolder: 'Root Folder',
languageprofile: 'Language Profile',
}); });
interface RequestBlockProps { interface RequestBlockProps {
@ -38,7 +39,8 @@ const RequestBlock: React.FC<RequestBlockProps> = ({ request, onUpdate }) => {
const intl = useIntl(); const intl = useIntl();
const [isUpdating, setIsUpdating] = useState(false); const [isUpdating, setIsUpdating] = useState(false);
const [showEditModal, setShowEditModal] = useState(false); const [showEditModal, setShowEditModal] = useState(false);
const { profile, rootFolder, server } = useRequestOverride(request); const { profile, rootFolder, server, languageProfile } =
useRequestOverride(request);
const updateRequest = async (type: 'approve' | 'decline'): Promise<void> => { const updateRequest = async (type: 'approve' | 'decline'): Promise<void> => {
setIsUpdating(true); setIsUpdating(true);
@ -209,7 +211,7 @@ const RequestBlock: React.FC<RequestBlockProps> = ({ request, onUpdate }) => {
</div> </div>
</div> </div>
)} )}
{(server || profile !== null || rootFolder) && ( {(server || profile || rootFolder || languageProfile) && (
<> <>
<div className="mt-4 mb-1 text-sm"> <div className="mt-4 mb-1 text-sm">
{intl.formatMessage(messages.requestoverrides)} {intl.formatMessage(messages.requestoverrides)}
@ -223,12 +225,12 @@ const RequestBlock: React.FC<RequestBlockProps> = ({ request, onUpdate }) => {
<span>{server}</span> <span>{server}</span>
</li> </li>
)} )}
{profile !== null && ( {profile && (
<li className="flex justify-between px-1 py-2"> <li className="flex justify-between px-1 py-2">
<span className="font-bold"> <span className="font-bold">
{intl.formatMessage(messages.profilechanged)} {intl.formatMessage(messages.profilechanged)}
</span> </span>
<span>ID {profile}</span> <span>{profile}</span>
</li> </li>
)} )}
{rootFolder && ( {rootFolder && (
@ -239,6 +241,14 @@ const RequestBlock: React.FC<RequestBlockProps> = ({ request, onUpdate }) => {
<span>{rootFolder}</span> <span>{rootFolder}</span>
</li> </li>
)} )}
{languageProfile && (
<li className="flex justify-between px-1 py-2">
<span className="mr-2 font-bold">
{intl.formatMessage(messages.languageprofile)}
</span>
<span>{languageProfile}</span>
</li>
)}
</ul> </ul>
</> </>
)} )}

@ -1,45 +1,61 @@
import useSWR from 'swr'; import useSWR from 'swr';
import { MediaRequest } from '../../server/entity/MediaRequest'; import { MediaRequest } from '../../server/entity/MediaRequest';
import { ServiceCommonServer } from '../../server/interfaces/api/serviceInterfaces'; import {
ServiceCommonServer,
ServiceCommonServerWithDetails,
} from '../../server/interfaces/api/serviceInterfaces';
interface OverrideStatus { interface OverrideStatus {
server: string | null; server?: string;
profile: number | null; profile?: string;
rootFolder: string | null; rootFolder?: string;
languageProfile?: string;
} }
const useRequestOverride = (request: MediaRequest): OverrideStatus => { const useRequestOverride = (request: MediaRequest): OverrideStatus => {
const { data } = useSWR<ServiceCommonServer[]>( const { data: allServers } = useSWR<ServiceCommonServer[]>(
`/api/v1/service/${request.type === 'movie' ? 'radarr' : 'sonarr'}` `/api/v1/service/${request.type === 'movie' ? 'radarr' : 'sonarr'}`
); );
if (!data) { const { data } = useSWR<ServiceCommonServerWithDetails>(
return { `/api/v1/service/${request.type === 'movie' ? 'radarr' : 'sonarr'}/${
server: null, request.serverId
profile: null, }`
rootFolder: null, );
};
if (!data || !allServers) {
return {};
} }
const defaultServer = data.find( const defaultServer = allServers.find(
(server) => server.is4k === request.is4k && server.isDefault (server) => server.is4k === request.is4k && server.isDefault
); );
const activeServer = data.find((server) => server.id === request.serverId); const activeServer = allServers.find(
(server) => server.id === request.serverId
);
return { return {
server: server:
activeServer && request.serverId !== defaultServer?.id activeServer && request.serverId !== defaultServer?.id
? activeServer.name ? activeServer.name
: null, : undefined,
profile: profile:
defaultServer?.activeProfileId !== request.profileId defaultServer?.activeProfileId !== request.profileId
? request.profileId ? data.profiles.find((profile) => profile.id === request.profileId)
: null, ?.name
: undefined,
rootFolder: rootFolder:
defaultServer?.activeDirectory !== request.rootFolder defaultServer?.activeDirectory !== request.rootFolder
? request.rootFolder ? request.rootFolder
: null, : undefined,
languageProfile:
request.type === 'tv' &&
defaultServer?.activeLanguageProfileId !== request.languageProfileId
? data.languageProfiles?.find(
(profile) => profile.id === request.languageProfileId
)?.name
: undefined,
}; };
}; };

@ -269,6 +269,7 @@
"components.QuotaSelector.unlimited": "Unlimited", "components.QuotaSelector.unlimited": "Unlimited",
"components.RegionSelector.regionDefault": "All Regions", "components.RegionSelector.regionDefault": "All Regions",
"components.RegionSelector.regionServerDefault": "Default ({region})", "components.RegionSelector.regionServerDefault": "Default ({region})",
"components.RequestBlock.languageprofile": "Language Profile",
"components.RequestBlock.profilechanged": "Quality Profile", "components.RequestBlock.profilechanged": "Quality Profile",
"components.RequestBlock.requestoverrides": "Request Overrides", "components.RequestBlock.requestoverrides": "Request Overrides",
"components.RequestBlock.rootfolder": "Root Folder", "components.RequestBlock.rootfolder": "Root Folder",

Loading…
Cancel
Save