-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration for the other providers (#376)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b206d2f
commit 4e12dcc
Showing
19 changed files
with
414 additions
and
38 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/TagzApp.Blazor.Client/Components/Admin/AzureQueue.Config.Ui.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@using System.ComponentModel.DataAnnotations | ||
<UiProviderConfig ProviderName="AzureQueue" Health="@Health" ProviderIconCssClass="bi-globe2"> | ||
|
||
<EditForm Model="Model" OnValidSubmit="SaveConfig"> | ||
<AntiforgeryToken /> | ||
<ValidationSummary /> | ||
<dl> | ||
<dt><label for="QueueConnectionString">Queue Connection String:</label></dt> | ||
<dd> | ||
<InputText name="QueueConnectionString" @bind-Value="Model.QueueConnectionString" placeholder="Queue Connection String" /> | ||
<ValidationMessage For="() => Model.QueueConnectionString" class="text-danger" /> | ||
</dd> | ||
<dt><label for="Enabled">Enabled:</label></dt> | ||
<dd> | ||
<InputCheckbox name="Enabled" @bind-Value="Model.Enabled" /> | ||
</dd> | ||
</dl> | ||
|
||
<button type="submit" class="btn btn-primary">Save</button> | ||
|
||
</EditForm> | ||
|
||
</UiProviderConfig> | ||
|
||
@code { | ||
|
||
[Parameter, EditorRequired] | ||
public ISocialMediaProvider Provider { get; set; } = null!; | ||
|
||
public (SocialMediaStatus Status, string Message) Health { get; set; } = (SocialMediaStatus.Unknown, string.Empty); | ||
|
||
|
||
public ViewModel Model { get; set; } = new(); | ||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
Model = new ViewModel | ||
{ | ||
QueueConnectionString = providerConfiguration.GetConfigurationByKey("QueueConnectionString"), | ||
Enabled = string.IsNullOrEmpty(providerConfiguration.GetConfigurationByKey("Enabled")) ? false : bool.Parse(providerConfiguration.GetConfigurationByKey("Enabled")) | ||
}; | ||
|
||
Health = await Provider.GetHealth(); | ||
|
||
await base.OnParametersSetAsync(); | ||
|
||
} | ||
|
||
private async Task SaveConfig() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
providerConfiguration.SetConfigurationByKey("QueueConnectionString", Model.QueueConnectionString); | ||
providerConfiguration.SetConfigurationByKey("Enabled", Model.Enabled.ToString()); | ||
|
||
await Provider.SaveConfiguration(ConfigureTagzAppFactory.Current, providerConfiguration); | ||
|
||
} | ||
|
||
public class ViewModel | ||
{ | ||
|
||
// add properties for each of the fields you want to edit | ||
[Required] | ||
public string QueueConnectionString { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
|
||
|
||
} | ||
|
||
} |
143 changes: 143 additions & 0 deletions
143
src/TagzApp.Blazor.Client/Components/Admin/Blazot.Config.Ui.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
@using System.ComponentModel.DataAnnotations | ||
@using System.Text.Json | ||
<UiProviderConfig ProviderName="Blazot" Health="@Health" ProviderIconCssClass="bi-blazot"> | ||
|
||
<EditForm Model="Model" OnValidSubmit="SaveConfig"> | ||
<AntiforgeryToken /> | ||
<ValidationSummary /> | ||
<dl> | ||
<dt><label for="ApiKey">Api Key:</label></dt> | ||
<dd> | ||
<InputText name="ApiKey" @bind-Value="Model.ApiKey" placeholder="Api Key" /> | ||
<ValidationMessage For="() => Model.ApiKey" class="text-danger" /> | ||
</dd> | ||
<dt><label for="SecretAuthKey">Secret Auth Key:</label></dt> | ||
<dd> | ||
<InputText name="SecretAuthKey" @bind-Value="Model.SecretAuthKey" placeholder="Secret Auth Key" /> | ||
<ValidationMessage For="() => Model.SecretAuthKey" class="text-danger" /> | ||
</dd> | ||
<dt><label for="BaseAddress">Base Address:</label></dt> | ||
<dd> | ||
<InputText name="BaseAddress" @bind-Value="Model.BaseAddress" placeholder="Base Address of Mastodon Server" /> | ||
<ValidationMessage For="() => Model.BaseAddress" class="text-danger" /> | ||
</dd> | ||
<dt><label for="Timeout">Timeout:</label></dt> | ||
<dd> | ||
<input name="Timeout" @bind="Model.Timeout" pattern="\d{2}:\d{2}:\d{2}" /> | ||
<ValidationMessage For="() => Model.Timeout" class="text-danger" /> | ||
</dd> | ||
<dt>Default Headers:</dt> | ||
<dd> | ||
@* Generate a set of textboxes to collect values for the DefaultHeaders dictionary in ViewModel*@ | ||
<InputDictionary Value="@Model.DefaultHeaders" KeyCaption="Name" /> | ||
|
||
</dd> | ||
<dt><label for="UseHttp2">UseHttp2:</label></dt> | ||
<dd> | ||
<InputCheckbox name="UseHttp2" @bind-Value="Model.UseHttp2" /> | ||
</dd> | ||
<dt><label for="WindowRequests">Window Requests:</label></dt> | ||
<dd> | ||
<InputNumber name="WindowRequests" @bind-Value="Model.WindowRequests" /> | ||
<ValidationMessage For="() => Model.WindowRequests" class="text-danger" /> | ||
</dd> | ||
<dt><label for="WindowSeconds">Window Seconds:</label></dt> | ||
<dd> | ||
<InputNumber name="WindowSeconds" @bind-Value="Model.WindowSeconds" /> | ||
<ValidationMessage For="() => Model.WindowSeconds" class="text-danger" /> | ||
</dd> | ||
|
||
<dt><label for="Enabled">Enabled:</label></dt> | ||
<dd> | ||
<InputCheckbox name="Enabled" @bind-Value="Model.Enabled" /> | ||
</dd> | ||
</dl> | ||
|
||
<button type="submit" class="btn btn-primary">Save</button> | ||
|
||
</EditForm> | ||
|
||
</UiProviderConfig> | ||
|
||
@code { | ||
|
||
[Parameter, EditorRequired] | ||
public ISocialMediaProvider Provider { get; set; } = null!; | ||
|
||
public (SocialMediaStatus Status, string Message) Health { get; set; } = (SocialMediaStatus.Unknown, string.Empty); | ||
|
||
|
||
public ViewModel Model { get; set; } = new(); | ||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
var headers = providerConfiguration.GetConfigurationByKey("DefaultHeaders"); | ||
var headerDictionary = string.IsNullOrEmpty(headers) ? new() : JsonSerializer.Deserialize<Dictionary<string, string>>(headers); | ||
|
||
Model = new ViewModel | ||
{ | ||
BaseAddress = providerConfiguration.GetConfigurationByKey("BaseAddress"), | ||
DefaultHeaders = headerDictionary, | ||
Timeout = TimeSpan.Parse(providerConfiguration.GetConfigurationByKey("Timeout")), | ||
UseHttp2 = string.IsNullOrEmpty(providerConfiguration.GetConfigurationByKey("UseHttp2")) ? false : bool.Parse(providerConfiguration.GetConfigurationByKey("UseHttp2")), | ||
Enabled = string.IsNullOrEmpty(providerConfiguration.GetConfigurationByKey("Enabled")) ? false : bool.Parse(providerConfiguration.GetConfigurationByKey("Enabled")) | ||
}; | ||
|
||
Health = await Provider.GetHealth(); | ||
|
||
await base.OnParametersSetAsync(); | ||
|
||
} | ||
|
||
private async Task SaveConfig() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
Model.DefaultHeaders.Remove(string.Empty); | ||
|
||
providerConfiguration.SetConfigurationByKey("BaseAddress", Model.BaseAddress); | ||
providerConfiguration.SetConfigurationByKey("Timeout", Model.Timeout.ToString()); | ||
providerConfiguration.SetConfigurationByKey("DefaultHeaders", JsonSerializer.Serialize(Model.DefaultHeaders)); | ||
providerConfiguration.SetConfigurationByKey("UseHttp2", Model.UseHttp2.ToString()); | ||
providerConfiguration.SetConfigurationByKey("Enabled", Model.Enabled.ToString()); | ||
|
||
await Provider.SaveConfiguration(ConfigureTagzAppFactory.Current, providerConfiguration); | ||
|
||
} | ||
|
||
public class ViewModel | ||
{ | ||
|
||
// add properties for each of the fields you want to edit | ||
[Required] | ||
public string ApiKey { get; set; } | ||
|
||
[Required] | ||
public string BaseAddress { get; set; } | ||
|
||
public Dictionary<string, string> DefaultHeaders { get; set; } = new(); | ||
|
||
[Required] | ||
public string SecretAuthKey { get; set; } | ||
|
||
[Required] | ||
public TimeSpan Timeout { get; set; } | ||
|
||
public bool UseHttp2 { get; set; } | ||
|
||
[Required] | ||
public int WindowSeconds { get; set; } | ||
|
||
[Required] | ||
public int WindowRequests { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
|
||
} | ||
|
||
|
||
} |
112 changes: 112 additions & 0 deletions
112
src/TagzApp.Blazor.Client/Components/Admin/Twitter.Config.Ui.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
@using System.ComponentModel.DataAnnotations | ||
@using System.Text.Json | ||
<UiProviderConfig ProviderName="Twitter" Health="@Health" ProviderIconCssClass="bi-twitter-x"> | ||
|
||
<EditForm Model="Model" OnValidSubmit="SaveConfig"> | ||
<AntiforgeryToken /> | ||
<ValidationSummary /> | ||
<dl> | ||
<dt><label for="BaseAddress">Base Address:</label></dt> | ||
<dd> | ||
<InputText name="BaseAddress" @bind-Value="Model.BaseAddress" placeholder="Base Address of Mastodon Server" /> | ||
<ValidationMessage For="() => Model.BaseAddress" class="text-danger" /> | ||
</dd> | ||
<dt><label for="Timeout">Timeout:</label></dt> | ||
<dd> | ||
<input name="Timeout" @bind="Model.Timeout" pattern="\d{2}:\d{2}:\d{2}" /> | ||
<ValidationMessage For="() => Model.Timeout" class="text-danger" /> | ||
</dd> | ||
<dt>Default Headers:</dt> | ||
<dd> | ||
@* Generate a set of textboxes to collect values for the DefaultHeaders dictionary in ViewModel*@ | ||
<InputDictionary Value="@Model.DefaultHeaders" KeyCaption="Name" /> | ||
|
||
</dd> | ||
<dt><label for="UseHttp2">UseHttp2:</label></dt> | ||
<dd> | ||
<InputCheckbox name="UseHttp2" @bind-Value="Model.UseHttp2" /> | ||
</dd> | ||
<dt><label for="Enabled">Enabled:</label></dt> | ||
<dd> | ||
<InputCheckbox name="Enabled" @bind-Value="Model.Enabled" /> | ||
</dd> | ||
</dl> | ||
|
||
<button type="submit" class="btn btn-primary">Save</button> | ||
|
||
</EditForm> | ||
|
||
</UiProviderConfig> | ||
|
||
@code { | ||
|
||
[Parameter, EditorRequired] | ||
public ISocialMediaProvider Provider { get; set; } = null!; | ||
|
||
public (SocialMediaStatus Status, string Message) Health { get; set; } = (SocialMediaStatus.Unknown, string.Empty); | ||
|
||
|
||
public ViewModel Model { get; set; } = new(); | ||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
var headers = providerConfiguration.GetConfigurationByKey("DefaultHeaders"); | ||
var headerDictionary = string.IsNullOrEmpty(headers) ? new() : JsonSerializer.Deserialize<Dictionary<string, string>>(headers); | ||
|
||
Model = new ViewModel | ||
{ | ||
BaseAddress = providerConfiguration.GetConfigurationByKey("BaseAddress"), | ||
DefaultHeaders = headerDictionary, | ||
Timeout = TimeSpan.Parse(providerConfiguration.GetConfigurationByKey("Timeout")), | ||
UseHttp2 = string.IsNullOrEmpty(providerConfiguration.GetConfigurationByKey("UseHttp2")) ? false : bool.Parse(providerConfiguration.GetConfigurationByKey("UseHttp2")), | ||
Enabled = string.IsNullOrEmpty(providerConfiguration.GetConfigurationByKey("Enabled")) ? false : bool.Parse(providerConfiguration.GetConfigurationByKey("Enabled")) | ||
}; | ||
|
||
Health = await Provider.GetHealth(); | ||
|
||
await base.OnParametersSetAsync(); | ||
|
||
} | ||
|
||
private async Task SaveConfig() | ||
{ | ||
|
||
var providerConfiguration = await Provider.GetConfiguration(ConfigureTagzAppFactory.Current); | ||
|
||
Model.DefaultHeaders.Remove(string.Empty); | ||
|
||
providerConfiguration.SetConfigurationByKey("BaseAddress", Model.BaseAddress); | ||
providerConfiguration.SetConfigurationByKey("Timeout", Model.Timeout.ToString()); | ||
providerConfiguration.SetConfigurationByKey("DefaultHeaders", JsonSerializer.Serialize(Model.DefaultHeaders)); | ||
providerConfiguration.SetConfigurationByKey("UseHttp2", Model.UseHttp2.ToString()); | ||
providerConfiguration.SetConfigurationByKey("Enabled", Model.Enabled.ToString()); | ||
|
||
await Provider.SaveConfiguration(ConfigureTagzAppFactory.Current, providerConfiguration); | ||
|
||
} | ||
|
||
public class ViewModel | ||
{ | ||
|
||
// add properties for each of the fields you want to edit | ||
[Required] | ||
public string BaseAddress { get; set; } | ||
|
||
[Required] | ||
public TimeSpan Timeout { get; set; } | ||
|
||
public Dictionary<string, string> DefaultHeaders { get; set; } = new(); | ||
|
||
public bool UseHttp2 { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
|
||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.