mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
Session Card css fixes
Session Card css fixes Refactored the syncitemInfo method to fetch data and then write in bulk vs writing on every fetch
This commit is contained in:
@@ -223,7 +223,7 @@ class sync {
|
||||
const results = response.data.MediaSources;
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log(error.message);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -593,6 +593,7 @@ async function syncItemInfo(seasons_and_episodes,library_items)
|
||||
|
||||
let current_item=0;
|
||||
let all_items=Items.length;
|
||||
let data_to_insert=[];
|
||||
//loop for each Movie
|
||||
for (const Item of Items) {
|
||||
current_item++;
|
||||
@@ -603,29 +604,20 @@ async function syncItemInfo(seasons_and_episodes,library_items)
|
||||
{
|
||||
//dont update item info if it already exists and running a partial sync
|
||||
const data = await _sync.getItemInfo(Item.Id,userid);
|
||||
|
||||
|
||||
let ItemInfoToInsert = await data.map(item => jf_item_info_mapping(item, 'Item'));
|
||||
const mapped_data= await data.map(item => jf_item_info_mapping(item, 'Item'));
|
||||
data_to_insert.push(...mapped_data);
|
||||
|
||||
|
||||
if (ItemInfoToInsert.length !== 0) {
|
||||
let result = await db.insertBulk("jf_item_info",ItemInfoToInsert,jf_item_info_columns);
|
||||
if (result.Result === "SUCCESS") {
|
||||
insertItemInfoCount +=ItemInfoToInsert.length- existingItemInfo.length;
|
||||
updateItemInfoCount+=existingItemInfo.length;
|
||||
|
||||
} else {
|
||||
syncTask.loggedData.push({
|
||||
color: "red",
|
||||
Message: "Error performing bulk insert:" + result.message,
|
||||
});
|
||||
logging.updateLog(syncTask.uuid,syncTask.loggedData,taskstate.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
if (mapped_data.length !== 0) {
|
||||
insertItemInfoCount +=mapped_data.length- existingItemInfo.length;
|
||||
updateItemInfoCount+=existingItemInfo.length;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}}
|
||||
|
||||
let current_episode=0;
|
||||
let all_episodes=Episodes.length;
|
||||
@@ -641,30 +633,32 @@ async function syncItemInfo(seasons_and_episodes,library_items)
|
||||
|
||||
//dont update item info if it already exists and running a partial sync
|
||||
const episodedata = await _sync.getItemInfo(Episode.EpisodeId,userid);
|
||||
|
||||
let EpisodeInfoToInsert = await episodedata.map(item => jf_item_info_mapping(item, 'Episode'));
|
||||
const mapped_data= await episodedata.map(item => jf_item_info_mapping(item, 'Episode'));
|
||||
data_to_insert.push(...mapped_data);
|
||||
|
||||
//filter fix if jf_libraries is empty
|
||||
|
||||
|
||||
if (EpisodeInfoToInsert.length !== 0) {
|
||||
let result = await db.insertBulk("jf_item_info",EpisodeInfoToInsert,jf_item_info_columns);
|
||||
if (result.Result === "SUCCESS") {
|
||||
insertEpisodeInfoCount += EpisodeInfoToInsert.length-existingEpisodeItemInfo.length;
|
||||
updateEpisodeInfoCount+= existingEpisodeItemInfo.length;
|
||||
} else {
|
||||
syncTask.loggedData.push({
|
||||
color: "red",
|
||||
Message: "Error performing bulk insert:" + result.message,
|
||||
});
|
||||
logging.updateLog(syncTask.uuid,syncTask.loggedData,taskstate.FAILED);
|
||||
}
|
||||
if (mapped_data.length !== 0) {
|
||||
insertEpisodeInfoCount += mapped_data.length-existingEpisodeItemInfo.length;
|
||||
updateEpisodeInfoCount+= existingEpisodeItemInfo.length;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (data_to_insert.length !== 0) {
|
||||
let result = await db.insertBulk("jf_item_info",data_to_insert,jf_item_info_columns);
|
||||
if (result.Result !== "SUCCESS") {
|
||||
syncTask.loggedData.push({
|
||||
color: "red",
|
||||
Message: "Error performing bulk insert:" + result.message,
|
||||
});
|
||||
logging.updateLog(syncTask.uuid,syncTask.loggedData,taskstate.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
syncTask.loggedData.push({color: "dodgerblue",Message: (insertItemInfoCount >0 ? insertItemInfoCount : 0) + " Item Info inserted. "+updateItemInfoCount +" Item Info Updated"});
|
||||
syncTask.loggedData.push({color: "dodgerblue",Message: (insertEpisodeInfoCount > 0 ? insertEpisodeInfoCount:0) + " Episodes Info inserted. "+updateEpisodeInfoCount +" Episodes Info Updated"});
|
||||
syncTask.loggedData.push({ color: "yellow", Message: "Info Sync Complete" });
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, {useState,useEffect} from "react";
|
||||
import { Link } from 'react-router-dom';
|
||||
import Card from 'react-bootstrap/Card';
|
||||
@@ -71,9 +72,7 @@ function SessionCard(props) {
|
||||
height:'100%',
|
||||
};
|
||||
|
||||
const pushNextToBottom = {
|
||||
marginBottom: 'auto'
|
||||
}
|
||||
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
@@ -139,16 +138,17 @@ function SessionCard(props) {
|
||||
<Col className="w-100 h-100">
|
||||
|
||||
<Card.Body className="w-100 h-100 p-1 pb-2" >
|
||||
<Container className="h-100 d-flex flex-column">
|
||||
<Container className="h-100 d-flex flex-column justify-content-between g-0">
|
||||
<Row className="d-flex justify-content-end" style={{fontSize: "smaller"}}>
|
||||
|
||||
<Col className="col-10">
|
||||
<Row className="ellipse"> {props.data.session.DeviceName}</Row>
|
||||
<Row className="ellipse card-client-version"> {props.data.session.Client + " " + props.data.session.ApplicationVersion}</Row>
|
||||
<Row>
|
||||
<Col className="col-auto ellipse">{props.data.session.DeviceName +" - "+props.data.session.Client + " " + props.data.session.ApplicationVersion}</Col>
|
||||
</Row>
|
||||
<Row className="d-flex flex-column flex-md-row">
|
||||
<Col className="px-0 col-auto ellipse">{props.data.session.PlayState.PlayMethod}</Col>
|
||||
<Col className="px-0 px-md-2 col-auto ellipse">{(props.data.session.NowPlayingItem.MediaStreams ? '( '+props.data.session.NowPlayingItem.MediaStreams.find(stream => stream.Type==='Video')?.Codec.toUpperCase()+(props.data.session.TranscodingInfo? ' - '+props.data.session.TranscodingInfo.VideoCodec.toUpperCase() : '')+' - '+convertBitrate(props.data.session.TranscodingInfo ? props.data.session.TranscodingInfo.Bitrate :props.data.session.NowPlayingItem.MediaStreams.find(stream => stream.Type==='Video')?.BitRate)+' )':'')}</Col>
|
||||
<Col className="px-0 col-auto ellipse">
|
||||
<Col className="col-auto ellipse">{props.data.session.PlayState.PlayMethod}</Col>
|
||||
<Col className="px-md-2 col-auto ellipse">{(props.data.session.NowPlayingItem.MediaStreams ? '( '+props.data.session.NowPlayingItem.MediaStreams.find(stream => stream.Type==='Video')?.Codec.toUpperCase()+(props.data.session.TranscodingInfo? ' - '+props.data.session.TranscodingInfo.VideoCodec.toUpperCase() : '')+' - '+convertBitrate(props.data.session.TranscodingInfo ? props.data.session.TranscodingInfo.Bitrate :props.data.session.NowPlayingItem.MediaStreams.find(stream => stream.Type==='Video')?.BitRate)+' )':'')}</Col>
|
||||
<Col className="col-auto ellipse">
|
||||
<Tooltip title={props.data.session.NowPlayingItem.SubtitleStream}>
|
||||
<span>
|
||||
{props.data.session.NowPlayingItem.SubtitleStream}
|
||||
@@ -157,7 +157,7 @@ function SessionCard(props) {
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col className="px-0 col-auto ellipse">
|
||||
<Col className="col-auto ellipse">
|
||||
|
||||
{isRemoteSession && (import.meta.env.VITE_GEOLITE_ACCOUNT_ID && import.meta.env.VITE_GEOLITE_LICENSE_KEY) ?
|
||||
<Card.Text>
|
||||
@@ -191,88 +191,88 @@ function SessionCard(props) {
|
||||
|
||||
</Row>
|
||||
|
||||
{props.data.session.NowPlayingItem.Type==='Episode' ?
|
||||
<Row className="d-flex flex-row justify-content-between">
|
||||
<Col className="p-0">
|
||||
<Card.Text>
|
||||
<Link to={`/libraries/item/${props.data.session.NowPlayingItem.Id}`} target="_blank" className="item-name">
|
||||
{props.data.session.NowPlayingItem.SeriesName ? (props.data.session.NowPlayingItem.SeriesName+" - "+ props.data.session.NowPlayingItem.Name) : (props.data.session.NowPlayingItem.Name)}
|
||||
</Link>
|
||||
</Card.Text>
|
||||
|
||||
<Row className="p-0 m-0">
|
||||
{props.data.session.NowPlayingItem.Type==='Episode' ?
|
||||
<Row className="d-flex flex-row justify-content-between p-0">
|
||||
|
||||
<Card.Text>
|
||||
<Link to={`/libraries/item/${props.data.session.NowPlayingItem.Id}`} target="_blank" className="item-name">
|
||||
{props.data.session.NowPlayingItem.SeriesName ? (props.data.session.NowPlayingItem.SeriesName+" - "+ props.data.session.NowPlayingItem.Name) : (props.data.session.NowPlayingItem.Name)}
|
||||
</Link>
|
||||
</Card.Text>
|
||||
|
||||
</Row>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
<Row className="d-flex flex-row justify-content-between p-0 m-0" >
|
||||
{props.data.session.NowPlayingItem.Type==='Episode' ?
|
||||
<Col className="col-auto p-0">
|
||||
<Card.Text >
|
||||
{'S'+props.data.session.NowPlayingItem.ParentIndexNumber +' - E'+ props.data.session.NowPlayingItem.IndexNumber}
|
||||
</Card.Text>
|
||||
</Col>
|
||||
|
||||
:
|
||||
<Col className="p-0">
|
||||
<Card.Text>
|
||||
<Link to={`/libraries/item/${props.data.session.NowPlayingItem.Id}`} target="_blank" className="item-name">
|
||||
{props.data.session.NowPlayingItem.SeriesName ? (props.data.session.NowPlayingItem.SeriesName+" - "+ props.data.session.NowPlayingItem.Name) : (props.data.session.NowPlayingItem.Name)}
|
||||
</Link>
|
||||
</Card.Text>
|
||||
</Col>
|
||||
}
|
||||
|
||||
<Col className="d-flex flex-row justify-content-end text-end col-auto">
|
||||
|
||||
{props.data.session.UserPrimaryImageTag !== undefined ? (
|
||||
<img
|
||||
className="session-card-user-image"
|
||||
src={
|
||||
"/proxy/Users/Images/Primary?id=" +
|
||||
props.data.session.UserId +
|
||||
"&quality=50"
|
||||
}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<AccountCircleFillIcon className="session-card-user-image"/>
|
||||
)}
|
||||
<Card.Text >
|
||||
<Tooltip title={props.data.session.UserName} >
|
||||
<Link to={`/users/${props.data.session.UserId}`} className="item-name" style={{maxWidth:'15ch'}}>{props.data.session.UserName}</Link>
|
||||
</Tooltip>
|
||||
</Card.Text>
|
||||
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
|
||||
<Row className="p-0 m-0">
|
||||
<Col className="col-auto p-0">
|
||||
|
||||
{props.data.session.PlayState.IsPaused ?
|
||||
<PauseFillIcon />
|
||||
:
|
||||
<PlayFillIcon />
|
||||
}
|
||||
|
||||
</Col>
|
||||
|
||||
<Col>
|
||||
|
||||
<Card.Text className="text-end">
|
||||
<Tooltip title={`Ends at ${getETAFromTicks(props.data.session.NowPlayingItem.RunTimeTicks - props.data.session.PlayState.PositionTicks)}`}>
|
||||
<span>
|
||||
{ticksToTimeString(props.data.session.PlayState.PositionTicks)}/
|
||||
{ticksToTimeString(props.data.session.NowPlayingItem.RunTimeTicks)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</Card.Text>
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
:
|
||||
<></>
|
||||
}
|
||||
|
||||
|
||||
|
||||
<Row className="d-flex flex-row justify-content-between" style={pushNextToBottom}>
|
||||
{props.data.session.NowPlayingItem.Type==='Episode' ?
|
||||
<Col className="col-auto p-0">
|
||||
<Card.Text >
|
||||
{'S'+props.data.session.NowPlayingItem.ParentIndexNumber +' - E'+ props.data.session.NowPlayingItem.IndexNumber}
|
||||
</Card.Text>
|
||||
</Col>
|
||||
|
||||
:
|
||||
<Col className="p-0">
|
||||
<Card.Text>
|
||||
<Link to={`/libraries/item/${props.data.session.NowPlayingItem.Id}`} target="_blank" className="item-name">
|
||||
{props.data.session.NowPlayingItem.SeriesName ? (props.data.session.NowPlayingItem.SeriesName+" - "+ props.data.session.NowPlayingItem.Name) : (props.data.session.NowPlayingItem.Name)}
|
||||
</Link>
|
||||
</Card.Text>
|
||||
</Col>
|
||||
}
|
||||
|
||||
<Col className="d-flex flex-row justify-content-end text-end col-auto">
|
||||
|
||||
{props.data.session.UserPrimaryImageTag !== undefined ? (
|
||||
<img
|
||||
className="session-card-user-image"
|
||||
src={
|
||||
"/proxy/Users/Images/Primary?id=" +
|
||||
props.data.session.UserId +
|
||||
"&quality=50"
|
||||
}
|
||||
alt=""
|
||||
/>
|
||||
) : (
|
||||
<AccountCircleFillIcon className="session-card-user-image"/>
|
||||
)}
|
||||
<Card.Text >
|
||||
<Tooltip title={props.data.session.UserName} >
|
||||
<Link to={`/users/${props.data.session.UserId}`} className="item-name" style={{maxWidth:'15ch'}}>{props.data.session.UserName}</Link>
|
||||
</Tooltip>
|
||||
</Card.Text>
|
||||
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
|
||||
<Row className="d-flex">
|
||||
<Col className="col-auto p-0">
|
||||
|
||||
{props.data.session.PlayState.IsPaused ?
|
||||
<PauseFillIcon />
|
||||
:
|
||||
<PlayFillIcon />
|
||||
}
|
||||
|
||||
</Col>
|
||||
|
||||
<Col>
|
||||
|
||||
<Card.Text className="text-end">
|
||||
<Tooltip title={`Ends at ${getETAFromTicks(props.data.session.NowPlayingItem.RunTimeTicks - props.data.session.PlayState.PositionTicks)}`}>
|
||||
<span>
|
||||
{ticksToTimeString(props.data.session.PlayState.PositionTicks)}/
|
||||
{ticksToTimeString(props.data.session.NowPlayingItem.RunTimeTicks)}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</Card.Text>
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
</Card.Body>
|
||||
|
||||
Reference in New Issue
Block a user