mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Project Aphrodite
This commit is contained in:
10
frontend/src/Utilities/Command/findCommand.js
Normal file
10
frontend/src/Utilities/Command/findCommand.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import _ from 'lodash';
|
||||
import isSameCommand from './isSameCommand';
|
||||
|
||||
function findCommand(commands, options) {
|
||||
return _.findLast(commands, (command) => {
|
||||
return isSameCommand(command.body, options);
|
||||
});
|
||||
}
|
||||
|
||||
export default findCommand;
|
5
frontend/src/Utilities/Command/index.js
Normal file
5
frontend/src/Utilities/Command/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export { default as findCommand } from './findCommand';
|
||||
export { default as isCommandComplete } from './isCommandComplete';
|
||||
export { default as isCommandExecuting } from './isCommandExecuting';
|
||||
export { default as isCommandFailed } from './isCommandFailed';
|
||||
export { default as isSameCommand } from './isSameCommand';
|
9
frontend/src/Utilities/Command/isCommandComplete.js
Normal file
9
frontend/src/Utilities/Command/isCommandComplete.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function isCommandComplete(command) {
|
||||
if (!command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return command.status === 'complete';
|
||||
}
|
||||
|
||||
export default isCommandComplete;
|
9
frontend/src/Utilities/Command/isCommandExecuting.js
Normal file
9
frontend/src/Utilities/Command/isCommandExecuting.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function isCommandExecuting(command) {
|
||||
if (!command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return command.status === 'queued' || command.status === 'started';
|
||||
}
|
||||
|
||||
export default isCommandExecuting;
|
12
frontend/src/Utilities/Command/isCommandFailed.js
Normal file
12
frontend/src/Utilities/Command/isCommandFailed.js
Normal file
@@ -0,0 +1,12 @@
|
||||
function isCommandFailed(command) {
|
||||
if (!command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return command.status === 'failed' ||
|
||||
command.status === 'aborted' ||
|
||||
command.status === 'cancelled' ||
|
||||
command.status === 'orphaned';
|
||||
}
|
||||
|
||||
export default isCommandFailed;
|
24
frontend/src/Utilities/Command/isSameCommand.js
Normal file
24
frontend/src/Utilities/Command/isSameCommand.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
function isSameCommand(commandA, commandB) {
|
||||
if (commandA.name.toLocaleLowerCase() !== commandB.name.toLocaleLowerCase()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const key in commandB) {
|
||||
if (key !== 'name') {
|
||||
const value = commandB[key];
|
||||
if (Array.isArray(value)) {
|
||||
if (_.difference(value, commandA[key]).length > 0) {
|
||||
return false;
|
||||
}
|
||||
} else if (value !== commandA[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export default isSameCommand;
|
Reference in New Issue
Block a user