commit
252d5ff2af
@ -4,30 +4,52 @@
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@inject IModuleService ModuleService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Module Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Description: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation.">Owner Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="owner" class="form-control" @bind="@_owner" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="module" HelpText="Enter a name for this module. It should be in singular form (ie. Car) and not contain spaces or punctuation.">Module Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="module" class="form-control" @bind="@_module" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="description" HelpText="Enter s short description for the module">Description: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="template" HelpText="Select a module template. Internal modules are created inside of the Oqtane solution. External modules are created outside of the Oqtane solution.">Template: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="template" class="form-control" @bind="@_template">
|
||||
<option value=""><Select Template></option>
|
||||
<option value="internal">Internal</option>
|
||||
<option value="external">External</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button type="button" class="btn btn-success" @onclick="CreateModule">Create Module</button>
|
||||
|
||||
@code {
|
||||
private string _name = string.Empty;
|
||||
private string _owner = string.Empty;
|
||||
private string _module = string.Empty;
|
||||
private string _description = string.Empty;
|
||||
private string _template = string.Empty;
|
||||
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
|
||||
|
||||
@ -35,19 +57,19 @@
|
||||
{
|
||||
AddModuleMessage("Please Note That Once You Select The Create Module Button The Application Must Restart In Order To Complete The Process.", MessageType.Info);
|
||||
}
|
||||
|
||||
|
||||
private async Task CreateModule()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_name))
|
||||
if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && !string.IsNullOrEmpty(_template))
|
||||
{
|
||||
var moduleDefinition = new ModuleDefinition { Name = _name, Description = _description };
|
||||
var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ",""), Name = _module.Replace(" ", ""), Description = _description, Template = _template };
|
||||
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage("You Must Provide A Name For The Module", MessageType.Warning);
|
||||
AddModuleMessage("You Must Provide An Owner, Module Name, And Template", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,10 +1,12 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@using Oqtane.Services.[Module]s
|
||||
@using Oqtane.Models.[Module]s
|
||||
@using Oqtane.Modules.Controls
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject I[Module]Service [Module]Service
|
||||
@inject HttpClient http
|
||||
@inject SiteState sitestate
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
@ -26,10 +28,10 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||
public override string Actions => "Add,Edit";
|
||||
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Edit; } }
|
||||
public override string Actions { get { return "Add,Edit"; } }
|
||||
|
||||
I[Module]Service [Module]Service;
|
||||
int _id;
|
||||
string _name;
|
||||
string _createdby;
|
||||
@ -39,9 +41,10 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (PageState.Action == "Edit")
|
||||
try
|
||||
{
|
||||
try
|
||||
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
|
||||
if (PageState.Action == "Edit")
|
||||
{
|
||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id);
|
||||
@ -54,11 +57,11 @@
|
||||
_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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Loading [Module] {[Module]Id} {Error}", _id, ex.Message);
|
||||
AddModuleMessage("Error Loading [Module]", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
101
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Client/Index.razor
vendored
Normal file
101
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Client/Index.razor
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject HttpClient http
|
||||
@inject SiteState sitestate
|
||||
|
||||
@if (_[Module]s == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" Text="Add [Module]" />
|
||||
<br />
|
||||
<br />
|
||||
@if (@_[Module]s.Count != 0)
|
||||
{
|
||||
<Pager Items="@_[Module]s" Format="Grid">
|
||||
<Header>
|
||||
<div class="col"><strong>[Module]s</strong></div>
|
||||
</Header>
|
||||
<Row>
|
||||
<div class="col">
|
||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.[Module]Id.ToString())" />
|
||||
<ActionDialog Header="Delete [Module]" Message="@("Are You Sure You Wish To Delete The " + context.Name + " [Module]?")" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" />
|
||||
@context.Name
|
||||
</div>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No [Module]s To Display</p>
|
||||
}
|
||||
}
|
||||
|
||||
<hr />
|
||||
[Module] Module Created Successfully. Use Edit Mode To Add A [Module]. You Can Access The Files At The Following Locations:<br /><br />
|
||||
[RootPath]Client\<br />
|
||||
- [Owner].[Module]s.Module.Client.csproj - client project<br />
|
||||
- _Imports.razor - global imports for module components<br />
|
||||
- Edit.razor - component for adding or editing content<br />
|
||||
- Index.razor - main component for your module **the content you are reading is in this file**<br />
|
||||
- ModuleInfo.cs - implements IModule interface to provide configuration settings for your module<br />
|
||||
- Settings.razor - component for managing module settings<br />
|
||||
- Services\I[Module]Service.cs - interface for defining service API methods<br />
|
||||
- Services\[Module]Service.cs - implements service API interface methods<br /><br />
|
||||
[RootPath]Package\<br />
|
||||
- [Owner].[Module]s.Module.nuspec - nuget manifest for packaging module<br />
|
||||
- [Owner].[Module]s.Module.Package.csproj - packaging project<br />
|
||||
- debug.cmd - copies assemblies to Oqtane bin folder when in Debug mode<br />
|
||||
- release.cmd - creates nuget package and deploys to Oqtane wwwroot/modules folder when in Release mode<br /><br />
|
||||
[RootPath]Server\<br />
|
||||
- [Owner].[Module]s.Module.Server.csproj - server project<br />
|
||||
- Controllers\[Module]Controller.cs - API methods implemented using a REST pattern<br />
|
||||
- Manager\[Module]Manager.cs - implements optional module interfaces for features such as import/export of content<br />
|
||||
- Repository\I[Module]Repository.cs - interface for defining repository methods<br />
|
||||
- Repository\[Module]Respository.cs - implements repository interface methods for data access using EF Core<br />
|
||||
- Repository\[Module]Context.cs - provides a DB Context for data access<br />
|
||||
- Scripts\01.00.00.sql - database schema definition<br /><br />
|
||||
[RootPath]Shared\<br />
|
||||
- [Owner].[Module]s.Module.Shared.csproj - shared project<br />
|
||||
- Models\[Module].cs - model definition<br /><br />
|
||||
|
||||
@code {
|
||||
I[Module]Service [Module]Service;
|
||||
List<[Module]> _[Module]s;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
|
||||
_[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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Modules.[Module]s
|
||||
namespace [Owner].[Module]s.Modules
|
||||
{
|
||||
public class ModuleInfo : IModule
|
||||
{
|
||||
@ -10,7 +10,8 @@ namespace Oqtane.Modules.[Module]s
|
||||
Name = "[Module]",
|
||||
Description = "[Module]",
|
||||
Version = "1.0.0",
|
||||
ServerAssemblyName = "Oqtane.Server"
|
||||
Dependencies = "[Owner].[Module]s.Module.Shared",
|
||||
ServerAssemblyName = "[ServerAssemblyName]"
|
||||
};
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace Oqtane.Services.[Module]s
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public interface I[Module]Service
|
||||
{
|
@ -3,12 +3,12 @@ using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace Oqtane.Services.[Module]s
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
</table>
|
||||
|
||||
@code {
|
||||
public override string Title { get { return "[Module] Settings"; } }
|
||||
public override string Title => "[Module] Settings";
|
||||
|
||||
string _value;
|
||||
|
@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<RazorLangVersion>3.0</RazorLangVersion>
|
||||
<Version>1.0.0</Version>
|
||||
<Authors>[Owner]</Authors>
|
||||
<Company>[Owner]</Company>
|
||||
<Description>[Description]</Description>
|
||||
<Product>[Owner].[Module]s.Module</Product>
|
||||
<Copyright>[Owner]</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview3.20168.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview3.20168.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview3.20168.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\[Owner].[Module]s.Module.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oqtane.Client">
|
||||
<HintPath>..\..\oqtane.framework\Oqtane.Client\bin\Debug\netstandard2.1\Oqtane.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Oqtane.Shared">
|
||||
<HintPath>..\..\oqtane.framework\Oqtane.Client\bin\Debug\netstandard2.1\Oqtane.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- there may be other elements here -->
|
||||
<BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
18
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Client/_Imports.razor
vendored
Normal file
18
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Client/_Imports.razor
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
@using System
|
||||
@using System.Linq
|
||||
@using System.Collections.Generic
|
||||
@using System.Net.Http
|
||||
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.JSInterop
|
||||
|
||||
@using Oqtane.Models
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Modules.Controls
|
||||
@using Oqtane.Providers
|
||||
@using Oqtane.Security
|
||||
@using Oqtane.Services
|
||||
@using Oqtane.Shared
|
||||
@using Oqtane.Themes
|
||||
@using Oqtane.Themes.Controls
|
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Client\[Owner].[Module]s.Module.Client.csproj" />
|
||||
<ProjectReference Include="..\Server\[Owner].[Module]s.Module.Server.csproj" />
|
||||
<ProjectReference Include="..\Shared\[Owner].[Module]s.Module.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="IF $(ConfigurationName) == Debug (debug.cmd)" />
|
||||
<Exec Command="IF $(ConfigurationName) == Release (release.cmd)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>[Owner].[Module]s.Module</id>
|
||||
<version>1.0.0</version>
|
||||
<authors>[Owner]</authors>
|
||||
<owners>[Owner]</owners>
|
||||
<title>[Module]s</title>
|
||||
<description>[Module]s</description>
|
||||
<copyright>[Owner]</copyright>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<license type="expression">MIT</license>
|
||||
<projectUrl>https://github.com/oqtane/oqtane.framework</projectUrl>
|
||||
<iconUrl>https://www.oqtane.org/Portals/0/icon.jpg</iconUrl>
|
||||
<tags>oqtane module</tags>
|
||||
<releaseNotes></releaseNotes>
|
||||
<summary></summary>
|
||||
<dependencies>
|
||||
<dependency id="Oqtane.Framework" version="0.0.9" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\Client\bin\Release\netstandard2.1\[Owner].[Module]s.Module.Client.dll" target="lib" />
|
||||
<file src="..\Server\bin\Release\netcoreapp3.1\[Owner].[Module]s.Module.Server.dll" target="lib" />
|
||||
<file src="..\Shared\bin\Release\netstandard2.1\[Owner].[Module]s.Module.Shared.dll" target="lib" />
|
||||
<file src="..\wwwroot\**\*.*" target="wwwroot" />
|
||||
</files>
|
||||
</package>
|
6
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/debug.cmd
vendored
Normal file
6
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/debug.cmd
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Client.dll" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
||||
XCOPY "..\Client\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Client.pdb" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
||||
XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Module.Server.dll" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
||||
XCOPY "..\Server\bin\Debug\netcoreapp3.1\[Owner].[Module]s.Module.Server.pdb" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
||||
XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Shared.dll" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
||||
XCOPY "..\Shared\bin\Debug\netstandard2.1\[Owner].[Module]s.Module.Shared.pdb" "..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\" /Y
|
2
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/release.cmd
vendored
Normal file
2
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Package/release.cmd
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"..\..\oqtane.framework\oqtane.package\nuget.exe" pack [Owner].[Module]s.Module.nuspec
|
||||
XCOPY "*.nupkg" "..\..\oqtane.framework\Oqtane.Server\wwwroot\Modules\" /Y
|
@ -1,13 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Repository.[Module]s;
|
||||
using Oqtane.Shared;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
|
||||
namespace Oqtane.Controllers.[Module]s
|
||||
namespace [Owner].[Module]s.Controllers
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class [Module]Controller : Controller
|
@ -1,10 +1,12 @@
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Repository.[Module]s;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
|
||||
namespace Oqtane.Modules.[Module]s
|
||||
namespace [Owner].[Module]s.Modules
|
||||
{
|
||||
public class [Module]Manager : IPortable
|
||||
{
|
||||
@ -15,7 +17,7 @@ namespace Oqtane.Modules.[Module]s
|
||||
_[Module]s = [Module]s;
|
||||
}
|
||||
|
||||
public string ExportModule(Models.Module module)
|
||||
public string ExportModule(Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<[Module]> [Module]s = _[Module]s.Get[Module]s(module.ModuleId).ToList();
|
||||
@ -26,7 +28,7 @@ namespace Oqtane.Modules.[Module]s
|
||||
return content;
|
||||
}
|
||||
|
||||
public void ImportModule(Models.Module module, string content, string version)
|
||||
public void ImportModule(Module module, string content, string version)
|
||||
{
|
||||
List<[Module]> [Module]s = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public interface I[Module]Repository
|
||||
{
|
@ -1,9 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public class [Module]Context : DBContextBase, IService
|
||||
{
|
@ -1,10 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models.[Module]s;
|
||||
using Oqtane.Modules;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace Oqtane.Repository.[Module]s
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public class [Module]Repository : I[Module]Repository, IService
|
||||
{
|
26
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Server/Scripts/01.00.00.sql
vendored
Normal file
26
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/Server/Scripts/01.00.00.sql
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Create [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
|
@ -0,0 +1,51 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
|
||||
<Version>1.0.0</Version>
|
||||
<Product>[Owner].[Module]s.Module</Product>
|
||||
<Authors>[Owner]</Authors>
|
||||
<Company>[Owner]</Company>
|
||||
<Description>[Description]</Description>
|
||||
<Copyright>[Owner]</Copyright>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<RepositoryUrl></RepositoryUrl>
|
||||
<RepositoryType></RepositoryType>
|
||||
<PackageReleaseNotes></PackageReleaseNotes>
|
||||
<ApplicationIcon />
|
||||
<OutputType>Library</OutputType>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Scripts\01.00.00.sql" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Scripts\01.00.00.sql" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.0-preview3.20168.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\[Owner].[Module]s.Module.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oqtane.Server">
|
||||
<HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\Oqtane.Server.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Oqtane.Shared">
|
||||
<HintPath>..\..\oqtane.framework\Oqtane.Server\bin\Debug\netcoreapp3.1\Oqtane.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Models.[Module]s
|
||||
namespace [Owner].[Module]s.Models
|
||||
{
|
||||
[Table("[Owner][Module]")]
|
||||
public class [Module] : IAuditable
|
||||
{
|
||||
[Key]
|
||||
public int [Module]Id { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
public string Name { get; set; }
|
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<Version>1.0.0</Version>
|
||||
<Product>[Owner].[Module].Module</Product>
|
||||
<Authors>[Owner]</Authors>
|
||||
<Company>[Owner]</Company>
|
||||
<Description>[Description]</Description>
|
||||
<Copyright>[Owner]</Copyright>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<RepositoryUrl></RepositoryUrl>
|
||||
<RepositoryType></RepositoryType>
|
||||
<PackageReleaseNotes></PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Oqtane.Shared">
|
||||
<HintPath>..\..\oqtane.framework\Oqtane.Shared\bin\Debug\netstandard2.1\Oqtane.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
52
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/[Owner].[Module]s.Module.sln
vendored
Normal file
52
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/[Owner].[Module]s.Module.sln
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28621.142
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Module.Client", "Client\[Owner].[Module]s.Module.Client.csproj", "{AA8E58A1-CD09-4208-BF66-A8BB341FD669}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Module.Server", "Server\[Owner].[Module]s.Module.Server.csproj", "{04B05448-788F-433D-92C0-FED35122D45A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "[Owner].[Module]s.Module.Shared", "Shared\[Owner].[Module]s.Module.Shared.csproj", "{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "[Owner].[Module]s.Module.Package", "Package\[Owner].[Module]s.Module.Package.csproj", "{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Wasm|Any CPU = Wasm|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Wasm|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AA8E58A1-CD09-4208-BF66-A8BB341FD669}.Wasm|Any CPU.Build.0 = Release|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Wasm|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{04B05448-788F-433D-92C0-FED35122D45A}.Wasm|Any CPU.Build.0 = Release|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Wasm|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{18D73F73-D7BE-4388-85BA-FBD9AC96FCA2}.Wasm|Any CPU.Build.0 = Release|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Wasm|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C5CE512D-CBB7-4545-AF0F-9B6591A0C3A7}.Wasm|Any CPU.Build.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1D016F15-46FE-4726-8DFD-2E4FD4DC7668}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
1
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/wwwroot/resources.txt
vendored
Normal file
1
Oqtane.Client/Modules/Admin/ModuleCreator/Templates/External/wwwroot/resources.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
This is the location where static resources such as images or style sheets should be located
|
@ -0,0 +1,95 @@
|
||||
@using Oqtane.Modules.Controls
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject HttpClient http
|
||||
@inject SiteState sitestate
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label">Name: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="_name" class="form-control" @bind="@_name" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" @onclick="Save">Save</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
@if (PageState.Action == "Edit")
|
||||
{
|
||||
<AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo>
|
||||
}
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||
public override string Actions => "Add,Edit";
|
||||
|
||||
I[Module]Service [Module]Service;
|
||||
int _id;
|
||||
string _name;
|
||||
string _createdby;
|
||||
DateTime _createdon;
|
||||
string _modifiedby;
|
||||
DateTime _modifiedon;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
|
||||
if (PageState.Action == "Edit")
|
||||
{
|
||||
_id = Int32.Parse(PageState.QueryString["id"]);
|
||||
[Module] [Module] = await [Module]Service.Get[Module]Async(_id);
|
||||
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);
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
@namespace Oqtane.Modules.[Module]s
|
||||
@using Oqtane.Services.[Module]s
|
||||
@using Oqtane.Models.[Module]s
|
||||
@using [Owner].[Module]s.Services
|
||||
@using [Owner].[Module]s.Models
|
||||
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject I[Module]Service [Module]Service
|
||||
@inject HttpClient http
|
||||
@inject SiteState sitestate
|
||||
|
||||
@if (_[Module]s == null)
|
||||
{
|
||||
@ -12,44 +14,57 @@
|
||||
else
|
||||
{
|
||||
<ActionLink Action="Add" Security="SecurityAccessLevel.Edit" Text="Add [Module]" />
|
||||
<br /><br />
|
||||
<Pager Items="@_[Module]s" Format="Grid">
|
||||
<Row>
|
||||
<div class="col">
|
||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.[Module]Id.ToString())" />
|
||||
<ActionDialog Header="Delete [Module]" Message="@("Are You Sure You Wish To Delete The " + context.Name + " [Module]?")" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" />
|
||||
@context.Name
|
||||
</div>
|
||||
</Row>
|
||||
</Pager>
|
||||
<br />
|
||||
<br />
|
||||
@if (@_[Module]s.Count != 0)
|
||||
{
|
||||
<Pager Items="@_[Module]s" Format="Grid">
|
||||
<Header>
|
||||
<div class="col"><strong>[Module]s</strong></div>
|
||||
</Header>
|
||||
<Row>
|
||||
<div class="col">
|
||||
<ActionLink Action="Edit" Parameters="@($"id=" + context.[Module]Id.ToString())" />
|
||||
<ActionDialog Header="Delete [Module]" Message="@("Are You Sure You Wish To Delete The " + context.Name + " [Module]?")" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await Delete(context))" />
|
||||
@context.Name
|
||||
</div>
|
||||
</Row>
|
||||
</Pager>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>No [Module]s To Display</p>
|
||||
}
|
||||
}
|
||||
|
||||
<hr />
|
||||
[Module] Module Created Successfully. You Can Access The Files At The Following Locations:<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Client\Modules\[Module]\<br />
|
||||
- Index.razor - main component for your module<br />
|
||||
[Module] Module Created Successfully. Use Edit Mode To Add A [Module]. You Can Access The Files At The Following Locations:<br /><br />
|
||||
[RootPath]Oqtane.Client\Modules\[Module]\<br />
|
||||
- Edit.razor - component for adding or editing content<br />
|
||||
- Index.razor - main component for your module **the content you are reading is in this file**<br />
|
||||
- ModuleInfo.cs - implements IModule interface to provide configuration settings for your module<br />
|
||||
- Settings.razor - component for managing module settings<br />
|
||||
- Module.cs - implements IModule interface to provide configuration settings for your module<br />
|
||||
- Services\I[Module]Service.cs - interface for defining service API methods<br />
|
||||
- Services\[Module]Service.cs - implements service API interface methods<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Server\Modules\[Module]\<br />
|
||||
[RootPath]Oqtane.Server\Modules\[Module]\<br />
|
||||
- Controllers\[Module]Controller.cs - API methods implemented using a REST pattern<br />
|
||||
- Manager\[Module]Manager.cs - implements optional module interfaces for features such as import/export of content<br />
|
||||
- Repository\I[Module]Repository.cs - interface for defining repository methods<br />
|
||||
- Repository\[Module]Respository.cs - implements repository interface methods for data access using EF Core<br />
|
||||
- Repository\[Module]Context.cs - provides a DB Context for data access<br />
|
||||
- Scripts\01.00.00.sql - database schema definition<br /><br />
|
||||
C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Shared\Modules\Models\[Module]\<br />
|
||||
- [Module].cs - model definition<br /><br />
|
||||
[RootPath]Oqtane.Shared\Modules\[Module]\<br />
|
||||
- Models\[Module].cs - model definition<br /><br />
|
||||
|
||||
@code {
|
||||
I[Module]Service [Module]Service;
|
||||
List<[Module]> _[Module]s;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
[Module]Service = new [Module]Service(http, sitestate, NavigationManager);
|
||||
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -65,7 +80,8 @@ C:\Users\Shaun.Walker\Source\Repos\sbwalker\oqtane.framework\Oqtane.Shared\Modul
|
||||
{
|
||||
await [Module]Service.Delete[Module]Async([Module].[Module]Id);
|
||||
await logger.LogInformation("[Module] Deleted {[Module]}", [Module]);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
@ -0,0 +1,17 @@
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace [Owner].[Module]s.Modules
|
||||
{
|
||||
public class ModuleInfo : IModule
|
||||
{
|
||||
public ModuleDefinition ModuleDefinition => new ModuleDefinition
|
||||
{
|
||||
Name = "[Module]",
|
||||
Description = "[Module]",
|
||||
Version = "1.0.0",
|
||||
Dependencies = "[Owner].[Module]s.Module.Shared",
|
||||
ServerAssemblyName = "[ServerAssemblyName]"
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public interface I[Module]Service
|
||||
{
|
||||
Task<List<[Module]>> Get[Module]sAsync(int ModuleId);
|
||||
|
||||
Task<[Module]> Get[Module]Async(int [Module]Id);
|
||||
|
||||
Task<[Module]> Add[Module]Async([Module] [Module]);
|
||||
|
||||
Task<[Module]> Update[Module]Async([Module] [Module]);
|
||||
|
||||
Task Delete[Module]Async(int [Module]Id);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Services
|
||||
{
|
||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
||||
{
|
||||
private readonly HttpClient _http;
|
||||
private readonly NavigationManager _navigationManager;
|
||||
private readonly SiteState _siteState;
|
||||
|
||||
public [Module]Service(HttpClient http, SiteState siteState, NavigationManager navigationManager)
|
||||
{
|
||||
_http = http;
|
||||
_siteState = siteState;
|
||||
_navigationManager = navigationManager;
|
||||
}
|
||||
|
||||
private string Apiurl
|
||||
{
|
||||
get { return CreateApiUrl(_siteState.Alias, _navigationManager.Uri, "[Module]"); }
|
||||
}
|
||||
|
||||
public async Task<List<[Module]>> Get[Module]sAsync(int ModuleId)
|
||||
{
|
||||
List<[Module]> [Module]s = await _http.GetJsonAsync<List<[Module]>>(Apiurl + "?moduleid=" + ModuleId.ToString());
|
||||
return [Module]s.OrderBy(item => item.Name).ToList();
|
||||
}
|
||||
|
||||
public async Task<[Module]> Get[Module]Async(int [Module]Id)
|
||||
{
|
||||
return await _http.GetJsonAsync<[Module]>(Apiurl + "/" + [Module]Id.ToString());
|
||||
}
|
||||
|
||||
public async Task<[Module]> Add[Module]Async([Module] [Module])
|
||||
{
|
||||
return await _http.PostJsonAsync<[Module]>(Apiurl + "?entityid=" + [Module].ModuleId, [Module]);
|
||||
}
|
||||
|
||||
public async Task<[Module]> Update[Module]Async([Module] [Module])
|
||||
{
|
||||
return await _http.PutJsonAsync<[Module]>(Apiurl + "/" + [Module].[Module]Id + "?entityid=" + [Module].ModuleId, [Module]);
|
||||
}
|
||||
|
||||
public async Task Delete[Module]Async(int [Module]Id)
|
||||
{
|
||||
await _http.DeleteAsync(Apiurl + "/" + [Module]Id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
@namespace [Owner].[Module]s.Modules
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Setting" class="control-label">Setting: </label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control" @bind="_value" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@code {
|
||||
public override string Title => "[Module] Settings";
|
||||
|
||||
string _value;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> 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<string, string> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
|
||||
namespace [Owner].[Module]s.Controllers
|
||||
{
|
||||
[Route("{site}/api/[controller]")]
|
||||
public class [Module]Controller : Controller
|
||||
{
|
||||
private readonly I[Module]Repository _[Module]s;
|
||||
private readonly ILogManager _logger;
|
||||
|
||||
public [Module]Controller(I[Module]Repository [Module]s, ILogManager logger)
|
||||
{
|
||||
_[Module]s = [Module]s;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// GET: api/<controller>?moduleid=x
|
||||
[HttpGet]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public IEnumerable<[Module]> Get(string moduleid)
|
||||
{
|
||||
return _[Module]s.Get[Module]s(int.Parse(moduleid));
|
||||
}
|
||||
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Roles = Constants.RegisteredRole)]
|
||||
public [Module] Get(int id)
|
||||
{
|
||||
return _[Module]s.Get[Module](id);
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public [Module] Post([FromBody] [Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
[Module] = _[Module]s.Add[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public [Module] Put(int id, [FromBody] [Module] [Module])
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
[Module] = _[Module]s.Update[Module]([Module]);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]);
|
||||
}
|
||||
return [Module];
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_[Module]s.Delete[Module](id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Models;
|
||||
using [Owner].[Module]s.Models;
|
||||
using [Owner].[Module]s.Repository;
|
||||
|
||||
namespace [Owner].[Module]s.Modules
|
||||
{
|
||||
public class [Module]Manager : IPortable
|
||||
{
|
||||
private I[Module]Repository _[Module]s;
|
||||
|
||||
public [Module]Manager(I[Module]Repository [Module]s)
|
||||
{
|
||||
_[Module]s = [Module]s;
|
||||
}
|
||||
|
||||
public string ExportModule(Module module)
|
||||
{
|
||||
string content = "";
|
||||
List<[Module]> [Module]s = _[Module]s.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]> [Module]s = null;
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
[Module]s = JsonSerializer.Deserialize<List<[Module]>>(content);
|
||||
}
|
||||
if ([Module]s != null)
|
||||
{
|
||||
foreach([Module] [Module] in [Module]s)
|
||||
{
|
||||
[Module] _[Module] = new [Module]();
|
||||
_[Module].ModuleId = module.ModuleId;
|
||||
_[Module].Name = [Module].Name;
|
||||
_[Module]s.Add[Module](_[Module]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public interface I[Module]Repository
|
||||
{
|
||||
IEnumerable<[Module]> Get[Module]s(int ModuleId);
|
||||
[Module] Get[Module](int [Module]Id);
|
||||
[Module] Add[Module]([Module] [Module]);
|
||||
[Module] Update[Module]([Module] [Module]);
|
||||
void Delete[Module](int [Module]Id);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Oqtane.Modules;
|
||||
using Oqtane.Repository;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public class [Module]Context : DBContextBase, IService
|
||||
{
|
||||
public virtual DbSet<[Module]> [Module] { get; set; }
|
||||
|
||||
public [Module]Context(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
||||
{
|
||||
// ContextBase handles multi-tenant database connections
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Modules;
|
||||
using [Owner].[Module]s.Models;
|
||||
|
||||
namespace [Owner].[Module]s.Repository
|
||||
{
|
||||
public class [Module]Repository : I[Module]Repository, IService
|
||||
{
|
||||
private readonly [Module]Context _db;
|
||||
|
||||
public [Module]Repository([Module]Context context)
|
||||
{
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<[Module]> Get[Module]s(int ModuleId)
|
||||
{
|
||||
return _db.[Module].Where(item => item.ModuleId == ModuleId);
|
||||
}
|
||||
|
||||
public [Module] Get[Module](int [Module]Id)
|
||||
{
|
||||
return _db.[Module].Find([Module]Id);
|
||||
}
|
||||
|
||||
public [Module] Add[Module]([Module] [Module])
|
||||
{
|
||||
_db.[Module].Add([Module]);
|
||||
_db.SaveChanges();
|
||||
return [Module];
|
||||
}
|
||||
|
||||
public [Module] Update[Module]([Module] [Module])
|
||||
{
|
||||
_db.Entry([Module]).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return [Module];
|
||||
}
|
||||
|
||||
public void Delete[Module](int [Module]Id)
|
||||
{
|
||||
[Module] [Module] = _db.[Module].Find([Module]Id);
|
||||
_db.[Module].Remove([Module]);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Create [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
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace [Owner].[Module]s.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; }
|
||||
}
|
||||
}
|
@ -121,6 +121,10 @@
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(_settingsModuleType);
|
||||
_settingstitle = (string)_settingsModuleType.GetProperty("Title").GetValue(moduleobject, null);
|
||||
if (string.IsNullOrEmpty(_settingstitle))
|
||||
{
|
||||
_settingstitle = "Other Settings";
|
||||
}
|
||||
|
||||
DynamicComponent = builder =>
|
||||
{
|
||||
@ -141,7 +145,7 @@
|
||||
pagemodule.PageId = int.Parse(_pageId);
|
||||
pagemodule.Title = _title;
|
||||
pagemodule.ContainerType = _containerType;
|
||||
|
||||
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
<summary>A modular application framework for Blazor</summary>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="Oqtane.Client\bin\Release\netstandard2.1\Oqtane.Client.dll" target="lib" />
|
||||
<file src="Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Server.dll" target="lib" />
|
||||
<file src="Oqtane.Shared\bin\Release\netstandard2.1\Oqtane.Shared.dll" target="lib" />
|
||||
<file src="Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Upgrade.dll" target="lib" />
|
||||
<file src="..\Oqtane.Client\bin\Release\netstandard2.1\Oqtane.Client.dll" target="lib" />
|
||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Server.dll" target="lib" />
|
||||
<file src="..\Oqtane.Shared\bin\Release\netstandard2.1\Oqtane.Shared.dll" target="lib" />
|
||||
<file src="..\Oqtane.Server\bin\Release\netcoreapp3.1\Oqtane.Upgrade.dll" target="lib" />
|
||||
</files>
|
||||
</package>
|
BIN
Oqtane.Package/nuget.exe
Normal file
BIN
Oqtane.Package/nuget.exe
Normal file
Binary file not shown.
3
Oqtane.Package/pack.cmd
Normal file
3
Oqtane.Package/pack.cmd
Normal file
@ -0,0 +1,3 @@
|
||||
DEL "*.nupkg"
|
||||
nuget.exe pack Oqtane.Framework.nuspec
|
||||
|
@ -12,6 +12,7 @@ using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Security;
|
||||
using System;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
// ReSharper disable StringIndexOfIsCultureSpecific.1
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
@ -147,22 +148,38 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string rootPath = Directory.GetParent(_environment.ContentRootPath).FullName;
|
||||
string templatePath = Path.Combine(rootPath, "Oqtane.Client\\Modules\\Admin\\ModuleCreator\\Templates\\");
|
||||
ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, moduleDefinition);
|
||||
moduleDefinition.ModuleDefinitionName = "Oqtane.Modules." + moduleDefinition.Name + "s, Oqtane.Client";
|
||||
string templatePath = Path.Combine(Directory.GetParent(_environment.ContentRootPath).FullName, "Oqtane.Client\\Modules\\Admin\\ModuleCreator\\Templates\\" + moduleDefinition.Template + "\\");
|
||||
string rootPath;
|
||||
|
||||
if (moduleDefinition.Template == "internal")
|
||||
{
|
||||
rootPath = Directory.GetParent(_environment.ContentRootPath).FullName + "\\";
|
||||
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, Oqtane.Client";
|
||||
moduleDefinition.ServerAssemblyName = "Oqtane.Server";
|
||||
}
|
||||
else
|
||||
{
|
||||
rootPath = Directory.GetParent(_environment.ContentRootPath).Parent.FullName + "\\" + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module\\";
|
||||
moduleDefinition.ModuleDefinitionName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Modules, " + moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Client";
|
||||
moduleDefinition.ServerAssemblyName = moduleDefinition.Owner + "." + moduleDefinition.Name + "s.Module.Server";
|
||||
}
|
||||
|
||||
ProcessTemplatesRecursively(new DirectoryInfo(templatePath), rootPath, templatePath, moduleDefinition);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Module Definition Created {ModuleDefinition}", moduleDefinition);
|
||||
|
||||
Models.Module module = _modules.GetModule(int.Parse(moduleid));
|
||||
module.ModuleDefinitionName = moduleDefinition.ModuleDefinitionName;
|
||||
_modules.UpdateModule(module);
|
||||
|
||||
_installationManager.RestartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessTemplatesRecursively(DirectoryInfo current, string rootPath, ModuleDefinition moduleDefinition)
|
||||
private void ProcessTemplatesRecursively(DirectoryInfo current, string rootPath, string templatePath, ModuleDefinition moduleDefinition)
|
||||
{
|
||||
// process folder
|
||||
string folderPath = current.FullName.Replace("Oqtane.Client\\Modules\\Admin\\ModuleCreator\\Templates\\", "");
|
||||
string folderPath = rootPath + current.FullName.Replace(templatePath, "");
|
||||
folderPath = folderPath.Replace("[Owner]", moduleDefinition.Owner);
|
||||
folderPath = folderPath.Replace("[Module]", moduleDefinition.Name);
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
@ -176,19 +193,22 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
// process file
|
||||
string filePath = Path.Combine(folderPath, file.Name);
|
||||
filePath = filePath.Replace("[Owner]", moduleDefinition.Owner);
|
||||
filePath = filePath.Replace("[Module]", moduleDefinition.Name);
|
||||
|
||||
string text = System.IO.File.ReadAllText(file.FullName);
|
||||
text = text.Replace("[Owner]", moduleDefinition.Owner);
|
||||
text = text.Replace("[Module]", moduleDefinition.Name);
|
||||
text = text.Replace("[Description]", moduleDefinition.Description);
|
||||
text = text.Replace("[RootPath]", rootPath);
|
||||
text = text.Replace("[ServerAssemblyName]", moduleDefinition.ServerAssemblyName);
|
||||
text = text.Replace("[Folder]", folderPath);
|
||||
text = text.Replace("[File]", Path.GetFileName(filePath));
|
||||
System.IO.File.WriteAllText(filePath, text);
|
||||
|
||||
if (Path.GetExtension(filePath) == ".sql")
|
||||
{
|
||||
// execute script
|
||||
// execute script in curent tenant
|
||||
foreach (string query in text.Split("GO", StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
_sql.ExecuteNonQuery(_resolver.GetTenant(), query);
|
||||
@ -200,7 +220,7 @@ namespace Oqtane.Controllers
|
||||
|
||||
foreach (DirectoryInfo folder in folders.Reverse())
|
||||
{
|
||||
ProcessTemplatesRecursively(folder, rootPath, moduleDefinition);
|
||||
ProcessTemplatesRecursively(folder, rootPath, templatePath, moduleDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,15 @@ namespace Oqtane.Repository
|
||||
using (conn)
|
||||
{
|
||||
PrepareCommand(conn, cmd, query);
|
||||
int val = cmd.ExecuteNonQuery();
|
||||
int val = -1;
|
||||
try
|
||||
{
|
||||
val = cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// an error occurred executing the query
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ namespace Oqtane.Models
|
||||
PermissionNames = "";
|
||||
ServerAssemblyName = "";
|
||||
ControlTypeRoutes = "";
|
||||
Template = "";
|
||||
}
|
||||
|
||||
public int ModuleDefinitionId { get; set; }
|
||||
@ -54,10 +55,12 @@ namespace Oqtane.Models
|
||||
[NotMapped]
|
||||
public string ServerAssemblyName { get; set; }
|
||||
[NotMapped]
|
||||
public string ControlTypeTemplate { get; set; }
|
||||
[NotMapped]
|
||||
public string ControlTypeRoutes { get; set; }
|
||||
[NotMapped]
|
||||
public string Template { get; set; }
|
||||
[NotMapped]
|
||||
public string ControlTypeTemplate { get; set; }
|
||||
[NotMapped]
|
||||
public string AssemblyName { get; set; }
|
||||
[NotMapped]
|
||||
public string Permissions { get; set; }
|
||||
|
@ -14,53 +14,33 @@ namespace Oqtane.Shared
|
||||
var assemblyName = assemblyFullName.Substring(0, assemblyFullName.IndexOf(",", StringComparison.Ordinal));
|
||||
return $"{type.Namespace}, {assemblyName}";
|
||||
}
|
||||
|
||||
public static string NavigateUrl(string alias, string path, string parameters)
|
||||
{
|
||||
string url = "";
|
||||
if (alias != "")
|
||||
var uriBuilder = new UriBuilder
|
||||
{
|
||||
url += alias + "/";
|
||||
}
|
||||
if (path != "" && path != "/")
|
||||
{
|
||||
url += path + "/";
|
||||
}
|
||||
if (url.EndsWith("/"))
|
||||
{
|
||||
url = url.Substring(0, url.Length - 1);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameters))
|
||||
{
|
||||
url += "?" + parameters;
|
||||
}
|
||||
if (!url.StartsWith("/"))
|
||||
{
|
||||
url = "/" + url;
|
||||
}
|
||||
return url;
|
||||
Path = !string.IsNullOrEmpty(alias)
|
||||
? (!string.IsNullOrEmpty(path))
|
||||
? $"{alias}/{path}"
|
||||
: $"{alias}"
|
||||
: $"{path}",
|
||||
Query = parameters
|
||||
};
|
||||
|
||||
return uriBuilder.Uri.PathAndQuery;
|
||||
}
|
||||
|
||||
public static string EditUrl(string alias, string path, int moduleid, string action, string parameters)
|
||||
{
|
||||
string url = NavigateUrl(alias, path, "");
|
||||
if (url == "/") url = "";
|
||||
if (moduleid != -1)
|
||||
{
|
||||
url += "/" + moduleid.ToString();
|
||||
path += $"/{moduleid}";
|
||||
if (!string.IsNullOrEmpty(action))
|
||||
{
|
||||
path += $"/{action}";
|
||||
}
|
||||
}
|
||||
if (moduleid != -1 && action != "")
|
||||
{
|
||||
url += "/" + action;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameters))
|
||||
{
|
||||
url += "?" + parameters;
|
||||
}
|
||||
if (!url.StartsWith("/"))
|
||||
{
|
||||
url = "/" + url;
|
||||
}
|
||||
return url;
|
||||
return NavigateUrl(alias, path, parameters);
|
||||
}
|
||||
|
||||
public static string ContentUrl(string alias, int fileid)
|
||||
|
31
Oqtane.Test/Oqtane.Shared.Tests/UtilitiesTests.cs
Normal file
31
Oqtane.Test/Oqtane.Shared.Tests/UtilitiesTests.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Oqtane.Shared;
|
||||
using Xunit;
|
||||
|
||||
namespace Oqtane.Test.Oqtane.Shared.Tests
|
||||
{
|
||||
public class UtilitiesTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("contoso", "login", "returnUrl=/admin", "/contoso/login?returnUrl=/admin")]
|
||||
[InlineData("contoso", "admin", "", "/contoso/admin")]
|
||||
[InlineData("contoso", "", "pageId=4", "/contoso?pageId=4")]
|
||||
[InlineData("contoso", "", "pageId=4&moduleId=10", "/contoso?pageId=4&moduleId=10")]
|
||||
[InlineData("contoso", "", "", "/contoso")]
|
||||
[InlineData("", "login", "returnUrl=/admin", "/login?returnUrl=/admin")]
|
||||
[InlineData("", "admin", "", "/admin")]
|
||||
[InlineData("", "", "pageId=4", "/?pageId=4")]
|
||||
[InlineData("", "", "pageId=4&moduleId=10", "/?pageId=4&moduleId=10")]
|
||||
[InlineData("", "", "", "/")]
|
||||
public void NavigateUrlTest(string alias, string path, string parameters, string expectedUrl)
|
||||
{
|
||||
// Arrange
|
||||
var navigatedUrl = string.Empty;
|
||||
|
||||
// Act
|
||||
navigatedUrl = Utilities.NavigateUrl(alias, path, parameters);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedUrl, navigatedUrl);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user