mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Show User Agent in System->Tasks for externally triggered commands (#6327)
* Show User Agent in System->Tasks for externally triggered commands (cherry picked from commit fe8f319f7bfdadb7218b6313ada6cae1d2a35ad8) * Translations Co-authored-by: Taloth Saldono <Taloth@users.noreply.github.com>
This commit is contained in:
parent
5fe8f65d64
commit
fcec787eb6
@ -10,6 +10,15 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.commandName {
|
||||
display: inline-block;
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.userAgent {
|
||||
color: #b0b0b0;
|
||||
}
|
||||
|
||||
.queued,
|
||||
.started,
|
||||
.ended {
|
||||
|
@ -157,6 +157,7 @@ class QueuedTaskRow extends Component {
|
||||
status,
|
||||
duration,
|
||||
message,
|
||||
clientUserAgent,
|
||||
longDateFormat,
|
||||
timeFormat,
|
||||
onCancelPress
|
||||
@ -192,7 +193,17 @@ class QueuedTaskRow extends Component {
|
||||
</span>
|
||||
</TableRowCell>
|
||||
|
||||
<TableRowCell>{commandName}</TableRowCell>
|
||||
<TableRowCell>
|
||||
<span className={styles.commandName}>
|
||||
{commandName}
|
||||
</span>
|
||||
{
|
||||
clientUserAgent &&
|
||||
<span className={styles.userAgent} title={translate('TaskUserAgentTooltip')}>
|
||||
{translate('from')}: {clientUserAgent}
|
||||
</span>
|
||||
}
|
||||
</TableRowCell>
|
||||
|
||||
<TableRowCell
|
||||
className={styles.queued}
|
||||
@ -256,6 +267,7 @@ QueuedTaskRow.propTypes = {
|
||||
status: PropTypes.string.isRequired,
|
||||
duration: PropTypes.string,
|
||||
message: PropTypes.string,
|
||||
clientUserAgent: PropTypes.string,
|
||||
showRelativeDates: PropTypes.bool.isRequired,
|
||||
shortDateFormat: PropTypes.string.isRequired,
|
||||
longDateFormat: PropTypes.string.isRequired,
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using Radarr.Http.REST;
|
||||
|
||||
@ -21,6 +22,8 @@ public class CommandResource : RestResource
|
||||
public string Exception { get; set; }
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string CompletionMessage { get; set; }
|
||||
|
||||
@ -125,6 +128,8 @@ public static CommandResource ToResource(this CommandModel model)
|
||||
Exception = model.Exception,
|
||||
Trigger = model.Trigger,
|
||||
|
||||
ClientUserAgent = UserAgentParser.SimplifyUserAgent(model.Body.ClientUserAgent),
|
||||
|
||||
CompletionMessage = model.Body.CompletionMessage,
|
||||
LastExecutionTime = model.Body.LastExecutionTime
|
||||
};
|
||||
|
21
src/NzbDrone.Common/Http/UserAgentParser.cs
Normal file
21
src/NzbDrone.Common/Http/UserAgentParser.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NzbDrone.Common.Http
|
||||
{
|
||||
public static class UserAgentParser
|
||||
{
|
||||
public static string SimplifyUserAgent(string userAgent)
|
||||
{
|
||||
if (userAgent == null || userAgent.StartsWith("Mozilla/5.0"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return userAgent;
|
||||
}
|
||||
}
|
||||
}
|
@ -344,6 +344,7 @@
|
||||
"ForMoreInformationOnTheIndividualImportListsClinkOnTheInfoButtons": "For more information on the individual import lists, click on the info buttons.",
|
||||
"ForMoreInformationOnTheIndividualIndexers": "For more information on the individual indexers, click on the info buttons.",
|
||||
"FreeSpace": "Free Space",
|
||||
"From": "From",
|
||||
"General": "General",
|
||||
"GeneralSettings": "General Settings",
|
||||
"GeneralSettingsSummary": "Port, SSL, username/password, proxy, analytics and updates",
|
||||
@ -963,6 +964,7 @@
|
||||
"TagsHelpText": "Applies to movies with at least one matching tag",
|
||||
"TagsSettingsSummary": "See all tags and how they are used. Unused tags can be removed",
|
||||
"Tasks": "Tasks",
|
||||
"TaskUserAgentTooltip": "User-Agent provided by the app that called the API",
|
||||
"Test": "Test",
|
||||
"TestAll": "Test All",
|
||||
"TestAllClients": "Test All Clients",
|
||||
|
@ -34,6 +34,8 @@ public virtual bool SendUpdatesToClient
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
public bool SuppressMessages { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
public Command()
|
||||
{
|
||||
Name = GetType().Name.Replace("Command", "");
|
||||
|
@ -57,6 +57,8 @@ private int StartCommand(CommandResource commandResource)
|
||||
command.SuppressMessages = !command.SendUpdatesToClient;
|
||||
command.SendUpdatesToClient = true;
|
||||
|
||||
command.ClientUserAgent = Request.Headers.UserAgent;
|
||||
|
||||
var trackedCommand = _commandQueueManager.Push(command, CommandPriority.Normal, CommandTrigger.Manual);
|
||||
return trackedCommand.Id;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using Radarr.Http.REST;
|
||||
|
||||
@ -23,6 +24,8 @@ public class CommandResource : RestResource
|
||||
public string Exception { get; set; }
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string CompletionMessage { get; set; }
|
||||
|
||||
@ -106,6 +109,8 @@ public static CommandResource ToResource(this CommandModel model)
|
||||
Exception = model.Exception,
|
||||
Trigger = model.Trigger,
|
||||
|
||||
ClientUserAgent = UserAgentParser.SimplifyUserAgent(model.Body.ClientUserAgent),
|
||||
|
||||
CompletionMessage = model.Body.CompletionMessage,
|
||||
LastExecutionTime = model.Body.LastExecutionTime
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user