Merge pull request #2565 from omnivore-app/fix/self-hosting-tweaks

fix/self hosting tweaks
This commit is contained in:
Jackson Harper 2023-07-31 12:20:52 +08:00 committed by GitHub
commit 4403e6619b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 9 deletions

View file

@ -10,9 +10,9 @@
}
struct SelfHostSettingsView: View {
@State var apiServerAddress = ""
@State var webServerAddress = ""
@State var ttsServerAddress = ""
@State var apiServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue) ?? ""
@State var webServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue) ?? ""
@State var ttsServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue) ?? ""
@State var showConfirmAlert = false
@ -39,16 +39,22 @@
Section("API Server Base URL") {
TextField("URL", text: $apiServerAddress, prompt: Text("https://api-prod.omnivore.app"))
.keyboardType(.URL)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
}
Section("Web Server URL") {
TextField("URL", text: $webServerAddress, prompt: Text("https://omnivore.app"))
.keyboardType(.URL)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
}
Section("Text-to-speech Server URL") {
TextField("URL", text: $ttsServerAddress, prompt: Text("https://tts.omnivore.app"))
.keyboardType(.URL)
.autocorrectionDisabled(true)
.textInputAutocapitalization(.never)
}
Section {

View file

@ -32,7 +32,7 @@ private let devWebURL = "https://web-dev.omnivore.app"
private let demoWebURL = "https://demo.omnivore.app"
private let prodWebURL = "https://omnivore.app"
private enum AppEnvironmentUserDefaultKey: String {
public enum AppEnvironmentUserDefaultKey: String {
case serverBaseURL = "AppEnvironment_serverBaseURL"
case webAppBaseURL = "AppEnvironment_webAppBaseURL"
case ttsBaseURL = "AppEnvironment_ttsBaseURL"
@ -40,9 +40,18 @@ private enum AppEnvironmentUserDefaultKey: String {
public extension AppEnvironment {
static func setCustom(serverBaseURL: String, webAppBaseURL: String, ttsBaseURL: String) {
UserDefaults.standard.set(serverBaseURL, forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue)
UserDefaults.standard.set(webAppBaseURL, forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue)
UserDefaults.standard.set(ttsBaseURL, forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue)
UserDefaults.standard.set(
serverBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines),
forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue
)
UserDefaults.standard.set(
webAppBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines),
forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue
)
UserDefaults.standard.set(
ttsBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines),
forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue
)
}
var graphqlPath: String {

View file

@ -1,9 +1,9 @@
#!/bin/bash
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';"
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" || true
echo "created app_user"
yarn workspace @omnivore/db migrate
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;"
psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;" || true
echo "granted omnivore_user to app_user"
# create demo user with email: demo@omnivore.app, password: demo