redirect to the setup in case zero has not been set up
This commit is contained in:
+23
-12
@@ -1,30 +1,41 @@
|
||||
namespace zero.Core
|
||||
{
|
||||
public class BackofficeConfiguration : IBackofficeConfiguration
|
||||
public class ZeroConfiguration : IZeroConfiguration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ZeroVersion { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DefaultLanguage { get; set; }
|
||||
|
||||
|
||||
public string SystemUserId { get; set; }
|
||||
|
||||
public FoldersConfig Folders { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RavenConfig Raven { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public LoggingConfig Logging { get; set; }
|
||||
}
|
||||
|
||||
public interface IBackofficeConfiguration
|
||||
public interface IZeroConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// The currently active version
|
||||
/// This should not be set manually, as it is used for setup and migrations and incremented automatically
|
||||
/// </summary>
|
||||
string ZeroVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default language ISO code
|
||||
/// </summary>
|
||||
string DefaultLanguage { get; set; }
|
||||
|
||||
|
||||
string SystemUserId { get; set; }
|
||||
|
||||
FoldersConfig Folders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// RavenDB configuration data
|
||||
/// </summary>
|
||||
RavenConfig Raven { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Logging
|
||||
/// </summary>
|
||||
LoggingConfig Logging { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace zero.Core.Identity
|
||||
/// <summary>
|
||||
/// Configuration
|
||||
/// </summary>
|
||||
protected IBackofficeConfiguration Config { get; private set; }
|
||||
protected IZeroConfiguration Config { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Currently logged-in user
|
||||
@@ -29,7 +29,7 @@ namespace zero.Core.Identity
|
||||
protected IBackofficeUser Current { get; private set; }
|
||||
|
||||
|
||||
public BackofficeUserStore(IDocumentStore raven, IBackofficeConfiguration config, IBackofficeUser currentUser)
|
||||
public BackofficeUserStore(IDocumentStore raven, IZeroConfiguration config, IBackofficeUser currentUser)
|
||||
{
|
||||
Raven = raven;
|
||||
Config = config;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core;
|
||||
|
||||
namespace zero.Web.Controllers
|
||||
{
|
||||
public abstract class BackofficeController : Controller
|
||||
{
|
||||
protected IZeroConfiguration Configuration { get; set; }
|
||||
|
||||
|
||||
public BackofficeController(IZeroConfiguration config)
|
||||
{
|
||||
Configuration = config;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using zero.Core;
|
||||
using zero.Core.Extensions;
|
||||
|
||||
namespace zero.Web.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class IndexController : BackofficeController
|
||||
{
|
||||
public IndexController(IZeroConfiguration config) : base(config)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("/Index.cshtml");
|
||||
if (Configuration.ZeroVersion.IsNullOrEmpty())
|
||||
{
|
||||
return RedirectToAction("Index", "Setup");
|
||||
}
|
||||
|
||||
return View("/Views/Index.cshtml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace zero.Web
|
||||
{
|
||||
return Host
|
||||
.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((context, config) =>
|
||||
{
|
||||
config.AddJsonFile("zeroSettings.json", optional: false, reloadOnChange: true);
|
||||
config.AddJsonFile($"zeroSettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
||||
})
|
||||
.ConfigureLogging((context, builder) =>
|
||||
{
|
||||
IConfigurationSection configuration = context.Configuration.GetSection("Logging");
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta name="author" content="brothers">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="expires" content="0">
|
||||
<base href="~/">
|
||||
<environment exclude="Development">
|
||||
<link href="~/Assets/app.css" rel="stylesheet" asp-append-version="true" />
|
||||
</environment>
|
||||
<title>zero</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="~/Assets/setup.js" asp-append-version="true"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using zero.Core;
|
||||
using zero.Web.Controllers;
|
||||
|
||||
namespace zero.Web.Setup
|
||||
{
|
||||
[AllowAnonymous]
|
||||
public class SetupController : BackofficeController
|
||||
{
|
||||
public SetupController(IZeroConfiguration config) : base(config)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("/Setup/Setup.cshtml");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import Setup from './setup.vue';
|
||||
//import 'filter/generic.js'
|
||||
//import 'directive/filedrop.js'
|
||||
|
||||
new Vue(Setup).$mount('#app');
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div class="app">
|
||||
setup
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
|
||||
data: () => ({
|
||||
count: 0
|
||||
}),
|
||||
|
||||
mounted ()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
add()
|
||||
{
|
||||
this.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
+9
-9
@@ -43,10 +43,10 @@ namespace zero.Web
|
||||
//CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
|
||||
|
||||
// build and register app configuration
|
||||
services.Configure<IBackofficeConfiguration>(config);
|
||||
BackofficeConfiguration appConfig = new BackofficeConfiguration();
|
||||
services.Configure<IZeroConfiguration>(config);
|
||||
ZeroConfiguration appConfig = new ZeroConfiguration();
|
||||
ConfigurationBinder.Bind(config, appConfig);
|
||||
services.AddSingleton<IBackofficeConfiguration>(appConfig);
|
||||
services.AddSingleton<IZeroConfiguration>(appConfig);
|
||||
|
||||
// add zero core
|
||||
//services.AddCore(appConfig, env);
|
||||
@@ -119,18 +119,18 @@ namespace zero.Web
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
// routes for API
|
||||
endpoints.MapControllerRoute(
|
||||
name: "api",
|
||||
pattern: "api/{controller=Index}/{action=Index}/{id?}"
|
||||
);
|
||||
|
||||
// default routes
|
||||
endpoints.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Index}/{action=Index}/{id?}"
|
||||
);
|
||||
|
||||
// routes for API
|
||||
endpoints.MapControllerRoute(
|
||||
name: "api",
|
||||
pattern: "api/{controller=Index}/{action=Index}/{id?}"
|
||||
);
|
||||
|
||||
// fallbacks for SPA
|
||||
endpoints.MapFallbackToController("Index", "Index");
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<environmentVariables>
|
||||
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44308" />
|
||||
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
|
||||
<environmentVariable name="COMPLUS_ForceENC" value="1" />
|
||||
</environmentVariables>
|
||||
</aspNetCore>
|
||||
<rewrite>
|
||||
|
||||
@@ -5,7 +5,10 @@ module.exports = {
|
||||
|
||||
// entry point of the app
|
||||
context: __dirname,
|
||||
entry: { app: './app.js' },
|
||||
entry: {
|
||||
app: './app.js',
|
||||
setup: './Setup/setup.js'
|
||||
},
|
||||
|
||||
// dev environment (gets overwritten by prod.js)
|
||||
mode: 'development',
|
||||
@@ -14,7 +17,7 @@ module.exports = {
|
||||
// output paths
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'wwwroot/Assets'),
|
||||
filename: 'app.js',
|
||||
filename: '[name].js',
|
||||
publicPath: '/Assets/'
|
||||
},
|
||||
|
||||
@@ -24,6 +27,7 @@ module.exports = {
|
||||
alias: {
|
||||
'vue$': 'vue/dist/vue.esm.js',
|
||||
'zero': path.join(__dirname, 'App'),
|
||||
'zerosetup': path.join(__dirname, 'Setup'),
|
||||
'@': __dirname
|
||||
}
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -16,8 +16,8 @@
|
||||
<Content Remove="package.json" />
|
||||
<None Include="package.json" />
|
||||
<None Remove="Logs/*" />
|
||||
<Content Remove="appsettings.Development.json" />
|
||||
<None Include="appsettings.Development.json" />
|
||||
<None Include="zeroSettings.json" />
|
||||
<None Include="zeroSettings.Development.json" />
|
||||
<Content Remove="wwwroot/Temp/**" />
|
||||
<Content Remove="wwwroot/Media/**" />
|
||||
<Content Remove="web.release.config" />
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
{
|
||||
"SystemUserId": "system",
|
||||
"ZeroVersion": null,
|
||||
|
||||
"Folders": {
|
||||
"Temp": "Temp"
|
||||
},
|
||||
"DefaultLanguage": "en-US",
|
||||
|
||||
"Raven": {
|
||||
"Url": "http://127.0.0.1:9800",
|
||||
Reference in New Issue
Block a user