Split actions to separate file
Only use the necessary actions for each component
This commit is contained in:
parent
1d1e239709
commit
9ba4af9d7d
@ -1,293 +0,0 @@
|
|||||||
import { configureAxios, request } from '../requests'
|
|
||||||
|
|
||||||
// ======================
|
|
||||||
// Alerts
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
export function addAlertError(message) {
|
|
||||||
return {
|
|
||||||
type: 'ADD_ALERT_ERROR',
|
|
||||||
payload: {
|
|
||||||
message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addAlertOk(message) {
|
|
||||||
return {
|
|
||||||
type: 'ADD_ALERT_OK',
|
|
||||||
payload: {
|
|
||||||
message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function dismissAlert() {
|
|
||||||
return {
|
|
||||||
type: 'DISMISS_ALERT',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================
|
|
||||||
// Users
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
export function userLogout() {
|
|
||||||
return {
|
|
||||||
type: 'USER_LOGOUT',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loginUser(username, password) {
|
|
||||||
return request(
|
|
||||||
'USER_LOGIN',
|
|
||||||
configureAxios().post(
|
|
||||||
'/users/login',
|
|
||||||
{
|
|
||||||
username: username,
|
|
||||||
password: password,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateUser(config) {
|
|
||||||
return request(
|
|
||||||
'USER_UPDATE',
|
|
||||||
configureAxios().post('/users/edit', config),
|
|
||||||
[
|
|
||||||
addAlertOk("User updated"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function userSignUp(config) {
|
|
||||||
return request(
|
|
||||||
'USER_SIGNUP',
|
|
||||||
configureAxios().post('/users/signup', config)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUserInfos() {
|
|
||||||
return request(
|
|
||||||
'GET_USER',
|
|
||||||
configureAxios().get('/users/details')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================
|
|
||||||
// Movies
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
export function updateLastMovieFetchUrl(url) {
|
|
||||||
return {
|
|
||||||
type: 'UPDATE_LAST_MOVIE_FETCH_URL',
|
|
||||||
payload: {
|
|
||||||
url: url,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function selectMovie(imdbId) {
|
|
||||||
return {
|
|
||||||
type: 'SELECT_MOVIE',
|
|
||||||
imdbId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getMovieExploreOptions() {
|
|
||||||
return request(
|
|
||||||
'MOVIE_GET_EXPLORE_OPTIONS',
|
|
||||||
configureAxios().get('/movies/explore/options')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getMovieDetails(imdbId) {
|
|
||||||
return request(
|
|
||||||
'MOVIE_GET_DETAILS',
|
|
||||||
configureAxios().post(`/movies/${imdbId}/refresh`)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteMovie(imdbId, lastFetchUrl) {
|
|
||||||
return request(
|
|
||||||
'MOVIE_DELETE',
|
|
||||||
configureAxios().delete(`/movies/${imdbId}`),
|
|
||||||
[
|
|
||||||
fetchMovies(lastFetchUrl),
|
|
||||||
addAlertOk("Movie deleted"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addMovieToWishlist(imdbId) {
|
|
||||||
return request(
|
|
||||||
'MOVIE_ADD_TO_WISHLIST',
|
|
||||||
configureAxios().post(`/wishlist/movies/${imdbId}`),
|
|
||||||
[
|
|
||||||
addAlertOk("Movie added to the wishlist"),
|
|
||||||
updateMovieWishlistStore(imdbId, true),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteMovieFromWishlist(imdbId) {
|
|
||||||
return request(
|
|
||||||
'MOVIE_DELETE_FROM_WISHLIST',
|
|
||||||
configureAxios().delete(`/wishlist/movies/${imdbId}`),
|
|
||||||
[
|
|
||||||
addAlertOk("Movie deleted from the wishlist"),
|
|
||||||
updateMovieWishlistStore(imdbId, false),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateMovieWishlistStore(imdbId, wishlisted) {
|
|
||||||
return {
|
|
||||||
type: 'MOVIE_UPDATE_STORE_WISHLIST',
|
|
||||||
payload: {
|
|
||||||
imdbId,
|
|
||||||
wishlisted,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchMovies(url) {
|
|
||||||
return request(
|
|
||||||
'MOVIE_LIST_FETCH',
|
|
||||||
configureAxios().get(url),
|
|
||||||
[
|
|
||||||
updateLastMovieFetchUrl(url),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================
|
|
||||||
// Shows
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
export function fetchShows(url) {
|
|
||||||
return request(
|
|
||||||
'SHOW_LIST_FETCH',
|
|
||||||
configureAxios().get(url),
|
|
||||||
[
|
|
||||||
updateLastShowsFetchUrl(url),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getShowDetails(imdbId) {
|
|
||||||
return request(
|
|
||||||
'SHOW_GET_DETAILS',
|
|
||||||
configureAxios().post(`/shows/${imdbId}/refresh`)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function getEpisodeDetails(imdbId, season, episode) {
|
|
||||||
return request(
|
|
||||||
'EPISODE_GET_DETAILS',
|
|
||||||
configureAxios().post(`/shows/${imdbId}/seasons/${season}/episodes/${episode}`),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateEpisodeDetailsStore(imdbId, season, episode) {
|
|
||||||
return {
|
|
||||||
type: 'EPISODE_GET_DETAILS',
|
|
||||||
payload: {
|
|
||||||
imdbId,
|
|
||||||
season,
|
|
||||||
episode,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchShowDetails(imdbId) {
|
|
||||||
return request(
|
|
||||||
'SHOW_FETCH_DETAILS',
|
|
||||||
configureAxios().get(`/shows/${imdbId}`)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addShowToWishlist(imdbId, season = null, episode = null) {
|
|
||||||
return request(
|
|
||||||
'SHOW_ADD_TO_WISHLIST',
|
|
||||||
configureAxios().post(`/wishlist/shows/${imdbId}`, {
|
|
||||||
season: season,
|
|
||||||
episode: episode,
|
|
||||||
}),
|
|
||||||
[
|
|
||||||
addAlertOk("Show added to the wishlist"),
|
|
||||||
updateShowWishlistStore(imdbId, true, season, episode),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteShowFromWishlist(imdbId) {
|
|
||||||
return request(
|
|
||||||
'SHOW_DELETE_FROM_WISHLIST',
|
|
||||||
configureAxios().delete(`/wishlist/shows/${imdbId}`),
|
|
||||||
[
|
|
||||||
addAlertOk("Show deleted from the wishlist"),
|
|
||||||
updateShowWishlistStore(imdbId, false),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateShowWishlistStore(imdbId, wishlisted, season = null, episode = null) {
|
|
||||||
return {
|
|
||||||
type: 'SHOW_UPDATE_STORE_WISHLIST',
|
|
||||||
payload: {
|
|
||||||
wishlisted: wishlisted,
|
|
||||||
imdbId,
|
|
||||||
season,
|
|
||||||
episode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getShowExploreOptions() {
|
|
||||||
return request(
|
|
||||||
'SHOW_GET_EXPLORE_OPTIONS',
|
|
||||||
configureAxios().get('/shows/explore/options')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function selectShow(imdbId) {
|
|
||||||
return {
|
|
||||||
type: 'SELECT_SHOW',
|
|
||||||
imdbId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateLastShowsFetchUrl(url) {
|
|
||||||
return {
|
|
||||||
type: 'UPDATE_LAST_SHOWS_FETCH_URL',
|
|
||||||
payload: {
|
|
||||||
url: url,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ======================
|
|
||||||
// AddTorrent
|
|
||||||
// ======================
|
|
||||||
|
|
||||||
export function addTorrent(url) {
|
|
||||||
return request(
|
|
||||||
'ADD_TORRENT',
|
|
||||||
configureAxios().post('/torrents', {
|
|
||||||
url: url,
|
|
||||||
}),
|
|
||||||
[
|
|
||||||
addAlertOk("Torrent added"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchTorrents() {
|
|
||||||
return request(
|
|
||||||
'TORRENTS_FETCH',
|
|
||||||
configureAxios().get('/torrents')
|
|
||||||
)
|
|
||||||
}
|
|
23
src/public/js/actions/alerts.js
Normal file
23
src/public/js/actions/alerts.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export function addAlertError(message) {
|
||||||
|
return {
|
||||||
|
type: 'ADD_ALERT_ERROR',
|
||||||
|
payload: {
|
||||||
|
message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addAlertOk(message) {
|
||||||
|
return {
|
||||||
|
type: 'ADD_ALERT_OK',
|
||||||
|
payload: {
|
||||||
|
message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dismissAlert() {
|
||||||
|
return {
|
||||||
|
type: 'DISMISS_ALERT',
|
||||||
|
}
|
||||||
|
}
|
86
src/public/js/actions/movies.js
Normal file
86
src/public/js/actions/movies.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
import { configureAxios, request } from '../requests'
|
||||||
|
|
||||||
|
import { addAlertOk } from './alerts'
|
||||||
|
|
||||||
|
export function updateLastMovieFetchUrl(url) {
|
||||||
|
return {
|
||||||
|
type: 'UPDATE_LAST_MOVIE_FETCH_URL',
|
||||||
|
payload: {
|
||||||
|
url: url,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectMovie(imdbId) {
|
||||||
|
return {
|
||||||
|
type: 'SELECT_MOVIE',
|
||||||
|
imdbId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMovieExploreOptions() {
|
||||||
|
return request(
|
||||||
|
'MOVIE_GET_EXPLORE_OPTIONS',
|
||||||
|
configureAxios().get('/movies/explore/options')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMovieDetails(imdbId) {
|
||||||
|
return request(
|
||||||
|
'MOVIE_GET_DETAILS',
|
||||||
|
configureAxios().post(`/movies/${imdbId}/refresh`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteMovie(imdbId, lastFetchUrl) {
|
||||||
|
return request(
|
||||||
|
'MOVIE_DELETE',
|
||||||
|
configureAxios().delete(`/movies/${imdbId}`),
|
||||||
|
[
|
||||||
|
fetchMovies(lastFetchUrl),
|
||||||
|
addAlertOk("Movie deleted"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addMovieToWishlist(imdbId) {
|
||||||
|
return request(
|
||||||
|
'MOVIE_ADD_TO_WISHLIST',
|
||||||
|
configureAxios().post(`/wishlist/movies/${imdbId}`),
|
||||||
|
[
|
||||||
|
addAlertOk("Movie added to the wishlist"),
|
||||||
|
updateMovieWishlistStore(imdbId, true),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteMovieFromWishlist(imdbId) {
|
||||||
|
return request(
|
||||||
|
'MOVIE_DELETE_FROM_WISHLIST',
|
||||||
|
configureAxios().delete(`/wishlist/movies/${imdbId}`),
|
||||||
|
[
|
||||||
|
addAlertOk("Movie deleted from the wishlist"),
|
||||||
|
updateMovieWishlistStore(imdbId, false),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateMovieWishlistStore(imdbId, wishlisted) {
|
||||||
|
return {
|
||||||
|
type: 'MOVIE_UPDATE_STORE_WISHLIST',
|
||||||
|
payload: {
|
||||||
|
imdbId,
|
||||||
|
wishlisted,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchMovies(url) {
|
||||||
|
return request(
|
||||||
|
'MOVIE_LIST_FETCH',
|
||||||
|
configureAxios().get(url),
|
||||||
|
[
|
||||||
|
updateLastMovieFetchUrl(url),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
106
src/public/js/actions/shows.js
Normal file
106
src/public/js/actions/shows.js
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { configureAxios, request } from '../requests'
|
||||||
|
|
||||||
|
import { addAlertOk } from './alerts'
|
||||||
|
|
||||||
|
export function fetchShows(url) {
|
||||||
|
return request(
|
||||||
|
'SHOW_LIST_FETCH',
|
||||||
|
configureAxios().get(url),
|
||||||
|
[
|
||||||
|
updateLastShowsFetchUrl(url),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getShowDetails(imdbId) {
|
||||||
|
return request(
|
||||||
|
'SHOW_GET_DETAILS',
|
||||||
|
configureAxios().post(`/shows/${imdbId}/refresh`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getEpisodeDetails(imdbId, season, episode) {
|
||||||
|
return request(
|
||||||
|
'EPISODE_GET_DETAILS',
|
||||||
|
configureAxios().post(`/shows/${imdbId}/seasons/${season}/episodes/${episode}`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateEpisodeDetailsStore(imdbId, season, episode) {
|
||||||
|
return {
|
||||||
|
type: 'EPISODE_GET_DETAILS',
|
||||||
|
payload: {
|
||||||
|
imdbId,
|
||||||
|
season,
|
||||||
|
episode,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchShowDetails(imdbId) {
|
||||||
|
return request(
|
||||||
|
'SHOW_FETCH_DETAILS',
|
||||||
|
configureAxios().get(`/shows/${imdbId}`)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addShowToWishlist(imdbId, season = null, episode = null) {
|
||||||
|
return request(
|
||||||
|
'SHOW_ADD_TO_WISHLIST',
|
||||||
|
configureAxios().post(`/wishlist/shows/${imdbId}`, {
|
||||||
|
season: season,
|
||||||
|
episode: episode,
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
addAlertOk("Show added to the wishlist"),
|
||||||
|
updateShowWishlistStore(imdbId, true, season, episode),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteShowFromWishlist(imdbId) {
|
||||||
|
return request(
|
||||||
|
'SHOW_DELETE_FROM_WISHLIST',
|
||||||
|
configureAxios().delete(`/wishlist/shows/${imdbId}`),
|
||||||
|
[
|
||||||
|
addAlertOk("Show deleted from the wishlist"),
|
||||||
|
updateShowWishlistStore(imdbId, false),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateShowWishlistStore(imdbId, wishlisted, season = null, episode = null) {
|
||||||
|
return {
|
||||||
|
type: 'SHOW_UPDATE_STORE_WISHLIST',
|
||||||
|
payload: {
|
||||||
|
wishlisted: wishlisted,
|
||||||
|
imdbId,
|
||||||
|
season,
|
||||||
|
episode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getShowExploreOptions() {
|
||||||
|
return request(
|
||||||
|
'SHOW_GET_EXPLORE_OPTIONS',
|
||||||
|
configureAxios().get('/shows/explore/options')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectShow(imdbId) {
|
||||||
|
return {
|
||||||
|
type: 'SELECT_SHOW',
|
||||||
|
imdbId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateLastShowsFetchUrl(url) {
|
||||||
|
return {
|
||||||
|
type: 'UPDATE_LAST_SHOWS_FETCH_URL',
|
||||||
|
payload: {
|
||||||
|
url: url,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
22
src/public/js/actions/torrents.js
Normal file
22
src/public/js/actions/torrents.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { configureAxios, request } from '../requests'
|
||||||
|
|
||||||
|
import { addAlertOk } from './alerts'
|
||||||
|
|
||||||
|
export function addTorrent(url) {
|
||||||
|
return request(
|
||||||
|
'ADD_TORRENT',
|
||||||
|
configureAxios().post('/torrents', {
|
||||||
|
url: url,
|
||||||
|
}),
|
||||||
|
[
|
||||||
|
addAlertOk("Torrent added"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchTorrents() {
|
||||||
|
return request(
|
||||||
|
'TORRENTS_FETCH',
|
||||||
|
configureAxios().get('/torrents')
|
||||||
|
)
|
||||||
|
}
|
46
src/public/js/actions/users.js
Normal file
46
src/public/js/actions/users.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
import { configureAxios, request } from '../requests'
|
||||||
|
|
||||||
|
import { addAlertOk } from './alerts'
|
||||||
|
|
||||||
|
export function userLogout() {
|
||||||
|
return {
|
||||||
|
type: 'USER_LOGOUT',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loginUser(username, password) {
|
||||||
|
return request(
|
||||||
|
'USER_LOGIN',
|
||||||
|
configureAxios().post(
|
||||||
|
'/users/login',
|
||||||
|
{
|
||||||
|
username: username,
|
||||||
|
password: password,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateUser(config) {
|
||||||
|
return request(
|
||||||
|
'USER_UPDATE',
|
||||||
|
configureAxios().post('/users/edit', config),
|
||||||
|
[
|
||||||
|
addAlertOk("User updated"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function userSignUp(config) {
|
||||||
|
return request(
|
||||||
|
'USER_SIGNUP',
|
||||||
|
configureAxios().post('/users/signup', config)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserInfos() {
|
||||||
|
return request(
|
||||||
|
'GET_USER',
|
||||||
|
configureAxios().get('/users/details')
|
||||||
|
)
|
||||||
|
}
|
@ -28,7 +28,7 @@ import { Router } from 'react-router'
|
|||||||
import { routerActions } from 'react-router-redux'
|
import { routerActions } from 'react-router-redux'
|
||||||
|
|
||||||
// Action creators
|
// Action creators
|
||||||
import { dismissAlert } from './actions/actionCreators'
|
import { dismissAlert } from './actions/alerts'
|
||||||
|
|
||||||
// Store
|
// Store
|
||||||
import store, { history } from './store'
|
import store, { history } from './store'
|
||||||
@ -41,9 +41,13 @@ import Alert from './components/alerts/alert'
|
|||||||
import getRoutes from './routes'
|
import getRoutes from './routes'
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
|
let torrentCount = 0;
|
||||||
|
if (state.torrentStore.has('torrents')) {
|
||||||
|
torrentCount = state.torrentStore.has('torrents').size;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
username: state.userStore.username,
|
username: state.userStore.username,
|
||||||
torrentCount: state.torrentStore.get('torrents').size,
|
torrentCount: torrentCount,
|
||||||
alerts: state.alerts,
|
alerts: state.alerts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { bindActionCreators } from 'redux'
|
import { bindActionCreators } from 'redux'
|
||||||
import { selectMovie, getMovieDetails, addTorrent,
|
import { addTorrent } from '../../actions/torrents'
|
||||||
addMovieToWishlist, deleteMovieFromWishlist } from '../../actions/actionCreators'
|
import { addMovieToWishlist, deleteMovieFromWishlist,
|
||||||
|
getMovieDetails, selectMovie } from '../../actions/movies'
|
||||||
|
|
||||||
import DownloadButton from '../buttons/download'
|
import DownloadButton from '../buttons/download'
|
||||||
import TorrentsButton from './torrents'
|
import TorrentsButton from './torrents'
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { bindActionCreators } from 'redux'
|
import { bindActionCreators } from 'redux'
|
||||||
import { addTorrent, addShowToWishlist, deleteFromWishlist,
|
import { addTorrent } from '../../actions/torrents'
|
||||||
updateShowDetails, updateEpisodeDetailsStore, getEpisodeDetails } from '../../actions/actionCreators'
|
import { addShowToWishlist, deleteFromWishlist, getEpisodeDetails,
|
||||||
|
updateEpisodeDetailsStore, updateShowDetails } from '../../actions/shows'
|
||||||
|
|
||||||
import Loader from '../loader/loader'
|
import Loader from '../loader/loader'
|
||||||
import DownloadButton from '../buttons/download'
|
import DownloadButton from '../buttons/download'
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { bindActionCreators } from 'redux'
|
import { bindActionCreators } from 'redux'
|
||||||
import { selectShow, addShowToWishlist,
|
import { selectShow, addShowToWishlist,
|
||||||
deleteFromWishlist, getShowDetails } from '../../actions/actionCreators'
|
deleteFromWishlist, getShowDetails } from '../../actions/shows'
|
||||||
|
|
||||||
import ListDetails from '../list/details'
|
import ListDetails from '../list/details'
|
||||||
import ListPosters from '../list/posters'
|
import ListPosters from '../list/posters'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { bindActionCreators } from 'redux'
|
import { bindActionCreators } from 'redux'
|
||||||
import { addTorrent } from '../../actions/actionCreators'
|
import { addTorrent } from '../../actions/torrents'
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return { torrents: state.torrentStore.get('torrents') };
|
return { torrents: state.torrentStore.get('torrents') };
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Control, Form } from 'react-redux-form';
|
import { connect } from 'react-redux'
|
||||||
|
import { bindActionCreators } from 'redux'
|
||||||
|
|
||||||
export default class UserEdit extends React.Component {
|
import { Control, Form } from 'react-redux-form';
|
||||||
componentWillMount() {
|
import { updateUser } from '../../actions/users'
|
||||||
this.props.getUserInfos();
|
|
||||||
}
|
function mapStateToProps(state) {
|
||||||
|
return { user: state.userStore };
|
||||||
|
}
|
||||||
|
const mapDispatchToProps = (dispatch) =>
|
||||||
|
bindActionCreators({ updateUser }, dispatch)
|
||||||
|
|
||||||
|
class UserEdit extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
}
|
}
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
this.props.updateUser({
|
this.props.updateUser({
|
||||||
'polochon_url': this.props.userStore.polochonUrl,
|
'polochon_url': this.props.user.polochonUrl,
|
||||||
'polochon_token': this.props.userStore.polochonToken,
|
'polochon_token': this.props.user.polochonToken,
|
||||||
'password': this.refs.newPassword.value,
|
'password': this.refs.newPassword.value,
|
||||||
'password_confirm': this.refs.newPasswordConfirm.value,
|
'password_confirm': this.refs.newPasswordConfirm.value,
|
||||||
});
|
});
|
||||||
@ -58,3 +65,4 @@ export default class UserEdit extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(UserEdit);
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { connect } from 'react-redux'
|
||||||
|
import { bindActionCreators } from 'redux'
|
||||||
|
|
||||||
export default class UserLoginForm extends React.Component {
|
import { loginUser } from '../../actions/users'
|
||||||
|
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
return { user: state.userStore };
|
||||||
|
}
|
||||||
|
const mapDispatchToProps = (dispatch) =>
|
||||||
|
bindActionCreators({ loginUser }, dispatch)
|
||||||
|
|
||||||
|
class UserLoginForm extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
}
|
}
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (!nextProps.userStore.isLogged) {
|
if (!nextProps.user.isLogged) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!nextProps.location.query.redirect) {
|
if (!nextProps.location.query.redirect) {
|
||||||
@ -19,7 +29,7 @@ export default class UserLoginForm extends React.Component {
|
|||||||
}
|
}
|
||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.props.userStore.userLoading) {
|
if (this.props.user.userLoading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const username = this.refs.username.value;
|
const username = this.refs.username.value;
|
||||||
@ -47,12 +57,12 @@ export default class UserLoginForm extends React.Component {
|
|||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{this.props.userStore.userLoading &&
|
{this.props.user.userLoading &&
|
||||||
<button className="btn btn-primary pull-right">
|
<button className="btn btn-primary pull-right">
|
||||||
<i className="fa fa-spinner fa-spin"></i>
|
<i className="fa fa-spinner fa-spin"></i>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
{this.props.userStore.userLoading ||
|
{this.props.user.userLoading ||
|
||||||
<input className="btn btn-primary pull-right" type="submit" value="Log in"/>
|
<input className="btn btn-primary pull-right" type="submit" value="Log in"/>
|
||||||
}
|
}
|
||||||
<br/>
|
<br/>
|
||||||
@ -64,3 +74,4 @@ export default class UserLoginForm extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(UserLoginForm);
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { connect } from 'react-redux'
|
||||||
|
import { bindActionCreators } from 'redux'
|
||||||
|
|
||||||
export default class UserSignUp extends React.Component {
|
import { userSignUp } from '../../actions/users'
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) =>
|
||||||
|
bindActionCreators({ userSignUp }, dispatch)
|
||||||
|
|
||||||
|
class UserSignUp extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
@ -46,3 +53,4 @@ export default class UserSignUp extends React.Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export default connect(null, mapDispatchToProps)(UserSignUp);
|
||||||
|
@ -8,7 +8,11 @@ import UserEdit from './components/users/edit'
|
|||||||
import UserSignUp from './components/users/signup'
|
import UserSignUp from './components/users/signup'
|
||||||
import TorrentList from './components/torrents/list'
|
import TorrentList from './components/torrents/list'
|
||||||
|
|
||||||
import * as actionCreators from './actions/actionCreators'
|
import { fetchTorrents } from './actions/torrents'
|
||||||
|
import { userLogout, getUserInfos } from './actions/users'
|
||||||
|
import { fetchMovies, getMovieExploreOptions } from './actions/movies'
|
||||||
|
import { fetchShows, fetchShowDetails, getShowExploreOptions } from './actions/shows'
|
||||||
|
|
||||||
import store from './store'
|
import store from './store'
|
||||||
|
|
||||||
function startPollingTorrents() {
|
function startPollingTorrents() {
|
||||||
@ -56,7 +60,7 @@ const loginCheck = function(nextState, replace, next, f = null) {
|
|||||||
if (!pollingTorrentsId) {
|
if (!pollingTorrentsId) {
|
||||||
// Fetch the torrents every 10s
|
// Fetch the torrents every 10s
|
||||||
pollingTorrentsId = setInterval(function() {
|
pollingTorrentsId = setInterval(function() {
|
||||||
store.dispatch(actionCreators.fetchTorrents());
|
store.dispatch(fetchTorrents());
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +94,9 @@ export default function getRoutes(App) {
|
|||||||
path: '/users/edit',
|
path: '/users/edit',
|
||||||
component: UserEdit,
|
component: UserEdit,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next);
|
loginCheck(nextState, replace, next, function() {
|
||||||
|
store.dispatch(getUserInfos());
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -101,7 +107,7 @@ export default function getRoutes(App) {
|
|||||||
clearInterval(pollingTorrentsId);
|
clearInterval(pollingTorrentsId);
|
||||||
pollingTorrentsId = null;
|
pollingTorrentsId = null;
|
||||||
}
|
}
|
||||||
store.dispatch(actionCreators.userLogout());
|
store.dispatch(userLogout());
|
||||||
replace('/users/login');
|
replace('/users/login');
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
@ -111,7 +117,7 @@ export default function getRoutes(App) {
|
|||||||
component: MovieList,
|
component: MovieList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchMovies(`/movies/search/${nextState.params.search}`));
|
store.dispatch(fetchMovies(`/movies/search/${nextState.params.search}`));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -120,7 +126,7 @@ export default function getRoutes(App) {
|
|||||||
component: MovieList,
|
component: MovieList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchMovies('/movies/polochon'));
|
store.dispatch(fetchMovies('/movies/polochon'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -132,9 +138,9 @@ export default function getRoutes(App) {
|
|||||||
var state = store.getState();
|
var state = store.getState();
|
||||||
// Fetch the explore options
|
// Fetch the explore options
|
||||||
if (Object.keys(state.movieStore.exploreOptions).length === 0) {
|
if (Object.keys(state.movieStore.exploreOptions).length === 0) {
|
||||||
store.dispatch(actionCreators.getMovieExploreOptions());
|
store.dispatch(getMovieExploreOptions());
|
||||||
}
|
}
|
||||||
store.dispatch(actionCreators.fetchMovies(
|
store.dispatch(fetchMovies(
|
||||||
`/movies/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}`
|
`/movies/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}`
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
@ -145,7 +151,7 @@ export default function getRoutes(App) {
|
|||||||
component: MovieList,
|
component: MovieList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchMovies('/wishlist/movies'));
|
store.dispatch(fetchMovies('/wishlist/movies'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -154,7 +160,7 @@ export default function getRoutes(App) {
|
|||||||
component: ShowList,
|
component: ShowList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchShows(`/shows/search/${nextState.params.search}`));
|
store.dispatch(fetchShows(`/shows/search/${nextState.params.search}`));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -163,7 +169,7 @@ export default function getRoutes(App) {
|
|||||||
component: ShowList,
|
component: ShowList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchShows('/shows/polochon'));
|
store.dispatch(fetchShows('/shows/polochon'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -172,7 +178,7 @@ export default function getRoutes(App) {
|
|||||||
component: ShowList,
|
component: ShowList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchShows('/wishlist/shows'));
|
store.dispatch(fetchShows('/wishlist/shows'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -181,7 +187,7 @@ export default function getRoutes(App) {
|
|||||||
component: ShowDetails,
|
component: ShowDetails,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchShowDetails(nextState.params.imdbId));
|
store.dispatch(fetchShowDetails(nextState.params.imdbId));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -193,9 +199,9 @@ export default function getRoutes(App) {
|
|||||||
var state = store.getState();
|
var state = store.getState();
|
||||||
// Fetch the explore options
|
// Fetch the explore options
|
||||||
if (Object.keys(state.showStore.exploreOptions).length === 0) {
|
if (Object.keys(state.showStore.exploreOptions).length === 0) {
|
||||||
store.dispatch(actionCreators.getShowExploreOptions());
|
store.dispatch(getShowExploreOptions());
|
||||||
}
|
}
|
||||||
store.dispatch(actionCreators.fetchShows(
|
store.dispatch(fetchShows(
|
||||||
`/shows/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}`
|
`/shows/explore?source=${encodeURI(nextState.params.source)}&category=${encodeURI(nextState.params.category)}`
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
@ -206,7 +212,7 @@ export default function getRoutes(App) {
|
|||||||
component: TorrentList,
|
component: TorrentList,
|
||||||
onEnter: function(nextState, replace, next) {
|
onEnter: function(nextState, replace, next) {
|
||||||
loginCheck(nextState, replace, next, function() {
|
loginCheck(nextState, replace, next, function() {
|
||||||
store.dispatch(actionCreators.fetchTorrents());
|
store.dispatch(fetchTorrents());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user