diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 0409b15..8a7a8ce 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -28,6 +28,12 @@ C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A1925D9CD1000591B77 /* Utility.swift */; }; C43A8A2025D9D1D700591B77 /* brew.json in Resources */ = {isa = PBXBuildFile; fileRef = C43A8A1F25D9D1D700591B77 /* brew.json */; }; C43A8A2425D9D20D00591B77 /* BrewJsonParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C43A8A2325D9D20D00591B77 /* BrewJsonParserTest.swift */; }; + C464ADAC275A7A3F003FCD53 /* SiteListWC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */; }; + C464ADAD275A7A3F003FCD53 /* SiteListWC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */; }; + C464ADAF275A7A69003FCD53 /* SiteListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADAE275A7A69003FCD53 /* SiteListVC.swift */; }; + C464ADB0275A7A6A003FCD53 /* SiteListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADAE275A7A69003FCD53 /* SiteListVC.swift */; }; + C464ADB2275A87CA003FCD53 /* SiteListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADB1275A87CA003FCD53 /* SiteListCell.swift */; }; + C464ADB3275A87CA003FCD53 /* SiteListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C464ADB1275A87CA003FCD53 /* SiteListCell.swift */; }; C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46FA23E246C358E00944F05 /* StringExtension.swift */; }; C473319F2470923A009A0597 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C473319E2470923A009A0597 /* Localizable.strings */; }; C47331A2247093B7009A0597 /* StatusMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C47331A1247093B7009A0597 /* StatusMenu.swift */; }; @@ -120,6 +126,9 @@ C43A8A1925D9CD1000591B77 /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = ""; }; C43A8A1F25D9D1D700591B77 /* brew.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = brew.json; sourceTree = ""; }; C43A8A2325D9D20D00591B77 /* BrewJsonParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrewJsonParserTest.swift; sourceTree = ""; }; + C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteListWC.swift; sourceTree = ""; }; + C464ADAE275A7A69003FCD53 /* SiteListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteListVC.swift; sourceTree = ""; }; + C464ADB1275A87CA003FCD53 /* SiteListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteListCell.swift; sourceTree = ""; }; C46FA23E246C358E00944F05 /* StringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = ""; }; C473319E2470923A009A0597 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; C47331A1247093B7009A0597 /* StatusMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusMenu.swift; sourceTree = ""; }; @@ -259,6 +268,7 @@ 54B20EDF263AA22C00D3250E /* PHP */, C4F7808A25D7F918000DBC97 /* Terminal */, C47331A0247093AC009A0597 /* Menu */, + C464ADAA275A7A25003FCD53 /* SiteList */, 5420395726135DB800FB00FA /* Preferences */, C4811D2822D70D9C00B5F6B3 /* Helpers */, C4F8C0A222D4F100002EFE61 /* Extensions */, @@ -266,6 +276,16 @@ path = Domain; sourceTree = ""; }; + C464ADAA275A7A25003FCD53 /* SiteList */ = { + isa = PBXGroup; + children = ( + C464ADAB275A7A3F003FCD53 /* SiteListWC.swift */, + C464ADAE275A7A69003FCD53 /* SiteListVC.swift */, + C464ADB1275A87CA003FCD53 /* SiteListCell.swift */, + ); + path = SiteList; + sourceTree = ""; + }; C47331A0247093AC009A0597 /* Menu */ = { isa = PBXGroup; children = ( @@ -502,6 +522,7 @@ C412E5FC25700D5300A1FB67 /* HomebrewPackage.swift in Sources */, C41C1B3722B0097F00E7CF16 /* AppDelegate.swift in Sources */, C42759672627662800093CAE /* NSMenuExtension.swift in Sources */, + C464ADAF275A7A69003FCD53 /* SiteListVC.swift in Sources */, C41C1B4B22B019FF00E7CF16 /* ActivePhpInstallation.swift in Sources */, C49EAB46259FC305007F6C3B /* Paths.swift in Sources */, C476FF9822B0DD830098105B /* Alert.swift in Sources */, @@ -509,6 +530,8 @@ C48D0C9625CC80B100CC7490 /* HeaderView.swift in Sources */, C47331A2247093B7009A0597 /* StatusMenu.swift in Sources */, C46FA23F246C358E00944F05 /* StringExtension.swift in Sources */, + C464ADAC275A7A3F003FCD53 /* SiteListWC.swift in Sources */, + C464ADB2275A87CA003FCD53 /* SiteListCell.swift in Sources */, C4EE188422D3386B00E126E5 /* Constants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -534,6 +557,7 @@ C42759682627662800093CAE /* NSMenuExtension.swift in Sources */, C4F780CD25D80B75000DBC97 /* Alert.swift in Sources */, C481F79726164A78004FBCFF /* PrefsVC.swift in Sources */, + C464ADB3275A87CA003FCD53 /* SiteListCell.swift in Sources */, C4AF9F78275447F100D44ED0 /* ValetConfigParserTest.swift in Sources */, C4F7809C25D80344000DBC97 /* CommandTest.swift in Sources */, C4F780BA25D80B62000DBC97 /* AppDelegate.swift in Sources */, @@ -548,7 +572,9 @@ C4F780B725D80B5D000DBC97 /* App.swift in Sources */, C4F780C925D80B75000DBC97 /* StringExtension.swift in Sources */, C481F79A26164A7C004FBCFF /* Preferences.swift in Sources */, + C464ADAD275A7A3F003FCD53 /* SiteListWC.swift in Sources */, C4F780CB25D80B75000DBC97 /* StatsView.swift in Sources */, + C464ADB0275A7A6A003FCD53 /* SiteListVC.swift in Sources */, C43A8A1A25D9CD1000591B77 /* Utility.swift in Sources */, C4F780C625D80B75000DBC97 /* XibLoadable.swift in Sources */, C4F7809F25D8037C000DBC97 /* Command.swift in Sources */, @@ -711,7 +737,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = "4.1-beta1"; + MARKETING_VERSION = "4.1-beta2"; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -735,7 +761,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = "4.1-beta1"; + MARKETING_VERSION = "4.1-beta2"; PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/phpmon/AppDelegate.swift b/phpmon/AppDelegate.swift index d0d3839..e0f070c 100644 --- a/phpmon/AppDelegate.swift +++ b/phpmon/AppDelegate.swift @@ -38,6 +38,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele */ let paths: Paths + /** + The Valet singleton that determines all information about Valet and its current configuration. + */ + let valet: Valet + // MARK: - Initializer /** @@ -48,6 +53,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele self.state = App.shared self.menu = MainMenu.shared self.paths = Paths.shared + self.valet = Valet.shared super.init() } diff --git a/phpmon/Assets.xcassets/LockIcon.imageset/Contents.json b/phpmon/Assets.xcassets/LockIcon.imageset/Contents.json new file mode 100644 index 0000000..6501997 --- /dev/null +++ b/phpmon/Assets.xcassets/LockIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "GreenLock.svg", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/phpmon/Assets.xcassets/LockIcon.imageset/GreenLock.svg b/phpmon/Assets.xcassets/LockIcon.imageset/GreenLock.svg new file mode 100644 index 0000000..d81604f --- /dev/null +++ b/phpmon/Assets.xcassets/LockIcon.imageset/GreenLock.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/phpmon/Assets.xcassets/RedLock.imageset/Contents.json b/phpmon/Assets.xcassets/RedLock.imageset/Contents.json new file mode 100644 index 0000000..116378f --- /dev/null +++ b/phpmon/Assets.xcassets/RedLock.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "RedLock.svg", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/phpmon/Assets.xcassets/RedLock.imageset/RedLock.svg b/phpmon/Assets.xcassets/RedLock.imageset/RedLock.svg new file mode 100644 index 0000000..66eeb55 --- /dev/null +++ b/phpmon/Assets.xcassets/RedLock.imageset/RedLock.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/phpmon/Domain/Core/App.swift b/phpmon/Domain/Core/App.swift index 49069e7..c63778d 100644 --- a/phpmon/Domain/Core/App.swift +++ b/phpmon/Domain/Core/App.swift @@ -30,9 +30,14 @@ class App { var preferences: [PreferenceName: Bool]! /** - The window controller of the currently active window. + The window controller of the currently active preferences window. */ - var windowController: NSWindowController? = nil + var preferencesWindowController: PrefsWC? = nil + + /** + The window controller of the currently active site list window. + */ + var siteListWindowController: SiteListWC? = nil /** Whether the application is busy switching versions. diff --git a/phpmon/Domain/Core/Base.lproj/Main.storyboard b/phpmon/Domain/Core/Base.lproj/Main.storyboard index 5d786e3..1b11da0 100644 --- a/phpmon/Domain/Core/Base.lproj/Main.storyboard +++ b/phpmon/Domain/Core/Base.lproj/Main.storyboard @@ -84,7 +84,7 @@ - + @@ -282,7 +282,168 @@ Gw - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phpmon/Domain/Integrations/Valet/Valet.swift b/phpmon/Domain/Integrations/Valet/Valet.swift index de7385a..9941174 100644 --- a/phpmon/Domain/Integrations/Valet/Valet.swift +++ b/phpmon/Domain/Integrations/Valet/Valet.swift @@ -10,8 +10,11 @@ import Foundation class Valet { + static let shared = Valet() + var version: String var config: Valet.Configuration + var parkedSites: [Site] = [] var linkedSites: [Site] = [] diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index 7ef3e2f..6ee497f 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -116,6 +116,8 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { menu.addPhpConfigurationMenuItems() menu.addItem(NSMenuItem.separator()) + menu.addItem(NSMenuItem(title: "mi_sitelist".localized, action: #selector(openSiteList), keyEquivalent: "l")) + // Add about & quit menu items menu.addItem(NSMenuItem(title: "mi_preferences".localized, action: #selector(openPrefs), keyEquivalent: ",")) menu.addItem(NSMenuItem(title: "mi_about".localized, action: #selector(openAbout), keyEquivalent: "")) @@ -372,6 +374,10 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate { PrefsVC.show() } + @objc func openSiteList() { + SiteListVC.show() + } + @objc func terminateApp() { NSApplication.shared.terminate(nil) } diff --git a/phpmon/Domain/Preferences/PrefsVC.swift b/phpmon/Domain/Preferences/PrefsVC.swift index da11b8a..c9aeb09 100644 --- a/phpmon/Domain/Preferences/PrefsVC.swift +++ b/phpmon/Domain/Preferences/PrefsVC.swift @@ -40,7 +40,7 @@ class PrefsVC: NSViewController { // MARK: - Display public static func show(delegate: NSWindowDelegate? = nil) { - if (App.shared.windowController == nil) { + if (App.shared.preferencesWindowController == nil) { let vc = NSStoryboard(name: "Main", bundle: nil) .instantiateController(withIdentifier: "preferences") as! PrefsVC let window = NSWindow(contentViewController: vc) @@ -49,10 +49,10 @@ class PrefsVC: NSViewController { window.delegate = delegate window.styleMask = [.titled, .closable] - App.shared.windowController = PrefsWC(window: window) + App.shared.preferencesWindowController = PrefsWC(window: window) } - App.shared.windowController!.showWindow(self) + App.shared.preferencesWindowController!.showWindow(self) NSApp.activate(ignoringOtherApps: true) } diff --git a/phpmon/Domain/SiteList/SiteListCell.swift b/phpmon/Domain/SiteList/SiteListCell.swift new file mode 100644 index 0000000..1cd7c5d --- /dev/null +++ b/phpmon/Domain/SiteList/SiteListCell.swift @@ -0,0 +1,25 @@ +// +// SiteListCell.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 03/12/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import Cocoa +import AppKit + +class SiteListCell: NSTableCellView +{ + @IBOutlet weak var labelSiteName: NSTextField! + @IBOutlet weak var labelPathName: NSTextField! + + @IBOutlet weak var imageViewLock: NSImageView! + + @IBOutlet weak var labelPhpVersion: NSTextField! + @IBOutlet weak var labelSiteType: NSTextField! + + override func draw(_ dirtyRect: NSRect) { + super.draw(dirtyRect) + } +} diff --git a/phpmon/Domain/SiteList/SiteListVC.swift b/phpmon/Domain/SiteList/SiteListVC.swift new file mode 100644 index 0000000..069f329 --- /dev/null +++ b/phpmon/Domain/SiteList/SiteListVC.swift @@ -0,0 +1,70 @@ +// +// SiteListVC.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 30/03/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import Cocoa +import HotKey +import Carbon + +class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource { + + // MARK: - Display + + public static func show(delegate: NSWindowDelegate? = nil) { + if (App.shared.siteListWindowController == nil) { + let vc = NSStoryboard(name: "Main", bundle: nil) + .instantiateController(withIdentifier: "siteList") as! SiteListVC + let window = NSWindow(contentViewController: vc) + + window.title = "site_list.title".localized + window.delegate = delegate + window.styleMask = [.titled, .closable, .resizable] + + App.shared.siteListWindowController = SiteListWC(window: window) + } + + App.shared.siteListWindowController!.showWindow(self) + NSApp.activate(ignoringOtherApps: true) + } + + // MARK: - Lifecycle + + override func viewWillAppear() { + + } + + override func viewWillDisappear() { + + } + + // MARK: - Table View + + func numberOfRows(in tableView: NSTableView) -> Int { + return Valet.shared.linkedSites.count + } + + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { + guard let userCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "siteItem"), owner: self) as? SiteListCell else { return nil } + + let item = Valet.shared.linkedSites[row] + + userCell.labelSiteName.stringValue = "\(item.name).\(Valet.shared.config.tld)" + userCell.labelPathName.stringValue = item.absolutePath + + userCell.labelSiteType.isHidden = true + userCell.labelPhpVersion.isHidden = true + + return userCell + } + + + // MARK: - Deinitialization + + deinit { + print("VC deallocated") + } +} diff --git a/phpmon/Domain/SiteList/SiteListWC.swift b/phpmon/Domain/SiteList/SiteListWC.swift new file mode 100644 index 0000000..2a3122a --- /dev/null +++ b/phpmon/Domain/SiteList/SiteListWC.swift @@ -0,0 +1,17 @@ +// +// SiteListWC.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 03/12/2021. +// Copyright © 2021 Nico Verbruggen. All rights reserved. +// + +import Cocoa + +class SiteListWC: NSWindowController { + + override func windowDidLoad() { + super.windowDidLoad() + } + +} diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 444c25b..9784d79 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -41,10 +41,16 @@ "mi_detected_extensions" = "Detected Extensions"; "mi_no_extensions_detected" = "No additional extensions detected."; +"mi_sitelist" = "Linked & Parked Domains..."; + "mi_preferences" = "Preferences..."; "mi_quit" = "Quit PHP Monitor"; "mi_about" = "About PHP Monitor"; +// SITE LIST + +"site_list.title" = "Linked & Parked Domains"; + // PREFERENCES "prefs.title" = "PHP Monitor";