module creator templates need to be in the server project in order to be distributed with application
This commit is contained in:
		
							
								
								
									
										98
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Edit.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,98 @@ | ||||
| @using Oqtane.Modules.Controls | ||||
| @using [Owner].[Module]s.Services | ||||
| @using [Owner].[Module]s.Models | ||||
|  | ||||
| @namespace [Owner].[Module]s | ||||
| @inherits ModuleBase | ||||
| @inject I[Module]Service [Module]Service | ||||
| @inject NavigationManager NavigationManager | ||||
|  | ||||
| <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"; | ||||
|  | ||||
|     public override List<Resource> Resources => new List<Resource>() | ||||
|     { | ||||
|         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); | ||||
|                 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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										109
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Index.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,109 @@ | ||||
| @using [Owner].[Module]s.Services | ||||
| @using [Owner].[Module]s.Models | ||||
|  | ||||
| @namespace [Owner].[Module]s | ||||
| @inherits ModuleBase | ||||
| @inject I[Module]Service [Module]Service | ||||
| @inject NavigationManager NavigationManager | ||||
|  | ||||
| @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> | ||||
|     } | ||||
| } | ||||
|  | ||||
| <!-- The content below is for informational purposes only and can be safely removed --> | ||||
|  | ||||
| <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.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.nuspec - nuget manifest for packaging module<br /> | ||||
| - [Owner].[Module]s.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.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\[Owner].[Module]s.1.0.0.sql - database schema definition script<br /> | ||||
| - Scripts\[Owner].[Module]s.Uninstall.sql - database uninstall script<br /> | ||||
| - wwwroot\Module.css - module style sheet<br /><br /> | ||||
| [RootPath]Shared\<br /> | ||||
| - [Owner].[Module]s.csproj - shared project<br /> | ||||
| - Models\[Module].cs - model definition<br /><br /> | ||||
|  | ||||
| <!-- The content above is for informational purposes only and can be safely removed --> | ||||
|  | ||||
| @code { | ||||
|     public override List<Resource> Resources => new List<Resource>() | ||||
|     { | ||||
|         new Resource { ResourceType = ResourceType.Stylesheet, Url = ModulePath() + "Module.css" } | ||||
|     }; | ||||
|  | ||||
|     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); | ||||
|             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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/ModuleInfo.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| using Oqtane.Models; | ||||
| using Oqtane.Modules; | ||||
|  | ||||
| namespace [Owner].[Module]s | ||||
| { | ||||
|     public class ModuleInfo : IModule | ||||
|     { | ||||
|         public ModuleDefinition ModuleDefinition => new ModuleDefinition | ||||
|         { | ||||
|             Name = "[Module]", | ||||
|             Description = "[Module]", | ||||
|             Version = "1.0.0", | ||||
|             ServerManagerType = "[ServerManagerType]", | ||||
|             ReleaseVersions = "1.0.0" | ||||
|         }; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										19
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/I[Module]Service.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -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); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										49
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | ||||
| 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]s.Models; | ||||
|  | ||||
| namespace [Owner].[Module]s.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<List<[Module]>> Get[Module]sAsync(int ModuleId) | ||||
|         { | ||||
|             List<[Module]> [Module]s = await GetJsonAsync<List<[Module]>>($"{Apiurl}?moduleid={ModuleId}"); | ||||
|             return [Module]s.OrderBy(item => item.Name).ToList(); | ||||
|         } | ||||
|  | ||||
|         public async Task<[Module]> Get[Module]Async(int [Module]Id) | ||||
|         { | ||||
|             return await GetJsonAsync<[Module]>($"{Apiurl}/{[Module]Id}"); | ||||
|         } | ||||
|  | ||||
|         public async Task<[Module]> Add[Module]Async([Module] [Module]) | ||||
|         { | ||||
|             return await PostJsonAsync<[Module]>($"{Apiurl}?entityid={[Module].ModuleId}", [Module]); | ||||
|         } | ||||
|  | ||||
|         public async Task<[Module]> Update[Module]Async([Module] [Module]) | ||||
|         { | ||||
|             return await PutJsonAsync<[Module]>($"{Apiurl}/{[Module].[Module]Id}?entityid={[Module].ModuleId}", [Module]); | ||||
|         } | ||||
|  | ||||
|         public async Task Delete[Module]Async(int [Module]Id) | ||||
|         { | ||||
|             await DeleteAsync($"{Apiurl}/{[Module]Id}"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										47
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/Settings.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | ||||
| @namespace [Owner].[Module]s | ||||
| @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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										42
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module]s.Client.csproj
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/[Owner].[Module]s.Client.csproj
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| <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</Product> | ||||
|     <Copyright>[Owner]</Copyright> | ||||
|     <AssemblyName>[Owner].[Module]s.Client.Oqtane</AssemblyName> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.4" /> | ||||
|     <PackageReference Include="System.Net.Http.Json" Version="3.2.0" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\Shared\[Owner].[Module]s.Shared.csproj" /> | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <Reference Include="Oqtane.Client"> | ||||
|       <HintPath>..\..\[RootFolder]\Oqtane.Client\bin\Debug\netstandard2.1\Oqtane.Client.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="Oqtane.Shared"> | ||||
|       <HintPath>..\..\[RootFolder]\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> | ||||
							
								
								
									
										20
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| @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 | ||||
| @using Oqtane.UI | ||||
| @using Oqtane.Enums | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker