Whitelabel: rename

This commit is contained in:
pavelbannov 2022-11-22 18:03:59 +03:00
parent 9ceec6103e
commit 4b180094e8
19 changed files with 142 additions and 114 deletions

View File

@ -195,7 +195,7 @@ public class NotifyHelper
{
args.Add(new TagValue(CommonTags.VirtualRootPath, url));
args.Add(new TagValue(CommonTags.ProfileUrl, url + _commonLinkUtility.GetMyStaff()));
args.Add(new TagValue(CommonTags.LetterLogo, _tenantLogoManager.GetLogoDark(true, false)));
args.Add(new TagValue(CommonTags.LetterLogo, _tenantLogoManager.GetLogoDark(false)));
}
return args;

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -617,7 +617,7 @@ public class CustomerConfig<T>
public string Address => _settingsManager.LoadForDefaultTenant<CompanyWhiteLabelSettings>().Address;
public string Logo => _baseCommonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LoginPage, !_configuration.EditorConfig.Customization.IsRetina, false));
public string Logo => _baseCommonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LoginPage, false));
public string Mail => _settingsManager.LoadForDefaultTenant<CompanyWhiteLabelSettings>().Email;
@ -768,8 +768,6 @@ public class CustomizationConfig<T>
}
}
public bool IsRetina { get; set; }
public LogoConfig<T> Logo { get; set; }
public bool MentionShare
@ -933,8 +931,8 @@ public class LogoConfig<T>
return _configuration.EditorType == EditorType.Embedded
|| fillingForm
? _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditorEmbed, !_configuration.EditorConfig.Customization.IsRetina))
: _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor, !_configuration.EditorConfig.Customization.IsRetina));
? _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditorEmbed))
: _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor));
}
}
@ -942,7 +940,7 @@ public class LogoConfig<T>
{
set { }
get => _commonLinkUtility.GetFullAbsolutePath(
_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor, !_configuration.EditorConfig.Customization.IsRetina));
_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor));
}
public string ImageEmbedded
@ -951,7 +949,7 @@ public class LogoConfig<T>
{
return _configuration.EditorType != EditorType.Embedded
? null
: _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditorEmbed, !_configuration.EditorConfig.Customization.IsRetina));
: _commonLinkUtility.GetFullAbsolutePath(_tenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditorEmbed));
}
}

View File

@ -158,38 +158,56 @@ public class WhitelabelController : BaseSettingsController
///<visible>false</visible>
[AllowNotPayment, AllowAnonymous]
[HttpGet("whitelabel/logos")]
public Dictionary<string, object> GetWhiteLabelLogos([FromQuery] WhiteLabelQueryRequestsDto inDto)
public IEnumerable<WhiteLabelItemDto> GetWhiteLabelLogos([FromQuery] WhiteLabelQueryRequestsDto inDto)
{
var _tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
var result = new Dictionary<string, object>();
foreach (var logoType in (WhiteLabelLogoTypeEnum[])Enum.GetValues(typeof(WhiteLabelLogoTypeEnum)))
{
var result = new WhiteLabelItemDto
{
Name = logoType.ToString(),
Size = TenantWhiteLabelSettings.GetSize(logoType)
};
if (inDto.IsDark.HasValue)
{
var dto = new
var path = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, inDto.IsDark.Value));
if (inDto.IsDark.Value)
{
Name = nameof(logoType),
Path = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, !inDto.IsRetina, inDto.IsDark.Value)),
height = TenantWhiteLabelSettings.GetSize(logoType).Height,
width = TenantWhiteLabelSettings.GetSize(logoType).Width
};
result.Add(((int)logoType).ToString(), dto);
result.Path = new WhiteLabelItemPathDto
{
Dark = path
};
}
else
{
result.Path = new WhiteLabelItemPathDto
{
Light = path
};
}
}
else
{
var dto = new
var lightPath = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, false));
var darkPath = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, true));
if (lightPath == darkPath)
{
Name = nameof(logoType),
LightPath = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, !inDto.IsRetina, false)),
DarkPath = _commonLinkUtility.GetFullAbsolutePath(_tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, logoType, !inDto.IsRetina, true)),
height = TenantWhiteLabelSettings.GetSize(logoType).Height,
width = TenantWhiteLabelSettings.GetSize(logoType).Width
darkPath = null;
}
result.Path = new WhiteLabelItemPathDto
{
Light = lightPath,
Dark = darkPath
};
result.Add(((int)logoType).ToString(), dto);
}
}
return result;
yield return result;
}
}
///<visible>false</visible>

View File

@ -40,6 +40,5 @@ public class LogoRequestsDto
public class WhiteLabelQueryRequestsDto
{
public bool IsRetina { get; set; }
public bool? IsDark { get; set; }
}

View File

@ -0,0 +1,40 @@
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Web.Api.ApiModels.ResponseDto;
public class WhiteLabelItemDto
{
public string Name { get; set; }
public SixLabors.ImageSharp.Size Size { get; set; }
public WhiteLabelItemPathDto Path { get; set; }
}
public class WhiteLabelItemPathDto
{
public string Light { get; set; }
public string Dark { get; set; }
}

View File

@ -404,7 +404,7 @@ public class NotifyTransferRequest : INotifyEngineAction
}
}
var logoUrl = _commonLinkUtility.GetFullAbsolutePath(_tenantLogoManager.GetLogoDark(true, false));
var logoUrl = _commonLinkUtility.GetFullAbsolutePath(_tenantLogoManager.GetLogoDark(false));
request.Arguments.Add(new TagValue(CommonTags.LetterLogo, logoUrl));
}

View File

@ -46,19 +46,19 @@ public class TenantLogoHelper
_tenantInfoSettingsHelper = tenantInfoSettingsHelper;
}
public string GetLogo(WhiteLabelLogoTypeEnum type, bool general = true, bool isDefIfNoWhiteLabel = false, bool dark = false)
public string GetLogo(WhiteLabelLogoTypeEnum type, bool isDefIfNoWhiteLabel = false, bool dark = false)
{
string imgUrl;
if (_tenantLogoManager.WhiteLabelEnabled)
{
var _tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, type, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(_tenantWhiteLabelSettings, type, dark);
}
else
{
if (isDefIfNoWhiteLabel)
{
imgUrl = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(type, general, dark);
imgUrl = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(type, dark);
}
else
{
@ -71,7 +71,7 @@ public class TenantLogoHelper
}
else
{
imgUrl = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(type, general, dark);
imgUrl = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(type, dark);
}
}
}

View File

@ -61,13 +61,13 @@ public class TenantLogoManager
_cacheNotify = cacheNotify;
}
public string GetFavicon(bool general, bool timeParam, bool dark)
public string GetFavicon(bool timeParam, bool dark)
{
string faviconPath;
var tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
if (WhiteLabelEnabled)
{
faviconPath = _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Favicon, general, dark);
faviconPath = _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.Favicon, dark);
if (timeParam)
{
var now = DateTime.Now;
@ -76,29 +76,29 @@ public class TenantLogoManager
}
else
{
faviconPath = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Favicon, general, dark);
faviconPath = _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Favicon, dark);
}
return faviconPath;
}
public string GetTopLogo(bool general, bool dark)//LogoLightSmall
public string GetTopLogo(bool dark)//LogoLightSmall
{
var tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
if (WhiteLabelEnabled)
{
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LightSmall, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LightSmall, dark);
}
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LightSmall, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.LightSmall, dark);
}
public string GetLogoDark(bool general, bool dark)
public string GetLogoDark(bool dark)
{
if (WhiteLabelEnabled)
{
var tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LoginPage, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.LoginPage, dark);
}
/*** simple scheme ***/
@ -106,26 +106,26 @@ public class TenantLogoManager
/***/
}
public string GetLogoDocsEditor(bool general, bool dark)
public string GetLogoDocsEditor(bool dark)
{
var tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
if (WhiteLabelEnabled)
{
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditor, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditor, dark);
}
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditor, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditor, dark);
}
public string GetLogoDocsEditorEmbed(bool general, bool dark)
public string GetLogoDocsEditorEmbed(bool dark)
{
var tenantWhiteLabelSettings = _settingsManager.Load<TenantWhiteLabelSettings>();
if (WhiteLabelEnabled)
{
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditorEmbed, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteLogoPath(tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum.DocsEditorEmbed, dark);
}
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditorEmbed, general, dark);
return _tenantWhiteLabelSettingsHelper.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.DocsEditorEmbed, dark);
}

View File

@ -387,18 +387,11 @@ public class TenantWhiteLabelSettingsHelper
using (var memory = new MemoryStream(data))
{
var logoFileName = BuildLogoFileName(type, logoFileExt, false, dark, tenantWhiteLabelSettings);
var logoFileName = BuildLogoFileName(type, logoFileExt, dark);
memory.Seek(0, SeekOrigin.Begin);
await store.SaveAsync(logoFileName, memory);
}
var generalSize = GetSize(type, true);
var generalFileName = BuildLogoFileName(type, logoFileExt, true, dark, tenantWhiteLabelSettings);
if (logoFileExt != "svg")
{
await ResizeLogo(generalFileName, data, -1, generalSize, store);
}
}
public async Task SetLogo(TenantWhiteLabelSettings tenantWhiteLabelSettings, Dictionary<int, KeyValuePair<string, string>> logo, IDataStore storage = null)
@ -559,51 +552,40 @@ public class TenantWhiteLabelSettingsHelper
#region Get logo path
public string GetAbsoluteLogoPath(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool general = true, bool dark = false)
public string GetAbsoluteLogoPath(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool dark = false)
{
if (tenantWhiteLabelSettings.GetIsDefault(type))
{
return GetAbsoluteDefaultLogoPath(type, general, dark);
return GetAbsoluteDefaultLogoPath(type, dark);
}
return GetAbsoluteStorageLogoPath(tenantWhiteLabelSettings, type, general, dark);
return GetAbsoluteStorageLogoPath(tenantWhiteLabelSettings, type, dark);
}
private string GetAbsoluteStorageLogoPath(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool general, bool dark)
private string GetAbsoluteStorageLogoPath(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool dark)
{
var store = _storageFactory.GetStorage(_tenantManager.GetCurrentTenant().Id, ModuleName);
var fileName = BuildLogoFileName(type, tenantWhiteLabelSettings.GetExt(type), general, dark, tenantWhiteLabelSettings);
var fileName = BuildLogoFileName(type, tenantWhiteLabelSettings.GetExt(type), dark);
if (store.IsFileAsync(fileName).Result)
{
return store.GetUriAsync(fileName).Result.ToString();
}
return GetAbsoluteDefaultLogoPath(type, general, dark);
return GetAbsoluteDefaultLogoPath(type, dark);
}
public string GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum type, bool general, bool dark)
public string GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum type, bool dark)
{
var partnerLogoPath = GetPartnerStorageLogoPath(type, general, dark);
var partnerLogoPath = GetPartnerStorageLogoPath(type, dark);
if (!string.IsNullOrEmpty(partnerLogoPath))
{
return partnerLogoPath;
}
var generalStr = general ? "_general" : "";
return type switch
{
WhiteLabelLogoTypeEnum.LightSmall => _webImageSupplier.GetAbsoluteWebPath("logo/light_small_doc_space.svg"),
WhiteLabelLogoTypeEnum.LoginPage => _webImageSupplier.GetAbsoluteWebPath("logo/login_page_doc_space.svg"),
WhiteLabelLogoTypeEnum.DocsEditor => _webImageSupplier.GetAbsoluteWebPath($"logo/editor_logo{generalStr}.png"),
WhiteLabelLogoTypeEnum.DocsEditorEmbed => _webImageSupplier.GetAbsoluteWebPath($"logo/editor_logo_embed{generalStr}.png"),
WhiteLabelLogoTypeEnum.Favicon => _webImageSupplier.GetAbsoluteWebPath($"logo/favicon.ico"),
WhiteLabelLogoTypeEnum.LeftMenu => _webImageSupplier.GetAbsoluteWebPath($"logo/left_menu.svg"),
WhiteLabelLogoTypeEnum.AboutPage => _webImageSupplier.GetAbsoluteWebPath("logo/about_doc_space.svg"),
_ => "",
};
return _webImageSupplier.GetAbsoluteWebPath($"logo/" + BuildLogoFileName(type, "svg", dark));
}
private string GetPartnerStorageLogoPath(WhiteLabelLogoTypeEnum type, bool general, bool dark)
private string GetPartnerStorageLogoPath(WhiteLabelLogoTypeEnum type, bool dark)
{
var partnerSettings = _settingsManager.LoadForDefaultTenant<TenantWhiteLabelSettings>();
@ -619,7 +601,7 @@ public class TenantWhiteLabelSettingsHelper
return null;
}
var logoPath = BuildLogoFileName(type, partnerSettings.GetExt(type), general, dark, partnerSettings);
var logoPath = BuildLogoFileName(type, partnerSettings.GetExt(type), dark);
return partnerStorage.IsFileAsync(logoPath).Result ? partnerStorage.GetUriAsync(logoPath).Result.ToString() : null;
}
@ -631,17 +613,17 @@ public class TenantWhiteLabelSettingsHelper
/// <summary>
/// Get logo stream or null in case of default whitelabel
/// </summary>
public Stream GetWhitelabelLogoData(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool general, bool dark = false)
public Stream GetWhitelabelLogoData(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool dark = false)
{
if (tenantWhiteLabelSettings.GetIsDefault(type))
{
return GetPartnerStorageLogoData(type, general, dark);
return GetPartnerStorageLogoData(type, dark);
}
return GetStorageLogoData(tenantWhiteLabelSettings, type, general, dark);
return GetStorageLogoData(tenantWhiteLabelSettings, type, dark);
}
private Stream GetStorageLogoData(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool general, bool dark)
private Stream GetStorageLogoData(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, bool dark)
{
var storage = _storageFactory.GetStorage(_tenantManager.GetCurrentTenant().Id, ModuleName);
@ -650,12 +632,12 @@ public class TenantWhiteLabelSettingsHelper
return null;
}
var fileName = BuildLogoFileName(type, tenantWhiteLabelSettings.GetExt(type), general, dark, tenantWhiteLabelSettings);
var fileName = BuildLogoFileName(type, tenantWhiteLabelSettings.GetExt(type), dark);
return storage.IsFileAsync(fileName).Result ? storage.GetReadStreamAsync(fileName).Result : null;
}
private Stream GetPartnerStorageLogoData(WhiteLabelLogoTypeEnum type, bool general, bool dark)
private Stream GetPartnerStorageLogoData(WhiteLabelLogoTypeEnum type, bool dark)
{
var partnerSettings = _settingsManager.LoadForDefaultTenant<TenantWhiteLabelSettings>();
@ -671,46 +653,38 @@ public class TenantWhiteLabelSettingsHelper
return null;
}
var fileName = BuildLogoFileName(type, partnerSettings.GetExt(type), general, dark, partnerSettings);
var fileName = BuildLogoFileName(type, partnerSettings.GetExt(type), dark);
return partnerStorage.IsFileAsync(fileName).Result ? partnerStorage.GetReadStreamAsync(fileName).Result : null;
}
#endregion
public static string BuildLogoFileName(WhiteLabelLogoTypeEnum type, string fileExt, bool general, bool dark, TenantWhiteLabelSettings tenantWhiteLabelSettings)
public static string BuildLogoFileName(WhiteLabelLogoTypeEnum type, string fileExt, bool dark)
{
general = fileExt != "svg" && general;
var arr = new WhiteLabelLogoTypeEnum[] { WhiteLabelLogoTypeEnum.Favicon, WhiteLabelLogoTypeEnum.DocsEditor, WhiteLabelLogoTypeEnum.DocsEditorEmbed };
dark = !arr.Contains(type) && dark;
return $"logo_{type.ToString().ToLowerInvariant()}{(general ? "_general" : "")}{(dark ? "_dark" : "")}.{fileExt}";
switch (type)
{
case WhiteLabelLogoTypeEnum.Favicon:
return "favicon.ico";
case WhiteLabelLogoTypeEnum.DocsEditor:
case WhiteLabelLogoTypeEnum.DocsEditorEmbed:
return $"{type.ToString().ToLowerInvariant()}.{fileExt}";
default:
return $"{(dark ? "dark_" : "")}{type.ToString().ToLowerInvariant()}.{fileExt}";
}
}
public static Size GetSize(WhiteLabelLogoTypeEnum type, bool general)
public static Size GetSize(WhiteLabelLogoTypeEnum type)
{
return type switch
{
WhiteLabelLogoTypeEnum.LightSmall => new Size(
general ? TenantWhiteLabelSettings.LogoLightSmallSize.Width / 2 : TenantWhiteLabelSettings.LogoLightSmallSize.Width,
general ? TenantWhiteLabelSettings.LogoLightSmallSize.Height / 2 : TenantWhiteLabelSettings.LogoLightSmallSize.Height),
WhiteLabelLogoTypeEnum.LoginPage => new Size(
general ? TenantWhiteLabelSettings.LogoLoginPageSize.Width / 2 : TenantWhiteLabelSettings.LogoLoginPageSize.Width,
general ? TenantWhiteLabelSettings.LogoLoginPageSize.Height / 2 : TenantWhiteLabelSettings.LogoLoginPageSize.Height),
WhiteLabelLogoTypeEnum.Favicon => new Size(
general ? TenantWhiteLabelSettings.LogoFaviconSize.Width / 2 : TenantWhiteLabelSettings.LogoFaviconSize.Width,
general ? TenantWhiteLabelSettings.LogoFaviconSize.Height / 2 : TenantWhiteLabelSettings.LogoFaviconSize.Height),
WhiteLabelLogoTypeEnum.DocsEditor => new Size(
general ? TenantWhiteLabelSettings.LogoDocsEditorSize.Width / 2 : TenantWhiteLabelSettings.LogoDocsEditorSize.Width,
general ? TenantWhiteLabelSettings.LogoDocsEditorSize.Height / 2 : TenantWhiteLabelSettings.LogoDocsEditorSize.Height),
WhiteLabelLogoTypeEnum.DocsEditorEmbed => new Size(
general ? TenantWhiteLabelSettings.LogoDocsEditorEmbedSize.Width / 2 : TenantWhiteLabelSettings.LogoDocsEditorEmbedSize.Width,
general ? TenantWhiteLabelSettings.LogoDocsEditorEmbedSize.Height / 2 : TenantWhiteLabelSettings.LogoDocsEditorEmbedSize.Height),
WhiteLabelLogoTypeEnum.LeftMenu => new Size(
general ? TenantWhiteLabelSettings.LogoLeftMenuSize.Width / 2 : TenantWhiteLabelSettings.LogoLeftMenuSize.Width,
general ? TenantWhiteLabelSettings.LogoLeftMenuSize.Height / 2 : TenantWhiteLabelSettings.LogoLeftMenuSize.Height),
WhiteLabelLogoTypeEnum.AboutPage => new Size(
general ? TenantWhiteLabelSettings.LogoAboutPageSize.Width / 2 : TenantWhiteLabelSettings.LogoAboutPageSize.Width,
general ? TenantWhiteLabelSettings.LogoAboutPageSize.Height / 2 : TenantWhiteLabelSettings.LogoAboutPageSize.Height),
WhiteLabelLogoTypeEnum.LightSmall => TenantWhiteLabelSettings.LogoLightSmallSize,
WhiteLabelLogoTypeEnum.LoginPage => TenantWhiteLabelSettings.LogoLoginPageSize,
WhiteLabelLogoTypeEnum.Favicon => TenantWhiteLabelSettings.LogoFaviconSize,
WhiteLabelLogoTypeEnum.DocsEditor => TenantWhiteLabelSettings.LogoDocsEditorSize,
WhiteLabelLogoTypeEnum.DocsEditorEmbed => TenantWhiteLabelSettings.LogoDocsEditorEmbedSize,
WhiteLabelLogoTypeEnum.LeftMenu => TenantWhiteLabelSettings.LogoLeftMenuSize,
WhiteLabelLogoTypeEnum.AboutPage => TenantWhiteLabelSettings.LogoAboutPageSize,
_ => new Size(0, 0),
};
}
@ -809,14 +783,13 @@ public class TenantWhiteLabelSettingsHelper
private async Task DeleteLogoFromStore(TenantWhiteLabelSettings tenantWhiteLabelSettings, IDataStore store, WhiteLabelLogoTypeEnum type, bool dark)
{
await DeleteLogoFromStoreByGeneral(tenantWhiteLabelSettings, store, type, false, dark);
await DeleteLogoFromStoreByGeneral(tenantWhiteLabelSettings, store, type, true, dark);
await DeleteLogoFromStoreByGeneral(tenantWhiteLabelSettings, store, type, dark);
}
private async Task DeleteLogoFromStoreByGeneral(TenantWhiteLabelSettings tenantWhiteLabelSettings, IDataStore store, WhiteLabelLogoTypeEnum type, bool general, bool dark)
private async Task DeleteLogoFromStoreByGeneral(TenantWhiteLabelSettings tenantWhiteLabelSettings, IDataStore store, WhiteLabelLogoTypeEnum type, bool dark)
{
var fileExt = tenantWhiteLabelSettings.GetExt(type);
var logo = BuildLogoFileName(type, fileExt, general, dark, tenantWhiteLabelSettings);
var logo = BuildLogoFileName(type, fileExt, dark);
if (await store.IsFileAsync(logo))
{
await store.DeleteAsync(logo);