From cbb22b9bc136b212f5d7c9193dcc235f5757e760 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Fri, 3 Jan 2025 15:45:08 +0000 Subject: [PATCH] Added postgres --- src/.idea/.idea.Ombi/.idea/workspace.xml | 155 +++++++++++------- .../Services/DatabaseConfigurationService.cs | 5 - .../wizard/database/database.component.html | 52 +++++- .../app/wizard/database/database.component.ts | 59 ++++++- 4 files changed, 197 insertions(+), 74 deletions(-) diff --git a/src/.idea/.idea.Ombi/.idea/workspace.xml b/src/.idea/.idea.Ombi/.idea/workspace.xml index 1ce993d89..de55774d1 100644 --- a/src/.idea/.idea.Ombi/.idea/workspace.xml +++ b/src/.idea/.idea.Ombi/.idea/workspace.xml @@ -1,25 +1,23 @@ + + - - - - - - - - - - + + + - + + @@ -237,27 +235,63 @@ + + + + + + - - - - - - - - + + + + + + + + - - - - - - - + - + + + + + + + + + + - - - - - - - - - - - - + + - - + @@ -505,7 +524,7 @@ file://$PROJECT_DIR$/Ombi/Controllers/V1/TokenController.cs 48 - + @@ -518,7 +537,7 @@ file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs 59 - + @@ -531,7 +550,7 @@ file://$PROJECT_DIR$/Ombi.Core/Engine/V2/MultiSearchEngine.cs 49 - + @@ -544,7 +563,7 @@ file://$PROJECT_DIR$/Ombi.Api.MusicBrainz/MusicBrainzApi.cs 30 - + @@ -554,6 +573,32 @@ + + file://$PROJECT_DIR$/Ombi/Controllers/V2/WizardController.cs + 112 + + + + + + + + + file://$PROJECT_DIR$/Ombi/Controllers/V2/WizardController.cs + 121 + + + + + + + diff --git a/src/Ombi.Core/Services/DatabaseConfigurationService.cs b/src/Ombi.Core/Services/DatabaseConfigurationService.cs index ef1f50be8..750499b19 100644 --- a/src/Ombi.Core/Services/DatabaseConfigurationService.cs +++ b/src/Ombi.Core/Services/DatabaseConfigurationService.cs @@ -2,16 +2,11 @@ using System; using System.IO; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Ombi.Core.Helpers; using Ombi.Core.Models; using Ombi.Helpers; -using Ombi.Store.Context; -using Ombi.Store.Context.MySql; -using Ombi.Store.Context.Postgres; namespace Ombi.Core.Services; diff --git a/src/Ombi/ClientApp/src/app/wizard/database/database.component.html b/src/Ombi/ClientApp/src/app/wizard/database/database.component.html index 4952cd947..40aa353b6 100644 --- a/src/Ombi/ClientApp/src/app/wizard/database/database.component.html +++ b/src/Ombi/ClientApp/src/app/wizard/database/database.component.html @@ -14,7 +14,7 @@ For more information on using alternate databases, see the documentation.
- +

Just press next to continue with SQLite @@ -27,16 +27,19 @@

+ This field is required
- + + This field is required
- + + This field is required
@@ -51,7 +54,47 @@

{{connectionString | async}}

-
+ +
+
+
+ + +

+ Please enter your Postgres connection details below +

+
+ + + This field is required + +
+
+ + + This field is required + +
+
+ + + This field is required + +
+
+ + + +
+
+ + + +
+

{{connectionString | async}}

+
+ +
@@ -59,4 +102,3 @@ - diff --git a/src/Ombi/ClientApp/src/app/wizard/database/database.component.ts b/src/Ombi/ClientApp/src/app/wizard/database/database.component.ts index ae04c1428..8c037f07f 100644 --- a/src/Ombi/ClientApp/src/app/wizard/database/database.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/database/database.component.ts @@ -3,6 +3,7 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { BehaviorSubject } from "rxjs"; import { WizardService } from "../services/wizard.service"; import { NotificationService } from "app/services"; +import { MatTabChangeEvent } from "@angular/material/tabs"; @Component({ templateUrl: "./database.component.html", @@ -19,7 +20,7 @@ export class DatabaseComponent implements OnInit { public ngOnInit(): void { this.form = this.fb.group({ - type: ["MySQL"], + type: [""], host: ["", [Validators.required]], port: [3306, [Validators.required]], name: ["ombi", [Validators.required]], @@ -28,24 +29,64 @@ export class DatabaseComponent implements OnInit { }); this.form.valueChanges.subscribe(x => { + console.log(x); let connection = `Server=${x.host};Port=${x.port};Database=${x.name}`; + if (x.user) { - connection = `Server=${x.host};Port=${x.port};Database=${x.name};User=${x.user}`; + connection += `;User=${x.user}`; if (x.password) { - connection = `Server=${x.host};Port=${x.port};Database=${x.name};User=${x.user};Password=*******`; + connection += `;Password=*******`; } } + + if (x.type !== "MySQL") { + connection = connection.replace("Server", "Host").replace("User", "Username"); + } + this.connectionString.next(connection); }); } + public tabChange(event: MatTabChangeEvent) { + if (event.index === 0) { + this.form.reset(); + } + if (event.index === 1) { + this.form.reset({ + type: "MySQL", + host: "", + name: "ombi", + port: 3306, + }); + this.form.controls.type.setValue("MySQL"); + + } + if (event.index === 2) { + this.form.reset({ + type:"Postgres", + host: "", + name: "ombi", + port: 5432, + }); + + } + this.form.markAllAsTouched(); + } + public save() { - this.service.addDatabaseConfig(this.form.value).subscribe(x => { - this.notification.success(`Database configuration updated! Please now restart ombi!`); - this.configuredDatabase.emit(); - }, error => { - this.notification.error(error.error.message); - }) + this.service.addDatabaseConfig(this.form.value).subscribe({ + next: () => { + this.notification.success(`Database configuration updated! Please now restart Ombi!`); + this.configuredDatabase.emit(); + }, + error: error => { + if (error.error.message) { + this.notification.error(error.error.message); + } else { + this.notification.error("Something went wrong, please check the logs"); + } + }, + }); } }