mirror of
https://github.com/zoriya/flood.git
synced 2026-05-27 17:11:58 +00:00
Add Check Hash menu item
This commit is contained in:
@@ -79,6 +79,31 @@ const TorrentActions = {
|
||||
});
|
||||
},
|
||||
|
||||
checkHash: (hash) => {
|
||||
return axios.post('/client/torrents/check-hash', {hash})
|
||||
.then((json = {}) => {
|
||||
return json.data;
|
||||
})
|
||||
.then((data) => {
|
||||
AppDispatcher.dispatchServerAction({
|
||||
type: ActionTypes.CLIENT_CHECK_HASH_SUCCESS,
|
||||
data: {
|
||||
data,
|
||||
count: hash.length
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
AppDispatcher.dispatchServerAction({
|
||||
type: ActionTypes.CLIENT_CHECK_HASH_ERROR,
|
||||
error: {
|
||||
error,
|
||||
count: hash.length
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
fetchTorrents: () => {
|
||||
return axios.get('/client/torrents')
|
||||
.then((json = {}) => {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -115,6 +115,10 @@ export default class TorrentListContainer extends React.Component {
|
||||
action: 'remove',
|
||||
clickHandler,
|
||||
label: 'Remove'
|
||||
}, {
|
||||
action: 'check-hash',
|
||||
clickHandler,
|
||||
label: 'Check Hash'
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
@@ -137,6 +141,9 @@ export default class TorrentListContainer extends React.Component {
|
||||
handleContextMenuItemClick(action, event) {
|
||||
let selectedTorrents = TorrentStore.getSelectedTorrents();
|
||||
switch (action) {
|
||||
case 'check-hash':
|
||||
TorrentActions.checkHash(selectedTorrents);
|
||||
break;
|
||||
case 'start':
|
||||
TorrentActions.startTorrents(selectedTorrents);
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
const ActionTypes = {
|
||||
CLIENT_ADD_TORRENT_ERROR: 'CLIENT_ADD_TORRENT_ERROR',
|
||||
CLIENT_ADD_TORRENT_SUCCESS: 'CLIENT_ADD_TORRENT_SUCCESS',
|
||||
CLIENT_CHECK_HASH_ERROR: 'CLIENT_CHECK_HASH_ERROR',
|
||||
CLIENT_CHECK_HASH_SUCCESS: 'CLIENT_CHECK_HASH_SUCCESS',
|
||||
CLIENT_FETCH_TORRENT_STATUS_COUNT_REQUEST_ERROR: 'CLIENT_FETCH_TORRENT_STATUS_COUNT_REQUEST_ERROR',
|
||||
CLIENT_FETCH_TORRENT_STATUS_COUNT_REQUEST_SUCCESS: 'CLIENT_FETCH_TORRENT_STATUS_COUNT_REQUEST_SUCCESS',
|
||||
CLIENT_FETCH_TORRENT_TRACKER_COUNT_REQUEST_ERROR: 'CLIENT_FETCH_TORRENT_TRACKER_COUNT_REQUEST_ERROR',
|
||||
|
||||
@@ -282,6 +282,7 @@ TorrentStore.dispatcherID = AppDispatcher.register((payload) => {
|
||||
TorrentStore.handleAddTorrentError(action.error);
|
||||
break;
|
||||
case ActionTypes.CLIENT_ADD_TORRENT_SUCCESS:
|
||||
TorrentStore.fetchTorrents();
|
||||
TorrentStore.handleAddTorrentSuccess(action.data);
|
||||
break;
|
||||
case ActionTypes.CLIENT_FETCH_TORRENTS_SUCCESS:
|
||||
@@ -313,9 +314,9 @@ TorrentStore.dispatcherID = AppDispatcher.register((payload) => {
|
||||
case ActionTypes.UI_SET_TORRENT_SORT:
|
||||
TorrentStore.triggerTorrentsFilter();
|
||||
break;
|
||||
case ActionTypes.CLIENT_ADD_TORRENT_SUCCESS:
|
||||
case ActionTypes.CLIENT_START_TORRENT_SUCCESS:
|
||||
case ActionTypes.CLIENT_STOP_TORRENT_SUCCESS:
|
||||
case ActionTypes.CLIENT_CHECK_HASH_SUCCESS:
|
||||
TorrentStore.fetchTorrents();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ import React from 'react';
|
||||
import ErrorIcon from '../components/icons/ErrorIcon';
|
||||
import PauseIcon from '../components/icons/PauseIcon';
|
||||
import propsMap from '../../../../shared/constants/propsMap';
|
||||
import SpinnerIcon from '../components/icons/SpinnerIcon';
|
||||
import StartIcon from '../components/icons/StartIcon';
|
||||
import StopIcon from '../components/icons/StopIcon';
|
||||
|
||||
const STATUS_ICON_MAP = {
|
||||
error: <ErrorIcon />,
|
||||
hashChecking: <SpinnerIcon />,
|
||||
stopped: <StopIcon />,
|
||||
paused: <PauseIcon />,
|
||||
running: <StartIcon />
|
||||
@@ -33,6 +35,7 @@ export function torrentStatusIcons(status) {
|
||||
if (condition) {
|
||||
statusString = status;
|
||||
}
|
||||
|
||||
return condition;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user