diff --git a/Oqtane.Client/Modules/Admin/Files/Edit.razor b/Oqtane.Client/Modules/Admin/Files/Edit.razor
index 892f0559..b2ac3b64 100644
--- a/Oqtane.Client/Modules/Admin/Files/Edit.razor
+++ b/Oqtane.Client/Modules/Admin/Files/Edit.razor
@@ -36,7 +36,7 @@
Permissions:
-
+
diff --git a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
index d824e595..6baa0376 100644
--- a/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
+++ b/Oqtane.Client/Modules/Admin/ModuleCreator/Index.razor
@@ -9,7 +9,7 @@
@using System.Text.RegularExpressions
@using System.IO;
-@if (string.IsNullOrEmpty(_moduledefinitionname))
+@if (string.IsNullOrEmpty(_moduledefinitionname) && _systeminfo != null && _templates != null)
{
@@ -38,13 +38,15 @@
- Template:
+ Template:
TemplateChanged(e))">
<@Localizer["Select Template"]>
- @Localizer["Internal"]
- @Localizer["External"]
+ @foreach (string template in _templates)
+ {
+ @template
+ }
@@ -90,9 +92,11 @@ else
private string _module = string.Empty;
private string _description = string.Empty;
private string _template = "-";
- public string _reference = Constants.Version;
+ private string _reference = Constants.Version;
private string _location = string.Empty;
+
private Dictionary _systeminfo;
+ private List _templates;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
@@ -102,6 +106,7 @@ else
{
_moduledefinitionname = SettingService.GetSetting(ModuleState.Settings, "ModuleDefinitionName", "");
_systeminfo = await SystemService.GetSystemInfoAsync();
+ _templates = await ModuleDefinitionService.GetModuleDefinitionTemplatesAsync();
if (string.IsNullOrEmpty(_moduledefinitionname))
{
@@ -185,18 +190,8 @@ else
if (_template != "-" && _systeminfo != null && _systeminfo.ContainsKey("serverpath"))
{
string[] path = _systeminfo["serverpath"].Split(Path.DirectorySeparatorChar);
- if (_template == "internal")
- {
- _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 1) +
- Path.DirectorySeparatorChar + "Oqtane.Client" +
- Path.DirectorySeparatorChar + "Modules" +
- Path.DirectorySeparatorChar + _owner + "." + _module;
- }
- else
- {
- _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 2) +
- Path.DirectorySeparatorChar + _owner + "." + _module;
- }
+ _location = string.Join(Path.DirectorySeparatorChar, path, 0, path.Length - 2) +
+ Path.DirectorySeparatorChar + _owner + "." + _module;
}
StateHasChanged();
}
diff --git a/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs b/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs
index e4b8ce64..55f8ad91 100644
--- a/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs
+++ b/Oqtane.Client/Services/Interfaces/IModuleDefinitionService.cs
@@ -13,5 +13,6 @@ namespace Oqtane.Services
Task InstallModuleDefinitionsAsync();
Task DeleteModuleDefinitionAsync(int moduleDefinitionId, int siteId);
Task CreateModuleDefinitionAsync(ModuleDefinition moduleDefinition);
+ Task> GetModuleDefinitionTemplatesAsync();
}
}
diff --git a/Oqtane.Client/Services/ModuleDefinitionService.cs b/Oqtane.Client/Services/ModuleDefinitionService.cs
index 87ae7e09..9f8984c0 100644
--- a/Oqtane.Client/Services/ModuleDefinitionService.cs
+++ b/Oqtane.Client/Services/ModuleDefinitionService.cs
@@ -53,5 +53,11 @@ namespace Oqtane.Services
{
return await PostJsonAsync($"{Apiurl}", moduleDefinition);
}
+
+ public async Task> GetModuleDefinitionTemplatesAsync()
+ {
+ List templates = await GetJsonAsync>($"{Apiurl}/templates");
+ return templates;
+ }
}
}
diff --git a/Oqtane.Server/Controllers/InstallationController.cs b/Oqtane.Server/Controllers/InstallationController.cs
index cac15728..01de103b 100644
--- a/Oqtane.Server/Controllers/InstallationController.cs
+++ b/Oqtane.Server/Controllers/InstallationController.cs
@@ -130,7 +130,14 @@ namespace Oqtane.Controllers
var instance = Activator.CreateInstance(type) as IModule;
foreach (string name in instance.ModuleDefinition.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
- if (!list.Contains(name)) list.Insert(0, name);
+ if (System.IO.File.Exists(Path.Combine(binFolder, name + ".dll")))
+ {
+ if (!list.Contains(name)) list.Insert(0, name);
+ }
+ else
+ {
+ Console.WriteLine("Module " + instance.ModuleDefinition.ModuleDefinitionName + " dependency " + name + ".dll does not exist");
+ }
}
}
foreach (var type in assembly.GetTypes().Where(item => item.GetInterfaces().Contains(typeof(ITheme))))
@@ -138,7 +145,14 @@ namespace Oqtane.Controllers
var instance = Activator.CreateInstance(type) as ITheme;
foreach (string name in instance.Theme.Dependencies.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
- if (!list.Contains(name)) list.Insert(0, name);
+ if (System.IO.File.Exists(Path.Combine(binFolder, name + ".dll")))
+ {
+ if (!list.Contains(name)) list.Insert(0, name);
+ }
+ else
+ {
+ Console.WriteLine("Theme " + instance.Theme.ThemeName + " dependency " + name + ".dll does not exist" );
+ }
}
}
}
diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
index f417ce33..8769c120 100644
--- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs
+++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs
@@ -13,8 +13,6 @@ using Oqtane.Repository;
using Oqtane.Security;
using System;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Configuration;
-using System.Xml.Linq;
using System.Text.Json;
namespace Oqtane.Controllers
@@ -174,6 +172,20 @@ namespace Oqtane.Controllers
}
}
+ // GET: api//templates
+ [HttpGet("templates")]
+ [Authorize(Roles = RoleNames.Host)]
+ public List Get()
+ {
+ var templates = new List();
+ string templatePath = Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", Path.DirectorySeparatorChar.ToString());
+ foreach (string directory in Directory.GetDirectories(templatePath))
+ {
+ templates.Add(directory.Replace(templatePath, ""));
+ }
+ return templates;
+ }
+
// POST api/?moduleid=x
[HttpPost]
[Authorize(Roles = RoleNames.Host)]
@@ -185,30 +197,12 @@ namespace Oqtane.Controllers
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
string templatePath = Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", moduleDefinition.Template,Path.DirectorySeparatorChar.ToString());
- if (moduleDefinition.Template == "internal")
- {
- rootPath = Utilities.PathCombine(rootFolder.FullName,Path.DirectorySeparatorChar.ToString());
- moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", Oqtane.Client";
- moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, Oqtane.Server";
- }
- else
- {
- rootPath = Utilities.PathCombine(rootFolder.Parent.FullName , moduleDefinition.Owner + "." + moduleDefinition.Name,Path.DirectorySeparatorChar.ToString());
- moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Client.Oqtane";
- moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Server.Oqtane";
- }
+ rootPath = Utilities.PathCombine(rootFolder.Parent.FullName , moduleDefinition.Owner + "." + moduleDefinition.Name,Path.DirectorySeparatorChar.ToString());
+ moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + ", " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Client.Oqtane";
+ moduleDefinition.ServerManagerType = moduleDefinition.Owner + "." + moduleDefinition.Name + ".Manager." + moduleDefinition.Name + "Manager, " + moduleDefinition.Owner + "." + moduleDefinition.Name + ".Server.Oqtane";
ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, rootFolder.Name, templatePath, moduleDefinition);
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Definition Created {ModuleDefinition}", moduleDefinition);
-
- if (moduleDefinition.Template == "internal")
- {
- // add embedded resources to project file
- List resources = new List();
- resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".1.0.0.sql"));
- resources.Add(Utilities.PathCombine("Modules", moduleDefinition.Owner + "." + moduleDefinition.Name, "Scripts", moduleDefinition.Owner + "." + moduleDefinition.Name + ".Uninstall.sql"));
- EmbedResourceFiles(Utilities.PathCombine(rootPath, "Oqtane.Server", "Oqtane.Server.csproj"), resources);
- }
}
return moduleDefinition;
@@ -269,19 +263,5 @@ namespace Oqtane.Controllers
}
}
}
-
- private void EmbedResourceFiles(string projectfile, List resources)
- {
- XDocument project = XDocument.Load(projectfile);
- var itemGroup = project.Descendants("ItemGroup").Descendants("EmbeddedResource").FirstOrDefault().Parent;
- if (itemGroup != null)
- {
- foreach (var resource in resources)
- {
- itemGroup.Add(new XElement("EmbeddedResource", new XAttribute("Include", resource)));
- }
- }
- project.Save(projectfile);
- }
}
}
diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs
index 0344de6e..cbfcc63b 100644
--- a/Oqtane.Server/Infrastructure/UpgradeManager.cs
+++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs
@@ -1,9 +1,11 @@
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
using Oqtane.Extensions;
using Oqtane.Models;
using Oqtane.Repository;
using Oqtane.Shared;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
namespace Oqtane.Infrastructure
@@ -12,11 +14,13 @@ namespace Oqtane.Infrastructure
{
private readonly IAliasRepository _aliases;
private readonly IServiceScopeFactory _serviceScopeFactory;
+ private readonly IWebHostEnvironment _environment;
- public UpgradeManager(IAliasRepository aliases, IServiceScopeFactory serviceScopeFactory)
+ public UpgradeManager(IAliasRepository aliases, IServiceScopeFactory serviceScopeFactory, IWebHostEnvironment environment)
{
_aliases = aliases;
_serviceScopeFactory = serviceScopeFactory;
+ _environment = environment;
}
public void Upgrade(Tenant tenant, string version)
@@ -61,6 +65,12 @@ namespace Oqtane.Infrastructure
//});
CreateSitePages(tenant, pageTemplates);
break;
+ case "2.0.2":
+ if (tenant.Name == TenantNames.Master)
+ {
+ Directory.Delete(Utilities.PathCombine(_environment.WebRootPath, "Modules", "Templates", "Internal", Path.DirectorySeparatorChar.ToString()), true);
+ }
+ break;
}
}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor
deleted file mode 100644
index 339879f8..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Edit.razor
+++ /dev/null
@@ -1,100 +0,0 @@
-@using Oqtane.Modules.Controls
-@using [Owner].[Module].Services
-@using [Owner].[Module].Models
-
-@namespace [Owner].[Module]
-@inherits ModuleBase
-@inject I[Module]Service [Module]Service
-@inject NavigationManager NavigationManager
-
-
-Save
-Cancel
-
-
-@if (PageState.Action == "Edit")
-{
-
-}
-
-@code {
- public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
-
- public override string Actions => "Add,Edit";
-
- public override string Title => "Manage [Module]";
-
- public override List Resources => new List()
- {
- new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" }
- };
-
- int _id;
- string _name;
- string _createdby;
- DateTime _createdon;
- string _modifiedby;
- DateTime _modifiedon;
-
- protected override async Task OnInitializedAsync()
- {
- try
- {
- if (PageState.Action == "Edit")
- {
- _id = Int32.Parse(PageState.QueryString["id"]);
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
- if ([Module] != null)
- {
- _name = [Module].Name;
- _createdby = [Module].CreatedBy;
- _createdon = [Module].CreatedOn;
- _modifiedby = [Module].ModifiedBy;
- _modifiedon = [Module].ModifiedOn;
- }
- }
- }
- catch (Exception ex)
- {
- await logger.LogError(ex, "Error Loading [Module] {[Module]Id} {Error}", _id, ex.Message);
- AddModuleMessage("Error Loading [Module]", MessageType.Error);
- }
- }
-
- private async Task Save()
- {
- try
- {
- if (PageState.Action == "Add")
- {
- [Module] [Module] = new [Module]();
- [Module].ModuleId = ModuleState.ModuleId;
- [Module].Name = _name;
- [Module] = await [Module]Service.Add[Module]Async([Module]);
- await logger.LogInformation("[Module] Added {[Module]}", [Module]);
- }
- else
- {
- [Module] [Module] = await [Module]Service.Get[Module]Async(_id, ModuleState.ModuleId);
- [Module].Name = _name;
- await [Module]Service.Update[Module]Async([Module]);
- await logger.LogInformation("[Module] Updated {[Module]}", [Module]);
- }
- NavigationManager.NavigateTo(NavigateUrl());
- }
- catch (Exception ex)
- {
- await logger.LogError(ex, "Error Saving [Module] {Error}", ex.Message);
- AddModuleMessage("Error Saving [Module]", MessageType.Error);
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor
deleted file mode 100644
index 37cfef2a..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Index.razor
+++ /dev/null
@@ -1,100 +0,0 @@
-@using [Owner].[Module].Services
-@using [Owner].[Module].Models
-
-@namespace [Owner].[Module]
-@inherits ModuleBase
-@inject I[Module]Service [Module]Service
-@inject NavigationManager NavigationManager
-
-@if (_[Module]s == null)
-{
- Loading...
-}
-else
-{
-
-
-
- @if (@_[Module]s.Count != 0)
- {
-
-
-
-
-
- @context.Name
-
-
- }
- else
- {
- No [Module]s To Display
- }
-}
-
-
-
-
-[Module] Module Created Successfully. Use Edit Mode To Add A [Module]. You Can Access The Files At The Following Locations:
-[RootPath]Oqtane.Client\Modules\[Module]\
-- Edit.razor - component for adding or editing content
-- Index.razor - main component for your module **the content you are reading is in this file**
-- ModuleInfo.cs - implements IModule interface to provide configuration settings for your module
-- Settings.razor - component for managing module settings
-- Services\I[Module]Service.cs - interface for defining service API methods
-- Services\[Module]Service.cs - implements service API interface methods
-[RootPath]Oqtane.Server\Modules\[Module]\
-- Controllers\[Module]Controller.cs - API methods implemented using a REST pattern
-- Manager\[Module]Manager.cs - implements optional module interfaces for features such as import/export of content
-- Repository\I[Module]Repository.cs - interface for defining repository methods
-- Repository\[Module]Respository.cs - implements repository interface methods for data access using EF Core
-- Repository\[Module]Context.cs - provides a DB Context for data access
-- Scripts\[Owner].[Module]s.1.0.0.sql - database schema definition script
-- Scripts\[Owner].[Module]s.Uninstall.sql - database uninstall script
-[RootPath]Oqtane.Shared\Modules\[Module]\
-- Models\[Module].cs - model definition
-
-
-
-@code {
- public override List Resources => new List()
- {
- new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" },
- new Resource { ResourceType = ResourceType.Script, Url = ModulePath() + "Module.js" }
- };
-
- List<[Module]> _[Module]s;
-
- protected override async Task OnInitializedAsync()
- {
- try
- {
- _[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
- }
- catch (Exception ex)
- {
- await logger.LogError(ex, "Error Loading [Module] {Error}", ex.Message);
- AddModuleMessage("Error Loading [Module]", MessageType.Error);
- }
- }
-
- private async Task Delete([Module] [Module])
- {
- try
- {
- await [Module]Service.Delete[Module]Async([Module].[Module]Id, ModuleState.ModuleId);
- await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
- _[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
- StateHasChanged();
- }
- catch (Exception ex)
- {
- await logger.LogError(ex, "Error Deleting [Module] {[Module]} {Error}", [Module], ex.Message);
- AddModuleMessage("Error Deleting [Module]", MessageType.Error);
- }
- }
-}
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Interop.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Interop.cs
deleted file mode 100644
index 9d6f0a4e..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Interop.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Microsoft.JSInterop;
-using System.Threading.Tasks;
-
-namespace [Owner].[Module]
-{
- public class Interop
- {
- private readonly IJSRuntime _jsRuntime;
-
- public Interop(IJSRuntime jsRuntime)
- {
- _jsRuntime = jsRuntime;
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs
deleted file mode 100644
index 6586d51d..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/ModuleInfo.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Oqtane.Models;
-using Oqtane.Modules;
-
-namespace [Owner].[Module]
-{
- public class ModuleInfo : IModule
- {
- public ModuleDefinition ModuleDefinition => new ModuleDefinition
- {
- Name = "[Module]",
- Description = "[Module]",
- Version = "1.0.0",
- ServerManagerType = "[ServerManagerType]",
- ReleaseVersions = "1.0.0"
- };
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs
deleted file mode 100644
index 601eba6a..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/I[Module]Service.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using [Owner].[Module].Models;
-
-namespace [Owner].[Module].Services
-{
- public interface I[Module]Service
- {
- Task> Get[Module]sAsync(int ModuleId);
-
- Task Get[Module]Async(int [Module]Id, int ModuleId);
-
- Task Add[Module]Async(Models.[Module] [Module]);
-
- Task Update[Module]Async(Models.[Module] [Module]);
-
- Task Delete[Module]Async(int [Module]Id, int ModuleId);
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs
deleted file mode 100644
index 05a85ac7..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Services/[Module]Service.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Oqtane.Modules;
-using Oqtane.Services;
-using Oqtane.Shared;
-using [Owner].[Module].Models;
-
-namespace [Owner].[Module].Services
-{
- public class [Module]Service : ServiceBase, I[Module]Service, IService
- {
- private readonly SiteState _siteState;
-
- public [Module]Service(HttpClient http, SiteState siteState) : base(http)
- {
- _siteState = siteState;
- }
-
- private string Apiurl => CreateApiUrl(_siteState.Alias, "[Module]");
-
- public async Task> Get[Module]sAsync(int ModuleId)
- {
- List [Module]s = await GetJsonAsync>(CreateAuthorizationPolicyUrl($"{Apiurl}?moduleid={ModuleId}", ModuleId));
- return [Module]s.OrderBy(item => item.Name).ToList();
- }
-
- public async Task Get[Module]Async(int [Module]Id, int ModuleId)
- {
- return await GetJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
- }
-
- public async Task Add[Module]Async(Models.[Module] [Module])
- {
- return await PostJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}", [Module].ModuleId), [Module]);
- }
-
- public async Task Update[Module]Async(Models.[Module] [Module])
- {
- return await PutJsonAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module].[Module]Id}", [Module].ModuleId), [Module]);
- }
-
- public async Task Delete[Module]Async(int [Module]Id, int ModuleId)
- {
- await DeleteAsync(CreateAuthorizationPolicyUrl($"{Apiurl}/{[Module]Id}", ModuleId));
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor
deleted file mode 100644
index 7989d7c9..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Client/Modules/[Owner].[Module]/Settings.razor
+++ /dev/null
@@ -1,47 +0,0 @@
-@namespace [Owner].[Module]
-@inherits ModuleBase
-@inject ISettingService SettingService
-
-
-
-@code {
- public override string Title => "[Module] Settings";
-
- string _value;
-
- protected override async Task OnInitializedAsync()
- {
- try
- {
- Dictionary settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
- _value = SettingService.GetSetting(settings, "SettingName", "");
- }
- catch (Exception ex)
- {
- ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
- }
- }
-
- public async Task UpdateSettings()
- {
- try
- {
- Dictionary settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
- SettingService.SetSetting(settings, "SettingName", _value);
- await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
- }
- catch (Exception ex)
- {
- ModuleInstance.AddModuleMessage(ex.Message, MessageType.Error);
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs
deleted file mode 100644
index 3e2fe7b8..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Controllers/[Module]Controller.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Authorization;
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Http;
-using Oqtane.Shared;
-using Oqtane.Enums;
-using Oqtane.Infrastructure;
-using [Owner].[Module].Models;
-using [Owner].[Module].Repository;
-
-namespace [Owner].[Module].Controllers
-{
- [Route(ControllerRoutes.Default)]
- public class [Module]Controller : Controller
- {
- private readonly I[Module]Repository _[Module]Repository;
- private readonly ILogManager _logger;
- protected int _entityId = -1;
-
- public [Module]Controller(I[Module]Repository [Module]Repository, ILogManager logger, IHttpContextAccessor accessor)
- {
- _[Module]Repository = [Module]Repository;
- _logger = logger;
-
- if (accessor.HttpContext.Request.Query.ContainsKey("entityid"))
- {
- _entityId = int.Parse(accessor.HttpContext.Request.Query["entityid"]);
- }
- }
-
- // GET: api/?moduleid=x
- [HttpGet]
- [Authorize(Policy = PolicyNames.ViewModule)]
- public IEnumerable Get(string moduleid)
- {
- return _[Module]Repository.Get[Module]s(int.Parse(moduleid));
- }
-
- // GET api//5
- [HttpGet("{id}")]
- [Authorize(Policy = PolicyNames.ViewModule)]
- public Models.[Module] Get(int id)
- {
- Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
- if ([Module] != null && [Module].ModuleId != _entityId)
- {
- [Module] = null;
- }
- return [Module];
- }
-
- // POST api/
- [HttpPost]
- [Authorize(Policy = PolicyNames.EditModule)]
- public Models.[Module] Post([FromBody] Models.[Module] [Module])
- {
- if (ModelState.IsValid && [Module].ModuleId == _entityId)
- {
- [Module] = _[Module]Repository.Add[Module]([Module]);
- _logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
- }
- return [Module];
- }
-
- // PUT api//5
- [HttpPut("{id}")]
- [Authorize(Policy = PolicyNames.EditModule)]
- public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module])
- {
- if (ModelState.IsValid && [Module].ModuleId == _entityId)
- {
- [Module] = _[Module]Repository.Update[Module]([Module]);
- _logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
- }
- return [Module];
- }
-
- // DELETE api//5
- [HttpDelete("{id}")]
- [Authorize(Policy = PolicyNames.EditModule)]
- public void Delete(int id)
- {
- Models.[Module] [Module] = _[Module]Repository.Get[Module](id);
- if ([Module] != null && [Module].ModuleId == _entityId)
- {
- _[Module]Repository.Delete[Module](id);
- _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
- }
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs
deleted file mode 100644
index 486c8ddf..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Manager/[Module]Manager.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.Json;
-using Oqtane.Modules;
-using Oqtane.Models;
-using Oqtane.Infrastructure;
-using Oqtane.Repository;
-using [Owner].[Module].Models;
-using [Owner].[Module].Repository;
-
-namespace [Owner].[Module].Manager
-{
- public class [Module]Manager : IInstallable, IPortable
- {
- private I[Module]Repository _[Module]Repository;
- private ISqlRepository _sql;
-
- public [Module]Manager(I[Module]Repository [Module]Repository, ISqlRepository sql)
- {
- _[Module]Repository = [Module]Repository;
- _sql = sql;
- }
-
- public bool Install(Tenant tenant, string version)
- {
- return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module]." + version + ".sql");
- }
-
- public bool Uninstall(Tenant tenant)
- {
- return _sql.ExecuteScript(tenant, GetType().Assembly, "[Owner].[Module].Uninstall.sql");
- }
-
- public string ExportModule(Module module)
- {
- string content = "";
- List [Module]s = _[Module]Repository.Get[Module]s(module.ModuleId).ToList();
- if ([Module]s != null)
- {
- content = JsonSerializer.Serialize([Module]s);
- }
- return content;
- }
-
- public void ImportModule(Module module, string content, string version)
- {
- List [Module]s = null;
- if (!string.IsNullOrEmpty(content))
- {
- [Module]s = JsonSerializer.Deserialize>(content);
- }
- if ([Module]s != null)
- {
- foreach(var [Module] in [Module]s)
- {
- _[Module]Repository.Add[Module](new Models.[Module] { ModuleId = module.ModuleId, Name = [Module].Name });
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs
deleted file mode 100644
index 52b7913a..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/I[Module]Repository.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Collections.Generic;
-using [Owner].[Module].Models;
-
-namespace [Owner].[Module].Repository
-{
- public interface I[Module]Repository
- {
- IEnumerable Get[Module]s(int ModuleId);
- Models.[Module] Get[Module](int [Module]Id);
- Models.[Module] Add[Module](Models.[Module] [Module]);
- Models.[Module] Update[Module](Models.[Module] [Module]);
- void Delete[Module](int [Module]Id);
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs
deleted file mode 100644
index a10d7219..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Context.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.AspNetCore.Http;
-using Oqtane.Modules;
-using Oqtane.Repository;
-using [Owner].[Module].Models;
-
-namespace [Owner].[Module].Repository
-{
- public class [Module]Context : DBContextBase, IService
- {
- public virtual DbSet [Module] { get; set; }
-
- public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
- {
- // ContextBase handles multi-tenant database connections
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs
deleted file mode 100644
index 9c8c3628..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Repository/[Module]Repository.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System.Linq;
-using System.Collections.Generic;
-using Oqtane.Modules;
-using [Owner].[Module].Models;
-
-namespace [Owner].[Module].Repository
-{
- public class [Module]Repository : I[Module]Repository, IService
- {
- private readonly [Module]Context _db;
-
- public [Module]Repository([Module]Context context)
- {
- _db = context;
- }
-
- public IEnumerable Get[Module]s(int ModuleId)
- {
- return _db.[Module].Where(item => item.ModuleId == ModuleId);
- }
-
- public Models.[Module] Get[Module](int [Module]Id)
- {
- return _db.[Module].Find([Module]Id);
- }
-
- public Models.[Module] Add[Module](Models.[Module] [Module])
- {
- _db.[Module].Add([Module]);
- _db.SaveChanges();
- return [Module];
- }
-
- public Models.[Module] Update[Module](Models.[Module] [Module])
- {
- _db.Entry([Module]).State = EntityState.Modified;
- _db.SaveChanges();
- return [Module];
- }
-
- public void Delete[Module](int [Module]Id)
- {
- Models.[Module] [Module] = _db.[Module].Find([Module]Id);
- _db.[Module].Remove([Module]);
- _db.SaveChanges();
- }
- }
-}
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].1.0.0.sql b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].1.0.0.sql
deleted file mode 100644
index 7a1b99ea..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].1.0.0.sql
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-Create [Owner][Module] table
-*/
-
-CREATE TABLE [dbo].[[Owner][Module]](
- [[Module]Id] [int] IDENTITY(1,1) NOT NULL,
- [ModuleId] [int] NOT NULL,
- [Name] [nvarchar](256) NOT NULL,
- [CreatedBy] [nvarchar](256) NOT NULL,
- [CreatedOn] [datetime] NOT NULL,
- [ModifiedBy] [nvarchar](256) NOT NULL,
- [ModifiedOn] [datetime] NOT NULL,
- CONSTRAINT [PK_[Owner][Module]] PRIMARY KEY CLUSTERED
- (
- [[Module]Id] ASC
- )
-)
-GO
-
-/*
-Create foreign key relationships
-*/
-ALTER TABLE [dbo].[[Owner][Module]] WITH CHECK ADD CONSTRAINT [FK_[Owner][Module]_Module] FOREIGN KEY([ModuleId])
-REFERENCES [dbo].Module ([ModuleId])
-ON DELETE CASCADE
-GO
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].Uninstall.sql b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].Uninstall.sql
deleted file mode 100644
index 47baecc9..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/Modules/[Owner].[Module]/Scripts/[Owner].[Module].Uninstall.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
-Remove [Owner][Module] table
-*/
-
-DROP TABLE [dbo].[[Owner][Module]]
-GO
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.css b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.css
deleted file mode 100644
index 0856a263..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.css
+++ /dev/null
@@ -1 +0,0 @@
-/* Module Custom Styles */
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.js b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.js
deleted file mode 100644
index 8f072470..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Server/wwwroot/Modules/[Owner].[Module]/Module.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/* Module Script */
-var [Owner] = [Owner] || {};
-
-[Owner].[Module] = {
-};
\ No newline at end of file
diff --git a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs b/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs
deleted file mode 100644
index 94f73ffa..00000000
--- a/Oqtane.Server/wwwroot/Modules/Templates/Internal/Oqtane.Shared/Modules/[Owner].[Module]/Models/[Module].cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations.Schema;
-using Oqtane.Models;
-
-namespace [Owner].[Module].Models
-{
- [Table("[Owner][Module]")]
- public class [Module] : IAuditable
- {
- public int [Module]Id { get; set; }
- public int ModuleId { get; set; }
- public string Name { get; set; }
-
- public string CreatedBy { get; set; }
- public DateTime CreatedOn { get; set; }
- public string ModifiedBy { get; set; }
- public DateTime ModifiedOn { get; set; }
- }
-}
diff --git a/Oqtane.Shared/Shared/Constants.cs b/Oqtane.Shared/Shared/Constants.cs
index 1b05a7e7..60106dd2 100644
--- a/Oqtane.Shared/Shared/Constants.cs
+++ b/Oqtane.Shared/Shared/Constants.cs
@@ -5,8 +5,8 @@ namespace Oqtane.Shared {
public class Constants {
public const string PackageId = "Oqtane.Framework";
- public const string Version = "2.0.1";
- public const string ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,2.0.0,2.0.1";
+ public const string Version = "2.0.2";
+ public const string ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,2.0.0,2.0.1,2.0.2";
public const string PageComponent = "Oqtane.UI.ThemeBuilder, Oqtane.Client";
public const string ContainerComponent = "Oqtane.UI.ContainerBuilder, Oqtane.Client";