1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 12:00:09 +02:00

👌 Quality of life changes, reload button

This commit is contained in:
2021-12-04 21:26:47 +01:00
parent 010c8eddde
commit 924edf6f96
5 changed files with 63 additions and 23 deletions

View File

@ -3,6 +3,7 @@
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19455"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="Search Toolbar Item" minToolsVersion="12.0" minSystemVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -520,17 +521,23 @@ Gw
<scene sceneID="4XS-kY-YIS">
<objects>
<windowController storyboardIdentifier="siteListWindow" id="8Ec-9q-82s" customClass="SiteListWC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="raw-02-3Q1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<window key="window" title="Domains" subtitle="Linked &amp; Parked" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="raw-02-3Q1">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="425" y="462" width="480" height="262"/>
<rect key="contentRect" x="425" y="461" width="550" height="263"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1415"/>
<view key="contentView" id="uVx-Da-x4I">
<rect key="frame" x="0.0" y="0.0" width="480" height="262"/>
<rect key="frame" x="0.0" y="0.0" width="550" height="263"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<toolbar key="toolbar" implicitIdentifier="594015E3-8428-4926-9341-4B8CE4C7E373" autosavesConfiguration="NO" displayMode="iconOnly" sizeMode="regular" id="OOz-oZ-vlN">
<toolbar key="toolbar" implicitIdentifier="594015E3-8428-4926-9341-4B8CE4C7E373" autosavesConfiguration="NO" allowsUserCustomization="NO" showsBaselineSeparator="NO" displayMode="iconOnly" sizeMode="regular" id="OOz-oZ-vlN">
<allowedToolbarItems>
<toolbarItem implicitItemIdentifier="B734CDE2-70E9-45A8-B1B3-5A5DE156621D" label="Reload" paletteLabel="Reload" tag="-1" bordered="YES" sizingBehavior="auto" id="YtK-vM-5y7">
<imageReference key="image" image="arrow.clockwise" catalog="system" symbolScale="medium"/>
<connections>
<action selector="pressedReload:" target="8Ec-9q-82s" id="fLc-bD-oYQ"/>
</connections>
</toolbarItem>
<searchToolbarItem implicitItemIdentifier="AA306E78-6DF1-4567-8EE9-4AEB9D23CB9D" label="Search" paletteLabel="Search" visibilityPriority="1001" id="clO-Y6-CdX">
<nil key="toolTip"/>
<searchField key="view" verticalHuggingPriority="750" textCompletion="NO" id="5ZH-Q1-kKs">
@ -545,6 +552,7 @@ Gw
</searchToolbarItem>
</allowedToolbarItems>
<defaultToolbarItems>
<toolbarItem reference="YtK-vM-5y7"/>
<searchToolbarItem reference="clO-Y6-CdX"/>
</defaultToolbarItems>
</toolbar>
@ -559,30 +567,30 @@ Gw
</windowController>
<customObject id="VCP-dF-cqM" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-374" y="774"/>
<point key="canvasLocation" x="-374" y="773.5"/>
</scene>
<!--Site ListVC-->
<scene sceneID="aZt-6w-TFl">
<objects>
<viewController storyboardIdentifier="siteList" id="JZI-Vd-9oq" customClass="SiteListVC" customModule="PHP_Monitor" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" misplaced="YES" id="rIZ-4U-bhj">
<rect key="frame" x="0.0" y="0.0" width="529" height="352"/>
<rect key="frame" x="0.0" y="0.0" width="550" height="347"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<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="529" height="352"/>
<rect key="frame" x="0.0" y="0.0" width="550" height="345"/>
<clipView key="contentView" id="6IL-DW-37w">
<rect key="frame" x="1" y="1" width="527" height="350"/>
<rect key="frame" x="1" y="1" width="548" height="343"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="69" rowSizeStyle="automatic" viewBased="YES" id="cp3-34-pQj">
<rect key="frame" x="0.0" y="0.0" width="527" height="350"/>
<rect key="frame" x="0.0" y="0.0" width="548" height="343"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="17" height="0.0"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="515" minWidth="40" maxWidth="1000" id="oeH-B2-0rA">
<tableColumn width="536" minWidth="40" maxWidth="1000" id="oeH-B2-0rA">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
@ -595,7 +603,7 @@ Gw
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="siteItem" wantsLayer="YES" id="5GY-nN-BWd" customClass="SiteListCell" customModule="PHP_Monitor" customModuleProvider="target">
<rect key="frame" x="8" y="0.0" width="510" height="69"/>
<rect key="frame" x="8" y="0.0" width="531" height="69"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="XJL-Uw-frD">
@ -623,7 +631,7 @@ Gw
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Lock" id="aJ0-ia-YrZ"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jKi-Ls-7FZ">
<rect key="frame" x="423" y="36" width="79" height="11"/>
<rect key="frame" x="444" y="36" width="79" height="11"/>
<constraints>
<constraint firstAttribute="width" constant="75" id="RuE-IX-D3c"/>
</constraints>
@ -634,7 +642,7 @@ Gw
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TbX-e2-3QL">
<rect key="frame" x="423" y="21" width="41" height="16"/>
<rect key="frame" x="444" y="21" width="41" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Driver" id="GMt-SG-vFl">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -642,7 +650,7 @@ Gw
</textFieldCell>
</textField>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="syz-LF-l6P">
<rect key="frame" x="0.0" y="-2" width="510" height="5"/>
<rect key="frame" x="0.0" y="-2" width="531" height="5"/>
</box>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YUU-Hg-chL">
<rect key="frame" x="301" y="27" width="51" height="14"/>
@ -654,7 +662,7 @@ Gw
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0NQ-ZD-CqD">
<rect key="frame" x="399" y="26" width="18" height="18"/>
<rect key="frame" x="420" y="26" width="18" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="18" id="Suw-gm-AEi"/>
<constraint firstAttribute="height" constant="18" id="qO6-vg-5nC"/>
@ -701,7 +709,7 @@ Gw
</clipView>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="300" id="R3Z-g3-tYQ"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="400" id="iRQ-sz-oyv"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="550" id="iRQ-sz-oyv"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="TDE-ff-DQT">
<rect key="frame" x="1" y="356" width="527" height="15"/>
@ -726,11 +734,12 @@ Gw
</viewController>
<customObject id="HgD-aB-bQb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="256.5" y="774.5"/>
<point key="canvasLocation" x="244" y="759.5"/>
</scene>
</scenes>
<resources>
<image name="IconLinked" width="512" height="512"/>
<image name="Lock" width="448" height="512"/>
<image name="arrow.clockwise" catalog="system" width="14" height="16"/>
</resources>
</document>

View File

@ -36,6 +36,10 @@ class Valet {
resolvePaths(tld: self.config.tld)
}
public func reloadSites() {
resolvePaths(tld: self.config.tld)
}
private func resolvePaths(tld: String) {
self.sites = []

View File

@ -20,6 +20,8 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
public var sites: [Valet.Site] = []
var lastSearchedFor = ""
// MARK: - Display
public static func show(delegate: NSWindowDelegate? = nil) {
@ -28,8 +30,10 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
let windowController = (storyboard.instantiateController(withIdentifier: "siteListWindow")) as! SiteListWC
windowController.window!.title = "site_list.title".localized
windowController.window!.subtitle = "site_list.subtitle".localized
windowController.window!.delegate = delegate
windowController.window!.styleMask = [.titled, .closable, .resizable]
windowController.window!.minSize = NSSize(width: 550, height: 200)
windowController.window!.maxSize = NSSize(width: 800, height: 10000)
App.shared.siteListWindowController = windowController
@ -49,6 +53,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
if (Shell.fileExists("/Applications/PhpStorm.app/Contents/Info.plist")) {
self.editorAvailability.append("phpstorm")
}
self.sites = Valet.shared.sites
}
@ -56,6 +61,19 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
override func viewWillDisappear() {}
// MARK: - Site Data Loading
func reloadSites() {
// Reload site information
Valet.shared.reloadSites()
// Update the site list
self.sites = Valet.shared.sites
// Re-apply any existing search
self.searchedFor(text: lastSearchedFor)
}
// MARK: - Table View
func numberOfRows(in tableView: NSTableView) -> Int {
@ -207,6 +225,8 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
// MARK: - (Search) Text Field Delegate
func searchedFor(text: String) {
self.lastSearchedFor = text
let searchString = text.lowercased()
if searchString.isEmpty {

View File

@ -8,7 +8,7 @@
import Cocoa
class SiteListWC: NSWindowController, NSSearchFieldDelegate {
class SiteListWC: NSWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
@IBOutlet weak var searchToolbarItem: NSSearchToolbarItem!
@ -18,14 +18,20 @@ class SiteListWC: NSWindowController, NSSearchFieldDelegate {
self.searchToolbarItem.searchField.becomeFirstResponder()
}
var contentVC: SiteListVC {
return self.contentViewController as! SiteListVC
}
func controlTextDidChange(_ notification: Notification) {
guard let searchField = notification.object as? NSSearchField else {
print("Unexpected control in update notification")
return
}
let window = self.contentViewController as! SiteListVC
window.searchedFor(text: searchField.stringValue)
contentVC.searchedFor(text: searchField.stringValue)
}
@IBAction func pressedReload(_ sender: Any) {
contentVC.reloadSites()
}
}

View File

@ -51,11 +51,12 @@
// SITE LIST
"site_list.title" = "Domains";
"site_list.subtitle" = "Linked & Parked";
// SITE LIST ACTIONS
"site_list.secure" = "Secure (Coming soon!)";
"site_list.unsecure" = "Unsecure (Coming soon!)";
"site_list.secure" = "Secure";
"site_list.unsecure" = "Unsecure";
"site_list.open_in_finder" = "Open in Finder";
"site_list.open_in_browser" = "Open in Browser";
"site_list.open_with_vs_code" = "Open with Visual Studio Code";