mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
✨ Add UI for displaying proxies (#105)
This commit is contained in:
@ -51,6 +51,8 @@
|
||||
C40C7F2927721FF600DDDCDC /* ActivePhpInstallation+Checks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2727721FF600DDDCDC /* ActivePhpInstallation+Checks.swift */; };
|
||||
C40C7F3027722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
|
||||
C40C7F3127722E8D00DDDCDC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40C7F2F27722E8D00DDDCDC /* Logger.swift */; };
|
||||
C40D88EB27F38D7600C94B40 /* SiteListProxiesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D88EA27F38D7600C94B40 /* SiteListProxiesCell.swift */; };
|
||||
C40D88EC27F38D7600C94B40 /* SiteListProxiesCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40D88EA27F38D7600C94B40 /* SiteListProxiesCell.swift */; };
|
||||
C412E5FC25700D5300A1FB67 /* HomebrewPackage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */; };
|
||||
C415937F27A1B54F00D2E1B7 /* PhpFrameworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */; };
|
||||
C415938027A1B54F00D2E1B7 /* PhpFrameworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */; };
|
||||
@ -269,6 +271,7 @@
|
||||
C40C7F1D2772136000DDDCDC /* PhpEnv.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpEnv.swift; sourceTree = "<group>"; };
|
||||
C40C7F2727721FF600DDDCDC /* ActivePhpInstallation+Checks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActivePhpInstallation+Checks.swift"; sourceTree = "<group>"; };
|
||||
C40C7F2F27722E8D00DDDCDC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
C40D88EA27F38D7600C94B40 /* SiteListProxiesCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SiteListProxiesCell.swift; sourceTree = "<group>"; };
|
||||
C412E5FB25700D5300A1FB67 /* HomebrewPackage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomebrewPackage.swift; sourceTree = "<group>"; };
|
||||
C415937E27A1B54F00D2E1B7 /* PhpFrameworks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpFrameworks.swift; sourceTree = "<group>"; };
|
||||
C415D3B62770F294005EF286 /* Actions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Actions.swift; sourceTree = "<group>"; };
|
||||
@ -584,6 +587,7 @@
|
||||
C44067F627E258410045BD4E /* SiteListPhpCell.swift */,
|
||||
C44067F827E2585E0045BD4E /* SiteListTypeCell.swift */,
|
||||
C4AC51FB27E27F47008528CA /* SiteListKindCell.swift */,
|
||||
C40D88EA27F38D7600C94B40 /* SiteListProxiesCell.swift */,
|
||||
);
|
||||
path = Cells;
|
||||
sourceTree = "<group>";
|
||||
@ -993,6 +997,7 @@
|
||||
C4EE55A927708B9E001DF387 /* PMHeaderView.swift in Sources */,
|
||||
C41C02A927E61A65009F26CB /* ValetSite+Fake.swift in Sources */,
|
||||
C4F2E4372752F0870020E974 /* HomebrewDiagnostics.swift in Sources */,
|
||||
C40D88EB27F38D7600C94B40 /* SiteListProxiesCell.swift in Sources */,
|
||||
C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */,
|
||||
C4B585442770FE3900DA4FBE /* Command.swift in Sources */,
|
||||
C44067F527E2582B0045BD4E /* SiteListNameCell.swift in Sources */,
|
||||
@ -1128,6 +1133,7 @@
|
||||
C417DC75277614690015E6EE /* Helpers.swift in Sources */,
|
||||
C4080FF727BD8C6400BF2C6B /* BetterAlert.swift in Sources */,
|
||||
C4B97B7C275CF20A003F3378 /* App+GlobalHotkey.swift in Sources */,
|
||||
C40D88EC27F38D7600C94B40 /* SiteListProxiesCell.swift in Sources */,
|
||||
54D9E0B327E4F51E003B9AD9 /* HotKeysController.swift in Sources */,
|
||||
C4B97B79275CF1B5003F3378 /* App+ActivationPolicy.swift in Sources */,
|
||||
C4CE3BBB27B324230086CA49 /* MainMenu+Switcher.swift in Sources */,
|
||||
|
Binary file not shown.
25
phpmon/Assets.xcassets/IconProxy.imageset/Contents.json
vendored
Normal file
25
phpmon/Assets.xcassets/IconProxy.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Proxy.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Proxy@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
BIN
phpmon/Assets.xcassets/IconProxy.imageset/Proxy.png
vendored
Normal file
BIN
phpmon/Assets.xcassets/IconProxy.imageset/Proxy.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 710 B |
BIN
phpmon/Assets.xcassets/IconProxy.imageset/Proxy@2x.png
vendored
Normal file
BIN
phpmon/Assets.xcassets/IconProxy.imageset/Proxy@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
@ -805,7 +805,7 @@ Gw
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" multipleSelection="NO" autosaveName="phpmon-sitelist-columns" rowHeight="54" headerView="xUg-Mq-OSh" viewBased="YES" id="cp3-34-pQj">
|
||||
<rect key="frame" x="0.0" y="0.0" width="662" height="281"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="689" height="281"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<size key="intercellSpacing" width="17" height="0.0"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -848,7 +848,7 @@ Gw
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="DOMAIN" width="290" minWidth="250" maxWidth="10000" id="oeH-B2-0rA">
|
||||
<tableColumn identifier="DOMAIN" width="200" minWidth="200" maxWidth="10000" id="oeH-B2-0rA">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Domain">
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -862,7 +862,7 @@ Gw
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="siteListNameCell" wantsLayer="YES" id="5GY-nN-BWd" customClass="SiteListNameCell" customModule="PHP_Monitor" customModuleProvider="target">
|
||||
<rect key="frame" x="69" y="0.0" width="290" height="54"/>
|
||||
<rect key="frame" x="69" y="0.0" width="200" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="XJL-Uw-frD">
|
||||
@ -911,7 +911,7 @@ Gw
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="siteListPhpCell" wantsLayer="YES" id="T49-0U-d58" customClass="SiteListPhpCell" customModule="PHP_Monitor" customModuleProvider="target">
|
||||
<rect key="frame" x="376" y="0.0" width="100" height="54"/>
|
||||
<rect key="frame" x="286" y="0.0" width="100" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZXQ-bg-Xba">
|
||||
@ -966,7 +966,7 @@ Gw
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="siteListKindCell" wantsLayer="YES" id="AhT-xR-16a" customClass="SiteListKindCell" customModule="PHP_Monitor" customModuleProvider="target">
|
||||
<rect key="frame" x="493" y="0.0" width="36" height="54"/>
|
||||
<rect key="frame" x="403" y="0.0" width="36" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="sYR-vb-OW1">
|
||||
@ -1003,11 +1003,11 @@ Gw
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="siteListTypeCell" wantsLayer="YES" id="ntU-Rl-ciP" customClass="SiteListTypeCell" customModule="PHP_Monitor" customModuleProvider="target">
|
||||
<rect key="frame" x="546" y="0.0" width="97" height="54"/>
|
||||
<rect key="frame" x="456" y="0.0" width="100" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ljl-8B-key">
|
||||
<rect key="frame" x="6" y="26" width="93" height="14"/>
|
||||
<rect key="frame" x="6" y="26" width="96" height="14"/>
|
||||
<textFieldCell key="cell" alignment="left" title="Laravel" id="0lu-L6-oKr">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -1015,7 +1015,7 @@ Gw
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aPK-Xc-J4B">
|
||||
<rect key="frame" x="6" y="15" width="93" height="11"/>
|
||||
<rect key="frame" x="6" y="15" width="96" height="11"/>
|
||||
<textFieldCell key="cell" alignment="left" title="PHP 8.0" id="puf-Jh-ham">
|
||||
<font key="font" metaFont="miniSystem"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -1038,6 +1038,66 @@ Gw
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="PROXY" width="125" minWidth="125" maxWidth="10000" id="x9O-Z3-87p" userLabel="Proxy">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Proxies">
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="Y0C-YC-tFJ">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<sortDescriptor key="sortDescriptorPrototype" selector="compare:" sortKey="Proxy"/>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="siteListProxiesCell" wantsLayer="YES" id="jC5-iZ-jmh" customClass="SiteListProxiesCell" customModule="PHP_Monitor" customModuleProvider="target">
|
||||
<rect key="frame" x="573" y="0.0" width="97" height="54"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="BSU-DN-9K8">
|
||||
<rect key="frame" x="30" y="26" width="69" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="127.0.0.1:9999" id="0An-oy-1Xj">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="9o7-xL-J28">
|
||||
<rect key="frame" x="30" y="12" width="49" height="14"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="and 1 more..." id="tqn-Uz-aDP">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LiO-BE-pT7">
|
||||
<rect key="frame" x="0.0" y="16" width="24" height="22"/>
|
||||
<buttonCell key="cell" type="inline" bezelStyle="inline" image="IconProxy" imagePosition="overlaps" alignment="center" borderStyle="border" inset="2" id="ClW-pH-7Y3">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="smallSystemBold"/>
|
||||
</buttonCell>
|
||||
<color key="contentTintColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="BSU-DN-9K8" secondAttribute="trailing" id="2jc-cn-oc0"/>
|
||||
<constraint firstItem="BSU-DN-9K8" firstAttribute="top" secondItem="jC5-iZ-jmh" secondAttribute="top" constant="14" id="BIK-YX-9Yv"/>
|
||||
<constraint firstItem="9o7-xL-J28" firstAttribute="top" secondItem="BSU-DN-9K8" secondAttribute="bottom" id="Dmr-nS-mBc"/>
|
||||
<constraint firstItem="BSU-DN-9K8" firstAttribute="leading" secondItem="LiO-BE-pT7" secondAttribute="trailing" constant="8" id="P2i-wa-PuT"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="9o7-xL-J28" secondAttribute="trailing" constant="20" symbolic="YES" id="Wpu-Eb-jMe"/>
|
||||
<constraint firstItem="LiO-BE-pT7" firstAttribute="centerY" secondItem="jC5-iZ-jmh" secondAttribute="centerY" id="gHf-jc-vFe"/>
|
||||
<constraint firstItem="9o7-xL-J28" firstAttribute="leading" secondItem="BSU-DN-9K8" secondAttribute="leading" id="r0a-nJ-Ncm"/>
|
||||
<constraint firstItem="LiO-BE-pT7" firstAttribute="leading" secondItem="jC5-iZ-jmh" secondAttribute="leading" id="y20-rI-Yfg"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="buttonProxyList" destination="LiO-BE-pT7" id="pl2-AC-p1A"/>
|
||||
<outlet property="textFieldAdditional" destination="9o7-xL-J28" id="wLz-Lj-QMd"/>
|
||||
<outlet property="textFieldPrimary" destination="BSU-DN-9K8" id="iwQ-wJ-aZH"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="JZI-Vd-9oq" id="sbf-YF-ENF"/>
|
||||
@ -1051,7 +1111,7 @@ Gw
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="300" id="R3Z-g3-tYQ"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="620" id="iRQ-sz-oyv"/>
|
||||
</constraints>
|
||||
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="TDE-ff-DQT">
|
||||
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="0.69841269841269837" horizontal="YES" id="TDE-ff-DQT">
|
||||
<rect key="frame" x="0.0" y="293" width="626" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
@ -1060,7 +1120,7 @@ Gw
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<tableHeaderView key="headerView" wantsLayer="YES" id="xUg-Mq-OSh">
|
||||
<rect key="frame" x="0.0" y="0.0" width="662" height="28"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="689" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</tableHeaderView>
|
||||
</scrollView>
|
||||
@ -1088,12 +1148,13 @@ Gw
|
||||
</viewController>
|
||||
<customObject id="HgD-aB-bQb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="388" y="715.5"/>
|
||||
<point key="canvasLocation" x="303" y="705.5"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="Checkmark" width="512" height="512"/>
|
||||
<image name="IconLinked" width="25" height="25"/>
|
||||
<image name="IconProxy" width="18" height="18"/>
|
||||
<image name="Lock" width="30" height="30"/>
|
||||
<image name="arrow.clockwise" catalog="system" width="14" height="16"/>
|
||||
<image name="plus" catalog="system" width="14" height="13"/>
|
||||
|
@ -59,6 +59,9 @@ class ValetSite {
|
||||
?? PhpEnv.phpInstall.version.short
|
||||
}
|
||||
|
||||
/// Proxies set up for this domain.
|
||||
var proxies: [String] = []
|
||||
|
||||
enum VersionSource: String {
|
||||
case unknown = "unknown"
|
||||
case require = "require"
|
||||
@ -84,6 +87,7 @@ class ValetSite {
|
||||
determineComposerPhpVersion()
|
||||
determineDriver()
|
||||
determineIsolated()
|
||||
determineProxies()
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,6 +224,18 @@ class ValetSite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
TODO: This method should determine which proxies are active for this site.
|
||||
For test purposes this method currently will set a fixed value for
|
||||
my own website, eyo. Fun. I will need to check how to determine which
|
||||
sites are being proxied, first (and how this works!).
|
||||
*/
|
||||
private func determineProxies() {
|
||||
if self.name == "nicoverbruggen" {
|
||||
self.proxies = ["127.0.0.1:1337", "127.0.0.1:9999"]
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: File Parsing
|
||||
|
||||
public static func isolatedVersion(_ filePath: String) -> String? {
|
||||
|
34
phpmon/Domain/SiteList/Cells/SiteListProxiesCell.swift
Normal file
34
phpmon/Domain/SiteList/Cells/SiteListProxiesCell.swift
Normal file
@ -0,0 +1,34 @@
|
||||
//
|
||||
// SiteListNameCell.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 16/03/2022.
|
||||
// Copyright © 2022 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import AppKit
|
||||
|
||||
class SiteListProxiesCell: NSTableCellView, SiteListCellProtocol
|
||||
{
|
||||
static let reusableName = "siteListProxiesCell"
|
||||
|
||||
@IBOutlet weak var textFieldPrimary: NSTextField!
|
||||
@IBOutlet weak var textFieldAdditional: NSTextField!
|
||||
@IBOutlet weak var buttonProxyList: NSButton!
|
||||
|
||||
func populateCell(with site: ValetSite) {
|
||||
// Show the first proxy
|
||||
textFieldPrimary.stringValue = (site.proxies.count == 0)
|
||||
? ""
|
||||
: site.proxies[0]
|
||||
|
||||
// Show additional proxy count
|
||||
textFieldAdditional.stringValue = site.proxies.count > 1
|
||||
? "and \(site.proxies.count - 1) more active"
|
||||
: site.proxies.count == 1 ? "(active)" : ""
|
||||
|
||||
// Show button
|
||||
buttonProxyList.isHidden = site.proxies.count == 0
|
||||
}
|
||||
}
|
@ -212,6 +212,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
"ENVIRONMENT": SiteListPhpCell.reusableName,
|
||||
"KIND": SiteListKindCell.reusableName,
|
||||
"TYPE": SiteListTypeCell.reusableName,
|
||||
"PROXY": SiteListProxiesCell.reusableName,
|
||||
]
|
||||
|
||||
let columnName = tableColumn!.identifier.rawValue
|
||||
@ -239,6 +240,30 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
|
||||
// MARK: - (Search) Text Field Delegate
|
||||
|
||||
func toggleProxyColumnBasedOnActiveProxies() {
|
||||
let id = self.tableView.column(
|
||||
withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "PROXY")
|
||||
)
|
||||
|
||||
let column = self.tableView.tableColumns[id]
|
||||
|
||||
column.isHidden = !sites.contains(where: { site in
|
||||
site.proxies.count > 0
|
||||
})
|
||||
}
|
||||
|
||||
func reloadTable() {
|
||||
toggleProxyColumnBasedOnActiveProxies()
|
||||
|
||||
if let sortDescriptor = sortDescriptor {
|
||||
self.applySortDescriptor(sortDescriptor)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
func searchedFor(text: String) {
|
||||
lastSearchedFor = text
|
||||
|
||||
@ -247,13 +272,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
if searchString.isEmpty {
|
||||
sites = Valet.shared.sites
|
||||
|
||||
if let sortDescriptor = sortDescriptor {
|
||||
self.applySortDescriptor(sortDescriptor)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
reloadTable()
|
||||
|
||||
return
|
||||
}
|
||||
@ -268,13 +287,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
}.contains(false)
|
||||
})
|
||||
|
||||
if let sortDescriptor = sortDescriptor {
|
||||
self.applySortDescriptor(sortDescriptor)
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.tableView.reloadData()
|
||||
}
|
||||
reloadTable()
|
||||
}
|
||||
|
||||
// MARK: - Deinitialization
|
||||
|
Reference in New Issue
Block a user