Merge pull request #102 from sbwalker/master
relocated IDeletable and added methods for downloading assemblies from server /bin when running under Wasm
This commit is contained in:
commit
4e67bc0177
|
@ -105,9 +105,11 @@
|
|||
await ModuleService.UpdateModuleAsync(module);
|
||||
|
||||
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);
|
||||
pagemodule.PageId = int.Parse(pageid);
|
||||
pagemodule.Title = title;
|
||||
pagemodule.ContainerType = containertype;
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
|
||||
|
||||
Type moduleType = Type.GetType(ModuleState.ModuleType);
|
||||
if (moduleType != null)
|
||||
|
|
50
Oqtane.Client/Modules/HelloWorld/Index.razor
Normal file
50
Oqtane.Client/Modules/HelloWorld/Index.razor
Normal file
|
@ -0,0 +1,50 @@
|
|||
@namespace YourCompany.Module.HelloWorld
|
||||
@inherits ModuleBase
|
||||
@inject ISettingService SettingService
|
||||
|
||||
<div class="mx-auto">
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions))
|
||||
{
|
||||
<div class="input-group">
|
||||
<input type="text" name="Url" class="form-control" placeholder="Enter An Image Url" @bind="@url1" />
|
||||
<span class="input-group-btn">
|
||||
<button type="button" class="btn btn-primary" @onclick="Save">Save</button>
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
@if (!string.IsNullOrEmpty(url2))
|
||||
{
|
||||
<br /><img src="@url2" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
@code {
|
||||
string url1 = ""; // use https://www.oqtane.org/Portals/0/Images/helloworld.png
|
||||
string url2 = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
url2 = SettingService.GetSetting(settings, "url", "");
|
||||
}
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(url1))
|
||||
{
|
||||
Dictionary<string, string> settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
|
||||
SettingService.SetSetting(settings, "url", url1);
|
||||
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
|
||||
ModuleInstance.AddModuleMessage("Url Saved", MessageType.Success);
|
||||
url2 = url1;
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleInstance.AddModuleMessage("You Must Enter A Url", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(moduledefinition.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + moduledefinition.AssemblyName + ".dll");
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/" + moduledefinition.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/" + assemblyname + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Oqtane.Services
|
|||
if (assemblies.Where(item => item.FullName.StartsWith(theme.AssemblyName + ",")).FirstOrDefault() == null)
|
||||
{
|
||||
// download assembly from server and load
|
||||
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + theme.AssemblyName + ".dll");
|
||||
var bytes = await http.GetByteArrayAsync(apiurl + "/" + theme.AssemblyName + ".dll");
|
||||
Assembly.Load(bytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ using Oqtane.Models;
|
|||
using Oqtane.Shared;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -20,11 +22,20 @@ namespace Oqtane.Controllers
|
|||
this.InstallationManager = InstallationManager;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
// GET: api/<controller>?siteid=x
|
||||
[HttpGet]
|
||||
public IEnumerable<ModuleDefinition> Get(string siteid)
|
||||
public IEnumerable<ModuleDefinition> Get(int siteid)
|
||||
{
|
||||
return ModuleDefinitions.GetModuleDefinitions(int.Parse(siteid));
|
||||
return ModuleDefinitions.GetModuleDefinitions(siteid);
|
||||
}
|
||||
|
||||
// GET api/<controller>/filename
|
||||
[HttpGet("{filename}")]
|
||||
public IActionResult Get(string filename)
|
||||
{
|
||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, filename));
|
||||
return File(file, "application/octet-stream", filename);
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
|
|
|
@ -5,6 +5,8 @@ using Oqtane.Models;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -27,6 +29,15 @@ namespace Oqtane.Controllers
|
|||
return Themes.GetThemes();
|
||||
}
|
||||
|
||||
// GET api/<controller>/filename
|
||||
[HttpGet("{filename}")]
|
||||
public IActionResult Get(string filename)
|
||||
{
|
||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, filename));
|
||||
return File(file, "application/octet-stream", filename);
|
||||
}
|
||||
|
||||
[HttpGet("install")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void InstallThemes()
|
||||
|
|
|
@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Identity;
|
|||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace Oqtane.Shared
|
||||
namespace Oqtane.Models
|
||||
{
|
||||
public interface IDeletable
|
||||
{
|
Loading…
Reference in New Issue
Block a user