mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗️ WIP: PHP Config Editor
- Has UI height rendering issues (w/ SwiftUI) - Needs debounce on UI elements - Cannot currently persist modified settings - Cannot display On/Off settings - Cannot display regular text settings
This commit is contained in:
@ -132,6 +132,7 @@
|
||||
C42CFB1627DFDE7900862737 /* nginx-site.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1527DFDE7900862737 /* nginx-site.test */; };
|
||||
C42CFB1827DFDFDC00862737 /* nginx-site-isolated.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */; };
|
||||
C42CFB1A27DFE8BD00862737 /* NginxConfigurationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */; };
|
||||
C42E3F772AB0D2880096DFC2 /* ConfigManagerWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42E3F762AB0D2880096DFC2 /* ConfigManagerWindowController.swift */; };
|
||||
C42F26732805B4B400938AC7 /* ValetListable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42F26722805B4B400938AC7 /* ValetListable.swift */; };
|
||||
C42F26742805B4B400938AC7 /* ValetListable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42F26722805B4B400938AC7 /* ValetListable.swift */; };
|
||||
C42F26762805FEE200938AC7 /* nginx-secure-proxy.test in Resources */ = {isa = PBXBuildFile; fileRef = C42F26752805FEE200938AC7 /* nginx-secure-proxy.test */; };
|
||||
@ -929,6 +930,7 @@
|
||||
C42CFB1527DFDE7900862737 /* nginx-site.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site.test"; sourceTree = "<group>"; };
|
||||
C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site-isolated.test"; sourceTree = "<group>"; };
|
||||
C42CFB1927DFE8BD00862737 /* NginxConfigurationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NginxConfigurationTest.swift; sourceTree = "<group>"; };
|
||||
C42E3F762AB0D2880096DFC2 /* ConfigManagerWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigManagerWindowController.swift; sourceTree = "<group>"; };
|
||||
C42F26722805B4B400938AC7 /* ValetListable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetListable.swift; sourceTree = "<group>"; };
|
||||
C42F26752805FEE200938AC7 /* nginx-secure-proxy.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-secure-proxy.test"; sourceTree = "<group>"; };
|
||||
C436039F275E67610028EFC6 /* AppDelegate+Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Notifications.swift"; sourceTree = "<group>"; };
|
||||
@ -1499,6 +1501,7 @@
|
||||
children = (
|
||||
C44DFA7B2A67043000B98ED5 /* ConfigManagerView.swift */,
|
||||
C4D5857B2A7038DB00DDBB63 /* ByteLimitView.swift */,
|
||||
C42E3F762AB0D2880096DFC2 /* ConfigManagerWindowController.swift */,
|
||||
);
|
||||
path = UI;
|
||||
sourceTree = "<group>";
|
||||
@ -2568,6 +2571,7 @@
|
||||
C4B97B75275CF08C003F3378 /* AppDelegate+MenuOutlets.swift in Sources */,
|
||||
C464ADAC275A7A3F003FCD53 /* DomainListWindowController.swift in Sources */,
|
||||
C4CB6E65292C362C002E9027 /* Homebrew.swift in Sources */,
|
||||
C42E3F772AB0D2880096DFC2 /* ConfigManagerWindowController.swift in Sources */,
|
||||
C464ADB2275A87CA003FCD53 /* DomainListCellProtocol.swift in Sources */,
|
||||
C4EE188422D3386B00E126E5 /* Constants.swift in Sources */,
|
||||
C493084A279F331F009C240B /* AddSiteVC.swift in Sources */,
|
||||
@ -3488,7 +3492,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -3501,7 +3505,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -3519,7 +3523,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -3532,7 +3536,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -3759,7 +3763,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -3772,7 +3776,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME) DEV";
|
||||
@ -3875,7 +3879,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -3888,7 +3892,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME) DEV";
|
||||
@ -3991,7 +3995,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = YES;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -4004,7 +4008,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME) EAP";
|
||||
@ -4172,7 +4176,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1306;
|
||||
CURRENT_PROJECT_VERSION = 1320;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEBUG = NO;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
@ -4185,7 +4189,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MARKETING_VERSION = 6.1;
|
||||
MARKETING_VERSION = 6.2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
|
||||
PRODUCT_MODULE_NAME = PHP_Monitor;
|
||||
PRODUCT_NAME = "$(TARGET_NAME) EAP";
|
||||
|
@ -69,8 +69,9 @@ class PhpConfigurationFile: CreatedFromFile {
|
||||
return nil
|
||||
}
|
||||
|
||||
enum ReplacementErrors: Error {
|
||||
public enum ReplacementErrors: Error {
|
||||
case missingKey
|
||||
case missingFile
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,10 +74,13 @@ class App {
|
||||
/** The window controller of the onboarding window. */
|
||||
var onboardingWindowController: OnboardingWindowController?
|
||||
|
||||
/** The window controller of the config manager window. */
|
||||
var phpConfigManagerWindowController: PhpConfigManagerWindowController?
|
||||
|
||||
/** The window controller of the warnings window. */
|
||||
var phpDoctorWindowController: PhpDoctorWindowController?
|
||||
|
||||
/** The window controller of the warnings window. */
|
||||
/** The window controller of the PHP version manager window. */
|
||||
var phpVersionManagerWindowController: PhpVersionManagerWindowController?
|
||||
|
||||
/** List of detected (installed) applications that PHP Monitor can work with. */
|
||||
|
@ -206,6 +206,10 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate
|
||||
PhpDoctorWindowController.show()
|
||||
}
|
||||
|
||||
@objc func openConfigGUI() {
|
||||
PhpConfigManagerWindowController.show()
|
||||
}
|
||||
|
||||
@objc func openDomainList() {
|
||||
DomainListVC.show()
|
||||
}
|
||||
|
@ -152,6 +152,9 @@ extension StatusMenu {
|
||||
NSMenuItem(title: "mi_php_version_manager".localized,
|
||||
action: #selector(MainMenu.openPhpVersionManager),
|
||||
keyEquivalent: "m"),
|
||||
NSMenuItem(title: "mi_php_config_manager".localized,
|
||||
action: #selector(MainMenu.openConfigGUI),
|
||||
keyEquivalent: "g"),
|
||||
NSMenuItem(title: "mi_php_config".localized,
|
||||
action: #selector(MainMenu.openActiveConfigFolder),
|
||||
keyEquivalent: "c"),
|
||||
|
@ -53,6 +53,13 @@ class BytePhpPreference: PhpPreference {
|
||||
|
||||
private func updatedFieldValue() {
|
||||
internalValue = "\(value)\(unit.rawValue)"
|
||||
|
||||
do {
|
||||
try PhpPreference.persistToIniFile(key: self.key, value: self.internalValue)
|
||||
Log.info("The preference \(key) was updated to: \(value)")
|
||||
} catch {
|
||||
Log.info("The preference \(key) could not be updated")
|
||||
}
|
||||
}
|
||||
|
||||
public static func readFrom(internalValue: String) -> (UnitOption, Int)? {
|
||||
|
@ -15,6 +15,14 @@ class PhpPreference {
|
||||
init(key: String) {
|
||||
self.key = key
|
||||
}
|
||||
|
||||
internal static func persistToIniFile(key: String, value: String) throws {
|
||||
if let file = PhpEnvironments.shared.getConfigFile(forKey: key) {
|
||||
try file.replace(key: key, value: value)
|
||||
}
|
||||
|
||||
throw PhpConfigurationFile.ReplacementErrors.missingFile
|
||||
}
|
||||
}
|
||||
|
||||
class BoolPhpPreference: PhpPreference {
|
||||
|
@ -40,7 +40,7 @@ struct PreferenceContainer<ControlView: View>: View {
|
||||
.font(.subheadline)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
||||
.frame(maxWidth: .infinity, maxHeight: 150, alignment: .topLeading)
|
||||
}
|
||||
}
|
||||
.padding(5)
|
||||
@ -79,7 +79,6 @@ struct ByteLimitView: View {
|
||||
.pickerStyle(.menu)
|
||||
.onChange(of: unit) { newValue in
|
||||
self.preference.unit = newValue
|
||||
print(self.preference.internalValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ struct ConfigManagerView: View {
|
||||
var preferences: [PhpPreference] = [
|
||||
BytePhpPreference(key: "memory_limit"),
|
||||
BytePhpPreference(key: "post_max_size"),
|
||||
BoolPhpPreference(key: "file_uploads"),
|
||||
// BoolPhpPreference(key: "file_uploads"),
|
||||
BytePhpPreference(key: "upload_max_filesize")
|
||||
]
|
||||
|
||||
@ -51,6 +51,7 @@ struct ConfigManagerView: View {
|
||||
if let preference = preference as? BytePhpPreference {
|
||||
ByteLimitView(preference: preference)
|
||||
}
|
||||
/*
|
||||
if let preference = preference as? BoolPhpPreference {
|
||||
Toggle("", isOn: preference.$value)
|
||||
.toggleStyle(.switch)
|
||||
@ -59,6 +60,7 @@ struct ConfigManagerView: View {
|
||||
if let preference = preference as? StringPhpPreference {
|
||||
TextField("Placeholder", text: preference.$value)
|
||||
}
|
||||
*/
|
||||
}.frame(maxWidth: .infinity)
|
||||
}
|
||||
}.padding(10)
|
||||
|
@ -0,0 +1,45 @@
|
||||
//
|
||||
// ConfigManagerWindowController.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 12/09/2023.
|
||||
// Copyright © 2023 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import SwiftUI
|
||||
|
||||
class PhpConfigManagerWindowController: PMWindowController {
|
||||
|
||||
// MARK: - Window Identifier
|
||||
|
||||
override var windowName: String {
|
||||
return "ConfigManager"
|
||||
}
|
||||
|
||||
public static func create(delegate: NSWindowDelegate?) {
|
||||
let windowController = Self()
|
||||
windowController.window = NSWindow()
|
||||
|
||||
guard let window = windowController.window else { return }
|
||||
window.title = ""
|
||||
window.styleMask = [.titled, .closable, .miniaturizable]
|
||||
window.titlebarAppearsTransparent = true
|
||||
window.delegate = delegate ?? windowController
|
||||
window.contentView = NSHostingView(rootView: ConfigManagerView())
|
||||
window.setContentSize(NSSize(width: 600, height: 480))
|
||||
|
||||
App.shared.phpConfigManagerWindowController = windowController
|
||||
}
|
||||
|
||||
public static func show(delegate: NSWindowDelegate? = nil) {
|
||||
if App.shared.phpConfigManagerWindowController == nil {
|
||||
Self.create(delegate: delegate)
|
||||
}
|
||||
|
||||
App.shared.phpConfigManagerWindowController?.showWindow(self)
|
||||
App.shared.phpConfigManagerWindowController?.window?.setCenterPosition(offsetY: 70)
|
||||
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
"mi_fix_php_link" = "Fix Automatically...";
|
||||
"mi_no_php_linked_explain" = "What's This?";
|
||||
"mi_php_version_manager" = "PHP Version Manager...";
|
||||
"mi_php_config_manager" = "PHP Configuration Editor...";
|
||||
|
||||
"mi_diagnostics" = "Diagnostics";
|
||||
"mi_active_services" = "Active Services";
|
||||
|
Reference in New Issue
Block a user