site group improvements
This commit is contained in:
@@ -97,6 +97,7 @@
|
||||
Alias = PageState.Alias,
|
||||
Site = new Site
|
||||
{
|
||||
SiteId = PageState.Site.SiteId,
|
||||
DefaultContainerType = PageState.Site.DefaultContainerType,
|
||||
Settings = PageState.Site.Settings,
|
||||
Themes = PageState.Site.Themes
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<button type="button" data-bs-dismiss="offcanvas" class="btn btn-primary col-12" @onclick=@(async () => Navigate("Admin"))>@Localizer["AdminDash"]</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (_siteGroups.Any(item => item.Type == SiteGroupTypes.Synchronization || item.Type == SiteGroupTypes.Comparison))
|
||||
@if (_siteGroups.Any(item => (item.Type == SiteGroupTypes.Synchronization || item.Type == SiteGroupTypes.Comparison) && item.PrimarySiteId == PageState.Site.SiteId))
|
||||
{
|
||||
<hr class="app-rule" />
|
||||
<button type="button" class="btn btn-secondary col-12 mt-1" @onclick="SynchronizeSite">@Localizer["Synchronize"]</button>
|
||||
@@ -642,7 +642,7 @@
|
||||
|
||||
private async Task SynchronizeSite()
|
||||
{
|
||||
foreach (var group in _siteGroups.Where(item => item.Type == SiteGroupTypes.Synchronization || item.Type == SiteGroupTypes.Comparison))
|
||||
foreach (var group in _siteGroups.Where(item => (item.Type == SiteGroupTypes.Synchronization || item.Type == SiteGroupTypes.Comparison) && item.PrimarySiteId == PageState.Site.SiteId))
|
||||
{
|
||||
group.Synchronize = true;
|
||||
await SiteGroupService.UpdateSiteGroupAsync(group);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
{
|
||||
@if (_contentLocalization)
|
||||
{
|
||||
<a class="dropdown-item" href="@(PageState.Alias.Protocol + language.AliasName)">@language.Name</a>
|
||||
<a class="dropdown-item @(PageState.Site.CultureCode == language.Code ? "active" : String.Empty)" href="@(PageState.Alias.Protocol + language.AliasName)" data-enhance-nav="false">@language.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -63,9 +63,9 @@ namespace Oqtane.Infrastructure
|
||||
aliases = aliasRepository.GetAliases().ToList();
|
||||
}
|
||||
|
||||
var aliasName = "https://" + aliases.First(item => item.TenantId == tenantManager.GetTenant().TenantId && item.SiteId == siteGroup.PrimarySiteId && item.IsDefault).Name;
|
||||
var primaryAliasName = "https://" + aliases.First(item => item.TenantId == tenantManager.GetTenant().TenantId && item.SiteId == siteGroup.PrimarySiteId && item.IsDefault).Name;
|
||||
log += (siteGroup.Type == SiteGroupTypes.Synchronization) ? "Synchronizing " : "Comparing ";
|
||||
log += $"Primary Site: {sites.First(item => item.SiteId == siteGroup.PrimarySiteId).Name} - {CreateLink(aliasName)}<br />";
|
||||
log += $"Primary Site: {sites.First(item => item.SiteId == siteGroup.PrimarySiteId).Name} - {CreateLink(primaryAliasName)}<br />";
|
||||
|
||||
// get primary site
|
||||
var primarySite = sites.FirstOrDefault(item => item.SiteId == siteGroup.PrimarySiteId);
|
||||
@@ -83,14 +83,8 @@ namespace Oqtane.Infrastructure
|
||||
if (secondarySite != null)
|
||||
{
|
||||
// get default alias for site
|
||||
if (siteGroupMember.SiteGroup.Type == SiteGroupTypes.Synchronization)
|
||||
{
|
||||
siteGroupMember.AliasName = "https://" + aliases.First(item => item.TenantId == tenantManager.GetTenant().TenantId && item.SiteId == siteGroupMember.SiteId && item.IsDefault).Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
siteGroupMember.AliasName = aliasName;
|
||||
}
|
||||
var secondaryAliasName = "https://" + aliases.First(item => item.TenantId == tenantManager.GetTenant().TenantId && item.SiteId == siteGroupMember.SiteId && item.IsDefault).Name;
|
||||
siteGroupMember.AliasName = (siteGroupMember.SiteGroup.Type == SiteGroupTypes.Synchronization) ? secondaryAliasName : primaryAliasName;
|
||||
|
||||
// initialize SynchronizedOn
|
||||
if (siteGroupMember.SynchronizedOn == null)
|
||||
@@ -100,12 +94,16 @@ namespace Oqtane.Infrastructure
|
||||
|
||||
// synchronize site
|
||||
var siteLog = SynchronizeSite(provider, tenantManager, settingRepository, siteGroupMember, primarySite, secondarySite);
|
||||
if (string.IsNullOrEmpty(siteLog))
|
||||
{
|
||||
siteLog = (siteGroupMember.SynchronizedOn != DateTime.MinValue) ? "No Changes Identified<br />" : "Initialization Complete<br />";
|
||||
}
|
||||
|
||||
// set synchronized on date/time
|
||||
siteGroupMember.SynchronizedOn = DateTime.UtcNow;
|
||||
siteGroupMemberRepository.UpdateSiteGroupMember(siteGroupMember);
|
||||
|
||||
log += $"With Secondary Site: {secondarySite.Name} - {CreateLink(siteGroupMember.AliasName)}<br />" + siteLog;
|
||||
log += $"With Secondary Site: {secondarySite.Name} - {CreateLink(secondaryAliasName)}<br />" + siteLog;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -208,6 +206,7 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
// send change log to administrators
|
||||
SendNotifications(provider, secondarySite.SiteId, secondarySite.Name, log);
|
||||
log += Log(siteGroupMember, $"Change Log Sent To Administrators");
|
||||
}
|
||||
|
||||
return log;
|
||||
|
||||
Reference in New Issue
Block a user