Compare commits
No commits in common. "6df71e3341faa6e7f71cee7fc35325d24a2ab125" and "57a48de52f09eb9a37af2def580a43e4a2e455e0" have entirely different histories.
6df71e3341
...
57a48de52f
@ -78,9 +78,6 @@ public class MediaResource {
|
|||||||
if (data.contentEquals("null")) {
|
if (data.contentEquals("null")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (data.contentEquals("undefined")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,43 +86,34 @@ public class MediaResource {
|
|||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@Operation(description = "Create a new Media", tags = "GLOBAL")
|
@Operation(description = "Create a new Media", tags = "GLOBAL")
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Media uploadMedia( //
|
public Media uploadFile( //
|
||||||
// @AsyncType(Long.class) @FormDataParam("universeId") String universeId, //
|
@FormDataParam("fileName") String fileName, //
|
||||||
// @AsyncType(Long.class) @FormDataParam("typeId") String typeId, //
|
@FormDataParam("universe") String universe, //
|
||||||
// @AsyncType(Long.class) @FormDataParam("seriesId") String seriesId, //
|
@FormDataParam("series") String series, //
|
||||||
// @AsyncType(Long.class) @FormDataParam("season") String season, // value of the season ==> local add if needed
|
// @FormDataParam("seriesId") String seriesId, // Not used ...
|
||||||
// @AsyncType(Long.class) @FormDataParam("episode") String episode, // value of the season ==> local add if needed
|
@FormDataParam("season") String season, //
|
||||||
@FormDataParam("universeId") String universeId, //
|
@FormDataParam("episode") String episode, //
|
||||||
@FormDataParam("typeId") String typeId, //
|
|
||||||
@FormDataParam("seriesId") String seriesId, //
|
|
||||||
@FormDataParam("season") String season, // value of the season ==> local add if needed
|
|
||||||
@FormDataParam("episode") String episode, // value of the season ==> local add if needed
|
|
||||||
@FormDataParam("title") String title, //
|
@FormDataParam("title") String title, //
|
||||||
|
@FormDataParam("typeId") String typeId, //
|
||||||
@FormDataParam("file") final InputStream fileInputStream, //
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||||
) throws FailException {
|
) throws FailException {
|
||||||
try (DBAccess db = DBAccess.createInterface()) {
|
try (DBAccess db = DBAccess.createInterface()) {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
final String fileName = multipartCorrection(fileMetaData.getFileName());
|
fileName = multipartCorrection(fileName);
|
||||||
universeId = multipartCorrection(universeId);
|
universe = multipartCorrection(universe);
|
||||||
final Long universeIdLong = universeId != null ? Long.parseLong(universeId) : null;
|
series = multipartCorrection(series);
|
||||||
typeId = multipartCorrection(typeId);
|
|
||||||
final Long typeIdLong = typeId != null ? Long.parseLong(typeId) : null;
|
|
||||||
seriesId = multipartCorrection(seriesId);
|
|
||||||
final Long seriesIdLong = seriesId != null ? Long.parseLong(seriesId) : null;
|
|
||||||
season = multipartCorrection(season);
|
season = multipartCorrection(season);
|
||||||
final Long seasonLong = season != null ? Long.parseLong(season) : null;
|
|
||||||
episode = multipartCorrection(episode);
|
episode = multipartCorrection(episode);
|
||||||
title = multipartCorrection(title);
|
title = multipartCorrection(title);
|
||||||
|
typeId = multipartCorrection(typeId);
|
||||||
// todo: check if all remotes Id exist ...
|
|
||||||
|
|
||||||
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||||
LOGGER.info(" - fileName: {}", fileName);
|
LOGGER.info(" - fileName: {}", fileName);
|
||||||
LOGGER.info(" - universe: {}", universeIdLong);
|
LOGGER.info(" - universe: {}", universe);
|
||||||
LOGGER.info(" - series: {}", seriesIdLong);
|
LOGGER.info(" - series: {}", series);
|
||||||
LOGGER.info(" - season: {}", seasonLong);
|
LOGGER.info(" - season: {}", season);
|
||||||
LOGGER.info(" - episode: {}", episode);
|
LOGGER.info(" - episode: {}", episode);
|
||||||
LOGGER.info(" - title: {}", title);
|
LOGGER.info(" - title: {}", title);
|
||||||
LOGGER.info(" - type: {}", typeId);
|
LOGGER.info(" - type: {}", typeId);
|
||||||
@ -161,32 +149,26 @@ public class MediaResource {
|
|||||||
// Fist step: retieve all the Id of each parents:...
|
// Fist step: retieve all the Id of each parents:...
|
||||||
LOGGER.info("Find typeNode");
|
LOGGER.info("Find typeNode");
|
||||||
// check if id of type exist:
|
// check if id of type exist:
|
||||||
final Type typeNode = TypeResource.getId(typeIdLong);
|
final Type typeNode = TypeResource.getId(Long.parseLong(typeId));
|
||||||
if (typeNode == null) {
|
if (typeNode == null) {
|
||||||
DataResource.removeTemporaryFile(tmpUID);
|
DataResource.removeTemporaryFile(tmpUID);
|
||||||
throw new InputException("typeId", "TypeId does not exist ...");
|
throw new InputException("typeId", "TypeId does not exist ...");
|
||||||
}
|
}
|
||||||
// check if id of type exist:
|
LOGGER.info(" ==> {}", typeNode);
|
||||||
|
LOGGER.info("Find seriesNode");
|
||||||
|
// get uid of group:
|
||||||
Series seriesNode = null;
|
Series seriesNode = null;
|
||||||
if (seriesIdLong != null) {
|
if (series != null) {
|
||||||
seriesNode = SeriesResource.getId(seriesIdLong);
|
seriesNode = SeriesResource.getOrCreate(series, typeNode.id);
|
||||||
if (seriesNode == null) {
|
|
||||||
DataResource.removeTemporaryFile(tmpUID);
|
|
||||||
throw new InputException("seriesId", "seriesId does not exist ...");
|
|
||||||
}
|
|
||||||
if (seriesNode.parentId != typeNode.id) {
|
|
||||||
DataResource.removeTemporaryFile(tmpUID);
|
|
||||||
throw new InputException("seriesId", "seriesId object have not the correct parent...");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info(" ==> {}", seriesNode);
|
LOGGER.info(" ==> {}", seriesNode);
|
||||||
LOGGER.info("Find seasonNode");
|
LOGGER.info("Find seasonNode");
|
||||||
// get uid of season:
|
// get uid of season:
|
||||||
Season seasonNode = null;
|
Season seasonNode = null;
|
||||||
if (seriesNode == null && seasonLong != null) {
|
if (seriesNode == null && season != null) {
|
||||||
DataResource.removeTemporaryFile(tmpUID);
|
DataResource.removeTemporaryFile(tmpUID);
|
||||||
throw new InputException("season", "Season is set but no series is set !!");
|
throw new InputException("season", "Season is set but no seraies is set !!");
|
||||||
}
|
}
|
||||||
if (season != null) {
|
if (season != null) {
|
||||||
seasonNode = SeasonResource.getOrCreate(season, seriesNode.id);
|
seasonNode = SeasonResource.getOrCreate(season, seriesNode.id);
|
||||||
|
@ -52,9 +52,6 @@ public class SeriesResource {
|
|||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Series getId(final Long id) throws Exception {
|
|
||||||
return DataAccess.get(Series.class, id);
|
|
||||||
}
|
|
||||||
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
@ -34,7 +34,6 @@ public class Media extends GenericDataSoftDelete {
|
|||||||
public ObjectId dataId;
|
public ObjectId dataId;
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Nullable
|
|
||||||
public UUID dataIdOld;
|
public UUID dataIdOld;
|
||||||
@Schema(description = "Type of the media")
|
@Schema(description = "Type of the media")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
||||||
|
@ -181,20 +181,21 @@ export namespace MediaResource {
|
|||||||
/**
|
/**
|
||||||
* Create a new Media
|
* Create a new Media
|
||||||
*/
|
*/
|
||||||
export function uploadMedia({
|
export function uploadFile({
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callbacks,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: {
|
data: {
|
||||||
|
fileName: string,
|
||||||
file: File,
|
file: File,
|
||||||
universeId: string,
|
series: string,
|
||||||
|
universe: string,
|
||||||
season: string,
|
season: string,
|
||||||
typeId: string,
|
|
||||||
episode: string,
|
episode: string,
|
||||||
|
typeId: string,
|
||||||
title: string,
|
title: string,
|
||||||
seriesId: string,
|
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callbacks?: RESTCallbacks,
|
||||||
}): Promise<Media> {
|
}): Promise<Media> {
|
||||||
|
@ -22,7 +22,7 @@ export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
|||||||
* Foreign Key Id of the data
|
* Foreign Key Id of the data
|
||||||
*/
|
*/
|
||||||
dataId: ZodObjectId,
|
dataId: ZodObjectId,
|
||||||
dataIdOld: ZodUUID.optional(),
|
dataIdOld: ZodUUID,
|
||||||
/**
|
/**
|
||||||
* Type of the media
|
* Type of the media
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,7 @@ export const ZodMediaWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|||||||
* Foreign Key Id of the data
|
* Foreign Key Id of the data
|
||||||
*/
|
*/
|
||||||
dataId: ZodObjectId.optional(),
|
dataId: ZodObjectId.optional(),
|
||||||
dataIdOld: ZodUUID.nullable().optional(),
|
dataIdOld: ZodUUID.optional(),
|
||||||
/**
|
/**
|
||||||
* Type of the media
|
* Type of the media
|
||||||
*/
|
*/
|
||||||
|
@ -69,8 +69,7 @@ export const Covers = ({
|
|||||||
loading="lazy"
|
loading="lazy"
|
||||||
src={url}
|
src={url}
|
||||||
maxWidth={size}
|
maxWidth={size}
|
||||||
maxHeight={size}
|
boxSize={size} /*{...rest}*/
|
||||||
boxSize={size}
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
MdFastForward,
|
MdFastForward,
|
||||||
MdFastRewind,
|
MdFastRewind,
|
||||||
MdFullscreen,
|
MdFullscreen,
|
||||||
MdFullscreenExit,
|
|
||||||
MdLooksOne,
|
MdLooksOne,
|
||||||
MdNavigateBefore,
|
MdNavigateBefore,
|
||||||
MdNavigateNext,
|
MdNavigateNext,
|
||||||
@ -64,8 +63,6 @@ const formatTime = (time) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const VideoPlayer = ({}: AudioPlayerProps) => {
|
export const VideoPlayer = ({}: AudioPlayerProps) => {
|
||||||
const { playMediaList, MediaOffset, previous, next, first, clear } =
|
|
||||||
useActivePlaylistService();
|
|
||||||
const [time, setTime] = useState(10);
|
const [time, setTime] = useState(10);
|
||||||
const [isRunning, setIsRunning] = useState(true);
|
const [isRunning, setIsRunning] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -85,24 +82,22 @@ export const VideoPlayer = ({}: AudioPlayerProps) => {
|
|||||||
}, [time, isRunning]);
|
}, [time, isRunning]);
|
||||||
|
|
||||||
const resetTimer = () => {
|
const resetTimer = () => {
|
||||||
if (playMediaList.length !== 0 && !!document.fullscreenElement) {
|
setTime(10);
|
||||||
setTime(10);
|
setIsRunning(true);
|
||||||
setIsRunning(true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const resetTimerLocal = () => {
|
const resetTimer = () => {
|
||||||
if (playMediaList.length !== 0 && !!document.fullscreenElement) {
|
setTime(10);
|
||||||
setTime(10);
|
setIsRunning(true);
|
||||||
setIsRunning(true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
window.addEventListener("mousemove", resetTimerLocal);
|
window.addEventListener("mousemove", resetTimer);
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener("mousemove", resetTimerLocal);
|
window.removeEventListener("mousemove", resetTimer);
|
||||||
};
|
};
|
||||||
}, [playMediaList, setTime, setIsRunning]);
|
}, []);
|
||||||
|
|
||||||
|
const { playMediaList, MediaOffset, previous, next, first, clear } =
|
||||||
|
useActivePlaylistService();
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const [isPlaying, setIsPlaying] = useState<boolean>(false);
|
const [isPlaying, setIsPlaying] = useState<boolean>(false);
|
||||||
@ -116,7 +111,7 @@ export const VideoPlayer = ({}: AudioPlayerProps) => {
|
|||||||
const { dataType } = useSpecificType(dataMedia?.typeId);
|
const { dataType } = useSpecificType(dataMedia?.typeId);
|
||||||
const { dataSeries } = useSpecificSeries(dataMedia?.seriesId);
|
const { dataSeries } = useSpecificSeries(dataMedia?.seriesId);
|
||||||
|
|
||||||
const isMobile = useBreakpointValue({ base: true, md: false });
|
const isMobile = useBreakpointValue({ base: false, sm: true });
|
||||||
const [mediaSource, setMediaSource] = useState<string>('');
|
const [mediaSource, setMediaSource] = useState<string>('');
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMediaSource(
|
setMediaSource(
|
||||||
@ -476,9 +471,7 @@ export const VideoPlayer = ({}: AudioPlayerProps) => {
|
|||||||
onClick={onFullScreen}
|
onClick={onFullScreen}
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
>
|
>
|
||||||
{!!document.fullscreenElement ?
|
<MdFullscreen style={{ width: '100%', height: '100%' }} />
|
||||||
<MdFullscreenExit style={{ width: '100%', height: '100%' }} />:
|
|
||||||
<MdFullscreen style={{ width: '100%', height: '100%' }} />}
|
|
||||||
</IconButton>
|
</IconButton>
|
||||||
{isPiPSupported && !isMobile &&
|
{isPiPSupported && !isMobile &&
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -16,8 +16,6 @@ export type FormSelectProps = {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
// Form: Specify if the element is required or not
|
// Form: Specify if the element is required or not
|
||||||
isRequired?: boolean;
|
isRequired?: boolean;
|
||||||
// is locked for edition
|
|
||||||
disabled?: boolean;
|
|
||||||
// List of object options
|
// List of object options
|
||||||
options: object[];
|
options: object[];
|
||||||
// in the option specify the value Key
|
// in the option specify the value Key
|
||||||
@ -37,7 +35,6 @@ export const FormSelect = ({
|
|||||||
options,
|
options,
|
||||||
keyInputKey = 'id',
|
keyInputKey = 'id',
|
||||||
keyInputValue = 'name',
|
keyInputValue = 'name',
|
||||||
disabled = false,
|
|
||||||
suggestion,
|
suggestion,
|
||||||
addNewItem,
|
addNewItem,
|
||||||
...rest
|
...rest
|
||||||
@ -63,7 +60,6 @@ export const FormSelect = ({
|
|||||||
keyValue={keyInputValue}
|
keyValue={keyInputValue}
|
||||||
onCreate={onCreate}
|
onCreate={onCreate}
|
||||||
suggestion={suggestion}
|
suggestion={suggestion}
|
||||||
disabled={disabled}
|
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
|
@ -73,13 +73,7 @@ export const PopUpUploadProgress = ({
|
|||||||
animated
|
animated
|
||||||
max={totalSize}
|
max={totalSize}
|
||||||
height="24px"
|
height="24px"
|
||||||
width="full"
|
/>
|
||||||
colorPalette="blue"
|
|
||||||
>
|
|
||||||
<Progress.Track>
|
|
||||||
<Progress.Range />
|
|
||||||
</Progress.Track>
|
|
||||||
</Progress.Root>
|
|
||||||
<Flex>
|
<Flex>
|
||||||
<Text>{currentSize.toLocaleString('fr-FR')} Bytes</Text>
|
<Text>{currentSize.toLocaleString('fr-FR')} Bytes</Text>
|
||||||
<Text marginLeft="auto">
|
<Text marginLeft="auto">
|
||||||
@ -87,7 +81,7 @@ export const PopUpUploadProgress = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
{error && (
|
{error && (
|
||||||
<Text fontWeight="bold" color="darkred" whiteSpace="pre-wrap">
|
<Text fontWeight="bold" color="darkred">
|
||||||
{error}
|
{error}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
|
@ -17,8 +17,6 @@ export type SelectSingleProps = {
|
|||||||
onChange?: (value: number | string | undefined) => void;
|
onChange?: (value: number | string | undefined) => void;
|
||||||
keyKey?: string;
|
keyKey?: string;
|
||||||
keyValue?: string;
|
keyValue?: string;
|
||||||
// is locked for edition
|
|
||||||
disabled?: boolean;
|
|
||||||
ref?: RefObject<any>;
|
ref?: RefObject<any>;
|
||||||
// if set add capability to add the search item
|
// if set add capability to add the search item
|
||||||
onCreate?: (data: string) => void;
|
onCreate?: (data: string) => void;
|
||||||
@ -33,7 +31,6 @@ export const SelectSingle = ({
|
|||||||
ref,
|
ref,
|
||||||
keyKey = 'id',
|
keyKey = 'id',
|
||||||
keyValue = keyKey,
|
keyValue = keyKey,
|
||||||
disabled = false,
|
|
||||||
suggestion,
|
suggestion,
|
||||||
onCreate,
|
onCreate,
|
||||||
}: SelectSingleProps) => {
|
}: SelectSingleProps) => {
|
||||||
@ -110,7 +107,6 @@ export const SelectSingle = ({
|
|||||||
<Flex>
|
<Flex>
|
||||||
<Input
|
<Input
|
||||||
ref={refFocus}
|
ref={refFocus}
|
||||||
disabled={disabled}
|
|
||||||
width="full"
|
width="full"
|
||||||
onChange={(e) => onChangeInput(e.target.value)}
|
onChange={(e) => onChangeInput(e.target.value)}
|
||||||
onFocus={() => setShowList(true)}
|
onFocus={() => setShowList(true)}
|
||||||
@ -128,7 +124,6 @@ export const SelectSingle = ({
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={onRemoveItem}
|
onClick={onRemoveItem}
|
||||||
disabled={disabled}
|
|
||||||
variant="outline"
|
variant="outline"
|
||||||
borderRadius="0 5px 5px 0"
|
borderRadius="0 5px 5px 0"
|
||||||
borderWidth="1px 1px 1px 0"
|
borderWidth="1px 1px 1px 0"
|
||||||
|
@ -17,7 +17,7 @@ import { SettingsPage } from './home/SettingsPage';
|
|||||||
import { MediaRoutes } from './media/MediaRoutes';
|
import { MediaRoutes } from './media/MediaRoutes';
|
||||||
import { OnAirPage } from './onAir/OnAirPage';
|
import { OnAirPage } from './onAir/OnAirPage';
|
||||||
import { SeasonRoutes } from './season/SeasonRoutes';
|
import { SeasonRoutes } from './season/SeasonRoutes';
|
||||||
import { SeriesRoutes } from './sso/series/SeriesRoutes';
|
import { SeriesRoutes } from './series/SeriesRoutes';
|
||||||
import { TypeRoutes } from './type/TypesRoutes';
|
import { TypeRoutes } from './type/TypesRoutes';
|
||||||
|
|
||||||
export const AppRoutes = () => {
|
export const AppRoutes = () => {
|
||||||
|
@ -5,10 +5,8 @@ import { LuTrash } from 'react-icons/lu';
|
|||||||
import { MdCloudUpload } from 'react-icons/md';
|
import { MdCloudUpload } from 'react-icons/md';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Media,
|
|
||||||
MediaResource,
|
|
||||||
RestErrorResponse,
|
|
||||||
Season,
|
Season,
|
||||||
|
SeasonResource,
|
||||||
Series,
|
Series,
|
||||||
SeriesResource,
|
SeriesResource,
|
||||||
Type,
|
Type,
|
||||||
@ -24,7 +22,8 @@ import {
|
|||||||
NumberInputRoot,
|
NumberInputRoot,
|
||||||
} from '@/components/ui/number-input';
|
} from '@/components/ui/number-input';
|
||||||
import { useMediaService } from '@/service/Media';
|
import { useMediaService } from '@/service/Media';
|
||||||
import { useOrderedSeries, useOrderedSeriesWithType, useSeriesService } from '@/service/Series';
|
import { useOrderedSeasons, useSeasonService } from '@/service/Season';
|
||||||
|
import { useOrderedSeries, useSeriesService } from '@/service/Series';
|
||||||
import { useServiceContext } from '@/service/ServiceContext';
|
import { useServiceContext } from '@/service/ServiceContext';
|
||||||
import { useOrderedTypes, useTypeService } from '@/service/Type';
|
import { useOrderedTypes, useTypeService } from '@/service/Type';
|
||||||
import { isNullOrUndefined } from '@/utils/validator';
|
import { isNullOrUndefined } from '@/utils/validator';
|
||||||
@ -40,17 +39,14 @@ export class ElementList {
|
|||||||
export class FileParsedElement {
|
export class FileParsedElement {
|
||||||
public isSended: boolean = false;
|
public isSended: boolean = false;
|
||||||
public nameDetected: boolean = false;
|
public nameDetected: boolean = false;
|
||||||
public mediaIdDetected: boolean = false;
|
public MediaIdDetected: boolean = false;
|
||||||
public seasonId?: Season['id'] = undefined;
|
|
||||||
public seriesId?: Series['id'] = undefined;
|
|
||||||
constructor(
|
constructor(
|
||||||
public uniqueId: number,
|
public uniqueId: number,
|
||||||
public file: File,
|
public file: File,
|
||||||
public title: string,
|
public title: string,
|
||||||
public universe?: string,
|
public Series?: string,
|
||||||
public series?: string,
|
public Season?: string,
|
||||||
public season?: number,
|
public MediaId?: number
|
||||||
public mediaId?: number
|
|
||||||
) {
|
) {
|
||||||
console.log(`Unique element: ${uniqueId}`);
|
console.log(`Unique element: ${uniqueId}`);
|
||||||
// nothing to do.
|
// nothing to do.
|
||||||
@ -68,8 +64,8 @@ export class FileFailParsedElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FormInsertData = {
|
type FormInsertData = {
|
||||||
typeId?: number;
|
TypeId?: number;
|
||||||
seriesId?: number;
|
SeriesId?: number;
|
||||||
titleSeason?: string;
|
titleSeason?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,9 +83,11 @@ export const AddPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { dataTypes } = useOrderedTypes();
|
const { dataTypes } = useOrderedTypes();
|
||||||
const { dataSeries: dataSeriesFull } = useOrderedSeries();
|
const { dataSeries } = useOrderedSeries();
|
||||||
|
const { dataSeasons } = useOrderedSeasons();
|
||||||
const { store: storeType } = useTypeService();
|
const { store: storeType } = useTypeService();
|
||||||
const { store: storeSeries } = useSeriesService();
|
const { store: storeSeries } = useSeriesService();
|
||||||
|
const { store: storeSeason } = useSeasonService();
|
||||||
const { store: storeMedia } = useMediaService();
|
const { store: storeMedia } = useMediaService();
|
||||||
const { session } = useServiceContext();
|
const { session } = useServiceContext();
|
||||||
|
|
||||||
@ -99,8 +97,6 @@ export const AddPage = () => {
|
|||||||
enableReset: false,
|
enableReset: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// I think this does not work ...
|
|
||||||
const { dataSeries } = useOrderedSeriesWithType(form.values["typeId"]);
|
|
||||||
|
|
||||||
const updateNeedSend = () => {
|
const updateNeedSend = () => {
|
||||||
if (parsedElement.length === 0) {
|
if (parsedElement.length === 0) {
|
||||||
@ -146,12 +142,7 @@ export const AddPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onMediaId = (data: FileParsedElement, value: any): void => {
|
const onMediaId = (data: FileParsedElement, value: any): void => {
|
||||||
data.mediaId = value;
|
data.MediaId = value;
|
||||||
setParsedElement([...parsedElement]);
|
|
||||||
updateNeedSend();
|
|
||||||
};
|
|
||||||
const onSeasonId = (data: FileParsedElement, value: any): void => {
|
|
||||||
data.season = value;
|
|
||||||
setParsedElement([...parsedElement]);
|
setParsedElement([...parsedElement]);
|
||||||
updateNeedSend();
|
updateNeedSend();
|
||||||
};
|
};
|
||||||
@ -160,64 +151,68 @@ export const AddPage = () => {
|
|||||||
setParsedElement([]);
|
setParsedElement([]);
|
||||||
setParsedFailedElement(undefined);
|
setParsedFailedElement(undefined);
|
||||||
setListFileInBdd(undefined);
|
setListFileInBdd(undefined);
|
||||||
|
|
||||||
setSuggestedSeries(undefined);
|
setSuggestedSeries(undefined);
|
||||||
//setSuggestedSeason(undefined);
|
setSuggestedSeason(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
const regex = /^(?:(?<universe>[\w. -]+):)?((?<series>[\w. -]+?)((-s| S)(?<season>\d{1,5}))?(?:(-e|E)(?<episode>\d{1,5}))[- ])?\s*(?<title>.+?)\.(webm|WEBM|Webm|mkv|MKV|Mkv)$/;
|
|
||||||
|
|
||||||
const addFileWithMetaData = (file: File, id: number) => {
|
const addFileWithMetaData = (file: File, id: number) => {
|
||||||
// parsedElement: FileParsedElement[] = [];
|
// parsedElement: FileParsedElement[] = [];
|
||||||
let universe: string | undefined = undefined;
|
let Series: string | undefined = undefined;
|
||||||
let series: string | undefined = undefined;
|
let Season: string | undefined = undefined;
|
||||||
let season: number | undefined = undefined;
|
let MediaIdNumber: number | undefined = undefined;
|
||||||
let mediaIdNumber: number | undefined = undefined;
|
|
||||||
let title: string = '';
|
let title: string = '';
|
||||||
|
|
||||||
form.restoreValues();
|
form.restoreValues();
|
||||||
|
|
||||||
console.log(`select file ${file.name}`);
|
console.log(`select file ${file.name}`);
|
||||||
|
let tmpName = file.name.replace(/[ \t]*-[ \t]*/g, '-');
|
||||||
const match = file.name.match(regex);
|
//tmpName = tmpName.replace(/_/g, '-');
|
||||||
if (match?.groups) {
|
//tmpName = tmpName.replace(/--/g, '-');
|
||||||
universe = match.groups.universe || undefined;
|
console.log(`select file ${tmpName}`);
|
||||||
series = match.groups.series ? match.groups.series.trim() : undefined;
|
const splitElement = tmpName.split('~');
|
||||||
season = match.groups.season? parseInt(match.groups.season, 10) : undefined;
|
if (splitElement.length > 1) {
|
||||||
mediaIdNumber = match.groups.episode ? parseInt(match.groups.episode, 10) : undefined;
|
Series = splitElement[0];
|
||||||
title = match.groups.title.trim();
|
tmpName = tmpName.substring(Series.length + 1);
|
||||||
} else {
|
|
||||||
console.log("❌ not match :", file.name);
|
|
||||||
title = file.name.trim();
|
|
||||||
}
|
}
|
||||||
|
const splitElement2 = tmpName.split('#');
|
||||||
if (season && isNaN(season)) {
|
if (splitElement2.length > 1) {
|
||||||
season = undefined;
|
Season = splitElement2[0];
|
||||||
|
tmpName = tmpName.substring(Season.length + 1);
|
||||||
}
|
}
|
||||||
if (mediaIdNumber && isNaN(mediaIdNumber)) {
|
//console.log("ploppppp " + tmpName);
|
||||||
mediaIdNumber = undefined;
|
const splitElement3 = tmpName.split('-');
|
||||||
|
if (splitElement3.length > 1) {
|
||||||
|
MediaIdNumber = parseInt(splitElement3[0], 10);
|
||||||
|
tmpName = tmpName.substring(splitElement3[0].length + 1);
|
||||||
|
}
|
||||||
|
//console.log("KKKppppp " + tmpName);
|
||||||
|
//console.log(" ===> " + splitElement3[0]);
|
||||||
|
title = tmpName;
|
||||||
|
|
||||||
|
if (MediaIdNumber && isNaN(MediaIdNumber)) {
|
||||||
|
MediaIdNumber = undefined;
|
||||||
}
|
}
|
||||||
// remove extension
|
// remove extension
|
||||||
title = title.replace(new RegExp('\\.(webm|WEBM|Webm|mkv|MKV|Mkv)'), '');
|
title = title.replace(new RegExp('\\.(webm|WEBM|Webm)'), '');
|
||||||
let tmp = new FileParsedElement(
|
let tmp = new FileParsedElement(
|
||||||
id,
|
id,
|
||||||
file,
|
file,
|
||||||
title,
|
title,
|
||||||
universe,
|
Series,
|
||||||
series,
|
Season,
|
||||||
season,
|
MediaIdNumber
|
||||||
mediaIdNumber
|
|
||||||
);
|
);
|
||||||
console.log(`==>${JSON.stringify(tmp, null, 2)}`);
|
console.log(`==>${JSON.stringify(tmp)}`);
|
||||||
|
|
||||||
// add it in the list.
|
// add it in the list.
|
||||||
return tmp;
|
return tmp;
|
||||||
};
|
};
|
||||||
const [suggestedSeries, setSuggestedSeries] = useState<string | undefined>(
|
const [suggestedSeries, setSuggestedSeries] = useState<string | undefined>(
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
// const [suggestedSeason, setSuggestedSeason] = useState<string | undefined>(
|
const [suggestedSeason, setSuggestedSeason] = useState<string | undefined>(
|
||||||
// undefined
|
undefined
|
||||||
// );
|
);
|
||||||
|
|
||||||
const onChangeFile = (value: any): void => {
|
const onChangeFile = (value: any): void => {
|
||||||
clearData();
|
clearData();
|
||||||
@ -237,9 +232,9 @@ export const AddPage = () => {
|
|||||||
// clean different Series:
|
// clean different Series:
|
||||||
for (let iii = 1; iii < parsedElementTmp.length; iii++) {
|
for (let iii = 1; iii < parsedElementTmp.length; iii++) {
|
||||||
console.log(
|
console.log(
|
||||||
`check Series [${iii + 1}/${parsedElementTmp.length}] '${parsedElementTmp[0].series} !== ${parsedElementTmp[iii].series}'`
|
`check Series [${iii + 1}/${parsedElementTmp.length}] '${parsedElementTmp[0].Series} !== ${parsedElementTmp[iii].Series}'`
|
||||||
);
|
);
|
||||||
if (parsedElementTmp[0].series !== parsedElementTmp[iii].series) {
|
if (parsedElementTmp[0].Series !== parsedElementTmp[iii].Series) {
|
||||||
parsedFailedElementTmp.push(
|
parsedFailedElementTmp.push(
|
||||||
new FileFailParsedElement(
|
new FileFailParsedElement(
|
||||||
parsedFailedElementTmp.length,
|
parsedFailedElementTmp.length,
|
||||||
@ -254,29 +249,64 @@ export const AddPage = () => {
|
|||||||
iii--;
|
iii--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// clean different Season:
|
||||||
|
for (let iii = 1; iii < parsedElementTmp.length; iii++) {
|
||||||
|
console.log(
|
||||||
|
`check Season [${iii + 1}/${parsedElementTmp.length}] '${parsedElementTmp[0].Season} !== ${parsedElementTmp[iii].Season}'`
|
||||||
|
);
|
||||||
|
if (parsedElementTmp[0].Season !== parsedElementTmp[iii].Season) {
|
||||||
|
parsedFailedElementTmp.push(
|
||||||
|
new FileFailParsedElement(
|
||||||
|
parsedFailedElementTmp.length,
|
||||||
|
parsedElementTmp[iii].file,
|
||||||
|
'Remove from list due to wrong Season value'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Remove from list (!= Season) : [${iii + 1}/${parsedElementTmp.length}] '${parsedElementTmp[iii].file.name}'`
|
||||||
|
);
|
||||||
|
parsedElementTmp.splice(iii, 1);
|
||||||
|
iii--;
|
||||||
|
}
|
||||||
|
}
|
||||||
setParsedElement(parsedElementTmp);
|
setParsedElement(parsedElementTmp);
|
||||||
setParsedFailedElement(parsedFailedElementTmp);
|
setParsedFailedElement(parsedFailedElementTmp);
|
||||||
console.log(`check : ${JSON.stringify(parsedElementTmp[0])}`);
|
console.log(`check : ${JSON.stringify(parsedElementTmp[0])}`);
|
||||||
|
|
||||||
// find seriesId:
|
// find SeriesId:
|
||||||
console.log(`try find Series : ${parsedElementTmp[0].series}`);
|
console.log(`try find Series : ${parsedElementTmp[0].Series}`);
|
||||||
let SeriesFound = false;
|
let SeriesFound = false;
|
||||||
dataSeriesFull.forEach((data) => {
|
dataSeries.forEach((data) => {
|
||||||
if (
|
if (
|
||||||
data.name?.toLowerCase() === parsedElementTmp[0].series?.toLowerCase()
|
data.name?.toLowerCase() === parsedElementTmp[0].Series?.toLowerCase()
|
||||||
) {
|
) {
|
||||||
console.log(` find Series : ${data.id}`);
|
console.log(` find Series : ${data.id}`);
|
||||||
form.setValues({ seriesId: data.id });
|
form.setValues({ SeriesId: data.id });
|
||||||
form.setValues({ typeId: data.parentId });
|
|
||||||
SeriesFound = true;
|
SeriesFound = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!SeriesFound) {
|
if (!SeriesFound) {
|
||||||
console.log(` set Suggested Series : ${parsedElementTmp[0].series}`);
|
console.log(` set Suggested Series : ${parsedElementTmp[0].Series}`);
|
||||||
setSuggestedSeries(parsedElementTmp[0].series);
|
setSuggestedSeries(parsedElementTmp[0].Series);
|
||||||
} else {
|
} else {
|
||||||
setSuggestedSeries(undefined);
|
setSuggestedSeries(undefined);
|
||||||
}
|
}
|
||||||
|
// try to find Season
|
||||||
|
console.log(`try find Season : ${parsedElementTmp[0].Season}`);
|
||||||
|
let SeasonFound = false;
|
||||||
|
dataSeasons.forEach((data) => {
|
||||||
|
if (
|
||||||
|
data.name?.toLowerCase() === parsedElementTmp[0].Season?.toLowerCase()
|
||||||
|
) {
|
||||||
|
console.log(` find Season : ${data.id}`);
|
||||||
|
form.setValues({ SeasonId: data.id });
|
||||||
|
SeasonFound = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!SeasonFound) {
|
||||||
|
console.log(` set Suggested Season : ${parsedElementTmp[0].Season}`);
|
||||||
|
setSuggestedSeason(parsedElementTmp[0].Season);
|
||||||
|
}
|
||||||
updateNeedSend();
|
updateNeedSend();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -297,9 +327,6 @@ export const AddPage = () => {
|
|||||||
|
|
||||||
const uploadNext = useCallback(
|
const uploadNext = useCallback(
|
||||||
(index: number = 0): void => {
|
(index: number = 0): void => {
|
||||||
// if (indexUpload == undefined) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if (parsedElement.length <= index) {
|
if (parsedElement.length <= index) {
|
||||||
console.log('end of upload');
|
console.log('end of upload');
|
||||||
setIsFinishedUpload(true);
|
setIsFinishedUpload(true);
|
||||||
@ -312,34 +339,33 @@ export const AddPage = () => {
|
|||||||
const data = {
|
const data = {
|
||||||
title: parsedElement[index].title,
|
title: parsedElement[index].title,
|
||||||
file: parsedElement[index].file,
|
file: parsedElement[index].file,
|
||||||
universeId: `${form.values['universeId']}`,
|
SeasonId: form.values['SeasonId'] ?? undefined,
|
||||||
typeId: `${form.values['typeId']}`,
|
SeriesId: form.values['SeriesId'] ?? undefined,
|
||||||
seriesId: `${form.values['seriesId']}`,
|
TypeId: form.values['TypeId'] ?? undefined,
|
||||||
season: `${parsedElement[index].season}`,
|
MediaId: parsedElement[index].MediaId ?? undefined,
|
||||||
episode: `${parsedElement[index].mediaId}`,
|
|
||||||
};
|
};
|
||||||
console.log(`data= ${JSON.stringify(data, null, 2)}`);
|
console.log(`data= ${JSON.stringify(data, null, 2)}`);
|
||||||
console.error("Not_ implemented");
|
console.error("Not_ implemented");
|
||||||
storeMedia
|
// storeMedia
|
||||||
.update(
|
// .update(
|
||||||
MediaResource.uploadMedia({
|
// MediaResource.uploadMedia({
|
||||||
restConfig: session.getRestConfig(),
|
// restConfig: session.getRestConfig(),
|
||||||
data,
|
// data,
|
||||||
callbacks: {
|
// callbacks: {
|
||||||
progressUpload: progressUpload,
|
// progressUpload: progressUpload,
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
)
|
// )
|
||||||
.then((data: Media) => {
|
// .then((data: Media) => {
|
||||||
// element sended good
|
// // element sended good
|
||||||
// Send next ...
|
// // Send next ...
|
||||||
uploadNext(index + 1);
|
// uploadNext(index + 1);
|
||||||
})
|
// })
|
||||||
.catch((error: RestErrorResponse) => {
|
// .catch((error: RestErrorResponse) => {
|
||||||
// TODO: manage error
|
// // TODO: manage error
|
||||||
console.log(`element error: ${JSON.stringify(error, null, 2)}`);
|
// console.log(`element error: ${JSON.stringify(error, null, 2)}`);
|
||||||
setUploadError(JSON.stringify(error, null, 2));
|
// setUploadError(JSON.stringify(error, null, 2));
|
||||||
});
|
// });
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
setUploadError,
|
setUploadError,
|
||||||
@ -348,7 +374,6 @@ export const AddPage = () => {
|
|||||||
parsedElement,
|
parsedElement,
|
||||||
form,
|
form,
|
||||||
form.values,
|
form.values,
|
||||||
indexUpload,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -384,7 +409,16 @@ export const AddPage = () => {
|
|||||||
restConfig: session.getRestConfig(),
|
restConfig: session.getRestConfig(),
|
||||||
data: {
|
data: {
|
||||||
name: data,
|
name: data,
|
||||||
parentId: form.values["typeId"]
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const addNewSeason = (data: string): Promise<Season> => {
|
||||||
|
return storeSeason.update(
|
||||||
|
SeasonResource.post({
|
||||||
|
restConfig: session.getRestConfig(),
|
||||||
|
data: {
|
||||||
|
name: data,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -405,10 +439,11 @@ export const AddPage = () => {
|
|||||||
<Flex>
|
<Flex>
|
||||||
<Text flex={1}>format:</Text>
|
<Text flex={1}>format:</Text>
|
||||||
<Text flex={4}>
|
<Text flex={4}>
|
||||||
The format of the media permit to automatic find meta-data:<br />
|
The format of the media permit to automatic find meta-data:
|
||||||
<li>Universe:Series name-s05-e22-Title.webm/mkv</li>
|
<br />
|
||||||
<li>Universe:Series name S05E22 Title.webm/mkv</li>
|
Series~Season#idMedia-my name of my media.webm
|
||||||
<b>example:</b> Stargate:SG1-s05-e22-Tolans.webm
|
<br />
|
||||||
|
<b>example:</b> Clarika~Moi En Mieux#22-des bulles.webm
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Flex>
|
<Flex>
|
||||||
@ -417,7 +452,7 @@ export const AddPage = () => {
|
|||||||
flex={4}
|
flex={4}
|
||||||
type="file"
|
type="file"
|
||||||
placeholder="Select a media file"
|
placeholder="Select a media file"
|
||||||
accept=".webm,.mkv"
|
accept=".webm"
|
||||||
multiple
|
multiple
|
||||||
onChange={onChangeFile}
|
onChange={onChangeFile}
|
||||||
/>
|
/>
|
||||||
@ -428,20 +463,24 @@ export const AddPage = () => {
|
|||||||
<Text fontSize="30px">Meta-data:</Text>
|
<Text fontSize="30px">Meta-data:</Text>
|
||||||
<FormSelect
|
<FormSelect
|
||||||
label="Type"
|
label="Type"
|
||||||
name="typeId"
|
name="TypeId"
|
||||||
options={dataTypes}
|
options={dataTypes}
|
||||||
addNewItem={addNewType}
|
addNewItem={addNewType}
|
||||||
isRequired
|
|
||||||
/>
|
/>
|
||||||
<FormSelect
|
<FormSelect
|
||||||
label="Series"
|
label="Series"
|
||||||
name="seriesId"
|
name="SeriesId"
|
||||||
options={dataSeries}
|
options={dataSeries}
|
||||||
addNewItem={addNewSeries}
|
addNewItem={addNewSeries}
|
||||||
suggestion={suggestedSeries}
|
suggestion={suggestedSeries}
|
||||||
disabled={form.values["typeId"] === undefined}
|
|
||||||
/>
|
/>
|
||||||
|
<FormSelect
|
||||||
|
label="Season"
|
||||||
|
name="SeasonId"
|
||||||
|
options={dataSeasons}
|
||||||
|
addNewItem={addNewSeason}
|
||||||
|
suggestion={suggestedSeason}
|
||||||
|
/>
|
||||||
<Table.Root
|
<Table.Root
|
||||||
colorPalette="striped"
|
colorPalette="striped"
|
||||||
colorScheme="teal"
|
colorScheme="teal"
|
||||||
@ -449,9 +488,6 @@ export const AddPage = () => {
|
|||||||
>
|
>
|
||||||
<Table.Header>
|
<Table.Header>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.ColumnHeader width="10%">
|
|
||||||
Season ID
|
|
||||||
</Table.ColumnHeader>
|
|
||||||
<Table.ColumnHeader width="10%">
|
<Table.ColumnHeader width="10%">
|
||||||
Media ID
|
Media ID
|
||||||
</Table.ColumnHeader>
|
</Table.ColumnHeader>
|
||||||
@ -463,38 +499,19 @@ export const AddPage = () => {
|
|||||||
{parsedElement.map((data) => (
|
{parsedElement.map((data) => (
|
||||||
<Table.Row key={data.uniqueId}>
|
<Table.Row key={data.uniqueId}>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
{form.values["seriesId"] &&
|
|
||||||
<NumberInputRoot
|
<NumberInputRoot
|
||||||
value={data.season ? `${data.season}` : undefined}
|
value={data.MediaId ? `${data.MediaId}` : undefined}
|
||||||
onValueChange={(e) => onSeasonId(data, e.value)}
|
|
||||||
min={0}
|
|
||||||
max={5000}
|
|
||||||
backgroundColor={
|
|
||||||
data.mediaIdDetected === true
|
|
||||||
? 'darkred'
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<NumberInputField />
|
|
||||||
</NumberInputRoot>
|
|
||||||
}
|
|
||||||
</Table.Cell>
|
|
||||||
<Table.Cell>
|
|
||||||
{form.values["seriesId"] &&
|
|
||||||
<NumberInputRoot
|
|
||||||
value={data.mediaId ? `${data.mediaId}` : undefined}
|
|
||||||
onValueChange={(e) => onMediaId(data, e.value)}
|
onValueChange={(e) => onMediaId(data, e.value)}
|
||||||
min={0}
|
min={0}
|
||||||
max={5000}
|
max={5000}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
data.mediaIdDetected === true
|
data.MediaIdDetected === true
|
||||||
? 'darkred'
|
? 'darkred'
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<NumberInputField />
|
<NumberInputField />
|
||||||
</NumberInputRoot>
|
</NumberInputRoot>
|
||||||
}
|
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
<Input
|
<Input
|
||||||
|
@ -45,8 +45,8 @@ export const TypesPage = () => {
|
|||||||
{dataTypes.map((data) => (
|
{dataTypes.map((data) => (
|
||||||
<Flex
|
<Flex
|
||||||
align="flex-start"
|
align="flex-start"
|
||||||
width={{ lg: "200px", base: "160px" }}
|
width={{ base: "200px", sm: "160px" }}
|
||||||
height={{ lg: "280px", base: "200px" }}
|
height={{ base: "280px", sm: "200px" }}
|
||||||
border="1px"
|
border="1px"
|
||||||
borderColor="brand.900"
|
borderColor="brand.900"
|
||||||
backgroundColor={useColorModeValue('#FFFFFF88', '#00000088')}
|
backgroundColor={useColorModeValue('#FFFFFF88', '#00000088')}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { Series, SeriesResource, Type } from '@/back-api';
|
import { Series, SeriesResource } from '@/back-api';
|
||||||
import { useServiceContext } from '@/service/ServiceContext';
|
import { useServiceContext } from '@/service/ServiceContext';
|
||||||
import { SessionServiceProps } from '@/service/session';
|
import { SessionServiceProps } from '@/service/session';
|
||||||
import { DataStoreType, useDataStore } from '@/utils/data-store';
|
import { DataStoreType, useDataStore } from '@/utils/data-store';
|
||||||
@ -60,35 +60,6 @@ export const useOrderedSeries = (nameFilter?: string) => {
|
|||||||
}, [store.data, nameFilter]);
|
}, [store.data, nameFilter]);
|
||||||
return { isLoading: store.isLoading, dataSeries };
|
return { isLoading: store.isLoading, dataSeries };
|
||||||
};
|
};
|
||||||
export const useOrderedSeriesWithType = (typeId?: Type["id"], nameFilter?: string) => {
|
|
||||||
const { store } = useSeriesService();
|
|
||||||
const dataSeries = useMemo(() => {
|
|
||||||
let tmpData = store.data;
|
|
||||||
if (!isNullOrUndefined(nameFilter)) {
|
|
||||||
tmpData = DataTools.getNameLike(tmpData, nameFilter);
|
|
||||||
}
|
|
||||||
if (typeId === undefined) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return DataTools.getsWhere(
|
|
||||||
tmpData,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
check: TypeCheck.NOT_EQUAL,
|
|
||||||
key: 'id',
|
|
||||||
value: [undefined, null],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
check: TypeCheck.EQUAL,
|
|
||||||
key: 'parentId',
|
|
||||||
value: typeId,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
['name', 'id']
|
|
||||||
);
|
|
||||||
}, [store.data, nameFilter, typeId]);
|
|
||||||
return { isLoading: store.isLoading, dataSeries };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useSpecificSeries = (id: number | undefined) => {
|
export const useSpecificSeries = (id: number | undefined) => {
|
||||||
const { store } = useSeriesService();
|
const { store } = useSeriesService();
|
||||||
|
@ -102,9 +102,6 @@ export const ServiceContext = createContext<ServiceContextType>({
|
|||||||
first: () => {
|
first: () => {
|
||||||
console.error('!!! WTF !!!');
|
console.error('!!! WTF !!!');
|
||||||
},
|
},
|
||||||
clear: () => {
|
|
||||||
console.error('!!! WTF !!!');
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user