mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
Select type added for client schema
This commit is contained in:
parent
954ac925d0
commit
ca334ef664
@ -1,4 +1,6 @@
|
||||
namespace NzbDrone.Api.ClientSchema
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Api.ClientSchema
|
||||
{
|
||||
public class Field
|
||||
{
|
||||
@ -8,5 +10,6 @@ public class Field
|
||||
public string HelpText { get; set; }
|
||||
public object Value { get; set; }
|
||||
public string Type { get; set; }
|
||||
public List<SelectOption> SelectOptions { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Reflection;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
@ -34,6 +36,11 @@ public static List<Field> GenerateSchema(object model)
|
||||
field.Value = value;
|
||||
}
|
||||
|
||||
if (fieldAttribute.Type == FieldType.Select)
|
||||
{
|
||||
field.SelectOptions = GetSelectOptions(fieldAttribute.SelectOptions);
|
||||
}
|
||||
|
||||
result.Add(field);
|
||||
}
|
||||
}
|
||||
@ -41,5 +48,13 @@ public static List<Field> GenerateSchema(object model)
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static List<SelectOption> GetSelectOptions(Type selectOptions)
|
||||
{
|
||||
var options = from Enum e in Enum.GetValues(selectOptions)
|
||||
select new SelectOption { Value = Convert.ToInt32(e), Name = e.ToString() };
|
||||
|
||||
return options.OrderBy(o => o.Value).ToList();
|
||||
}
|
||||
}
|
||||
}
|
13
NzbDrone.Api/ClientSchema/SelectOption.cs
Normal file
13
NzbDrone.Api/ClientSchema/SelectOption.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Api.ClientSchema
|
||||
{
|
||||
public class SelectOption
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -97,6 +97,7 @@
|
||||
<Compile Include="ClientSchema\FieldDefinitionAttribute.cs" />
|
||||
<Compile Include="ClientSchema\Field.cs" />
|
||||
<Compile Include="ClientSchema\SchemaBuilder.cs" />
|
||||
<Compile Include="ClientSchema\SelectOption.cs" />
|
||||
<Compile Include="Commands\CommandModule.cs" />
|
||||
<Compile Include="Commands\CommandResource.cs" />
|
||||
<Compile Include="Directories\DirectoryModule.cs" />
|
||||
|
@ -14,12 +14,14 @@ public FieldDefinitionAttribute(int order)
|
||||
public string Label { get; set; }
|
||||
public string HelpText { get; set; }
|
||||
public FieldType Type { get; set; }
|
||||
public Type SelectOptions { get; set; }
|
||||
}
|
||||
|
||||
public enum FieldType
|
||||
{
|
||||
Textbox,
|
||||
Password,
|
||||
Checkbox
|
||||
Checkbox,
|
||||
Select
|
||||
}
|
||||
}
|
16
NzbDrone.Core/Notifications/Prowl/ProwlPriority.cs
Normal file
16
NzbDrone.Core/Notifications/Prowl/ProwlPriority.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Prowl
|
||||
{
|
||||
public enum ProwlPriority
|
||||
{
|
||||
VeryLow = -2,
|
||||
Low = -1,
|
||||
Normal = 0,
|
||||
High = 1,
|
||||
Emergency = 2
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ public class ProwlSettings : INotifcationSettings
|
||||
[FieldDefinition(0, Label = "API Key", HelpText = "API Key for Prowl")]
|
||||
public String ApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Priority", HelpText = "Priority to send messages at")]
|
||||
public Nullable<Int32> Priority { get; set; }
|
||||
[FieldDefinition(1, Label = "Priority", HelpText = "Priority to send messages at", Type = FieldType.Select, SelectOptions= typeof(ProwlPriority) )]
|
||||
public Int32 Priority { get; set; }
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
|
@ -332,6 +332,7 @@
|
||||
<Compile Include="Notifications\Plex\PlexServerSettings.cs" />
|
||||
<Compile Include="Notifications\Plex\TestPlexClientCommand.cs" />
|
||||
<Compile Include="Notifications\Prowl\InvalidApiKeyException.cs" />
|
||||
<Compile Include="Notifications\Prowl\ProwlPriority.cs" />
|
||||
<Compile Include="Notifications\Prowl\ProwlSettings.cs" />
|
||||
<Compile Include="Notifications\Email\EmailSettings.cs" />
|
||||
<Compile Include="Notifications\Prowl\TestProwlCommand.cs" />
|
||||
|
@ -22,6 +22,10 @@ define(['app'], function () {
|
||||
return Handlebars.helpers.partial.apply(field, ['Form/CheckboxTemplate']);
|
||||
}
|
||||
|
||||
if (field.type === 'select') {
|
||||
return Handlebars.helpers.partial.apply(field, ['Form/SelectTemplate']);
|
||||
}
|
||||
|
||||
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
|
||||
};
|
||||
});
|
||||
|
16
UI/Form/SelectTemplate.html
Normal file
16
UI/Form/SelectTemplate.html
Normal file
@ -0,0 +1,16 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{label}}</label>
|
||||
|
||||
<div class="controls">
|
||||
<select name="fields.{{order}}.value">
|
||||
{{#each selectOptions}}
|
||||
<option value="{{value}}">{{name}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{#if helpText}}
|
||||
<span class="help-inline">
|
||||
<i class="icon-question-sign" title="{{helpText}}"></i>
|
||||
</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user