diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index c54dcec..e483b05 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -199,6 +199,8 @@ C4D9ADC0277610E1007277F4 /* PhpSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */; }; C4D9ADC8277611A0007277F4 /* InternalSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */; }; C4D9ADC9277611A0007277F4 /* InternalSwitcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */; }; + C4D9F24B280B69E100DCD39A /* AddProxyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9F24A280B69E100DCD39A /* AddProxyVC.swift */; }; + C4D9F24C280B69E100DCD39A /* AddProxyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4D9F24A280B69E100DCD39A /* AddProxyVC.swift */; }; C4DEB7D427A5D60B00834718 /* Stats.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DEB7D327A5D60B00834718 /* Stats.swift */; }; C4E0F7ED27BEBDA9007475F2 /* NSWindowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4E0F7EC27BEBDA9007475F2 /* NSWindowExtension.swift */; }; C4E0F7EE27BEBDA9007475F2 /* NSWindowExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4E0F7EC27BEBDA9007475F2 /* NSWindowExtension.swift */; }; @@ -383,6 +385,7 @@ C4D936C827E3EB6100BD69FE /* PhpHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpHelper.swift; sourceTree = ""; }; C4D9ADBE277610E1007277F4 /* PhpSwitcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpSwitcher.swift; sourceTree = ""; }; C4D9ADC7277611A0007277F4 /* InternalSwitcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalSwitcher.swift; sourceTree = ""; }; + C4D9F24A280B69E100DCD39A /* AddProxyVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddProxyVC.swift; sourceTree = ""; }; C4DEB7D327A5D60B00834718 /* Stats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stats.swift; sourceTree = ""; }; C4E0F7EC27BEBDA9007475F2 /* NSWindowExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSWindowExtension.swift; sourceTree = ""; }; C4E4404527C56F4700D225E1 /* ValetSite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValetSite.swift; sourceTree = ""; }; @@ -678,6 +681,7 @@ C41CA5EC2774F8EE00A2C80E /* DomainListVC+Actions.swift */, C4FE011028084FC200D1DE6D /* SelectionVC.swift */, C4930849279F331F009C240B /* AddSiteVC.swift */, + C4D9F24A280B69E100DCD39A /* AddProxyVC.swift */, ); path = DomainList; sourceTree = ""; @@ -1101,6 +1105,7 @@ C4E4404627C56F4700D225E1 /* ValetSite.swift in Sources */, C4EC1E68279DE0540010F296 /* ServicesView.swift in Sources */, C4F2E43A2752F7D00020E974 /* PhpInstallation.swift in Sources */, + C4D9F24B280B69E100DCD39A /* AddProxyVC.swift in Sources */, C41E871A2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */, C48D0CA325CC992000CC7490 /* StatsView.swift in Sources */, C40C7F2827721FF600DDDCDC /* ActivePhpInstallation+Checks.swift in Sources */, @@ -1290,6 +1295,7 @@ C48D6C71279CD2AC00F26D7E /* PhpVersionNumber.swift in Sources */, C41C02AB27E61CB3009F26CB /* ValetSite+Fake.swift in Sources */, C4F780C925D80B75000DBC97 /* StringExtension.swift in Sources */, + C4D9F24C280B69E100DCD39A /* AddProxyVC.swift in Sources */, C4B5853F2770FE3900DA4FBE /* Paths.swift in Sources */, C481F79A26164A7C004FBCFF /* Preferences.swift in Sources */, C4E0F7EE27BEBDA9007475F2 /* NSWindowExtension.swift in Sources */, diff --git a/phpmon/Domain/App/Base.lproj/Main.storyboard b/phpmon/Domain/App/Base.lproj/Main.storyboard index e0f1b46..163dd71 100644 --- a/phpmon/Domain/App/Base.lproj/Main.storyboard +++ b/phpmon/Domain/App/Base.lproj/Main.storyboard @@ -6,7 +6,6 @@ - @@ -1120,7 +1119,7 @@ Gw - + @@ -1128,7 +1127,7 @@ Gw - + @@ -1337,6 +1336,9 @@ Gw l + + + diff --git a/phpmon/Domain/DomainList/AddProxyVC.swift b/phpmon/Domain/DomainList/AddProxyVC.swift new file mode 100644 index 0000000..a2cf2d3 --- /dev/null +++ b/phpmon/Domain/DomainList/AddProxyVC.swift @@ -0,0 +1,42 @@ +// +// AddSiteVC.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 24/01/2022. +// Copyright © 2022 Nico Verbruggen. All rights reserved. +// + +import Foundation +import Cocoa + +class AddProxyVC: NSViewController, NSTextFieldDelegate { + + // MARK: - View Lifecycle + + override func viewDidLoad() { + super.viewDidLoad() + loadStaticLocalisedStrings() + } + + private func dismissView(outcome: NSApplication.ModalResponse) { + guard let window = self.view.window, let parent = window.sheetParent else { return } + parent.endSheet(window, returnCode: outcome) + } + + // MARK: - Localisation + + func loadStaticLocalisedStrings() { + + } + + // MARK: - Outlet Interactions + + @IBAction func pressedCreateProxy(_ sender: Any) { + // valet proxy (domain) http://127.0.0.1:90 (--secure) + } + + @IBAction func pressedCancel(_ sender: Any) { + self.dismissView(outcome: .cancel) + } + +} diff --git a/phpmon/Domain/DomainList/DomainListWC.swift b/phpmon/Domain/DomainList/DomainListWC.swift index b708c96..de0d1f4 100644 --- a/phpmon/Domain/DomainList/DomainListWC.swift +++ b/phpmon/Domain/DomainList/DomainListWC.swift @@ -67,12 +67,25 @@ class DomainListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate withIdentifier: "showSelectionWindow" ) as! NSWindowController - // let viewController = windowController.window!.contentViewController! + let viewController = windowController.window! + .contentViewController as! SelectionVC + + viewController.domainListWC = self self.window?.beginSheet(windowController.window!) } - func selectFolder() { + func startCreateLinkFlow() { + self.showFolderSelectionForLink() + } + + func startCreateProxyFlow() { + self.showProxyPopup() + } + + // MARK: - Popups + + private func showFolderSelectionForLink() { let dialog = NSOpenPanel() dialog.message = "domain_list.add.modal_description".localized dialog.showsResizeIndicator = true @@ -84,12 +97,12 @@ class DomainListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate let result = dialog.url if (result != nil && response == .OK) { let path: String = result!.path - self.showSitePopup(path) + self.showLinkPopup(path) } } } - func showSitePopup(_ folder: String) { + private func showLinkPopup(_ folder: String) { let storyboard = NSStoryboard(name: "Main", bundle : nil) let windowController = storyboard.instantiateController( @@ -103,4 +116,16 @@ class DomainListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate self.window?.beginSheet(windowController.window!) } + + private func showProxyPopup() { + let storyboard = NSStoryboard(name: "Main", bundle : nil) + + let windowController = storyboard.instantiateController( + withIdentifier: "addProxyWindow" + ) as! NSWindowController + + // let viewController = windowController.window!.contentViewController as! AddSiteVC + + self.window?.beginSheet(windowController.window!) + } } diff --git a/phpmon/Domain/DomainList/SelectionVC.swift b/phpmon/Domain/DomainList/SelectionVC.swift index d57b268..1ca637e 100644 --- a/phpmon/Domain/DomainList/SelectionVC.swift +++ b/phpmon/Domain/DomainList/SelectionVC.swift @@ -11,6 +11,8 @@ import Cocoa class SelectionVC: NSViewController { + weak var domainListWC: DomainListWC? + @IBOutlet weak var buttonCreateLink: NSButton! @IBOutlet weak var buttonCreateProxy: NSButton! @IBOutlet weak var buttonCancel: NSButton! @@ -37,6 +39,16 @@ class SelectionVC: NSViewController { // MARK: - Outlet Interactions + @IBAction func pressedCreateLink(_ sender: Any) { + self.dismissView(outcome: .continue) + domainListWC?.startCreateLinkFlow() + } + + @IBAction func pressedCreateProxy(_ sender: Any) { + self.dismissView(outcome: .continue) + domainListWC?.startCreateProxyFlow() + } + @IBAction func pressedCancel(_ sender: Any) { self.dismissView(outcome: .cancel) }