mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-09 13:10:24 +01:00
✨ Add option to turn all services off (#35)
This commit is contained in:
18
phpmon/Domain/Extensions/NSMenuExtension.swift
Normal file
18
phpmon/Domain/Extensions/NSMenuExtension.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// NSMenuExtension.swift
|
||||
// PHP Monitor
|
||||
//
|
||||
// Created by Nico Verbruggen on 14/04/2021.
|
||||
// Copyright © 2021 Nico Verbruggen. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
extension NSMenu {
|
||||
|
||||
open func addItem(_ newItem: NSMenuItem, withKeyModifier modifier: NSEvent.ModifierFlags) {
|
||||
newItem.keyEquivalentModifierMask = modifier
|
||||
self.addItem(newItem)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -215,12 +215,26 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
||||
Actions.restartDnsMasq()
|
||||
Actions.restartPhpFpm()
|
||||
Actions.restartNginx()
|
||||
} completion: {
|
||||
DispatchQueue.main.async {
|
||||
LocalNotification.send(
|
||||
title: "notification.services_restarted".localized,
|
||||
subtitle: "notification.services_restarted_desc".localized
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func stopAllServices() {
|
||||
waitAndExecute {
|
||||
Actions.stopAllServices()
|
||||
} completion: {
|
||||
DispatchQueue.main.async {
|
||||
LocalNotification.send(
|
||||
title: "notification.services_stopped".localized,
|
||||
subtitle: "notification.services_stopped_desc".localized
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,14 +297,12 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate {
|
||||
}
|
||||
|
||||
@objc func switchToPhpVersion(sender: PhpMenuItem) {
|
||||
// print("Switching to: PHP \(sender.version)")
|
||||
|
||||
setBusyImage()
|
||||
App.shared.busy = true
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
|
||||
// Update the PHP version in the status bar
|
||||
updatePhpVersionInStatusBar()
|
||||
updatePhpVersionInStatusBar()
|
||||
|
||||
// Update the menu
|
||||
update()
|
||||
|
||||
@@ -58,11 +58,15 @@ class StatusMenu : NSMenu {
|
||||
private func addServicesMenuItems() {
|
||||
self.addItem(HeaderView.asMenuItem(text: "mi_active_services".localized))
|
||||
|
||||
let services = NSMenuItem(title: "mi_restart_specific".localized, action: nil, keyEquivalent: "")
|
||||
let services = NSMenuItem(title: "mi_manage_services".localized, action: nil, keyEquivalent: "")
|
||||
let servicesMenu = NSMenu()
|
||||
servicesMenu.addItem(NSMenuItem(title: "mi_restart_dnsmasq".localized, action: #selector(MainMenu.restartDnsMasq), keyEquivalent: "d"))
|
||||
servicesMenu.addItem(NSMenuItem(title: "mi_restart_php_fpm".localized, action: #selector(MainMenu.restartPhpFpm), keyEquivalent: "p"))
|
||||
servicesMenu.addItem(NSMenuItem(title: "mi_restart_nginx".localized, action: #selector(MainMenu.restartNginx), keyEquivalent: "n"))
|
||||
servicesMenu.addItem(
|
||||
NSMenuItem(title: "mi_stop_all_services".localized, action: #selector(MainMenu.stopAllServices), keyEquivalent: "s"),
|
||||
withKeyModifier: [.command, .shift]
|
||||
)
|
||||
for item in servicesMenu.items {
|
||||
item.target = MainMenu.shared
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"mi_restart_php_fpm" = "Restart service: php";
|
||||
"mi_restart_nginx" = "Restart service: nginx";
|
||||
"mi_restart_dnsmasq" = "Restart service: dnsmasq";
|
||||
"mi_restart_specific" = "Restart specific service";
|
||||
"mi_manage_services" = "Manage services";
|
||||
"mi_restart_all_services" = "Restart all services";
|
||||
"mi_stop_all_services" = "Stop all services";
|
||||
"mi_force_load_latest" = "Force load latest PHP version";
|
||||
@@ -60,6 +60,12 @@
|
||||
"notification.version_changed_title" = "PHP %@ now active";
|
||||
"notification.version_changed_desc" = "PHP Monitor has finished the switch to PHP %@.";
|
||||
|
||||
"notification.services_stopped" = "Valet services stopped";
|
||||
"notification.services_stopped_desc" = "All services have been successfully stopped.";
|
||||
|
||||
"notification.services_restarted" = "Valet services restarted";
|
||||
"notification.services_restarted_desc" = "All services have been successfully restarted.";
|
||||
|
||||
// ALERTS
|
||||
|
||||
// Force Reload Started
|
||||
|
||||
Reference in New Issue
Block a user