Skip to content

Commit

Permalink
Fixes for duplicate PSAs, back-to-back sequences, and Dashboard toolt…
Browse files Browse the repository at this point in the history
…ip styling (#120)
  • Loading branch information
whitesoup12 authored Dec 1, 2023
1 parent e0ae4df commit e8ab300
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.remotefalcon.api.repository;

import com.remotefalcon.api.entity.FppSchedule;
import com.remotefalcon.api.entity.RemoteJuke;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import jakarta.transaction.Transactional;
import java.util.List;
import java.util.Optional;

@Repository
Expand All @@ -16,4 +14,5 @@ public interface FppScheduleRepository extends JpaRepository<FppSchedule, Intege
@Transactional
void deleteByRemoteToken(String remoteToken);
Optional<FppSchedule> findByRemoteToken(String remoteToken);
Optional<FppSchedule> findFirstByRemoteToken(String remoteToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,11 @@ public ResponseEntity<?> saveRemotePrefs(RemotePreference request) {
request.setRemotePrefToken(remotePreference.getRemotePrefToken());
this.remotePreferenceRepository.save(request);

if(remotePreference.getPsaEnabled() && request.getPsaSequenceList() != null) {
for(PsaSequence psaSequence : request.getPsaSequenceList()) {
psaSequence.setRemoteToken(tokenDTO.getRemoteToken());
psaSequence.setPsaSequenceLastPlayed(ZonedDateTime.now());
}
this.psaSequenceRepository.saveAll(request.getPsaSequenceList());
for(PsaSequence psaSequence : request.getPsaSequenceList()) {
psaSequence.setRemoteToken(tokenDTO.getRemoteToken());
psaSequence.setPsaSequenceLastPlayed(ZonedDateTime.now());
}
this.psaSequenceRepository.saveAll(request.getPsaSequenceList());

List<PsaSequence> psaSequenceList = this.psaSequenceRepository.findAllByRemoteTokenOrderByPsaSequenceOrderAsc(tokenDTO.getRemoteToken());
if(!remotePreference.getPsaEnabled() && CollectionUtils.isNotEmpty(psaSequenceList)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@ public ResponseEntity<AddSequenceResponse> addPlaylistToQueue(ViewerTokenDTO vie
return ResponseEntity.status(202).body(AddSequenceResponse.builder().message("SONG_REQUESTED").build());
}

//Request Limit Check for Schedule
Optional<FppSchedule> fppSchedule = this.fppScheduleRepository.findFirstByRemoteToken(remoteToken);
if(fppSchedule.isPresent()) {
if(StringUtils.equalsIgnoreCase(request.getSequence(), fppSchedule.get().getNextScheduledSequence())) {
return ResponseEntity.status(202).body(AddSequenceResponse.builder().message("SONG_REQUESTED").build());
}
}

//Checks Done
//Add Request
int futureRequestSequence = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const ApexBarChart = ({ ...otherProps }) => {
borderColor: grey200
},
tooltip: {
followCursor: true,
theme: navType === 'dark' ? 'dark' : 'light',
y: {
formatter(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const ApexLineChart = ({ ...otherProps }) => {
borderColor: grey200
},
tooltip: {
followCursor: true,
theme: navType === 'dark' ? 'dark' : 'light',
y: {
formatter(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const DashboardCharts = ({ ...otherProps }) => {
<DashboardChartsSkeleton />
) : (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Unique Viewers by Date">
<MainCard title="Unique Viewers by Date" sx={{ overflow: 'visible' }}>
<ApexLineChart chartData={uniqueViewersByDate(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -137,7 +137,7 @@ const DashboardCharts = ({ ...otherProps }) => {
<DashboardChartsSkeleton />
) : (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Total Viewers by Date">
<MainCard title="Total Viewers by Date" sx={{ overflow: 'visible' }}>
<ApexLineChart chartData={totalViewersByDate(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -147,7 +147,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'jukebox' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Sequence Requests by Date">
<MainCard title="Sequence Requests by Date" sx={{ overflow: 'visible' }}>
<ApexLineChart chartData={sequenceRequestsByDate(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -158,7 +158,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'jukebox' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Sequence Requests">
<MainCard title="Sequence Requests" sx={{ overflow: 'visible' }}>
<ApexBarChart chartData={sequenceRequests(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -169,7 +169,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'voting' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Sequence Votes by Date">
<MainCard title="Sequence Votes by Date" sx={{ overflow: 'visible' }}>
<ApexLineChart chartData={sequenceVotesByDate(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -180,7 +180,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'voting' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Sequence Votes">
<MainCard title="Sequence Votes" sx={{ overflow: 'visible' }}>
<ApexBarChart chartData={sequenceVotes(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -191,7 +191,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'voting' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Total Wins by Date">
<MainCard title="Total Wins by Date" sx={{ overflow: 'visible' }}>
<ApexLineChart chartData={sequenceVoteWinsByDate(dashboardStats)} />
</MainCard>
</Grid>
Expand All @@ -202,7 +202,7 @@ const DashboardCharts = ({ ...otherProps }) => {
) : (
otherProps.viewerControlMode === 'voting' && (
<Grid item xs={12} md={6} lg={6}>
<MainCard title="Sequence Wins">
<MainCard title="Sequence Wins" sx={{ overflow: 'visible' }}>
<ApexBarChart chartData={sequenceVoteWins(dashboardStats)} />
</MainCard>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import PropTypes from 'prop-types';

import MainCard from 'ui-component/cards/MainCard';

import { saveGPSLocation } from './helpers';

const viewerPresentModes = [
{ label: 'GPS Location', id: 'gps' },
{ label: 'Code', id: 'code' }
Expand Down
130 changes: 67 additions & 63 deletions remote-falcon-web/src/views/pages/externalViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,40 +291,42 @@ const ExternalViewerPage = () => {
const categorizedSequencesArray = [];
const categorizedSequencesToIterate = _.cloneDeep(externalViewerPageDetails?.sequences);
_.map(categorizedSequencesToIterate, (categorizedSequence) => {
if (categorizedSequence.sequenceCategory === sequence.sequenceCategory) {
sequenceImageElement = [<></>];
if (
categorizedSequence &&
categorizedSequence.sequenceImageUrl &&
categorizedSequence.sequenceImageUrl.replace(/\s/g, '').length
) {
const classname = `sequence-image sequence-image-${categorizedSequence.sequenceKey}`;
sequenceImageElement = (
<img
alt={categorizedSequence.sequenceName}
className={classname}
src={categorizedSequence.sequenceImageUrl}
data-key={categorizedSequence.sequenceName}
/>
if (categorizedSequence.sequenceVisible) {
if (categorizedSequence.sequenceCategory === sequence.sequenceCategory) {
sequenceImageElement = [<></>];
if (
categorizedSequence &&
categorizedSequence.sequenceImageUrl &&
categorizedSequence.sequenceImageUrl.replace(/\s/g, '').length
) {
const classname = `sequence-image sequence-image-${categorizedSequence.sequenceKey}`;
sequenceImageElement = (
<img
alt={categorizedSequence.sequenceName}
className={classname}
src={categorizedSequence.sequenceImageUrl}
data-key={categorizedSequence.sequenceName}
/>
);
}
const categorizedVotingListClassname = `cell-vote-playlist cell-vote-playlist-${sequence.sequenceKey}`;
const categorizedVotingListArtistClassname = `cell-vote-playlist-artist cell-vote-playlist-artist-${sequence.sequenceKey}`;
const theElement = (
<>
<div
className={categorizedVotingListClassname}
onClick={(e) => voteForSequence(e)}
data-key={categorizedSequence.sequenceName}
>
{sequenceImageElement}
{categorizedSequence.sequenceDisplayName}
<div className={categorizedVotingListArtistClassname}>{categorizedSequence.sequenceArtist}</div>
</div>
<div className="cell-vote">{categorizedSequence.sequenceVotes}</div>
</>
);
categorizedSequencesArray.push(theElement);
}
const categorizedVotingListClassname = `cell-vote-playlist cell-vote-playlist-${sequence.sequenceKey}`;
const categorizedVotingListArtistClassname = `cell-vote-playlist-artist cell-vote-playlist-artist-${sequence.sequenceKey}`;
const theElement = (
<>
<div
className={categorizedVotingListClassname}
onClick={(e) => voteForSequence(e)}
data-key={categorizedSequence.sequenceName}
>
{sequenceImageElement}
{categorizedSequence.sequenceDisplayName}
<div className={categorizedVotingListArtistClassname}>{categorizedSequence.sequenceArtist}</div>
</div>
<div className="cell-vote">{categorizedSequence.sequenceVotes}</div>
</>
);
categorizedSequencesArray.push(theElement);
}
});

Expand Down Expand Up @@ -356,39 +358,41 @@ const ExternalViewerPage = () => {
const categorizedSequencesArray = [];
const categorizedSequencesToIterate = _.cloneDeep(externalViewerPageDetails?.sequences);
_.map(categorizedSequencesToIterate, (categorizedSequence) => {
if (categorizedSequence.sequenceCategory === sequence.sequenceCategory) {
sequenceImageElement = [<></>];
if (
categorizedSequence &&
categorizedSequence.sequenceImageUrl &&
categorizedSequence.sequenceImageUrl.replace(/\s/g, '').length
) {
const classname = `sequence-image sequence-image-${categorizedSequence.sequenceKey}`;
sequenceImageElement = (
<img
alt={categorizedSequence.sequenceName}
className={classname}
src={categorizedSequence.sequenceImageUrl}
data-key={categorizedSequence.sequenceName}
/>
if (categorizedSequence.sequenceVisible) {
if (categorizedSequence.sequenceCategory === sequence.sequenceCategory) {
sequenceImageElement = [<></>];
if (
categorizedSequence &&
categorizedSequence.sequenceImageUrl &&
categorizedSequence.sequenceImageUrl.replace(/\s/g, '').length
) {
const classname = `sequence-image sequence-image-${categorizedSequence.sequenceKey}`;
sequenceImageElement = (
<img
alt={categorizedSequence.sequenceName}
className={classname}
src={categorizedSequence.sequenceImageUrl}
data-key={categorizedSequence.sequenceName}
/>
);
}
const categorizedJukeboxListClassname = `jukebox-list jukebox-list-${categorizedSequence.sequenceKey}`;
const categorizedJukeboxListArtistClassname = `jukebox-list-artist jukebox-list-artist-${categorizedSequence.sequenceKey}`;
const theElement = (
<>
<div
className={categorizedJukeboxListClassname}
onClick={(e) => addSequenceToQueue(e)}
data-key={categorizedSequence.sequenceName}
>
{sequenceImageElement}
{categorizedSequence.sequenceDisplayName}
<div className={categorizedJukeboxListArtistClassname}>{categorizedSequence.sequenceArtist}</div>
</div>
</>
);
categorizedSequencesArray.push(theElement);
}
const categorizedJukeboxListClassname = `jukebox-list jukebox-list-${categorizedSequence.sequenceKey}`;
const categorizedJukeboxListArtistClassname = `jukebox-list-artist jukebox-list-artist-${categorizedSequence.sequenceKey}`;
const theElement = (
<>
<div
className={categorizedJukeboxListClassname}
onClick={(e) => addSequenceToQueue(e)}
data-key={categorizedSequence.sequenceName}
>
{sequenceImageElement}
{categorizedSequence.sequenceDisplayName}
<div className={categorizedJukeboxListArtistClassname}>{categorizedSequence.sequenceArtist}</div>
</div>
</>
);
categorizedSequencesArray.push(theElement);
}
});

Expand Down

0 comments on commit e8ab300

Please sign in to comment.