Commit 11984df4 authored by GDBSol's avatar GDBSol
Browse files

Server & Client: Initial commit

parent a686c66a
.vs/*
.vs/*/**
packages/*
packages/**/*
RuPublic.Server/wwwroot/*
RuPublic.WebApplication/node_modules/*
build/
**/bin
**/obj
**/Log
*.tmp
*.suo
*.csproj.user
**/project.lock.json

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RuPublic.Server", "RuPublic.Server\RuPublic.Server.csproj", "{A8B51A95-7A93-49F6-9132-3077B9C5A132}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8B51A95-7A93-49F6-9132-3077B9C5A132}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8B51A95-7A93-49F6-9132-3077B9C5A132}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8B51A95-7A93-49F6-9132-3077B9C5A132}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8B51A95-7A93-49F6-9132-3077B9C5A132}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F2A6EE3F-C20E-4D9F-A8F2-DC93BC76FCBD}
EndGlobalSection
EndGlobal
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ProxyKit;
using RuPublic.Server.Infrastructure.Configurations.Models;
using RuPublic.Server.Infrastructure.Middlewares;
namespace RuPublic.Server.Infrastructure.Configurations
{
public static class InternalServicesExtensions
{
public static void ConfigureMiddlewares(this IApplicationBuilder app)
{
app.UseMiddleware<RedirectionMiddleware>();
}
public static void GetSections(this IServiceCollection services, IConfiguration Configuration)
{
services.Configure<ProxyPaths>(Configuration.GetSection("ProxyPaths"));
}
public static void ConfigureProxy(this IApplicationBuilder app, ProxyPaths proxyPaths)
{
var options = new RewriteOptions()
.AddRewrite(@"api/(.*)", "api/$1", skipRemainingRules: true);
var emsOptions = new RewriteOptions()
.AddRewrite(@"api/ems/(.*)", "api/$1", skipRemainingRules: true);
app.UseWhen(
context => !context.Request.Path.Value.Contains("/api/ems") && context.Request.Path.Value.Contains("/api"),
builder => builder
.UseRewriter(options)
.RunProxy(context => context
.ForwardTo(proxyPaths.Server)
.AddXForwardedHeaders()
.Send()
));
app.UseWhen(
context => context.Request.Path.Value.Contains("/api/ems"),
builder => builder
.UseRewriter(emsOptions)
.RunProxy(context => context
.ForwardTo(proxyPaths.Ems)
.AddXForwardedHeaders()
.Send()
));
}
}
}
namespace RuPublic.Server.Infrastructure.Configurations.Models
{
public class ProxyPaths
{
public string Server { get; set; }
public string Ems { get; set; }
}
}
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Threading.Tasks;
namespace RuPublic.Server.Infrastructure.Middlewares
{
public class RedirectionMiddleware
{
private readonly RequestDelegate next;
public RedirectionMiddleware(RequestDelegate next)
{
this.next = next;
}
public async Task Invoke(HttpContext context)
{
await next(context);
if (context.Response.StatusCode == 404 &&
!context.Request.Path.Value.Contains("/api/") &&
!Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = new PathString("/");
await next(context);
}
}
}
}
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Public.Server
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
}
}
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iis": {
"applicationUrl": "http://localhost:10213",
"sslPort": 0
},
"iisExpress": {
"applicationUrl": "http://localhost:52166",
"sslPort": 44340
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Public.Server": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"IIS": {
"commandName": "IIS",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ProxyKit" Version="2.3.4" />
</ItemGroup>
</Project>
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using ProxyKit;
using RuPublic.Server.Infrastructure.Configurations;
using RuPublic.Server.Infrastructure.Configurations.Models;
namespace Public.Server
{
public class Startup
{
public IWebHostEnvironment Environment { get; }
public Startup(
IConfiguration configuration,
IWebHostEnvironment environment
)
{
Configuration = configuration;
this.Environment = environment;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.GetSections(Configuration);
if (Environment.IsProduction())
{
services.AddHttpsRedirection(options => {
options.RedirectStatusCode = StatusCodes.Status308PermanentRedirect;
options.HttpsPort = 443;
});
}
services.AddProxy();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions<ProxyPaths> proxyPaths)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.ConfigureMiddlewares();
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseStaticFiles(new StaticFileOptions {
OnPrepareResponse = context => {
if (context.File.Name == "index.html")
{
if (context.Context.Response.Headers.ContainsKey("Cache-Control"))
{
context.Context.Response.Headers.Remove("Cache-Control");
}
context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
context.Context.Response.Headers.Add("Expires", "-1");
}
}
});
app.ConfigureProxy(proxyPaths.Value);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="bin\Debug\net5.0\RuPublic.Server.exe" arguments="" stdoutLogEnabled="false" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
\ No newline at end of file
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
{
"js/ts.implicitProjectConfig.experimentalDecorators": true
}
\ No newline at end of file
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"rupublic-web-application": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "../RuPublic.Server/wwwroot",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/favicon.ico",
"src/assets",
"src/configuration.json",
{
"glob": "**/DocsUtilsSetup*.exe",
"input": "node_modules/@abb/ab-docs-utils/assets",
"output": "assets"
}
],
"styles": [
"node_modules/@fortawesome/fontawesome-free/css/all.min.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/flag-icon-css/css/flag-icon.min.css",
"src/assets/styles.css",
"node_modules/ol/ol.css"
],
"scripts": [],
"allowedCommonJsDependencies": [
"file-saver",
"lodash",
"ng-inline-svg"
]
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "rupublic-web-application:build",
"open": true,
"port": 4213,
"proxyConfig": "src/proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "rupublic-web-application:build:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "rupublic-web-application"
}
\ No newline at end of file
This diff is collapsed.
{
"name": "rupublic-web-application",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "~10.2.0",
"@angular/common": "~10.2.0",
"@angular/compiler": "~10.2.0",
"@angular/core": "~10.2.0",
"@angular/forms": "~10.2.0",
"@angular/localize": "~10.2.0",
"@angular/platform-browser": "~10.2.0",
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"@fortawesome/fontawesome-free": "^5.9.0",
"@ng-bootstrap/ng-bootstrap": "^8.0.1",
"bootstrap": "^4.5.0",
"file-saver": "^2.0.5",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"ng-recaptcha": "^7.0.1",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@abb/ab-docs-utils": "10.0.3",
"@abb/angular-lib": "^10.0.31",
"@angular-devkit/build-angular": "~0.1002.0",
"@angular/cli": "~10.2.0",
"@angular/compiler-cli": "~10.2.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@types/node": "^12.11.1",
"@types/ol": "^6.4.2",
"flag-icon-css": "^3.5.0",
"ng-inline-svg": "8.4.1",
"ol": "^6.5.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './root/home.component';
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: 'home'
},
{
path: 'home',
component: HomeComponent,
data: {
title: 'ROOT.HOME_PAGE'
}
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'})],
exports: [RouterModule]
})
export class AppRoutingModule { }
<div #topElement></div>
<div class="page">
<ru-header (languageChange)="changeLang($event)"></ru-header>
<section>
<router-outlet></router-outlet>
</section>
<ru-footer [currentLanguage]="currentLanguage"
(scrollToTopEmitter)="scrollToTop($event)"></ru-footer>
</div>
<div #bottomElement></div>
\ No newline at end of file
import { ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Configuration } from 'src/infrastructure/configuration/configuration';
import { filter } from 'rxjs/operators';
import { Title } from '@angular/platform-browser';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
currentLanguage = null;
@ViewChild('topElement') headerElement: ElementRef;