From 66d13c92d5ea421057467727a4b9abcc5ffced6d Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 18 Apr 2022 11:59:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Run=20the=20`valet=20proxy`=20comma?= =?UTF-8?q?nd=20(#105)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/DomainList/AddProxyVC.swift | 18 +++++++++++++++++- phpmon/Domain/DomainList/DomainListVC.swift | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/phpmon/Domain/DomainList/AddProxyVC.swift b/phpmon/Domain/DomainList/AddProxyVC.swift index ef7eef8b..29872343 100644 --- a/phpmon/Domain/DomainList/AddProxyVC.swift +++ b/phpmon/Domain/DomainList/AddProxyVC.swift @@ -63,7 +63,23 @@ class AddProxyVC: NSViewController, NSTextFieldDelegate { } @IBAction func pressedCreateProxy(_ sender: Any) { - // valet proxy (domain) http://127.0.0.1:90 (--secure) + let domain = self.inputDomainName.stringValue + let proxyName = self.inputProxySubject.stringValue + let secure = self.buttonSecure.state == .on ? " --secure" : "" + + dismissView(outcome: .OK) + + App.shared.domainListWindowController?.contentVC.setUIBusy() + + DispatchQueue.global(qos: .userInitiated).async { + Shell.run("\(Paths.valet) proxy \(domain) \(proxyName)\(secure)", requiresPath: true) + Actions.restartNginx() + + DispatchQueue.main.async { + App.shared.domainListWindowController?.contentVC.setUINotBusy() + App.shared.domainListWindowController?.pressedReload(nil) + } + } } @IBAction func pressedCancel(_ sender: Any) { diff --git a/phpmon/Domain/DomainList/DomainListVC.swift b/phpmon/Domain/DomainList/DomainListVC.swift index 7171c31e..f9f7add5 100644 --- a/phpmon/Domain/DomainList/DomainListVC.swift +++ b/phpmon/Domain/DomainList/DomainListVC.swift @@ -101,7 +101,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource Disables the UI so the user cannot interact with it. Also shows a spinner to indicate that we're busy. */ - private func setUIBusy() { + public func setUIBusy() { // If it takes more than 0.5s to set the UI to not busy, show a spinner timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: { _ in self.progressIndicator.startAnimation(true) @@ -115,7 +115,7 @@ class DomainListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource /** Re-enables the UI so the user can interact with it. */ - private func setUINotBusy() { + public func setUINotBusy() { timer?.invalidate() progressIndicator.stopAnimation(nil) tableView.alphaValue = 1.0