Merge pull request #28 from oqtane/master

sync
This commit is contained in:
Shaun Walker 2020-05-28 10:30:12 -04:00 committed by GitHub
commit 19f8b3d429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 27 deletions

View File

@ -9,7 +9,11 @@
}
else
{
<ActionLink Action="Add" Text="Add User" />
<ActionLink Action="Add" Text="Add User"/>
<div class="d-flex p-1">
<input class="form-control mr-4" @bind="@search"/><button class="btn btn-outline-primary ml-1" @onclick="OnSearch">Search</button>
</div>
<Pager Items="@userroles">
<Header>
@ -28,16 +32,32 @@ else
}
@code {
private List<UserRole> allroles;
private List<UserRole> userroles;
private string search;
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
protected override async Task OnInitializedAsync()
{
userroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
userroles = userroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList();
allroles = await UserRoleService.GetUserRolesAsync(PageState.Site.SiteId);
userroles = allroles.Where(item => item.Role.Name == Constants.RegisteredRole).ToList();
}
private void OnSearch()
{
userroles = allroles
.Where(item => item.Role.Name == Constants.RegisteredRole &&
(
item.User.Username.Contains(search, StringComparison.OrdinalIgnoreCase) ||
item.User.Email.Contains(search, StringComparison.OrdinalIgnoreCase) ||
item.User.DisplayName.Contains(search, StringComparison.OrdinalIgnoreCase)
)
)
.ToList();
}
private async Task DeleteUser(UserRole UserRole)
{
try
@ -56,4 +76,4 @@ else
AddModuleMessage(ex.Message, MessageType.Error);
}
}
}
}

View File

@ -17,6 +17,7 @@
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Not for production use.</PackageReleaseNotes>
<RootNamespace>Oqtane</RootNamespace>
<IsPackable>true</IsPackable>
</PropertyGroup>
<ItemGroup>
@ -37,5 +38,4 @@
<ItemGroup>
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
</ItemGroup>
</Project>

View File

@ -1,6 +1,5 @@
DEL "*.nupkg"
nuget.exe pack Oqtane.Framework.nuspec
nuget.exe pack Oqtane.Client.nuspec
nuget.exe pack Oqtane.Server.nuspec
nuget.exe pack Oqtane.Shared.nuspec
dotnet clean -c Release ..\Oqtane.sln
dotnet build -c Release ..\Oqtane.sln
dotnet pack -o .\ -c Release ..\Oqtane.sln
nuget.exe pack Oqtane.Framework.nuspec

View File

@ -47,7 +47,7 @@ namespace Oqtane.Controllers
}
// GET api/<controller>/name/xxx?sync=yyyyMMddHHmmssfff
[HttpGet("name/{name}")]
[HttpGet("name/{**name}")]
public Alias Get(string name, string sync)
{
List<Alias> aliases = _aliases.GetAliases().ToList(); // cached

View File

@ -15,6 +15,7 @@
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Not for production use.</PackageReleaseNotes>
<RootNamespace>Oqtane</RootNamespace>
<IsPackable>true</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\Modules\Templates\**" />
@ -43,4 +44,4 @@
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
<ProjectReference Include="..\Oqtane.Shared\Oqtane.Shared.csproj" />
</ItemGroup>
</Project>
</Project>

View File

@ -1,5 +1,6 @@
using Oqtane.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
@ -15,7 +16,7 @@ namespace Oqtane.Shared
{
if (type == null) return null;
var assemblyFullName = type.Assembly.FullName;
var assemblyName = assemblyFullName.Substring(0, assemblyFullName.IndexOf(",", StringComparison.Ordinal));
var assemblyName = assemblyFullName.Substring(0, assemblyFullName.IndexOf(",", StringComparison.Ordinal));
return $"{type.Namespace}, {assemblyName}";
}
@ -24,10 +25,10 @@ namespace Oqtane.Shared
var uriBuilder = new UriBuilder
{
Path = !string.IsNullOrEmpty(alias)
? (!string.IsNullOrEmpty(path))
? $"{alias}/{path}"
: $"{alias}"
: $"{path}",
? (!string.IsNullOrEmpty(path))
? $"{alias}/{path}"
: $"{alias}"
: $"{path}",
Query = parameters
};
@ -44,6 +45,7 @@ namespace Oqtane.Shared
path += $"/{action}";
}
}
return NavigateUrl(alias, path, parameters);
}
@ -98,6 +100,7 @@ namespace Oqtane.Shared
// remove assembly if fully qualified type
typename = typename.Substring(0, typename.IndexOf(","));
}
// segment 0 is the last segment, segment 1 is the second to last segment, etc...
string[] segments = typename.Split('.');
string name = "";
@ -105,6 +108,7 @@ namespace Oqtane.Shared
{
name = segments[segments.Length - (segment + 1)];
}
return name;
}
@ -142,11 +146,14 @@ namespace Oqtane.Shared
stringBuilder.Append('-');
prevdash = true;
}
break;
}
}
result = stringBuilder.ToString().Trim('-');
}
return result;
}
@ -236,25 +243,28 @@ namespace Oqtane.Shared
if (string.IsNullOrEmpty(email)) return false;
return Regex.IsMatch(email,
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
}
public static string PathCombine(params string[] segments)
{
var separators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
var separators = new char[] {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar};
for (int i =1;i < segments.Length; i++){
if(Path.IsPathRooted(segments[i])){
for (int i = 1; i < segments.Length; i++)
{
if (Path.IsPathRooted(segments[i]))
{
segments[i] = segments[i].TrimStart(separators);
if(String.IsNullOrEmpty(segments[i])){
segments[i]=" ";
if (String.IsNullOrEmpty(segments[i]))
{
segments[i] = " ";
}
}
}
return Path.Combine(segments).TrimEnd();
return Path.Combine(segments).TrimEnd();
}
public static bool IsPathValid(this Folder folder)
@ -273,5 +283,54 @@ namespace Oqtane.Shared
!Constants.InvalidFileNameEndingChars.Any(name.EndsWith) &&
!Constants.ReservedDevices.Split(',').Contains(name.ToUpper().Split('.')[0]));
}
public static bool TryGetQueryValue(
this Uri uri,
string key,
out string value,
string defaultValue = null)
{
value = defaultValue;
string query = uri.Query;
return !string.IsNullOrEmpty(query) && Utilities.ParseQueryString(query).TryGetValue(key, out value);
}
public static bool TryGetQueryValueInt(
this Uri uri,
string key,
out int value,
int defaultValue = 0)
{
value = defaultValue;
string s;
return uri.TryGetQueryValue(key, out s, (string) null) && int.TryParse(s, out value);
}
public static Dictionary<string, string> ParseQueryString(string query)
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(query))
{
query = query.Substring(1);
string str = query;
char[] separator = new char[1] {'&'};
foreach (string key in str.Split(separator, StringSplitOptions.RemoveEmptyEntries))
{
if (key != "")
{
if (key.Contains("="))
{
string[] strArray = key.Split('=', StringSplitOptions.None);
dictionary.Add(strArray[0], strArray[1]);
}
else
dictionary.Add(key, "true");
}
}
}
return dictionary;
}
}
}

View File

@ -15,6 +15,7 @@
<RepositoryType>Git</RepositoryType>
<PackageReleaseNotes>Not for production use.</PackageReleaseNotes>
<RootNamespace>Oqtane</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">