authorization changes
This commit is contained in:
		| @ -5,6 +5,8 @@ using System.Linq; | ||||
| using Microsoft.AspNetCore.Components; | ||||
| using System.Collections.Generic; | ||||
| using Oqtane.Shared; | ||||
| using System.Net; | ||||
| using System; | ||||
|  | ||||
| namespace Oqtane.Services | ||||
| { | ||||
| @ -37,6 +39,21 @@ namespace Oqtane.Services | ||||
|             return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString()); | ||||
|         } | ||||
|  | ||||
|         public async Task<Alias> GetAliasAsync(string Url) | ||||
|         { | ||||
|             Uri uri = new Uri(Url); | ||||
|             string name = uri.Authority; | ||||
|             if (uri.Segments.Count() > 1) | ||||
|             { | ||||
|                 name += "/" + uri.Segments[1]; | ||||
|             } | ||||
|             if (name.EndsWith("/"))  | ||||
|             {  | ||||
|                 name = name.Substring(0, name.Length - 1);  | ||||
|             } | ||||
|             return await http.GetJsonAsync<Alias>(apiurl + "/name/" + WebUtility.UrlEncode(name)); | ||||
|         } | ||||
|  | ||||
|         public async Task<Alias> AddAliasAsync(Alias alias) | ||||
|         { | ||||
|             return await http.PostJsonAsync<Alias>(apiurl, alias); | ||||
|  | ||||
| @ -87,6 +87,15 @@ namespace Oqtane.Services | ||||
|             }; | ||||
|             Folders = Folders.OrderBy(item => item.Order).ToList(); | ||||
|             GetPath(Folders, null); | ||||
|  | ||||
|             // add any non-hierarchical items to the end of the list | ||||
|             foreach(Folder folder in Folders) | ||||
|             { | ||||
|                 if (hierarchy.Find(item => item.FolderId == folder.FolderId) == null) | ||||
|                 { | ||||
|                     hierarchy.Add(folder); | ||||
|                 } | ||||
|             } | ||||
|             return hierarchy; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -10,6 +10,8 @@ namespace Oqtane.Services | ||||
|  | ||||
|         Task<Alias> GetAliasAsync(int AliasId); | ||||
|  | ||||
|         Task<Alias> GetAliasAsync(string Url); | ||||
|  | ||||
|         Task<Alias> AddAliasAsync(Alias Alias); | ||||
|  | ||||
|         Task<Alias> UpdateAliasAsync(Alias Alias); | ||||
|  | ||||
| @ -7,8 +7,10 @@ namespace Oqtane.Services | ||||
|     public interface IModuleDefinitionService | ||||
|     { | ||||
|         Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId); | ||||
|         Task<ModuleDefinition> GetModuleDefinitionAsync(int ModuleDefinitionId, int SiteId); | ||||
|         Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition); | ||||
|         Task InstallModuleDefinitionsAsync(); | ||||
|         Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId); | ||||
|         Task LoadModuleDefinitionsAsync(int SiteId); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -10,6 +10,7 @@ namespace Oqtane.Services | ||||
|         Task<Page> GetPageAsync(int PageId); | ||||
|         Task<Page> GetPageAsync(int PageId, int UserId); | ||||
|         Task<Page> AddPageAsync(Page Page); | ||||
|         Task<Page> AddPageAsync(int PageId, int UserId); | ||||
|         Task<Page> UpdatePageAsync(Page Page); | ||||
|         Task UpdatePageOrderAsync(int SiteId, int PageId, int? ParentId); | ||||
|         Task DeletePageAsync(int PageId); | ||||
|  | ||||
| @ -30,6 +30,10 @@ namespace Oqtane.Services | ||||
|  | ||||
|         Task UpdateUserSettingsAsync(Dictionary<string, string> UserSettings, int UserId); | ||||
|  | ||||
|         Task<Dictionary<string, string>> GetFolderSettingsAsync(int FolderId); | ||||
|  | ||||
|         Task UpdateFolderSettingsAsync(Dictionary<string, string> FolderSettings, int FolderId); | ||||
|  | ||||
|         Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId); | ||||
|  | ||||
|         Task UpdateSettingsAsync(Dictionary<string, string> Settings, string EntityName, int EntityId); | ||||
|  | ||||
| @ -30,8 +30,34 @@ namespace Oqtane.Services | ||||
|  | ||||
|         public async Task<List<ModuleDefinition>> GetModuleDefinitionsAsync(int SiteId) | ||||
|         { | ||||
|             // get list of modules from the server | ||||
|             List<ModuleDefinition> moduledefinitions = await http.GetJsonAsync<List<ModuleDefinition>>(apiurl + "?siteid=" + SiteId.ToString()); | ||||
|             return moduledefinitions.OrderBy(item => item.Name).ToList(); | ||||
|         } | ||||
|  | ||||
|         public async Task<ModuleDefinition> GetModuleDefinitionAsync(int ModuleDefinitionId, int SiteId) | ||||
|         { | ||||
|             return await http.GetJsonAsync<ModuleDefinition>(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString()); | ||||
|         } | ||||
|  | ||||
|         public async Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition) | ||||
|         { | ||||
|             await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition); | ||||
|         } | ||||
|  | ||||
|         public async Task InstallModuleDefinitionsAsync() | ||||
|         { | ||||
|             await http.GetJsonAsync<List<string>>(apiurl + "/install"); | ||||
|         } | ||||
|  | ||||
|         public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId) | ||||
|         { | ||||
|             await http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString()); | ||||
|         } | ||||
|  | ||||
|         public async Task LoadModuleDefinitionsAsync(int SiteId) | ||||
|         { | ||||
|             // get list of modules from the server | ||||
|             List<ModuleDefinition> moduledefinitions = await GetModuleDefinitionsAsync(SiteId); | ||||
|  | ||||
|             // get list of loaded assemblies on the client ( in the client-side hosting module the browser client has its own app domain ) | ||||
|             Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); | ||||
| @ -60,23 +86,6 @@ namespace Oqtane.Services | ||||
|                     Assembly.Load(bytes); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return moduledefinitions.OrderBy(item => item.Name).ToList(); | ||||
|         } | ||||
|  | ||||
|         public async Task UpdateModuleDefinitionAsync(ModuleDefinition ModuleDefinition) | ||||
|         { | ||||
|             await http.PutJsonAsync(apiurl + "/" + ModuleDefinition.ModuleDefinitionId.ToString(), ModuleDefinition); | ||||
|         } | ||||
|  | ||||
|         public async Task InstallModuleDefinitionsAsync() | ||||
|         { | ||||
|             await http.GetJsonAsync<List<string>>(apiurl + "/install"); | ||||
|         } | ||||
|  | ||||
|         public async Task DeleteModuleDefinitionAsync(int ModuleDefinitionId, int SiteId) | ||||
|         { | ||||
|             await http.DeleteAsync(apiurl + "/" + ModuleDefinitionId.ToString() + "?siteid=" + SiteId.ToString()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -49,6 +49,11 @@ namespace Oqtane.Services | ||||
|             return await http.PostJsonAsync<Page>(apiurl, Page); | ||||
|         } | ||||
|  | ||||
|         public async Task<Page> AddPageAsync(int PageId, int UserId) | ||||
|         { | ||||
|             return await http.PostJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString(), null); | ||||
|         } | ||||
|  | ||||
|         public async Task<Page> UpdatePageAsync(Page Page) | ||||
|         { | ||||
|             return await http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page); | ||||
| @ -92,6 +97,15 @@ namespace Oqtane.Services | ||||
|             }; | ||||
|             Pages = Pages.OrderBy(item => item.Order).ToList(); | ||||
|             GetPath(Pages, null); | ||||
|  | ||||
|             // add any non-hierarchical items to the end of the list | ||||
|             foreach (Page page in Pages) | ||||
|             { | ||||
|                 if (hierarchy.Find(item => item.PageId == page.PageId) == null) | ||||
|                 { | ||||
|                     hierarchy.Add(page); | ||||
|                 } | ||||
|             } | ||||
|             return hierarchy; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -86,6 +86,16 @@ namespace Oqtane.Services | ||||
|             await UpdateSettingsAsync(UserSettings, "User", UserId); | ||||
|         } | ||||
|  | ||||
|         public async Task<Dictionary<string, string>> GetFolderSettingsAsync(int FolderId) | ||||
|         { | ||||
|             return await GetSettingsAsync("Folder", FolderId); | ||||
|         } | ||||
|  | ||||
|         public async Task UpdateFolderSettingsAsync(Dictionary<string, string> FolderSettings, int FolderId) | ||||
|         { | ||||
|             await UpdateSettingsAsync(FolderSettings, "Folder", FolderId); | ||||
|         } | ||||
|  | ||||
|         public async Task<Dictionary<string, string>> GetSettingsAsync(string EntityName, int EntityId) | ||||
|         { | ||||
|             Dictionary<string, string> dictionary = new Dictionary<string, string>(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker