Skip to content

Commit

Permalink
Merge pull request #20 from sbwalker/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
sbwalker authored May 24, 2019
2 parents ae2c5fb + 8deb119 commit d8d09ed
Show file tree
Hide file tree
Showing 57 changed files with 878 additions and 307 deletions.
2 changes: 1 addition & 1 deletion Oqtane.Client/Modules/Admin/Admin/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
if (p.IsNavigation && UserService.IsAuthorized(PageState.User, p.ViewPermissions))
{
string url = PageState.Alias + p.Path;
string url = NavigateUrl(p.Path);
<li class="list-group-item">
<NavLink class="nav-link" href="@url" Match="NavLinkMatch.All">
<span class="oi @p.Icon" aria-hidden="true"></span> @p.Name
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/Modules/Admin/Login/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
var interop = new Interop(jsRuntime);
await interop.SetCookie("user", user.UserId.ToString(), 7);
UriHelper.NavigateTo(PageState.Alias, true);
UriHelper.NavigateTo(NavigateUrl(""), true);
}
else
{
Expand Down
8 changes: 3 additions & 5 deletions Oqtane.Client/Modules/Admin/Pages/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@using Oqtane.Services
@using Oqtane.Modules
@using Oqtane.Shared
@using Oqtane.Client.Modules.Controls
@inherits ModuleBase
@inject IUriHelper UriHelper
@inject IPageService PageService
Expand Down Expand Up @@ -132,11 +131,10 @@
string viewpermissions = "All Users";
string editpermissions = "Administrators";

protected override async Task OnInitAsync()
protected override void OnInit()
{
var Themes = await ThemeService.GetThemesAsync();
themes = ThemeService.GetThemeTypes(Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
themes = ThemeService.GetThemeTypes(PageState.Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);
}

private async Task SavePage()
Expand Down
10 changes: 4 additions & 6 deletions Oqtane.Client/Modules/Admin/Pages/Delete.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@using Oqtane.Services
@using Oqtane.Modules
@using Oqtane.Shared
@using Oqtane.Client.Modules.Controls
@inherits ModuleBase
@inject IUriHelper UriHelper
@inject IPageService PageService
Expand Down Expand Up @@ -133,11 +132,10 @@
string viewpermissions;
string editpermissions;

protected override async Task OnInitAsync()
protected override void OnInit()
{
List<Theme> Themes = await ThemeService.GetThemesAsync();
themes = ThemeService.GetThemeTypes(Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
themes = ThemeService.GetThemeTypes(PageState.Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);

PageId = Int32.Parse(PageState.QueryString["id"]);
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
Expand All @@ -159,6 +157,6 @@
private async Task DeletePage()
{
await PageService.DeletePageAsync(Int32.Parse(PageState.QueryString["id"]));
UriHelper.NavigateTo(PageState.Alias);
UriHelper.NavigateTo(NavigateUrl("", true));
}
}
7 changes: 3 additions & 4 deletions Oqtane.Client/Modules/Admin/Pages/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@
string viewpermissions;
string editpermissions;

protected override async Task OnInitAsync()
protected override void OnInit()
{
List<Theme> Themes = await ThemeService.GetThemesAsync();
themes = ThemeService.GetThemeTypes(Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(Themes);
themes = ThemeService.GetThemeTypes(PageState.Themes);
panelayouts = ThemeService.GetPaneLayoutTypes(PageState.Themes);

PageId = Int32.Parse(PageState.QueryString["id"]);
Page p = PageState.Pages.Where(item => item.PageId == PageId).FirstOrDefault();
Expand Down
7 changes: 4 additions & 3 deletions Oqtane.Client/Modules/HtmlText/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
@using Oqtane.Client.Modules.HtmlText.Services
@using Oqtane.Shared.Modules.HtmlText.Models
@using System.Net.Http;
@using Oqtane.Client.Modules.Controls
@using Oqtane.Shared;
@inherits ModuleBase
@inject IUriHelper UriHelper
@inject HttpClient http
@inject SiteState sitestate

<form>
<table class="form-group">
Expand All @@ -32,7 +33,7 @@

protected override async Task OnInitAsync()
{
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate);
List<HtmlTextInfo> htmltextlist = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltextlist != null)
{
Expand All @@ -43,7 +44,7 @@

private async Task SaveContent()
{
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate);
if (htmltext != null)
{
htmltext.Content = content;
Expand Down
5 changes: 3 additions & 2 deletions Oqtane.Client/Modules/HtmlText/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
@using Oqtane.Shared.Modules.HtmlText.Models
@using System.Net.Http;
@using Oqtane.Client.Modules.Controls
@using Oqtane.Shared;
@inherits ModuleBase
@inject HttpClient http
@inject IUriHelper UriHelper
@inject SiteState sitestate

@((MarkupString)content)

Expand All @@ -16,7 +17,7 @@

protected override async Task OnInitAsync()
{
HtmlTextService htmltextservice = new HtmlTextService(http, UriHelper);
HtmlTextService htmltextservice = new HtmlTextService(http, sitestate);
List<HtmlTextInfo> htmltext = await htmltextservice.GetHtmlTextAsync(ModuleState.ModuleId);
if (htmltext != null)
{
Expand Down
12 changes: 9 additions & 3 deletions Oqtane.Client/Modules/HtmlText/Services/HtmlTextService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
using Microsoft.AspNetCore.Components;
using Oqtane.Services;
using Oqtane.Shared.Modules.HtmlText.Models;
using Oqtane.Shared;

namespace Oqtane.Client.Modules.HtmlText.Services
{
public class HtmlTextService : ServiceBase, IHtmlTextService
{
private readonly HttpClient http;
private readonly string apiurl;
private readonly SiteState sitestate;

public HtmlTextService(HttpClient http, IUriHelper urihelper)
public HtmlTextService(HttpClient http, SiteState sitestate)
{
this.http = http;
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "HtmlText");
this.sitestate = sitestate;
}

private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "HtmlText"); }
}

public async Task<List<HtmlTextInfo>> GetHtmlTextAsync(int ModuleId)
Expand Down
26 changes: 6 additions & 20 deletions Oqtane.Client/Modules/ModuleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,32 @@ public class ModuleBase : ComponentBase, IModuleControl

public string NavigateUrl()
{
return NavigateUrl(PageState.Page.Path, false);
return Utilities.NavigateUrl(PageState);
}

public string NavigateUrl(bool reload)
{
return NavigateUrl(PageState.Page.Path, reload);
return Utilities.NavigateUrl(PageState, reload);
}

public string NavigateUrl(string path)
{
return NavigateUrl(path, false);
return Utilities.NavigateUrl(PageState, path);
}

public string NavigateUrl(string path, bool reload)
{
string url = PageState.Alias + path;
if (reload)
{
url += "?reload=true";
}
return url;
return Utilities.NavigateUrl(PageState, path, reload);
}

public string EditUrl(string action)
{
return EditUrl(action, "");
return Utilities.EditUrl(PageState, ModuleState, action, "");
}

public string EditUrl(string action, string parameters)
{
string url = PageState.Alias + PageState.Page.Path + "?mid=" + ModuleState.ModuleId.ToString();
if (action != "")
{
url += "&ctl=" + action;
}
if (!string.IsNullOrEmpty(parameters))
{
url += "&" + parameters;
}
return url;
return Utilities.EditUrl(PageState, ModuleState, action, parameters);
}
}
}
53 changes: 53 additions & 0 deletions Oqtane.Client/Services/AliasService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Oqtane.Models;
using System.Threading.Tasks;
using System.Net.Http;
using System.Linq;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using Oqtane.Shared;

namespace Oqtane.Services
{
public class AliasService : ServiceBase, IAliasService
{
private readonly HttpClient http;
private readonly IUriHelper urihelper;

public AliasService(HttpClient http, IUriHelper urihelper)
{
this.http = http;
this.urihelper = urihelper;
}

private string apiurl
{
get { return CreateApiUrl(urihelper.GetAbsoluteUri(), "Alias"); }
}

public async Task<List<Alias>> GetAliasesAsync()
{
List<Alias> aliases = await http.GetJsonAsync<List<Alias>>(apiurl);
return aliases.OrderBy(item => item.Name).ToList();
}

public async Task<Alias> GetAliasAsync(int AliasId)
{
List<Alias> aliases = await http.GetJsonAsync<List<Alias>>(apiurl);
return aliases.Where(item => item.AliasId == AliasId).FirstOrDefault();
}

public async Task AddAliasAsync(Alias alias)
{
await http.PostJsonAsync(apiurl, alias);
}

public async Task UpdateAliasAsync(Alias alias)
{
await http.PutJsonAsync(apiurl + "/" + alias.AliasId.ToString(), alias);
}
public async Task DeleteAliasAsync(int AliasId)
{
await http.DeleteAsync(apiurl + "/" + AliasId.ToString());
}
}
}
19 changes: 19 additions & 0 deletions Oqtane.Client/Services/IAliasService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Oqtane.Models;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Oqtane.Services
{
public interface IAliasService
{
Task<List<Alias>> GetAliasesAsync();

Task<Alias> GetAliasAsync(int AliasId);

Task AddAliasAsync(Alias alias);

Task UpdateAliasAsync(Alias alias);

Task DeleteAliasAsync(int AliasId);
}
}
54 changes: 28 additions & 26 deletions Oqtane.Client/Services/ModuleDefinitionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,56 @@
using Microsoft.AspNetCore.Components;
using System;
using System.Reflection;
using Oqtane.Shared;

namespace Oqtane.Services
{
public class ModuleDefinitionService : ServiceBase, IModuleDefinitionService
{
private readonly HttpClient http;
private readonly string apiurl;
private readonly SiteState sitestate;

private List<ModuleDefinition> moduledefinitions;

public ModuleDefinitionService(HttpClient http, IUriHelper urihelper)
public ModuleDefinitionService(HttpClient http, SiteState sitestate)
{
this.http = http;
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "ModuleDefinition");
this.sitestate = sitestate;
}

private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "ModuleDefinition"); }
}

public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync()
{
if (moduledefinitions == null)
{
moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl);
List<ModuleDefinition> moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl);

// get list of loaded assemblies
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
// get list of loaded assemblies
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();

foreach (ModuleDefinition moduledefinition in moduledefinitions)
foreach (ModuleDefinition moduledefinition in moduledefinitions)
{
if (moduledefinition.Dependencies != "")
{
if (moduledefinition.Dependencies != "")
foreach (string dependency in moduledefinition.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
foreach (string dependency in moduledefinition.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
string assemblyname = dependency.Replace(".dll", "");
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
{
string assemblyname = dependency.Replace(".dll", "");
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");
Assembly.Load(bytes);
}
// download assembly from server and load
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
Assembly.Load(bytes);
}
}
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");
Assembly.Load(bytes);
}
}
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");
Assembly.Load(bytes);
}
}

return moduledefinitions.OrderBy(item => item.Name).ToList();
}
}
Expand Down
Loading

0 comments on commit d8d09ed

Please sign in to comment.