This commit is contained in:
Patrick Haßel 2024-10-22 15:54:47 +02:00
commit 5c493be073
28 changed files with 15312 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/target/
/.idea/
/*.iws
/*.iml
/*.ipr
/*.db

8
application.properties Normal file
View File

@ -0,0 +1,8 @@
#logging.level.de.ph87=DEBUG
#-
spring.datasource.url=jdbc:h2:./database;AUTO_SERVER=TRUE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
#-
spring.jpa.hibernate.ddl-auto=update

127
pom.xml Normal file
View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.ph87</groupId>
<artifactId>Tools</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.4</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>npm-install</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>ng-build</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
<executable>ng</executable>
<arguments>
<argument>build</argument>
<argument>--base-href</argument>
<argument>/Tools/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>scp</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>/usr/bin/scp</executable>
<arguments>
<argument>-P</argument>
<argument>2222</argument>
<argument>${project.build.directory}/${project.artifactId}.war</argument>
<argument>root@app.ph87.de:/srv/app.ph87.de/tomcat/webapps/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/classes/resources/</outputDirectory>
<resources>
<resource>
<directory>src/main/angular/dist/angular/browser/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
# noinspection EditorConfigKeyCorrectness
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false

42
src/main/angular/.gitignore vendored Normal file
View File

@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

View File

@ -0,0 +1,27 @@
# Angular
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.3.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.

View File

@ -0,0 +1,124 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "less",
"skipTests": true
},
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:guard": {
"skipTests": true
},
"@schematics/angular:interceptor": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:resolver": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/angular",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "less",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.less"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kB",
"maximumError": "4kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "angular:build:production"
},
"development": {
"buildTarget": "angular:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "less",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.less"
],
"scripts": []
}
}
}
}
}
}

14581
src/main/angular/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
{
"name": "angular",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.0",
"@angular/common": "^18.2.0",
"@angular/compiler": "^18.2.0",
"@angular/core": "^18.2.0",
"@angular/forms": "^18.2.0",
"@angular/platform-browser": "^18.2.0",
"@angular/platform-browser-dynamic": "^18.2.0",
"@angular/router": "^18.2.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.3",
"@angular/cli": "^18.2.3",
"@angular/compiler-cli": "^18.2.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.2.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.5.2"
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="800px" height="800px" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
<path d="M5.3 10.4c-.9.9-.9 2.3 0 3.1l43 43c.9.9 2.3.9 3.1 0l3.1-3.1c.9-.9.9-2.3 0-3.1l-43-43c-.9-.9-2.3-.9-3.1 0l-3.1 3.1" fill="#89664c"></path>
<path fill="#3e4347" d="M27.4 11.4c.9.9.9 2.3 0 3.2L12.6 29.4c-.9.9-2.3.9-3.2 0l-6.7-6.7c-.9-.9-.9-2.3 0-3.2L17.5 4.7c.9-.9 2.3-.9 3.2 0l6.7 6.7"></path>
<path fill="#3e4347" d="M41.4 31L36 25.8l5.4-5.2l5.4 5.2z"></path>
<path fill="#94989b" d="M57.2 19.7l-9.5-9.2c-.3-.3-.9-.3-1.3 0l-3.5 3.4l-3.5 3.4c-.3.3-.3.9 0 1.2l9.5 9.2c.3.3.9.3 1.3 0l7.1-6.9c.3-.3.3-.8-.1-1.1"></path>
<path fill="#94989b" d="M41.3 4.3c-.3-.3-.9-.3-1.3 0l-7 6.9c-.3.3-.3.9 0 1.2l2 1.9l8.4-8.1c-.1 0-2.1-1.9-2.1-1.9"></path>
<path fill="#3e4347" d="M42.9 13.9l3.5-3.4s-2 1.1-2.3-1.8c-.1-1.2-.4-1.9-.8-2.4l-8.3 8c.4.3 1.2.6 2.4.7c3.1.3 1.9 2.3 1.9 2.3l3.6-3.4"></path>
<path fill="#3e4347" d="M58 41.1c9.7-9.4-1.1-19.8-1.1-19.8l-6.3 6.1s7.9 5.9 5.7 13.3c-.3.9-.7 1.6-.5 1.9c.3.3 1.5-.8 2.2-1.5"></path>
<path fill="#f2b200" d="M38.7 28.4L35.3 25s-2.8 1.7-5.9 4.7c-3.4 3.3-5.3 7.7-9.8 12c-6.8 6.6-10.1 8.1-12.8 10c-1 .7-.9.9 0 1.8l2.9 2.8l29-27.9"></path>
<path fill="#ffce31" d="M38.7 28.4l3.5 3.4s-1.8 2.7-4.9 5.7c-3.4 3.3-7.9 5.2-12.4 9.5c-6.8 6.6-8.4 9.6-10.5 12.3c-.8 1-.9.9-1.8 0l-2.9-2.8l29-28.1"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1 @@
<router-outlet/>

View File

@ -0,0 +1,12 @@
import {Component} from '@angular/core';
import {RouterOutlet} from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
templateUrl: './app.component.html',
styleUrl: './app.component.less'
})
export class AppComponent {
}

View File

@ -0,0 +1,8 @@
import {ApplicationConfig, provideZoneChangeDetection} from '@angular/core';
import {provideRouter} from '@angular/router';
import {routes} from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [provideZoneChangeDetection({eventCoalescing: true}), provideRouter(routes)]
};

View File

@ -0,0 +1,7 @@
import {Routes} from '@angular/router';
import {SolarComponent} from './solar/solar.component';
export const routes: Routes = [
{path: 'Solar', component: SolarComponent},
{path: '**', redirectTo: '/Solar'},
];

View File

@ -0,0 +1,15 @@
export class Mass {
modelMeters: number;
constructor(
readonly name: string,
readonly diameterMeters: number,
readonly massKg: number,
readonly moons: Mass[],
modeMeters?: number,
) {
this.modelMeters = modeMeters || diameterMeters;
}
}

View File

@ -0,0 +1,11 @@
<select [(ngModel)]="pivot">
<option *ngFor="let mass of masses" [ngValue]="mass">{{ mass.name }}</option>
</select>
<input type="number" [(ngModel)]="pivot.modelMeters" (ngModelChange)="ngOnInit()">m
<table>
<tr *ngFor="let mass of masses">
<th>{{ mass.name }}</th>
<td>{{ doPrefix(mass.diameterMeters, 'm', 1000, 'k', 0) }}</td>
<td>{{ unit(mass.modelMeters, 'm') }}</td>
</tr>
</table>

View File

@ -0,0 +1,19 @@
table {
width: 100%;
}
th {
text-align: left;
}
td {
text-align: right;
}
@media (min-width: 1000px) {
table {
width: 400px;
}
}

View File

@ -0,0 +1,90 @@
import {Component, OnInit} from '@angular/core';
import {DecimalPipe, NgForOf} from "@angular/common";
import {FormsModule} from "@angular/forms";
import {Mass} from "./Mass";
const PREFIXES_POSITIVE: string[] = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];
const PREFIXES_NEGATIVE: string[] = ['', 'm', 'µ', 'n', 'p', 'f', 'a', 'z', 'y', 'r', 'q'];
@Component({
selector: 'app-solar',
standalone: true,
imports: [
NgForOf,
DecimalPipe,
FormsModule
],
templateUrl: './solar.component.html',
styleUrl: './solar.component.less'
})
export class SolarComponent implements OnInit {
protected readonly jupiter = new Mass('Jupiter', 139820000, 1.898e30, [
new Mass('Io', 3643000, 8.932e25, []),
new Mass('Europa', 3121600, 4.799e25, []),
new Mass('Ganymede', 5262400, 1.4819e26, []),
new Mass('Callisto', 4820600, 1.0759e26, [])
], 0.18);
protected masses: Mass[] = [
new Mass('Sonne', 1392700000, 1.989e33, []),
new Mass('Merkur', 4879400, 3.285e26, []),
new Mass('Venus', 12104000, 4.867e27, []),
new Mass('Erde', 12742000, 5.972e27, [
new Mass('Mond', 3474800, 7.342e25, [])
]),
new Mass('Mars', 6779000, 6.39e26, [
new Mass('Phobos', 22533, 1.0659e19, []),
new Mass('Deimos', 12400, 1.4762e18, [])
]),
this.jupiter,
new Mass('Saturn', 116460000, 5.683e29, [
new Mass('Titan', 5149460, 1.3452e26, []),
new Mass('Enceladus', 504200, 1.08e23, [])
]),
new Mass('Uranus', 50724000, 8.681e28, [
new Mass('Miranda', 471600, 6.59e22, []),
new Mass('Ariel', 1157800, 1.35e24, []),
new Mass('Umbriel', 1169400, 1.17e24, []),
new Mass('Titania', 1576800, 3.42e24, []),
new Mass('Oberon', 1522800, 3.01e24, [])
]),
new Mass('Neptun', 49244000, 1.024e29, [
new Mass('Triton', 2706800, 2.14e25, [])
])
];
protected pivot: Mass = this.jupiter;
protected divisor: number = 1;
protected prefix = "";
ngOnInit() {
const scale = this.pivot.modelMeters / this.pivot.diameterMeters;
this.masses.filter(m => m != this.pivot).forEach(m => m.modelMeters = scale * m.diameterMeters);
this.updatePrefix();
}
private updatePrefix() {
const exponent = Math.floor(Math.log10(this.jupiter.modelMeters));
const prefixGroup = Math.floor(exponent / 3);
if (prefixGroup <= 0) {
this.prefix = PREFIXES_NEGATIVE[-prefixGroup];
} else {
this.prefix = PREFIXES_POSITIVE[prefixGroup];
}
const exponentFromGroup = prefixGroup * 3;
this.divisor = Math.pow(10, exponentFromGroup);
}
unit(value: number, unit: string) {
return this.doPrefix(value, unit, this.divisor, this.prefix, 2);
}
doPrefix(value: number, unit: string, divisor: number, prefix: string, digits: number) {
return (value / divisor).toFixed(digits) + ' ' + prefix + unit;
}
}

View File

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Patrix Tools</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--suppress HtmlUnknownTarget -->
<link rel="icon" type="image/svg" href="favicon.svg">
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@ -0,0 +1,6 @@
import {bootstrapApplication} from '@angular/platform-browser';
import {appConfig} from './app/app.config';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));

View File

@ -0,0 +1,25 @@
body {
font-family: sans-serif;
font-size: 4vw;
}
div {
box-sizing: border-box;
overflow: hidden;
}
a {
text-decoration: none;
}
table {
border-collapse: collapse;
}
@media (min-width: 1000px) {
body {
font-size: 18px;
}
}

View File

@ -0,0 +1,15 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

View File

@ -0,0 +1,33 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"isolatedModules": true,
"esModuleInterop": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"lib": [
"ES2022",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

View File

@ -0,0 +1,15 @@
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

View File

@ -0,0 +1,14 @@
package de.ph87.tools;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class Backend extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Backend.class, args);
}
}

View File

@ -0,0 +1,39 @@
package de.ph87.tools.web;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.resource.PathResourceResolver;
import java.io.IOException;
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*").allowedMethods("*");
}
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/**")
.addResourceLocations("classpath:/resources/")
.resourceChain(true)
.addResolver(new PathResourceResolver() {
protected Resource getResource(@NonNull String resourcePath, @NonNull Resource roomLocation) throws IOException {
final Resource requestedResource = roomLocation.createRelative(resourcePath);
return requestedResource.exists() && requestedResource.isReadable() ? requestedResource : new ClassPathResource("/resources/index.html");
}
});
}
}

View File

@ -0,0 +1,6 @@
logging.level.root=WARN
logging.level.de.ph87=INFO
#-
spring.jackson.serialization.indent_output=true
#-
spring.main.banner-mode=off