mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🏗 WIP: Linked & parked sites UI (#58)
This commit is contained in:
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 811 B |
@ -2,4 +2,12 @@
|
|||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
<svg width="100%" height="100%" viewBox="0 0 448 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
<svg width="100%" height="100%" viewBox="0 0 448 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
<path d="M400,224L376,224L376,152C376,68.2 307.8,0 224,0C140.2,0 72,68.2 72,152L72,224L48,224C21.5,224 0,245.5 0,272L0,464C0,490.5 21.5,512 48,512L400,512C426.5,512 448,490.5 448,464L448,272C448,245.5 426.5,224 400,224ZM296,224L152,224L152,152C152,112.3 184.3,80 224,80C263.7,80 296,112.3 296,152L296,224Z" style="fill:rgb(255,43,20);fill-rule:nonzero;"/>
|
<path d="M400,224L376,224L376,152C376,68.2 307.8,0 224,0C140.2,0 72,68.2 72,152L72,224L48,224C21.5,224 0,245.5 0,272L0,464C0,490.5 21.5,512 48,512L400,512C426.5,512 448,490.5 448,464L448,272C448,245.5 426.5,224 400,224ZM296,224L152,224L152,152C152,112.3 184.3,80 224,80C263.7,80 296,112.3 296,152L296,224Z" style="fill:rgb(255,43,20);fill-rule:nonzero;"/>
|
||||||
|
<g transform="matrix(0.549498,0.549498,-0.549498,0.549498,300.93,41.1032)">
|
||||||
|
<g transform="matrix(1,0,0,1,-19,26)">
|
||||||
|
<rect x="113" y="325" width="276" height="42" style="fill:white;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(6.12323e-17,-1,1,6.12323e-17,-114,623)">
|
||||||
|
<rect x="113" y="325" width="276" height="42" style="fill:white;"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 1.2 KiB |
@ -313,18 +313,18 @@ Gw
|
|||||||
<scene sceneID="aZt-6w-TFl">
|
<scene sceneID="aZt-6w-TFl">
|
||||||
<objects>
|
<objects>
|
||||||
<viewController storyboardIdentifier="siteList" id="JZI-Vd-9oq" customClass="SiteListVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
|
<viewController storyboardIdentifier="siteList" id="JZI-Vd-9oq" customClass="SiteListVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
<view key="view" id="rIZ-4U-bhj">
|
<view key="view" misplaced="YES" id="rIZ-4U-bhj">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="574" height="263"/>
|
<rect key="frame" x="0.0" y="0.0" width="574" height="262"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="69" horizontalPageScroll="10" verticalLineScroll="69" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p0j-eB-I2i">
|
<scrollView autohidesScrollers="YES" horizontalLineScroll="69" horizontalPageScroll="10" verticalLineScroll="69" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p0j-eB-I2i">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="574" height="263"/>
|
<rect key="frame" x="0.0" y="0.0" width="574" height="259"/>
|
||||||
<clipView key="contentView" id="6IL-DW-37w">
|
<clipView key="contentView" id="6IL-DW-37w">
|
||||||
<rect key="frame" x="1" y="1" width="572" height="261"/>
|
<rect key="frame" x="1" y="1" width="572" height="257"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="69" rowSizeStyle="automatic" viewBased="YES" id="cp3-34-pQj">
|
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="69" rowSizeStyle="automatic" viewBased="YES" id="cp3-34-pQj">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="572" height="261"/>
|
<rect key="frame" x="0.0" y="0.0" width="572" height="257"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<size key="intercellSpacing" width="17" height="0.0"/>
|
<size key="intercellSpacing" width="17" height="0.0"/>
|
||||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
@ -368,10 +368,18 @@ Gw
|
|||||||
<constraint firstAttribute="width" constant="16" id="Bmk-CN-Yyn"/>
|
<constraint firstAttribute="width" constant="16" id="Bmk-CN-Yyn"/>
|
||||||
<constraint firstAttribute="height" constant="16" id="d4z-lb-Ww0"/>
|
<constraint firstAttribute="height" constant="16" id="d4z-lb-Ww0"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="LockIcon" id="aJ0-ia-YrZ"/>
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="GreenLock" id="aJ0-ia-YrZ"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YUU-Hg-chL">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Uyv-Cs-wjO">
|
||||||
<rect key="frame" x="482" y="34" width="65" height="20"/>
|
<rect key="frame" x="485" y="28" width="62" height="14"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="clipping" title="Linked Site" id="DIn-VE-rO6">
|
||||||
|
<font key="font" metaFont="smallSystem"/>
|
||||||
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YUU-Hg-chL">
|
||||||
|
<rect key="frame" x="407" y="25" width="65" height="20"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="20" id="rSA-sX-afj"/>
|
<constraint firstAttribute="height" constant="20" id="rSA-sX-afj"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
@ -381,26 +389,18 @@ Gw
|
|||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Uyv-Cs-wjO">
|
|
||||||
<rect key="frame" x="485" y="20" width="62" height="14"/>
|
|
||||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Linked Site" id="DIn-VE-rO6">
|
|
||||||
<font key="font" metaFont="smallSystem"/>
|
|
||||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</textFieldCell>
|
|
||||||
</textField>
|
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="XJL-Uw-frD" firstAttribute="leading" secondItem="QPX-eu-eV8" secondAttribute="trailing" constant="15" id="55y-3V-RYt"/>
|
<constraint firstItem="XJL-Uw-frD" firstAttribute="leading" secondItem="QPX-eu-eV8" secondAttribute="trailing" constant="15" id="55y-3V-RYt"/>
|
||||||
|
<constraint firstItem="Uyv-Cs-wjO" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" id="7s1-ZB-q0F"/>
|
||||||
<constraint firstItem="QPX-eu-eV8" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="top" constant="3" id="9QB-jZ-k1V"/>
|
<constraint firstItem="QPX-eu-eV8" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="top" constant="3" id="9QB-jZ-k1V"/>
|
||||||
<constraint firstItem="Uyv-Cs-wjO" firstAttribute="top" secondItem="YUU-Hg-chL" secondAttribute="bottom" id="Edq-sS-4W1"/>
|
<constraint firstItem="YUU-Hg-chL" firstAttribute="centerY" secondItem="5GY-nN-BWd" secondAttribute="centerY" id="BLi-JF-LuQ"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="YUU-Hg-chL" secondAttribute="trailing" constant="10" id="GYS-Hy-r1R"/>
|
|
||||||
<constraint firstItem="XJL-Uw-frD" firstAttribute="leading" secondItem="5GY-nN-BWd" secondAttribute="leading" constant="48" id="Kns-wj-vAJ"/>
|
<constraint firstItem="XJL-Uw-frD" firstAttribute="leading" secondItem="5GY-nN-BWd" secondAttribute="leading" constant="48" id="Kns-wj-vAJ"/>
|
||||||
<constraint firstItem="CXK-Q9-CpO" firstAttribute="leading" secondItem="XJL-Uw-frD" secondAttribute="leading" id="Ojw-VZ-3EG"/>
|
<constraint firstItem="CXK-Q9-CpO" firstAttribute="leading" secondItem="XJL-Uw-frD" secondAttribute="leading" id="Ojw-VZ-3EG"/>
|
||||||
<constraint firstItem="XJL-Uw-frD" firstAttribute="top" secondItem="5GY-nN-BWd" secondAttribute="top" constant="15" id="QeE-c7-I9U"/>
|
<constraint firstItem="XJL-Uw-frD" firstAttribute="top" secondItem="5GY-nN-BWd" secondAttribute="top" constant="15" id="QeE-c7-I9U"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="Uyv-Cs-wjO" secondAttribute="trailing" constant="10" id="RCh-KS-hqe"/>
|
||||||
<constraint firstItem="CXK-Q9-CpO" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="bottom" id="VKg-Vq-sYa"/>
|
<constraint firstItem="CXK-Q9-CpO" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="bottom" id="VKg-Vq-sYa"/>
|
||||||
<constraint firstItem="YUU-Hg-chL" firstAttribute="top" secondItem="XJL-Uw-frD" secondAttribute="top" id="kgH-CT-WFl"/>
|
<constraint firstItem="Uyv-Cs-wjO" firstAttribute="leading" secondItem="YUU-Hg-chL" secondAttribute="trailing" constant="17" id="ZgE-sh-azb"/>
|
||||||
<constraint firstItem="Uyv-Cs-wjO" firstAttribute="trailing" secondItem="YUU-Hg-chL" secondAttribute="trailing" id="neu-FK-lgz"/>
|
|
||||||
</constraints>
|
</constraints>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="imageViewLock" destination="QPX-eu-eV8" id="Nnh-kB-adG"/>
|
<outlet property="imageViewLock" destination="QPX-eu-eV8" id="Nnh-kB-adG"/>
|
||||||
@ -437,6 +437,9 @@ Gw
|
|||||||
<constraint firstAttribute="trailing" secondItem="p0j-eB-I2i" secondAttribute="trailing" id="zWH-TD-RZv"/>
|
<constraint firstAttribute="trailing" secondItem="p0j-eB-I2i" secondAttribute="trailing" id="zWH-TD-RZv"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="cp3-34-pQj" id="sdw-Ac-27X"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<customObject id="HgD-aB-bQb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
<customObject id="HgD-aB-bQb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
@ -444,6 +447,6 @@ Gw
|
|||||||
</scene>
|
</scene>
|
||||||
</scenes>
|
</scenes>
|
||||||
<resources>
|
<resources>
|
||||||
<image name="LockIcon" width="448" height="512"/>
|
<image name="GreenLock" width="448" height="512"/>
|
||||||
</resources>
|
</resources>
|
||||||
</document>
|
</document>
|
||||||
|
@ -15,8 +15,7 @@ class Valet {
|
|||||||
var version: String
|
var version: String
|
||||||
var config: Valet.Configuration
|
var config: Valet.Configuration
|
||||||
|
|
||||||
var parkedSites: [Site] = []
|
var sites: [Site] = []
|
||||||
var linkedSites: [Site] = []
|
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.version = Actions.valet("--version")
|
self.version = Actions.valet("--version")
|
||||||
@ -34,22 +33,21 @@ class Valet {
|
|||||||
print("PHP Monitor should scan the following paths:")
|
print("PHP Monitor should scan the following paths:")
|
||||||
print(self.config.paths)
|
print(self.config.paths)
|
||||||
|
|
||||||
resolvePaths()
|
resolvePaths(tld: self.config.tld)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func resolvePaths() {
|
private func resolvePaths(tld: String) {
|
||||||
self.linkedSites = []
|
self.sites = []
|
||||||
self.parkedSites = []
|
|
||||||
|
|
||||||
for path in self.config.paths {
|
for path in self.config.paths {
|
||||||
let entries = try! FileManager.default.contentsOfDirectory(atPath: path)
|
let entries = try! FileManager.default.contentsOfDirectory(atPath: path)
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
self.resolvePath(entry, forPath: path)
|
self.resolvePath(entry, forPath: path, tld: tld)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func resolvePath(_ entry: String, forPath path: String) {
|
private func resolvePath(_ entry: String, forPath path: String, tld: String) {
|
||||||
let siteDir = path + "/" + entry
|
let siteDir = path + "/" + entry
|
||||||
|
|
||||||
// See if the file is a symlink, if so, resolve it
|
// See if the file is a symlink, if so, resolve it
|
||||||
@ -59,11 +57,9 @@ class Valet {
|
|||||||
let type = attrs[FileAttributeKey.type] as! FileAttributeType
|
let type = attrs[FileAttributeKey.type] as! FileAttributeType
|
||||||
|
|
||||||
if type == FileAttributeType.typeSymbolicLink {
|
if type == FileAttributeType.typeSymbolicLink {
|
||||||
self.linkedSites.append(Site(aliasPath: siteDir))
|
self.sites.append(Site(aliasPath: siteDir, tld: tld))
|
||||||
} else if type == FileAttributeType.typeDirectory {
|
} else if type == FileAttributeType.typeDirectory {
|
||||||
self.parkedSites.append(Site(absolutePath: siteDir))
|
self.sites.append(Site(absolutePath: siteDir, tld: tld))
|
||||||
} else {
|
|
||||||
print("The item at: `\(siteDir)` was neither a symlink nor a directory. Skipping.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,19 +70,20 @@ class Valet {
|
|||||||
|
|
||||||
var absolutePath: String
|
var absolutePath: String
|
||||||
var aliasPath: String?
|
var aliasPath: String?
|
||||||
|
var secured: Bool
|
||||||
|
|
||||||
init(absolutePath: String) {
|
init(absolutePath: String, tld: String) {
|
||||||
self.absolutePath = absolutePath
|
self.absolutePath = absolutePath
|
||||||
self.aliasPath = nil
|
self.aliasPath = nil
|
||||||
self.name = URL(string: absolutePath)!.lastPathComponent
|
self.name = URL(string: absolutePath)!.lastPathComponent
|
||||||
self.detectSiteProperties()
|
self.secured = Shell.fileExists("~/.config/valet/Certificates/\(self.name).\(tld).key")
|
||||||
}
|
}
|
||||||
|
|
||||||
convenience init(aliasPath: String) {
|
convenience init(aliasPath: String, tld: String) {
|
||||||
// Resolve the symlink
|
// Resolve the symlink
|
||||||
let absolutePath = try! FileManager.default
|
let absolutePath = try! FileManager.default
|
||||||
.destinationOfSymbolicLink(atPath: aliasPath)
|
.destinationOfSymbolicLink(atPath: aliasPath)
|
||||||
self.init(absolutePath: absolutePath)
|
self.init(absolutePath: absolutePath, tld: tld)
|
||||||
|
|
||||||
// TODO: Make sure the destination is a valid directory!
|
// TODO: Make sure the destination is a valid directory!
|
||||||
|
|
||||||
@ -95,10 +92,9 @@ class Valet {
|
|||||||
|
|
||||||
// Update the alias' path
|
// Update the alias' path
|
||||||
self.aliasPath = aliasPath
|
self.aliasPath = aliasPath
|
||||||
}
|
|
||||||
|
// Make sure we check again, this time for the aliased file
|
||||||
private func detectSiteProperties() {
|
self.secured = Shell.fileExists("~/.config/valet/Certificates/\(self.name).\(tld).key")
|
||||||
// TODO: Determine additional information, like Composer status and PHP version?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@ import Carbon
|
|||||||
|
|
||||||
class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||||
|
|
||||||
|
// MARK: - Outlets
|
||||||
|
|
||||||
|
@IBOutlet weak var tableView: NSTableView!
|
||||||
|
|
||||||
// MARK: - Display
|
// MARK: - Display
|
||||||
|
|
||||||
public static func show(delegate: NSWindowDelegate? = nil) {
|
public static func show(delegate: NSWindowDelegate? = nil) {
|
||||||
@ -33,6 +37,13 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
|
|
||||||
// MARK: - Lifecycle
|
// MARK: - Lifecycle
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
let menu = NSMenu()
|
||||||
|
// menu.addItem(withTitle: "Secure", action: #selector(self.action), keyEquivalent: "L")
|
||||||
|
menu.addItem(withTitle: "Open in Browser...", action: #selector(self.openInBrowser), keyEquivalent: "O")
|
||||||
|
tableView.menu = menu
|
||||||
|
}
|
||||||
|
|
||||||
override func viewWillAppear() {
|
override func viewWillAppear() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -44,23 +55,45 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
// MARK: - Table View
|
// MARK: - Table View
|
||||||
|
|
||||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||||
return Valet.shared.linkedSites.count
|
return Valet.shared.sites.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
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 }
|
guard let userCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "siteItem"), owner: self) as? SiteListCell else { return nil }
|
||||||
|
|
||||||
let item = Valet.shared.linkedSites[row]
|
let item = Valet.shared.sites[row]
|
||||||
|
|
||||||
|
/// Make sure to show the TLD
|
||||||
userCell.labelSiteName.stringValue = "\(item.name).\(Valet.shared.config.tld)"
|
userCell.labelSiteName.stringValue = "\(item.name).\(Valet.shared.config.tld)"
|
||||||
userCell.labelPathName.stringValue = item.absolutePath
|
|
||||||
|
|
||||||
userCell.labelSiteType.isHidden = true
|
/// Show the absolute path, except make sure to replace the /Users/username segment with ~ for readability
|
||||||
userCell.labelPhpVersion.isHidden = true
|
userCell.labelPathName.stringValue = item.absolutePath
|
||||||
|
.replacingOccurrences(of: "/Users/\(Paths.whoami)", with: "~")
|
||||||
|
|
||||||
|
/// If the `aliasPath` is nil, we're dealing with a parked site. Otherwise, it's a link that was explicitly created.
|
||||||
|
userCell.labelSiteType.stringValue = item.aliasPath == nil
|
||||||
|
? "Parked Site"
|
||||||
|
: "Linked Site"
|
||||||
|
|
||||||
|
/// Show the green or red lock based on whether the site was secured
|
||||||
|
userCell.imageViewLock.image = NSImage(named: item.secured ? "GreenLock" : "RedLock")
|
||||||
|
|
||||||
|
/// TODO: Load the correct PHP version (not determined as of yet)
|
||||||
|
userCell.labelPhpVersion.stringValue = "PHP 8.0"
|
||||||
|
|
||||||
return userCell
|
return userCell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc public func openInBrowser() {
|
||||||
|
if self.tableView.selectedRow == -1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let site = Valet.shared.sites[self.tableView.selectedRow]
|
||||||
|
let prefix = site.secured ? "https://" : "http://"
|
||||||
|
let url = "\(prefix)\(site.name).\(Valet.shared.config.tld)"
|
||||||
|
NSWorkspace.shared.open(URL(string: url)!)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Deinitialization
|
// MARK: - Deinitialization
|
||||||
|
|
||||||
|
@ -14,4 +14,18 @@ class SiteListWC: NSWindowController {
|
|||||||
super.windowDidLoad()
|
super.windowDidLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allow users to close the window using Cmd-W, a shortcut I definitely use a lot.
|
||||||
|
*/
|
||||||
|
override func keyDown(with event: NSEvent) {
|
||||||
|
if event.modifierFlags.contains(.command) {
|
||||||
|
switch event.charactersIgnoringModifiers! {
|
||||||
|
case "w":
|
||||||
|
self.window?.close()
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user