Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for IsPublic to all Setting types, enable Url Mapping for internal links #1884

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Oqtane.Client/Modules/Admin/Site/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@
site = await SiteService.UpdateSiteAsync(site);

var settings = await SettingService.GetSiteSettingsAsync(site.SiteId);
SettingService.SetSetting(settings, "SMTPHost", _smtphost);
SettingService.SetSetting(settings, "SMTPPort", _smtpport);
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl);
SettingService.SetSetting(settings, "SMTPUsername", _smtpusername);
SettingService.SetSetting(settings, "SMTPPassword", _smtppassword);
SettingService.SetSetting(settings, "SMTPSender", _smtpsender);
SettingService.SetSetting(settings, "SMTPHost", _smtphost, false);
SettingService.SetSetting(settings, "SMTPPort", _smtpport, false);
SettingService.SetSetting(settings, "SMTPSSL", _smtpssl, false);
SettingService.SetSetting(settings, "SMTPUsername", _smtpusername, false);
SettingService.SetSetting(settings, "SMTPPassword", _smtppassword, false);
SettingService.SetSetting(settings, "SMTPSender", _smtpsender, false);
await SettingService.UpdateSiteSettingsAsync(settings, site.SiteId);

if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
Expand Down
9 changes: 2 additions & 7 deletions Oqtane.Client/Modules/Admin/UrlMappings/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ else
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.UrlMappingId.ToString())" ResourceKey="Edit" /></td>
<td><ActionDialog Header="Delete Url Mapping" Message="@string.Format(Localizer["Confirm.DeleteUrlMapping"], context.Url)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteUrlMapping(context))" ResourceKey="DeleteUrlMapping" /></td>
<td>
<a href="" onclick="@(() => BrowseUrl(context.Url))">@context.Url</a>
<a href="@context.Url">@context.Url</a>
@if (_mapped)
{
@((MarkupString)"<br />&gt;&gt;&nbsp;")<a href="" onclick="@(() => BrowseUrl(context.MappedUrl))">@context.MappedUrl</a>
@((MarkupString)"<br />&gt;&gt;&nbsp;")<a href="@context.MappedUrl">@context.MappedUrl</a>
}
</td>
<td>@context.Requests</td>
Expand Down Expand Up @@ -96,11 +96,6 @@ else
}
}

private void BrowseUrl(string url)
{
NavigationManager.NavigateTo(url, true);
}

private async Task DeleteUrlMapping(UrlMapping urlMapping)
{
try
Expand Down
8 changes: 8 additions & 0 deletions Oqtane.Client/Services/Interfaces/IUrlMappingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public interface IUrlMappingService
/// <returns></returns>
Task<UrlMapping> GetUrlMappingAsync(int urlMappingId);

/// <summary>
/// Get one specific <see cref="UrlMapping"/>
/// </summary>
/// <param name="siteId">ID-reference of a <see cref="Site"/></param>
/// <param name="url">A url</param>
/// <returns></returns>
Task<UrlMapping> GetUrlMappingAsync(int siteId, string url);

/// <summary>
/// Add / save a new <see cref="UrlMapping"/> to the database.
/// </summary>
Expand Down
23 changes: 7 additions & 16 deletions Oqtane.Client/Services/SettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,14 @@ public async Task UpdateSettingsAsync(Dictionary<string, string> settings, strin
foreach (KeyValuePair<string, string> kvp in settings)
{
string value = kvp.Value;
bool ispublic = false;
if (value.StartsWith("[Public]"))
bool ispublic = true;

if (value.StartsWith("[Private]"))
{
switch (entityName)
{
case EntityNames.Site:
case EntityNames.ModuleDefinition:
ispublic = true;
break;
default:
ispublic = false;
break;
}
value = value.Substring(8); // remove [Public]
value = value.Substring(9); // remove [Private]
ispublic = false;
}


Setting setting = settingsList.FirstOrDefault(item => item.SettingName.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase));
if (setting == null)
{
Expand Down Expand Up @@ -205,7 +196,7 @@ public string GetSetting(Dictionary<string, string> settings, string settingName

public Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue)
{
return SetSetting(settings, settingName, settingValue, false);
return SetSetting(settings, settingName, settingValue, true);
}

public Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue, bool isPublic)
Expand All @@ -214,7 +205,7 @@ public Dictionary<string, string> SetSetting(Dictionary<string, string> settings
{
settings = new Dictionary<string, string>();
}
settingValue = (isPublic) ? "[Public]" + settingValue : settingValue;
settingValue = (isPublic) ? settingValue : "[Private]" + settingValue;
if (settings.ContainsKey(settingName))
{
settings[settingName] = settingValue;
Expand Down
6 changes: 6 additions & 0 deletions Oqtane.Client/Services/UrlMappingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using Oqtane.Documentation;
using Oqtane.Shared;
using System.Net;

namespace Oqtane.Services
{
Expand Down Expand Up @@ -33,6 +34,11 @@ public async Task<UrlMapping> GetUrlMappingAsync(int urlMappingId)
return await GetJsonAsync<UrlMapping>($"{Apiurl}/{urlMappingId}");
}

public async Task<UrlMapping> GetUrlMappingAsync(int siteId, string url)
{
return await GetJsonAsync<UrlMapping>($"{Apiurl}/url/{siteId}?url={WebUtility.UrlEncode(url)}");
}

public async Task<UrlMapping> AddUrlMappingAsync(UrlMapping role)
{
return await PostJsonAsync<UrlMapping>(Apiurl, role);
Expand Down
Loading