Merge pull request #14 from oqtane/master

sync
This commit is contained in:
Shaun Walker 2020-04-28 09:25:31 -04:00 committed by GitHub
commit 099fddf2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 54 deletions

View File

@ -29,13 +29,12 @@ namespace Oqtane.Themes.Controls
var actionList = new List<ActionViewModel>(); var actionList = new List<ActionViewModel>();
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions)) if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions))
{ {
actionList.Add(new ActionViewModel {Name = "Manage Settings", Action = async (u, m) => await Settings(u, m)});
actionList.Add(new ActionViewModel {Name = "Manage Settings", Action = async (u,m) => Settings(u, m)});
if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerManagerType != "") if (ModuleState.ModuleDefinition != null && ModuleState.ModuleDefinition.ServerManagerType != "")
{ {
actionList.Add(new ActionViewModel {Name = "Import Content", Action = async(u,m)=> EditUrl(m.ModuleId, "Import")}); actionList.Add(new ActionViewModel {Name = "Import Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Import")});
actionList.Add(new ActionViewModel {Name = "Export Content", Action = async(u,m)=> EditUrl(m.ModuleId, "Export")}); actionList.Add(new ActionViewModel {Name = "Export Content", Action = async (u, m) => await EditUrlAsync(u, m.ModuleId, "Export")});
} }
actionList.Add(new ActionViewModel {Name = "Delete Module", Action = async (u, m) => await DeleteModule(u, m)}); actionList.Add(new ActionViewModel {Name = "Delete Module", Action = async (u, m) => await DeleteModule(u, m)});
@ -69,9 +68,17 @@ namespace Oqtane.Themes.Controls
} }
} }
} }
return actionList; return actionList;
} }
private async Task<string> EditUrlAsync(string url, int moduleId, string import)
{
await Task.Yield();
EditUrl(moduleId, import);
return url;
}
protected async Task ModuleAction(ActionViewModel action) protected async Task ModuleAction(ActionViewModel action)
{ {
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions)) if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions))
@ -84,6 +91,7 @@ namespace Oqtane.Themes.Controls
{ {
url = await action.Action(url, pagemodule); url = await action.Action(url, pagemodule);
} }
NavigationManager.NavigateTo(url); NavigationManager.NavigateTo(url);
} }
} }
@ -107,8 +115,9 @@ namespace Oqtane.Themes.Controls
return url; return url;
} }
private string Settings(string url, PageModule pagemodule) private async Task<string> Settings(string url, PageModule pagemodule)
{ {
await Task.Yield();
url = EditUrl(pagemodule.ModuleId, "Settings"); url = EditUrl(pagemodule.ModuleId, "Settings");
return url; return url;
} }
@ -128,6 +137,7 @@ namespace Oqtane.Themes.Controls
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
return s; return s;
} }
private async Task<string> MoveUp(string s, PageModule pagemodule) private async Task<string> MoveUp(string s, PageModule pagemodule)
{ {
pagemodule.Order -= 3; pagemodule.Order -= 3;
@ -135,6 +145,7 @@ namespace Oqtane.Themes.Controls
await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane);
return s; return s;
} }
private async Task<string> MoveDown(string s, PageModule pagemodule) private async Task<string> MoveDown(string s, PageModule pagemodule)
{ {
pagemodule.Order += 3; pagemodule.Order += 3;
@ -148,7 +159,6 @@ namespace Oqtane.Themes.Controls
public string Name { set; get; } public string Name { set; get; }
public Func<string, PageModule, Task<string>> Action { set; get; } public Func<string, PageModule, Task<string>> Action { set; get; }
} }
} }
} }

View File

@ -179,31 +179,8 @@
}; };
var installation = await InstallationService.Install(config); var installation = await InstallationService.Install(config);
//TODO: Should be moved to Database manager
if (installation.Success) if (installation.Success)
{ {
Site site = new Site();
site.TenantId = -1; // will be populated on server
site.Name = "Default Site";
site.LogoFileId = null;
site.FaviconFileId = null;
site.DefaultThemeType = Constants.DefaultTheme;
site.DefaultLayoutType = Constants.DefaultLayout;
site.DefaultContainerType = Constants.DefaultContainer;
site.PwaIsEnabled = false;
site.PwaAppIconFileId = null;
site.PwaSplashIconFileId = null;
site.AllowRegistration = false;
site = await SiteService.AddSiteAsync(site, null);
User user = new User();
user.SiteId = site.SiteId;
user.Username = _hostUsername;
user.Password = _hostPassword;
user.Email = _hostEmail;
user.DisplayName = _hostUsername;
user = await UserService.AddUserAsync(user);
NavigationManager.NavigateTo("", true); NavigationManager.NavigateTo("", true);
} }
else else

View File

@ -44,6 +44,7 @@ namespace Oqtane.Controllers
_config.Reload(); _config.Reload();
} }
_databaseManager.BuildDefaultSite(config.Password, config.HostEmail);
installation.Success = true; installation.Success = true;
return installation; return installation;
} }

View File

@ -315,7 +315,7 @@ namespace Oqtane.Infrastructure
} }
} }
private void BuildDefaultSite(string password, string email) public void BuildDefaultSite(string password, string email)
{ {
using (var scope = _serviceScopeFactory.CreateScope()) using (var scope = _serviceScopeFactory.CreateScope())
{ {