Initial commit
This commit is contained in:
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
61
Oqtane.Client/Modules/HtmlText/Edit.razor
Normal file
@ -0,0 +1,61 @@
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.HtmlText.Services
|
||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
||||
@using System.Net.Http;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject HttpClient http
|
||||
|
||||
<form>
|
||||
<table class="form-group">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Content: </label>
|
||||
</td>
|
||||
<td>
|
||||
<textarea class="form-control" bind="@content" rows="5" style="width:400px;" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="btn btn-success" onclick="@SaveContent">Save</button>
|
||||
<NavLink class="btn btn" href="@NavigateUrl()">Cancel</NavLink>
|
||||
</form>
|
||||
|
||||
@functions {
|
||||
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Edit; } }
|
||||
public override string Title { get { return "Edit Html/Text"; } }
|
||||
|
||||
HtmlTextInfo htmltext;
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltextlist != null)
|
||||
{
|
||||
htmltext = htmltextlist.FirstOrDefault();
|
||||
content = htmltext.Content;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveContent()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
if (htmltext != null)
|
||||
{
|
||||
htmltext.Content = content;
|
||||
await htmltextservice.UpdateHtmlTextAsync(htmltext);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = new HtmlTextInfo();
|
||||
htmltext.ModuleId = ModuleState.ModuleId;
|
||||
htmltext.Content = content;
|
||||
await htmltextservice.AddHtmlTextAsync(htmltext);
|
||||
}
|
||||
UriHelper.NavigateTo(NavigateUrl(), true);
|
||||
}
|
||||
}
|
26
Oqtane.Client/Modules/HtmlText/Index.razor
Normal file
26
Oqtane.Client/Modules/HtmlText/Index.razor
Normal file
@ -0,0 +1,26 @@
|
||||
@using Oqtane.Client.Modules.HtmlText.Services
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Shared.Modules.HtmlText.Models
|
||||
@using System.Net.Http;
|
||||
@using Oqtane.Client.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
@inject HttpClient http
|
||||
@inject IUriHelper UriHelper
|
||||
|
||||
@((MarkupString)content)
|
||||
|
||||
<br /><ActionLink Action="Edit" /><br /><br />
|
||||
|
||||
@functions {
|
||||
string content;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
|
||||
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
|
||||
if (htmltext != null)
|
||||
{
|
||||
content = htmltext.FirstOrDefault().Content;
|
||||
}
|
||||
}
|
||||
}
|
16
Oqtane.Client/Modules/HtmlText/Module.cs
Normal file
16
Oqtane.Client/Modules/HtmlText/Module.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "HtmlText"; } }
|
||||
public string Description { get { return "Renders HTML or Text"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
}
|
||||
}
|
46
Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
Normal file
46
Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
||||
{
|
||||
public class HtmlTextService : ServiceBase, IHtmlTextService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
private readonly string apiurl;
|
||||
|
||||
public HtmlTextService(HttpClient http, IUriHelper urihelper)
|
||||
{
|
||||
this.http = http;
|
||||
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "HtmlText");
|
||||
}
|
||||
|
||||
public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId)
|
||||
{
|
||||
List<HtmlTextInfo> htmltext = await http.GetJsonAsync<List<HtmlTextInfo>>(apiurl);
|
||||
htmltext = htmltext
|
||||
.Where(item => item.ModuleId == ModuleId)
|
||||
.ToList();
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
public async Task AddHtmlTextAsync(HtmlTextInfo htmltext)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, htmltext);
|
||||
}
|
||||
|
||||
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmltext)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + htmltext.HtmlTextId.ToString(), htmltext);
|
||||
}
|
||||
|
||||
public async Task DeleteHtmlTextAsync(int HtmlTextId)
|
||||
{
|
||||
await http.DeleteAsync(apiurl + "/" + HtmlTextId.ToString());
|
||||
}
|
||||
}
|
||||
}
|
17
Oqtane.Client/Modules/HtmlText/Services/IHtmlTextService.cs
Normal file
17
Oqtane.Client/Modules/HtmlText/Services/IHtmlTextService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Oqtane.Shared.Modules.HtmlText.Models;
|
||||
|
||||
namespace Oqtane.Client.Modules.HtmlText.Services
|
||||
{
|
||||
public interface IHtmlTextService
|
||||
{
|
||||
Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId);
|
||||
|
||||
Task AddHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
|
||||
Task UpdateHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
|
||||
Task DeleteHtmlTextAsync(int HtmlTextId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user