diff --git a/.gitignore b/.gitignore
index b7bcada..aca8222 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,4 @@
/target/
/.idea/
/.jpb/
-/application.properties
+/*.db
\ No newline at end of file
diff --git a/application.properties b/application.properties
new file mode 100644
index 0000000..af357e3
--- /dev/null
+++ b/application.properties
@@ -0,0 +1,10 @@
+#logging.level.de.ph87.homeautomation=DEBUG
+#-
+spring.datasource.url=jdbc:h2:./Homeautomation;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=sa
+spring.datasource.password=password
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
+#-
+spring.jpa.hibernate.ddl-auto=update
+de.ph87.homeautomation.insert-demo-data=true
\ No newline at end of file
diff --git a/deploy.sh b/deploy.sh
deleted file mode 100755
index 198041f..0000000
--- a/deploy.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-cd "$(dirname "$0")" || exit 1
-
-mvn clean package spring-boot:repackage && \
-scp target/Homeautomation.jar media@10.0.0.50:/home/media/java/Homeautomation/Homeautomation.jar.update && \
-curl -m 2 -s http://10.0.0.50:8080/server/shutdown && echo "Server restarting..." || echo "Failed to restart server!"
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 50c1f6c..d5a6b84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,16 +7,17 @@
de.ph87
Homeautomation
1.0-SNAPSHOT
+ war
- 15
- 15
+ 11
+ 11
org.springframework.boot
spring-boot-starter-parent
- 2.3.6.RELEASE
+ 2.6.4
@@ -28,10 +29,6 @@
org.springframework.boot
spring-boot-starter-data-jpa
-
- org.springframework.boot
- spring-boot-starter-security
-
org.springframework.boot
spring-boot-configuration-processor
@@ -40,15 +37,24 @@
org.springframework.boot
spring-boot-starter-websocket
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ provided
+
com.h2database
h2
+
+ org.postgresql
+ postgresql
+
+
org.projectlombok
lombok
- 1.18.22
@@ -148,18 +154,6 @@
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- de.ph87.homeautomation.BackendApplication
-
-
-
-
-
diff --git a/src/main/angular/.gitignore b/src/main/angular/.gitignore
index 62a055a..812ec09 100644
--- a/src/main/angular/.gitignore
+++ b/src/main/angular/.gitignore
@@ -1,5 +1,8 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
-/node/
+
+### PATRICK
+/node
+### END
# compiled output
/dist
diff --git a/src/main/angular/package.json b/src/main/angular/package.json
index bc19afb..d10ccfd 100644
--- a/src/main/angular/package.json
+++ b/src/main/angular/package.json
@@ -4,7 +4,7 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
- "build": "ng build",
+ "build": "ng build --base-href /Homeautomation/",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
diff --git a/src/main/angular/src/app/api/api.service.ts b/src/main/angular/src/app/api/api.service.ts
index 51fb3f9..beaa1ac 100644
--- a/src/main/angular/src/app/api/api.service.ts
+++ b/src/main/angular/src/app/api/api.service.ts
@@ -5,6 +5,7 @@ import {environment} from "../../environments/environment";
import {Subject} from "rxjs";
import {CompatClient, Stomp} from "@stomp/stompjs";
import {Update} from "./Update";
+import {LocationStrategy} from "@angular/common";
export function NO_OP() {
}
@@ -21,7 +22,7 @@ function errorInterceptor(errorHandler: (error: any) => void): ((error: any) =>
}
@Injectable({
- providedIn: 'root'
+ providedIn: 'root',
})
export class ApiService {
@@ -30,10 +31,12 @@ export class ApiService {
private updateSubject = new Subject>();
constructor(
- private http: HttpClient,
+ protected readonly http: HttpClient,
+ protected readonly locationStrategy: LocationStrategy,
) {
+ const url = this.websocketUrl("websocket");
this.webSocketClient = Stomp.over(function () {
- return new WebSocket(ApiService.url("ws", "websocket"));
+ return new WebSocket(url);
});
this.webSocketClient.debug = () => null;
this.webSocketClient.connect({}, () => {
@@ -46,27 +49,31 @@ export class ApiService {
}
getItem(path: string, fromJson: (json: any) => T, next: (item: T) => void = NO_OP, error: (error: any) => void = NO_OP) {
- this.http.get(ApiService.url("http", path)).pipe(map(fromJson)).subscribe(next, errorInterceptor(error));
+ this.http.get(this.restUrl(path)).pipe(map(fromJson)).subscribe(next, errorInterceptor(error));
}
getList(path: string, fromJson: (json: any) => T, compare: (a: T, b: T) => number = NO_COMPARE, next: (list: T[]) => void = NO_OP, error: (error: any) => void = NO_OP) {
- this.http.get(ApiService.url("http", path)).pipe(map(list => list.map(fromJson).sort(compare))).subscribe(next, errorInterceptor(error));
+ this.http.get(this.restUrl(path)).pipe(map(list => list.map(fromJson).sort(compare))).subscribe(next, errorInterceptor(error));
}
postReturnNone(path: string, data: any, next: (_: void) => void = NO_OP, error: (error: any) => void = NO_OP) {
- this.http.post(ApiService.url("http", path), data).subscribe(next, errorInterceptor(error));
+ this.http.post(this.restUrl(path), data).subscribe(next, errorInterceptor(error));
}
postReturnItem(path: string, data: any, fromJson: (json: any) => T, next: (item: T) => void = NO_OP, error: (error: any) => void = NO_OP) {
- this.http.post(ApiService.url("http", path), data).pipe(map(fromJson)).subscribe(next, errorInterceptor(error));
+ this.http.post(this.restUrl(path), data).pipe(map(fromJson)).subscribe(next, errorInterceptor(error));
}
postReturnList(path: string, data: any, fromJson: (json: any) => T, next: (list: T[]) => void = NO_OP, error: (error: any) => void = NO_OP) {
- this.http.post(ApiService.url("http", path), data).pipe(map(list => list.map(fromJson))).subscribe(next, errorInterceptor(error));
+ this.http.post(this.restUrl(path), data).pipe(map(list => list.map(fromJson))).subscribe(next, errorInterceptor(error));
}
- private static url(schema: string, path: string): string {
- return schema + "://" + environment.host + ":" + environment.port + "/" + path;
+ private restUrl(path: string): string {
+ return environment.restBase + this.locationStrategy.getBaseHref() + path;
+ }
+
+ private websocketUrl(path: string) {
+ return environment.websocketBase + this.locationStrategy.getBaseHref() + path;
}
}
diff --git a/src/main/angular/src/app/shared/search/search.component.spec.ts b/src/main/angular/src/app/shared/search/search.component.spec.ts
index b17eced..3fe0a21 100644
--- a/src/main/angular/src/app/shared/search/search.component.spec.ts
+++ b/src/main/angular/src/app/shared/search/search.component.spec.ts
@@ -3,8 +3,8 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
import {SearchComponent} from './search.component';
describe('SearchComponent', () => {
- let component: SearchComponent;
- let fixture: ComponentFixture;
+ let component: SearchComponent;
+ let fixture: ComponentFixture>;
beforeEach(async () => {
await TestBed.configureTestingModule({
diff --git a/src/main/angular/src/environments/UrlHelper.ts b/src/main/angular/src/environments/UrlHelper.ts
new file mode 100644
index 0000000..53ae3e2
--- /dev/null
+++ b/src/main/angular/src/environments/UrlHelper.ts
@@ -0,0 +1,6 @@
+const secure: boolean = window.location.protocol === "https:";
+const host: string = window.location.host.split(":", 1)[0];
+
+export function getBaseUrl(protocol: string, port: number) {
+ return protocol + (secure ? 's' : '') + "://" + host + ":" + port;
+}
diff --git a/src/main/angular/src/environments/environment.prod.ts b/src/main/angular/src/environments/environment.prod.ts
index 87d85a3..f55fd2c 100644
--- a/src/main/angular/src/environments/environment.prod.ts
+++ b/src/main/angular/src/environments/environment.prod.ts
@@ -1,5 +1,7 @@
+import {getBaseUrl} from "./UrlHelper";
+
export const environment = {
production: true,
- host: window.location.host.split(":")[0],
- port: window.location.port,
+ restBase: '',
+ websocketBase: getBaseUrl('ws', parseInt(window.location.port)),
};
diff --git a/src/main/angular/src/environments/environment.ts b/src/main/angular/src/environments/environment.ts
index fa2442e..66de4ae 100644
--- a/src/main/angular/src/environments/environment.ts
+++ b/src/main/angular/src/environments/environment.ts
@@ -2,10 +2,12 @@
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
+import {getBaseUrl} from "./UrlHelper";
+
export const environment = {
production: false,
- host: window.location.host.split(":")[0],
- port: 8080,
+ restBase: getBaseUrl('http', 8080),
+ websocketBase: getBaseUrl('ws', 8080),
};
/*
diff --git a/src/main/angular/src/index.html b/src/main/angular/src/index.html
index d3d0ec5..aa06306 100644
--- a/src/main/angular/src/index.html
+++ b/src/main/angular/src/index.html
@@ -8,6 +8,6 @@
-
+