mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Convert some selectors to Typescript
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
import IndexerAppState, { IndexerIndexAppState } from './IndexerAppState';
|
import CommandAppState from './CommandAppState';
|
||||||
|
import IndexerAppState, {
|
||||||
|
IndexerIndexAppState,
|
||||||
|
IndexerStatusAppState,
|
||||||
|
} from './IndexerAppState';
|
||||||
import IndexerStatsAppState from './IndexerStatsAppState';
|
import IndexerStatsAppState from './IndexerStatsAppState';
|
||||||
import SettingsAppState from './SettingsAppState';
|
import SettingsAppState from './SettingsAppState';
|
||||||
import TagsAppState from './TagsAppState';
|
import TagsAppState from './TagsAppState';
|
||||||
@@ -36,8 +40,10 @@ export interface CustomFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AppState {
|
interface AppState {
|
||||||
|
commands: CommandAppState;
|
||||||
indexerIndex: IndexerIndexAppState;
|
indexerIndex: IndexerIndexAppState;
|
||||||
indexerStats: IndexerStatsAppState;
|
indexerStats: IndexerStatsAppState;
|
||||||
|
indexerStatus: IndexerStatusAppState;
|
||||||
indexers: IndexerAppState;
|
indexers: IndexerAppState;
|
||||||
settings: SettingsAppState;
|
settings: SettingsAppState;
|
||||||
tags: TagsAppState;
|
tags: TagsAppState;
|
||||||
|
6
frontend/src/App/State/CommandAppState.ts
Normal file
6
frontend/src/App/State/CommandAppState.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import AppSectionState from 'App/State/AppSectionState';
|
||||||
|
import Command from 'Commands/Command';
|
||||||
|
|
||||||
|
export type CommandAppState = AppSectionState<Command>;
|
||||||
|
|
||||||
|
export default CommandAppState;
|
@@ -1,6 +1,6 @@
|
|||||||
import Column from 'Components/Table/Column';
|
import Column from 'Components/Table/Column';
|
||||||
import SortDirection from 'Helpers/Props/SortDirection';
|
import SortDirection from 'Helpers/Props/SortDirection';
|
||||||
import Indexer from 'Indexer/Indexer';
|
import Indexer, { IndexerStatus } from 'Indexer/Indexer';
|
||||||
import AppSectionState, {
|
import AppSectionState, {
|
||||||
AppSectionDeleteState,
|
AppSectionDeleteState,
|
||||||
AppSectionSaveState,
|
AppSectionSaveState,
|
||||||
@@ -30,4 +30,6 @@ interface IndexerAppState
|
|||||||
AppSectionDeleteState,
|
AppSectionDeleteState,
|
||||||
AppSectionSaveState {}
|
AppSectionSaveState {}
|
||||||
|
|
||||||
|
export type IndexerStatusAppState = AppSectionState<IndexerStatus>;
|
||||||
|
|
||||||
export default IndexerAppState;
|
export default IndexerAppState;
|
||||||
|
@@ -7,6 +7,11 @@ import DownloadClient from 'typings/DownloadClient';
|
|||||||
import Notification from 'typings/Notification';
|
import Notification from 'typings/Notification';
|
||||||
import { UiSettings } from 'typings/UiSettings';
|
import { UiSettings } from 'typings/UiSettings';
|
||||||
|
|
||||||
|
export interface AppProfileAppState
|
||||||
|
extends AppSectionState<Application>,
|
||||||
|
AppSectionDeleteState,
|
||||||
|
AppSectionSaveState {}
|
||||||
|
|
||||||
export interface ApplicationAppState
|
export interface ApplicationAppState
|
||||||
extends AppSectionState<Application>,
|
extends AppSectionState<Application>,
|
||||||
AppSectionDeleteState,
|
AppSectionDeleteState,
|
||||||
@@ -24,6 +29,7 @@ export interface NotificationAppState
|
|||||||
export type UiSettingsAppState = AppSectionState<UiSettings>;
|
export type UiSettingsAppState = AppSectionState<UiSettings>;
|
||||||
|
|
||||||
interface SettingsAppState {
|
interface SettingsAppState {
|
||||||
|
appProfiles: AppProfileAppState;
|
||||||
applications: ApplicationAppState;
|
applications: ApplicationAppState;
|
||||||
downloadClients: DownloadClientAppState;
|
downloadClients: DownloadClientAppState;
|
||||||
notifications: NotificationAppState;
|
notifications: NotificationAppState;
|
||||||
|
37
frontend/src/Commands/Command.ts
Normal file
37
frontend/src/Commands/Command.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import ModelBase from 'App/ModelBase';
|
||||||
|
|
||||||
|
export interface CommandBody {
|
||||||
|
sendUpdatesToClient: boolean;
|
||||||
|
updateScheduledTask: boolean;
|
||||||
|
completionMessage: string;
|
||||||
|
requiresDiskAccess: boolean;
|
||||||
|
isExclusive: boolean;
|
||||||
|
isLongRunning: boolean;
|
||||||
|
name: string;
|
||||||
|
lastExecutionTime: string;
|
||||||
|
lastStartTime: string;
|
||||||
|
trigger: string;
|
||||||
|
suppressMessages: boolean;
|
||||||
|
seriesId?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Command extends ModelBase {
|
||||||
|
name: string;
|
||||||
|
commandName: string;
|
||||||
|
message: string;
|
||||||
|
body: CommandBody;
|
||||||
|
priority: string;
|
||||||
|
status: string;
|
||||||
|
result: string;
|
||||||
|
queued: string;
|
||||||
|
started: string;
|
||||||
|
ended: string;
|
||||||
|
duration: string;
|
||||||
|
trigger: string;
|
||||||
|
stateChangeTime: string;
|
||||||
|
sendUpdatesToClient: boolean;
|
||||||
|
updateScheduledTask: boolean;
|
||||||
|
lastExecutionTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Command;
|
@@ -12,7 +12,7 @@ interface IndexerStatusCellProps {
|
|||||||
className: string;
|
className: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
redirect: boolean;
|
redirect: boolean;
|
||||||
status: IndexerStatus;
|
status?: IndexerStatus;
|
||||||
longDateFormat: string;
|
longDateFormat: string;
|
||||||
timeFormat: string;
|
timeFormat: string;
|
||||||
component?: React.ElementType;
|
component?: React.ElementType;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createAllIndexersSelector() {
|
function createAllIndexersSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.indexers,
|
(state: AppState) => state.indexers,
|
||||||
(indexers) => {
|
(indexers) => {
|
||||||
return indexers.items;
|
return indexers.items;
|
||||||
}
|
}
|
@@ -1,8 +1,9 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createCommandsSelector() {
|
function createCommandsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.commands,
|
(state: AppState) => state.commands,
|
||||||
(commands) => {
|
(commands) => {
|
||||||
return commands.items;
|
return commands.items;
|
||||||
}
|
}
|
@@ -1,9 +1,10 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
import { isCommandExecuting } from 'Utilities/Command';
|
import { isCommandExecuting } from 'Utilities/Command';
|
||||||
|
|
||||||
function createExecutingCommandsSelector() {
|
function createExecutingCommandsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.commands.items,
|
(state: AppState) => state.commands.items,
|
||||||
(commands) => {
|
(commands) => {
|
||||||
return commands.filter((command) => isCommandExecuting(command));
|
return commands.filter((command) => isCommandExecuting(command));
|
||||||
}
|
}
|
@@ -1,9 +1,10 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
import { createIndexerSelectorForHook } from './createIndexerSelector';
|
import { createIndexerSelectorForHook } from './createIndexerSelector';
|
||||||
|
|
||||||
function createIndexerAppProfileSelector(indexerId) {
|
function createIndexerAppProfileSelector(indexerId: number) {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.settings.appProfiles.items,
|
(state: AppState) => state.settings.appProfiles.items,
|
||||||
createIndexerSelectorForHook(indexerId),
|
createIndexerSelectorForHook(indexerId),
|
||||||
(appProfiles, indexer = {}) => {
|
(appProfiles, indexer = {}) => {
|
||||||
return appProfiles.find((profile) => {
|
return appProfiles.find((profile) => {
|
@@ -1,13 +0,0 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
function createIndexerStatusSelector(indexerId) {
|
|
||||||
return createSelector(
|
|
||||||
(state) => state.indexerStatus.items,
|
|
||||||
(indexerStatus) => {
|
|
||||||
return _.find(indexerStatus, { indexerId });
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createIndexerStatusSelector;
|
|
15
frontend/src/Store/Selectors/createIndexerStatusSelector.ts
Normal file
15
frontend/src/Store/Selectors/createIndexerStatusSelector.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { find } from 'lodash';
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
import { IndexerStatus } from 'Indexer/Indexer';
|
||||||
|
|
||||||
|
function createIndexerStatusSelector(indexerId: number) {
|
||||||
|
return createSelector(
|
||||||
|
(state: AppState) => state.indexerStatus.items,
|
||||||
|
(indexerStatus) => {
|
||||||
|
return find(indexerStatus, { indexerId }) as IndexerStatus | undefined;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createIndexerStatusSelector;
|
@@ -1,8 +1,9 @@
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createTagsSelector() {
|
function createTagsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.tags.items,
|
(state: AppState) => state.tags.items,
|
||||||
(tags) => {
|
(tags) => {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
Reference in New Issue
Block a user