Merge pull request #120 from sbwalker/master

improvements to module/theme installation and removal
This commit is contained in:
Shaun Walker
2019-10-09 12:06:59 -04:00
committed by GitHub
23 changed files with 169 additions and 37 deletions

View File

@ -103,7 +103,7 @@
private async Task InstallModules()
{
await ModuleDefinitionService.InstallModulesAsync();
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
}

View File

@ -24,7 +24,12 @@ else
<td>@context.Name</td>
<td>@context.Version</td>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" /></td>
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" Class="btn btn-danger" /></td>
<td>
@if (context.AssemblyName != "Oqtane.Client")
{
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteModule(context.ModuleDefinitionId, context.SiteId))>Delete</button>
}
</td>
<td>
@if (UpgradeAvailable(context.ModuleDefinitionName, context.Version))
{
@ -61,7 +66,13 @@ else
private async Task DownloadModule(string moduledefinitionname, string version)
{
await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules");
await ModuleDefinitionService.InstallModulesAsync();
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
}
private async Task DeleteModule(int moduledefinitionid, int siteid)
{
await ModuleDefinitionService.DeleteModuleDefinitionAsync(moduledefinitionid, siteid);
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
}
}

View File

@ -108,9 +108,10 @@ else
private async Task SaveSite()
{
if (name != "" && urls != "" && themetype != "")
if (tenantid != "-1" && name != "" && urls != "" && themetype != "")
{
Site site = new Site();
site.TenantId = int.Parse(tenantid);
site.Name = name;
site.Logo = (logo == null ? "" : logo);
site.DefaultThemeType = themetype;
@ -131,7 +132,7 @@ else
}
else
{
ModuleInstance.AddModuleMessage("You Must Provide A Site Name, Alias, And Default Theme", MessageType.Warning);
ModuleInstance.AddModuleMessage("You Must Provide A Tenant, Site Name, Alias, And Default Theme", MessageType.Warning);
}
}

View File

@ -115,7 +115,7 @@ else
if (site != null)
{
name = site.Name;
aliases = PageState.Aliases.Where(item => item.SiteId == site.SiteId).ToList();
aliases = PageState.Aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList();
foreach (Alias alias in aliases)
{
urls += alias.Name + "\n";

View File

@ -117,7 +117,7 @@ else
if (site != null)
{
name = site.Name;
aliases = PageState.Aliases.Where(item => item.SiteId == site.SiteId).ToList();
aliases = PageState.Aliases.Where(item => item.SiteId == site.SiteId && item.TenantId == site.TenantId).ToList();
foreach (Alias alias in aliases)
{
urls += alias.Name + "\n";
@ -173,7 +173,7 @@ else
{
Alias alias = new Alias();
alias.Name = name;
alias.TenantId = PageState.Alias.TenantId;
alias.TenantId = site.TenantId;
alias.SiteId = site.SiteId;
await AliasService.AddAliasAsync(alias);
}

View File

@ -22,7 +22,12 @@ else
<Row>
<td>@context.Name</td>
<td>@context.Version</td>
<td><ActionLink Action="Delete" Parameters="@($"id=" + context.ThemeName)" Class="btn btn-danger" /></td>
<td>
@if (context.AssemblyName != "Oqtane.Client")
{
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteTheme(context.ThemeName))>Delete</button>
}
</td>
<td>
@if (UpgradeAvailable(context.ThemeName, context.Version))
{
@ -62,4 +67,10 @@ else
await ThemeService.InstallThemesAsync();
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
}
private async Task DeleteTheme(string themename)
{
await ThemeService.DeleteThemeAsync(themename);
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
}
}

View File

@ -49,7 +49,7 @@ else
}
if (!upgradeavailable)
{
ModuleInstance.AddModuleMessage("Framework Up To Date", MessageType.Info);
ModuleInstance.AddModuleMessage("Framework Is Up To Date", MessageType.Info);
}
}

View File

@ -8,6 +8,7 @@ namespace Oqtane.Services
{
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId);
Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition);
Task InstallModulesAsync();
Task InstallModuleDefinitionsAsync();
Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId);
}
}

View File

@ -7,9 +7,10 @@ namespace Oqtane.Services
public interface IThemeService
{
Task<List<Theme>> GetThemesAsync();
Dictionary<string, string> GetThemeTypes(List<Theme> themes);
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes);
Dictionary<string, string> GetContainerTypes(List<Theme> themes);
Dictionary<string, string> GetThemeTypes(List<Theme> Themes);
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes);
Dictionary<string, string> GetContainerTypes(List<Theme> Themes);
Task InstallThemesAsync();
Task DeleteThemeAsync(string ThemeName);
}
}

View File

@ -69,9 +69,14 @@ namespace Oqtane.Services
await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
}
public async Task InstallModulesAsync()
public async Task InstallModuleDefinitionsAsync()
{
await http.GetJsonAsync<List<string>>(apiurl + "/install");
}
public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
{
await http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
}
}
}

View File

@ -61,10 +61,10 @@ namespace Oqtane.Services
return themes.OrderBy(item => item.Name).ToList();
}
public Dictionary<string, string> GetThemeTypes(List<Theme> themes)
public Dictionary<string, string> GetThemeTypes(List<Theme> Themes)
{
var selectableThemes = new Dictionary<string, string>();
foreach (Theme theme in themes)
foreach (Theme theme in Themes)
{
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
@ -74,10 +74,10 @@ namespace Oqtane.Services
return selectableThemes;
}
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes)
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes)
{
var selectablePaneLayouts = new Dictionary<string, string>();
foreach (Theme theme in themes)
foreach (Theme theme in Themes)
{
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
@ -87,10 +87,10 @@ namespace Oqtane.Services
return selectablePaneLayouts;
}
public Dictionary<string, string> GetContainerTypes(List<Theme> themes)
public Dictionary<string, string> GetContainerTypes(List<Theme> Themes)
{
var selectableContainers = new Dictionary<string, string>();
foreach (Theme theme in themes)
foreach (Theme theme in Themes)
{
foreach (string container in theme.ContainerControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
@ -104,5 +104,10 @@ namespace Oqtane.Services
{
await http.GetJsonAsync<List<string>>(apiurl + "/install");
}
public async Task DeleteThemeAsync(string ThemeName)
{
await http.DeleteAsync(apiurl + "/" + ThemeName);
}
}
}

View File

@ -2,7 +2,7 @@
@inject NavigationManager NavigationManager
@inject IInstallationService InstallationService
@inject ISiteService SiteService
@inject IAliasService AliasService
@inject ITenantService TenantService
@inject IUserService UserService
<div class="container">
@ -172,8 +172,10 @@
GenericResponse response = await InstallationService.Install(connectionstring);
if (response.Success)
{
List<Tenant> tenants = await TenantService.GetTenantsAsync();
Site site = new Site();
site.Name = "Site1";
site.TenantId = tenants.FirstOrDefault().TenantId;
site.Name = "Default Site";
site.Logo = "oqtane.png";
site.DefaultThemeType = "Oqtane.Themes.Theme2.Theme2, Oqtane.Client";
site.DefaultLayoutType = "";