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

♻️ Refactor displaying domains

This commit is contained in:
2022-04-12 17:36:18 +02:00
parent f0f7a3f7d6
commit 1b8d6311ba
18 changed files with 167 additions and 78 deletions

View File

@@ -11,4 +11,5 @@ import AppKit
protocol DomainListCellProtocol {
func populateCell(with site: ValetSite)
func populateCell(with proxy: ValetProxy)
}

View File

@@ -30,4 +30,8 @@ class DomainListKindCell: NSTableCellView, DomainListCellProtocol
imageViewType.contentTintColor = NSColor.tertiaryLabelColor
}
func populateCell(with proxy: ValetProxy) {
imageViewType.image = NSImage(named: "IconProxy")
}
}

View File

@@ -17,10 +17,12 @@ class DomainListNameCell: NSTableCellView, DomainListCellProtocol
@IBOutlet weak var labelPathName: NSTextField!
func populateCell(with site: ValetSite) {
// Show the name of the site (including tld)
labelSiteName.stringValue = "\(site.name).\(Valet.shared.config.tld)"
// Show the absolute path, except make sure to replace the /Users/username segment with ~ for readability
labelSiteName.stringValue = "\(site.name).\(site.tld)"
labelPathName.stringValue = site.absolutePathRelative
}
func populateCell(with proxy: ValetProxy) {
labelSiteName.stringValue = "\(proxy.domain).\(proxy.tld)"
labelPathName.stringValue = proxy.target
}
}

View File

@@ -34,6 +34,15 @@ class DomainListPhpCell: NSTableCellView, DomainListCellProtocol
imageViewPhpVersionOK.image = NSImage(named: "Checkmark")
imageViewPhpVersionOK.toolTip = "domain_list.tooltips.checkmark".localized(site.composerPhp)
}
buttonPhpVersion.isHidden = false
imageViewPhpVersionOK.isHidden = false
}
func populateCell(with proxy: ValetProxy) {
buttonPhpVersion.isHidden = true
imageViewPhpVersionOK.isHidden = true
return
}
@IBAction func pressedPhpVersion(_ sender: Any) {

View File

@@ -1,37 +0,0 @@
//
// DomainListNameCell.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/03/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Cocoa
import AppKit
class DomainListProxiesCell: NSTableCellView, DomainListCellProtocol
{
static let reusableName = "domainListProxiesCell"
@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
*/
}
}

View File

@@ -16,9 +16,14 @@ class DomainListTLSCell: NSTableCellView, DomainListCellProtocol
@IBOutlet weak var imageViewLock: NSImageView!
func populateCell(with site: ValetSite) {
// Show the green or red lock based on whether the site was secured
imageViewLock.contentTintColor = site.secured
? NSColor(named: "IconColorGreen") // green
? NSColor(named: "IconColorGreen")
: NSColor(named: "IconColorRed")
}
func populateCell(with proxy: ValetProxy) {
imageViewLock.contentTintColor = proxy.target.contains("https")
? NSColor(named: "IconColorGreen")
: NSColor(named: "IconColorRed")
}
}

View File

@@ -28,4 +28,10 @@ class DomainListTypeCell: NSTableCellView, DomainListCellProtocol
// PHP version
labelPhpVersion.stringValue = site.composerPhp == "???" ? "Any PHP" : "PHP \(site.composerPhp)"
}
func populateCell(with proxy: ValetProxy) {
labelDriver.stringValue = "Proxy"
labelPhpVersion.stringValue = "Active"
return
}
}