-
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.
Initial connection to Bluesky working (#350)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f137817
commit b206d2f
Showing
15 changed files
with
385 additions
and
42 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/TagzApp.Blazor.Client/Components/Admin/Bluesky.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,70 @@ | ||
@using System.ComponentModel.DataAnnotations | ||
@using System.Text.Json | ||
<UiProviderConfig ProviderName="Bluesky" Health="@Health" ProviderIconCssClass="icon-bluesky"> | ||
|
||
<EditForm Model="Model" OnValidSubmit="SaveConfig"> | ||
<AntiforgeryToken /> | ||
<ValidationSummary /> | ||
<dl> | ||
<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 | ||
{ | ||
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("Enabled", Model.Enabled.ToString()); | ||
|
||
await Provider.SaveConfiguration(ConfigureTagzAppFactory.Current, providerConfiguration); | ||
|
||
} | ||
|
||
public class ViewModel | ||
{ | ||
|
||
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
12 changes: 9 additions & 3 deletions
12
src/TagzApp.Blazor/Components/Admin/Pages/GenericProvider.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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,31 @@ | ||
namespace TagzApp.Providers.Bluesky; | ||
|
||
public class BlueskyConfiguration : IProviderConfiguration | ||
{ | ||
public string Name => "Bluesky"; | ||
|
||
public string Description => "The Bluesky social network served by the AT Protocol"; | ||
|
||
public bool Enabled { get; set; } | ||
|
||
public string[] Keys => new string[] { }; | ||
|
||
public string GetConfigurationByKey(string key) | ||
{ | ||
if (key == "Enabled") | ||
{ | ||
return Enabled.ToString(); | ||
} | ||
|
||
return string.Empty; | ||
|
||
} | ||
|
||
public void SetConfigurationByKey(string key, string value) | ||
{ | ||
if (key == "Enabled") | ||
{ | ||
Enabled = bool.Parse(value); | ||
} | ||
} | ||
} |
Oops, something went wrong.