1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00

🏗️ Mapping more PHP configuration values

This commit is contained in:
2023-08-30 20:20:08 +02:00
parent 93e841735e
commit f8e6aa988e
3 changed files with 43 additions and 16 deletions

View File

@ -27,7 +27,7 @@ struct PreferenceContainer<ControlView: View>: View {
VStack(alignment: .leading, spacing: 10) { VStack(alignment: .leading, spacing: 10) {
HStack(alignment: .top, spacing: 50) { HStack(alignment: .top, spacing: 50) {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(self.name) Text(self.name.localizedForSwiftUI)
.bold() .bold()
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.frame(minWidth: 150, maxWidth: 150, alignment: .leading) .frame(minWidth: 150, maxWidth: 150, alignment: .leading)
@ -35,7 +35,7 @@ struct PreferenceContainer<ControlView: View>: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
controlView controlView
Text(self.description).font(.subheadline) Text(self.description.localizedForSwiftUI).font(.subheadline)
}.frame(maxWidth: .infinity, alignment: .leading) }.frame(maxWidth: .infinity, alignment: .leading)
} }
} }

View File

@ -9,9 +9,24 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
struct PhpPreference { class PhpPreference {
let key: String let key: String
let type: PhpPreferenceType
init(key: String) {
self.key = key
}
}
class BoolPhpPreference: PhpPreference {
@State var value: Bool = false
}
class StringPhpPreference: PhpPreference {
@State var value: String = ""
}
class BytePhpPreference: PhpPreference {
@State var value: String = ""
} }
enum PhpPreferenceType { enum PhpPreferenceType {
@ -22,10 +37,10 @@ enum PhpPreferenceType {
struct ConfigManagerView: View { struct ConfigManagerView: View {
var preferences: [PhpPreference] = [ var preferences: [PhpPreference] = [
PhpPreference(key: "memory_limit", type: .byteLimit), BytePhpPreference(key: "memory_limit"),
PhpPreference(key: "post_max_size", type: .byteLimit), BytePhpPreference(key: "post_max_size"),
PhpPreference(key: "file_uploads", type: .boolean), BoolPhpPreference(key: "file_uploads"),
PhpPreference(key: "upload_max_filesize", type: .byteLimit) BytePhpPreference(key: "upload_max_filesize")
] ]
var body: some View { var body: some View {
@ -55,26 +70,28 @@ struct ConfigManagerView: View {
VStack(spacing: 5) { VStack(spacing: 5) {
ForEach(preferences, id: \.key) { preference in ForEach(preferences, id: \.key) { preference in
PreferenceContainer( PreferenceContainer(
name: "php_ini." + preference.key + ".title", name: "php_ini.\(preference.key).title",
description: "php_ini." + preference.key + ".description" description: "php_ini.\(preference.key).description"
) { ) {
if preference.type == .byteLimit { if let preference = preference as? BytePhpPreference {
ByteLimitView() ByteLimitView()
} }
if preference.type == .boolean { if let preference = preference as? BoolPhpPreference {
Text("Boolean value here") Toggle("", isOn: preference.$value)
// Toggle(isOn: preference.) }
if let preference = preference as? StringPhpPreference {
TextField("Placeholder", text: preference.$value)
} }
}.frame(maxWidth: .infinity) }.frame(maxWidth: .infinity)
} }
Divider() Divider()
HStack { HStack {
Button("Close", action: { Button("Cancel", action: {
}) })
Spacer() Spacer()
Button("Restart PHP-FPM", action: { Button("Apply", action: {
}) })
} }

View File

@ -786,3 +786,13 @@ Please note that some features (greyed out below) are currently unavailable beca
"onboarding.tour.feature_unavailable" = "This feature is currently unavailable and requires Laravel Valet to be installed."; "onboarding.tour.feature_unavailable" = "This feature is currently unavailable and requires Laravel Valet to be installed.";
"onboarding.tour.once" = "You will only see the Welcome Tour once. You can re-open the Welcome Tour later via the menu bar icon (available in the menu, under First Aid & Services)."; "onboarding.tour.once" = "You will only see the Welcome Tour once. You can re-open the Welcome Tour later via the menu bar icon (available in the menu, under First Aid & Services).";
"onboarding.tour.close" = "Close Tour"; "onboarding.tour.close" = "Close Tour";
// CONFIGURATION MANAGER
"confman.title" = "Configuration Manager";
"confman.description" = "You can update configuration values for the currently active PHP version.";
"php_ini.memory_limit.title" = "Memory Limit";
"php_ini.post_max_size.title" = "POST Max Size";
"php_ini.file_uploads.title" = "File Uploads";
"php_ini.upload_max_filesize.title" = "Upload Max Size";