Merge pull request #120 from sbwalker/master
improvements to module/theme installation and removal
This commit is contained in:
commit
6a60c16f57
@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
private async Task InstallModules()
|
private async Task InstallModules()
|
||||||
{
|
{
|
||||||
await ModuleDefinitionService.InstallModulesAsync();
|
await ModuleDefinitionService.InstallModuleDefinitionsAsync();
|
||||||
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,12 @@ else
|
|||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</td>
|
<td>@context.Version</td>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ModuleDefinitionId.ToString())" /></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>
|
<td>
|
||||||
@if (UpgradeAvailable(context.ModuleDefinitionName, context.Version))
|
@if (UpgradeAvailable(context.ModuleDefinitionName, context.Version))
|
||||||
{
|
{
|
||||||
@ -61,7 +66,13 @@ else
|
|||||||
private async Task DownloadModule(string moduledefinitionname, string version)
|
private async Task DownloadModule(string moduledefinitionname, string version)
|
||||||
{
|
{
|
||||||
await PackageService.DownloadPackageAsync(moduledefinitionname, version, "Modules");
|
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));
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,9 +108,10 @@ else
|
|||||||
|
|
||||||
private async Task SaveSite()
|
private async Task SaveSite()
|
||||||
{
|
{
|
||||||
if (name != "" && urls != "" && themetype != "")
|
if (tenantid != "-1" && name != "" && urls != "" && themetype != "")
|
||||||
{
|
{
|
||||||
Site site = new Site();
|
Site site = new Site();
|
||||||
|
site.TenantId = int.Parse(tenantid);
|
||||||
site.Name = name;
|
site.Name = name;
|
||||||
site.Logo = (logo == null ? "" : logo);
|
site.Logo = (logo == null ? "" : logo);
|
||||||
site.DefaultThemeType = themetype;
|
site.DefaultThemeType = themetype;
|
||||||
@ -131,7 +132,7 @@ else
|
|||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ else
|
|||||||
if (site != null)
|
if (site != null)
|
||||||
{
|
{
|
||||||
name = site.Name;
|
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)
|
foreach (Alias alias in aliases)
|
||||||
{
|
{
|
||||||
urls += alias.Name + "\n";
|
urls += alias.Name + "\n";
|
||||||
|
@ -117,7 +117,7 @@ else
|
|||||||
if (site != null)
|
if (site != null)
|
||||||
{
|
{
|
||||||
name = site.Name;
|
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)
|
foreach (Alias alias in aliases)
|
||||||
{
|
{
|
||||||
urls += alias.Name + "\n";
|
urls += alias.Name + "\n";
|
||||||
@ -173,7 +173,7 @@ else
|
|||||||
{
|
{
|
||||||
Alias alias = new Alias();
|
Alias alias = new Alias();
|
||||||
alias.Name = name;
|
alias.Name = name;
|
||||||
alias.TenantId = PageState.Alias.TenantId;
|
alias.TenantId = site.TenantId;
|
||||||
alias.SiteId = site.SiteId;
|
alias.SiteId = site.SiteId;
|
||||||
await AliasService.AddAliasAsync(alias);
|
await AliasService.AddAliasAsync(alias);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,12 @@ else
|
|||||||
<Row>
|
<Row>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
<td>@context.Version</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>
|
<td>
|
||||||
@if (UpgradeAvailable(context.ThemeName, context.Version))
|
@if (UpgradeAvailable(context.ThemeName, context.Version))
|
||||||
{
|
{
|
||||||
@ -62,4 +67,10 @@ else
|
|||||||
await ThemeService.InstallThemesAsync();
|
await ThemeService.InstallThemesAsync();
|
||||||
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeleteTheme(string themename)
|
||||||
|
{
|
||||||
|
await ThemeService.DeleteThemeAsync(themename);
|
||||||
|
NavigationManager.NavigateTo(NavigateUrl(Reload.Application));
|
||||||
|
}
|
||||||
}
|
}
|
@ -49,7 +49,7 @@ else
|
|||||||
}
|
}
|
||||||
if (!upgradeavailable)
|
if (!upgradeavailable)
|
||||||
{
|
{
|
||||||
ModuleInstance.AddModuleMessage("Framework Up To Date", MessageType.Info);
|
ModuleInstance.AddModuleMessage("Framework Is Up To Date", MessageType.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ namespace Oqtane.Services
|
|||||||
{
|
{
|
||||||
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId);
|
Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId);
|
||||||
Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition);
|
Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition);
|
||||||
Task InstallModulesAsync();
|
Task InstallModuleDefinitionsAsync();
|
||||||
|
Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,10 @@ namespace Oqtane.Services
|
|||||||
public interface IThemeService
|
public interface IThemeService
|
||||||
{
|
{
|
||||||
Task<List<Theme>> GetThemesAsync();
|
Task<List<Theme>> GetThemesAsync();
|
||||||
Dictionary<string, string> GetThemeTypes(List<Theme> themes);
|
Dictionary<string, string> GetThemeTypes(List<Theme> Themes);
|
||||||
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes);
|
Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes);
|
||||||
Dictionary<string, string> GetContainerTypes(List<Theme> themes);
|
Dictionary<string, string> GetContainerTypes(List<Theme> Themes);
|
||||||
Task InstallThemesAsync();
|
Task InstallThemesAsync();
|
||||||
|
Task DeleteThemeAsync(string ThemeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,14 @@ namespace Oqtane.Services
|
|||||||
await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InstallModulesAsync()
|
public async Task InstallModuleDefinitionsAsync()
|
||||||
{
|
{
|
||||||
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,10 @@ namespace Oqtane.Services
|
|||||||
return themes.OrderBy(item => item.Name).ToList();
|
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>();
|
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))
|
foreach (string themecontrol in theme.ThemeControls.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
@ -74,10 +74,10 @@ namespace Oqtane.Services
|
|||||||
return selectableThemes;
|
return selectableThemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> themes)
|
public Dictionary<string, string> GetPaneLayoutTypes(List<Theme> Themes)
|
||||||
{
|
{
|
||||||
var selectablePaneLayouts = new Dictionary<string, string>();
|
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))
|
foreach (string panelayout in theme.PaneLayouts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
@ -87,10 +87,10 @@ namespace Oqtane.Services
|
|||||||
return selectablePaneLayouts;
|
return selectablePaneLayouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> GetContainerTypes(List<Theme> themes)
|
public Dictionary<string, string> GetContainerTypes(List<Theme> Themes)
|
||||||
{
|
{
|
||||||
var selectableContainers = new Dictionary<string, string>();
|
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))
|
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");
|
await http.GetJsonAsync<List<string>>(apiurl + "/install");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteThemeAsync(string ThemeName)
|
||||||
|
{
|
||||||
|
await http.DeleteAsync(apiurl + "/" + ThemeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
@inject IAliasService AliasService
|
@inject ITenantService TenantService
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -172,8 +172,10 @@
|
|||||||
GenericResponse response = await InstallationService.Install(connectionstring);
|
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||||
if (response.Success)
|
if (response.Success)
|
||||||
{
|
{
|
||||||
|
List<Tenant> tenants = await TenantService.GetTenantsAsync();
|
||||||
Site site = new Site();
|
Site site = new Site();
|
||||||
site.Name = "Site1";
|
site.TenantId = tenants.FirstOrDefault().TenantId;
|
||||||
|
site.Name = "Default Site";
|
||||||
site.Logo = "oqtane.png";
|
site.Logo = "oqtane.png";
|
||||||
site.DefaultThemeType = "Oqtane.Themes.Theme2.Theme2, Oqtane.Client";
|
site.DefaultThemeType = "Oqtane.Themes.Theme2.Theme2, Oqtane.Client";
|
||||||
site.DefaultLayoutType = "";
|
site.DefaultLayoutType = "";
|
||||||
|
@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
@ -15,11 +17,13 @@ namespace Oqtane.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||||
private readonly IInstallationManager InstallationManager;
|
private readonly IInstallationManager InstallationManager;
|
||||||
|
private readonly IWebHostEnvironment environment;
|
||||||
|
|
||||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallationManager InstallationManager)
|
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallationManager InstallationManager, IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
this.ModuleDefinitions = ModuleDefinitions;
|
this.ModuleDefinitions = ModuleDefinitions;
|
||||||
this.InstallationManager = InstallationManager;
|
this.InstallationManager = InstallationManager;
|
||||||
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/<controller>?siteid=x
|
// GET: api/<controller>?siteid=x
|
||||||
@ -55,5 +59,34 @@ namespace Oqtane.Controllers
|
|||||||
{
|
{
|
||||||
InstallationManager.InstallPackages("Modules");
|
InstallationManager.InstallPackages("Modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DELETE api/<controller>/5?siteid=x
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
|
public void Delete(int id, int siteid)
|
||||||
|
{
|
||||||
|
List<ModuleDefinition> moduledefinitions = ModuleDefinitions.GetModuleDefinitions(siteid).ToList();
|
||||||
|
ModuleDefinition moduledefinition = moduledefinitions.Where(item => item.ModuleDefinitionId == id).FirstOrDefault();
|
||||||
|
if (moduledefinition != null)
|
||||||
|
{
|
||||||
|
string moduledefinitionname = moduledefinition.ModuleDefinitionName.Substring(0, moduledefinition.ModuleDefinitionName.IndexOf(","));
|
||||||
|
|
||||||
|
string folder = Path.Combine(environment.WebRootPath, "Modules\\" + moduledefinitionname);
|
||||||
|
if (Directory.Exists(folder))
|
||||||
|
{
|
||||||
|
Directory.Delete(folder, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
|
foreach (string file in Directory.EnumerateFiles(binfolder, moduledefinitionname + "*.dll"))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModuleDefinitions.DeleteModuleDefinition(id, siteid);
|
||||||
|
|
||||||
|
InstallationManager.RestartApplication();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ using Oqtane.Shared;
|
|||||||
using Oqtane.Infrastructure;
|
using Oqtane.Infrastructure;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
|
||||||
namespace Oqtane.Controllers
|
namespace Oqtane.Controllers
|
||||||
{
|
{
|
||||||
@ -15,11 +17,13 @@ namespace Oqtane.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IThemeRepository Themes;
|
private readonly IThemeRepository Themes;
|
||||||
private readonly IInstallationManager InstallationManager;
|
private readonly IInstallationManager InstallationManager;
|
||||||
|
private readonly IWebHostEnvironment environment;
|
||||||
|
|
||||||
public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager)
|
public ThemeController(IThemeRepository Themes, IInstallationManager InstallationManager, IWebHostEnvironment environment)
|
||||||
{
|
{
|
||||||
this.Themes = Themes;
|
this.Themes = Themes;
|
||||||
this.InstallationManager = InstallationManager;
|
this.InstallationManager = InstallationManager;
|
||||||
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
@ -44,5 +48,32 @@ namespace Oqtane.Controllers
|
|||||||
{
|
{
|
||||||
InstallationManager.InstallPackages("Themes");
|
InstallationManager.InstallPackages("Themes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DELETE api/<controller>/xxx
|
||||||
|
[HttpDelete("{themename}")]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
|
public void Delete(string themename)
|
||||||
|
{
|
||||||
|
List<Theme> themes = Themes.GetThemes().ToList();
|
||||||
|
Theme theme = themes.Where(item => item.ThemeName == themename).FirstOrDefault();
|
||||||
|
if (theme != null)
|
||||||
|
{
|
||||||
|
themename = theme.ThemeName.Substring(0, theme.ThemeName.IndexOf(","));
|
||||||
|
|
||||||
|
string folder = Path.Combine(environment.WebRootPath, "Themes\\" + themename);
|
||||||
|
if (Directory.Exists(folder))
|
||||||
|
{
|
||||||
|
Directory.Delete(folder, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
|
foreach (string file in Directory.EnumerateFiles(binfolder, themename + "*.dll"))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
InstallationManager.RestartApplication();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
public interface IInstallationManager
|
public interface IInstallationManager
|
||||||
{
|
{
|
||||||
void InstallPackages(string Folders);
|
void InstallPackages(string Folders);
|
||||||
|
void RestartApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,13 @@ namespace Oqtane.Infrastructure
|
|||||||
if (install)
|
if (install)
|
||||||
{
|
{
|
||||||
// restart application
|
// restart application
|
||||||
HostApplicationLifetime.StopApplication();
|
RestartApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RestartApplication()
|
||||||
|
{
|
||||||
|
HostApplicationLifetime.StopApplication();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace Oqtane.Repository
|
|||||||
{
|
{
|
||||||
IEnumerable<ModuleDefinition> GetModuleDefinitions(int SideId);
|
IEnumerable<ModuleDefinition> GetModuleDefinitions(int SideId);
|
||||||
void UpdateModuleDefinition(ModuleDefinition ModuleDefinition);
|
void UpdateModuleDefinition(ModuleDefinition ModuleDefinition);
|
||||||
|
void DeleteModuleDefinition(int ModuleDefinitionId, int SiteId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Oqtane.Repository
|
|||||||
void UpdatePermissions(int SiteId, string EntityName, int EntityId, string Permissions);
|
void UpdatePermissions(int SiteId, string EntityName, int EntityId, string Permissions);
|
||||||
Permission GetPermission(int PermissionId);
|
Permission GetPermission(int PermissionId);
|
||||||
void DeletePermission(int PermissionId);
|
void DeletePermission(int PermissionId);
|
||||||
|
void DeletePermissions(int SiteId, string EntityName, int EntityId);
|
||||||
string EncodePermissions(int EntityId, IEnumerable<Permission> Permissions);
|
string EncodePermissions(int EntityId, IEnumerable<Permission> Permissions);
|
||||||
IEnumerable<Permission> DecodePermissions(string Permissions, int SiteId, string EntityName, int EntityId);
|
IEnumerable<Permission> DecodePermissions(string Permissions, int SiteId, string EntityName, int EntityId);
|
||||||
}
|
}
|
||||||
|
@ -186,5 +186,13 @@ namespace Oqtane.Repository
|
|||||||
{
|
{
|
||||||
Permissions.UpdatePermissions(ModuleDefinition.SiteId, "ModuleDefinition", ModuleDefinition.ModuleDefinitionId, ModuleDefinition.Permissions);
|
Permissions.UpdatePermissions(ModuleDefinition.SiteId, "ModuleDefinition", ModuleDefinition.ModuleDefinitionId, ModuleDefinition.Permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteModuleDefinition(int ModuleDefinitionId, int SiteId)
|
||||||
|
{
|
||||||
|
ModuleDefinition ModuleDefinition = db.ModuleDefinition.Find(ModuleDefinitionId);
|
||||||
|
Permissions.DeletePermissions(SiteId, "ModuleDefinition", ModuleDefinitionId);
|
||||||
|
db.ModuleDefinition.Remove(ModuleDefinition);
|
||||||
|
db.SaveChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,9 @@ namespace Oqtane.Repository
|
|||||||
// get current permissions and delete
|
// get current permissions and delete
|
||||||
IEnumerable<Permission> permissions = db.Permission
|
IEnumerable<Permission> permissions = db.Permission
|
||||||
.Where(item => item.EntityName == EntityName)
|
.Where(item => item.EntityName == EntityName)
|
||||||
.Where(item => item.EntityId == EntityId);
|
.Where(item => item.EntityId == EntityId)
|
||||||
foreach(Permission permission in permissions)
|
.Where(item => item.SiteId == SiteId);
|
||||||
|
foreach (Permission permission in permissions)
|
||||||
{
|
{
|
||||||
db.Permission.Remove(permission);
|
db.Permission.Remove(permission);
|
||||||
}
|
}
|
||||||
@ -87,6 +88,19 @@ namespace Oqtane.Repository
|
|||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeletePermissions(int SiteId, string EntityName, int EntityId)
|
||||||
|
{
|
||||||
|
IEnumerable<Permission> permissions = db.Permission
|
||||||
|
.Where(item => item.EntityName == EntityName)
|
||||||
|
.Where(item => item.EntityId == EntityId)
|
||||||
|
.Where(item => item.SiteId == SiteId);
|
||||||
|
foreach (Permission permission in permissions)
|
||||||
|
{
|
||||||
|
db.Permission.Remove(permission);
|
||||||
|
}
|
||||||
|
db.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
// permissions are stored in the format "{permissionname:!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]}" where "!" designates Deny permissions
|
// permissions are stored in the format "{permissionname:!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]}" where "!" designates Deny permissions
|
||||||
public string EncodePermissions(int EntityId, IEnumerable<Permission> Permissions)
|
public string EncodePermissions(int EntityId, IEnumerable<Permission> Permissions)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ Create tables
|
|||||||
|
|
||||||
CREATE TABLE [dbo].[Site](
|
CREATE TABLE [dbo].[Site](
|
||||||
[SiteId] [int] IDENTITY(1,1) NOT NULL,
|
[SiteId] [int] IDENTITY(1,1) NOT NULL,
|
||||||
|
[TenantId] [int] NOT NULL,
|
||||||
[Name] [nvarchar](200) NOT NULL,
|
[Name] [nvarchar](200) NOT NULL,
|
||||||
[Logo] [nvarchar](50) NOT NULL,
|
[Logo] [nvarchar](50) NOT NULL,
|
||||||
[DefaultThemeType] [nvarchar](200) NOT NULL,
|
[DefaultThemeType] [nvarchar](200) NOT NULL,
|
||||||
|
@ -187,8 +187,8 @@ namespace Oqtane.Server
|
|||||||
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
// load assembly ( as long as dependencies are in /bin they will load as well )
|
// load assembly from stream to prevent locking file ( as long as dependencies are in /bin they will load as well )
|
||||||
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
|
assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file.FullName)));
|
||||||
moduleassemblies.Add(assembly);
|
moduleassemblies.Add(assembly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,8 +200,8 @@ namespace Oqtane.Server
|
|||||||
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
// load assembly ( as long as dependencies are in /bin they will load as well )
|
// load assembly from stream to prevent locking file ( as long as dependencies are in /bin they will load as well )
|
||||||
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
|
assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file.FullName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,9 +374,8 @@ namespace Oqtane.Server
|
|||||||
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
// load assembly ( as long as dependencies are in /bin they will load as well )
|
// load assembly from stream to prevent locking file ( as long as dependencies are in /bin they will load as well )
|
||||||
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
|
assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file.FullName)));
|
||||||
moduleassemblies.Add(assembly);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,8 +386,8 @@ namespace Oqtane.Server
|
|||||||
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
Assembly assembly = assemblies.Where(item => item.Location == file.FullName).FirstOrDefault();
|
||||||
if (assembly == null)
|
if (assembly == null)
|
||||||
{
|
{
|
||||||
// load assembly ( as long as dependencies are in /bin they will load as well )
|
// load assembly from stream to prevent locking file ( as long as dependencies are in /bin they will load as well )
|
||||||
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName);
|
assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file.FullName)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Oqtane.Models
|
|||||||
public class Site : IAuditable, IDeletable
|
public class Site : IAuditable, IDeletable
|
||||||
{
|
{
|
||||||
public int SiteId { get; set; }
|
public int SiteId { get; set; }
|
||||||
|
public int TenantId { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Logo { get; set; }
|
public string Logo { get; set; }
|
||||||
public string DefaultThemeType { get; set; }
|
public string DefaultThemeType { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user