Skip to content

Commit

Permalink
remove icon preview if corresponding policy is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
BIG-RAT committed Jun 11, 2024
1 parent 999a9d0 commit 3f87664
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 326 deletions.
4 changes: 2 additions & 2 deletions SYM-Helper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.1.2;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = "jamf.ie.SYM-Helper";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -402,7 +402,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.1.2;
MARKETING_VERSION = 1.2.0;
PRODUCT_BUNDLE_IDENTIFIER = "jamf.ie.SYM-Helper";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
4 changes: 4 additions & 0 deletions SYM-Helper/Alert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import Cocoa

class Alert: NSObject {

static let shared = Alert()
private override init() { }

func display(header: String, message: String, secondButton: String) -> String {
NSApplication.shared.activate(ignoringOtherApps: true)
var selected = ""
Expand Down
2 changes: 1 addition & 1 deletion SYM-Helper/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if (FileManager.default.fileExists(atPath: Log.path!)) {
NSWorkspace.shared.open(URL(fileURLWithPath: Log.path!))
} else {
_ = Alert().display(header: "Alert", message: "There are currently no log files to display.", secondButton: "")
_ = Alert.shared.display(header: "Alert", message: "There are currently no log files to display.", secondButton: "")
}
}
}
Expand Down
106 changes: 60 additions & 46 deletions SYM-Helper/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SYM-Helper/CloneConfigVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CloneConfigVC: NSViewController {
delegate?.sendClonedConfigInfo(newConfig: clonedConfigName_TextField.stringValue, existingConfig: configs_Button.titleOfSelectedItem!)
dismiss(self)
} else {
_ = alert.display(header: "Attention:", message: "\(clonedConfigName_TextField.stringValue) already exists. Please edit the name so that it is unique.", secondButton: "")
_ = Alert.shared.display(header: "Attention:", message: "\(clonedConfigName_TextField.stringValue) already exists. Please edit the name so that it is unique.", secondButton: "")
}
}

Expand Down
4 changes: 2 additions & 2 deletions SYM-Helper/ConfigsSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ class ConfigsSettings: NSObject {
try JSONSerialization.data(withJSONObject: data)
.write(to: saveURL)
} catch {
_ = alert.display(header: "Attention:", message: "Current configurations could not be saved.\n\(error)", secondButton: "")
_ = Alert.shared.display(header: "Attention:", message: "Current configurations could not be saved.\n\(error)", secondButton: "")
}

do {
let saveData = try PropertyListSerialization.data(fromPropertyList: data, format: .xml, options: 0)
try saveData.write(to: URL(fileURLWithPath: AppInfo.appSupport + "/\(theServer).\(dataType).plist"))
} catch {
_ = alert.display(header: "Attention:", message: "Current configurations could not be saved.", secondButton: "")
_ = Alert.shared.display(header: "Attention:", message: "Current configurations could not be saved.", secondButton: "")
}
}
}
2 changes: 1 addition & 1 deletion SYM-Helper/Credentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Credentials {
private func itemLookup(service: String) -> [String:String] {

// print("[Credentials.itemLookup] start search for: \(service)")

userPassDict.removeAll()
let keychainQuery: [String: Any] = [kSecClass as String: kSecClassGenericPasswordString,
kSecAttrService as String: service,
kSecAttrAccessGroup as String: accessGroup,
Expand Down
2 changes: 1 addition & 1 deletion SYM-Helper/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var tokenTimeCreated: Date?

var useApiClient = 0

let alert: Alert = Alert()
//let alert: Alert = Alert()
let writeToLog: WriteToLog = WriteToLog()

var scriptSource = ""
Expand Down
233 changes: 0 additions & 233 deletions SYM-Helper/Login2VC.swift

This file was deleted.

20 changes: 13 additions & 7 deletions SYM-Helper/LoginVC.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//
// LoginVC.swift
// SYM-Helper
//

import Cocoa
Expand Down Expand Up @@ -59,7 +58,7 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
// header_TextField.frame.size.height = 0.0
if NSEvent.modifierFlags.contains(.option) {
let selectedServer = selectServer_Button.titleOfSelectedItem!
let response = Alert().display(header: "", message: "Are you sure you want to remove \(selectedServer) from the list?", secondButton: "Cancel")
let response = Alert.shared.display(header: "", message: "Are you sure you want to remove \(selectedServer) from the list?", secondButton: "Cancel")
if response == "Cancel" {
return
} else {
Expand Down Expand Up @@ -169,7 +168,7 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
// check for update/removal of server display name
if jamfProServer_textfield.stringValue == "" {
let serverToRemove = (theSender == "Login") ? "\(selectServer_Button.titleOfSelectedItem ?? "")":displayName_TextField.stringValue
let deleteReply = Alert().display(header: "Attention:", message: "Do you wish to remove \(serverToRemove) from the list?", secondButton: "Cancel")
let deleteReply = Alert.shared.display(header: "Attention:", message: "Do you wish to remove \(serverToRemove) from the list?", secondButton: "Cancel")
if deleteReply != "Cancel" && serverToRemove != "Add Server..." {
if availableServersDict[serverToRemove] != nil {
let serverIndex = selectServer_Menu.indexOfItem(withTitle: serverToRemove)
Expand All @@ -196,7 +195,7 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
}
} else if jamfProServer_textfield.stringValue != availableServersDict[selectServer_Button.titleOfSelectedItem!]?["server"] as? String && selectServer_Button.titleOfSelectedItem ?? "" != "Add Server..." {
let serverToUpdate = (theSender == "Login") ? "\(selectServer_Button.titleOfSelectedItem ?? "")":displayName_TextField.stringValue.fqdnFromUrl
let updateReply = Alert().display(header: "Attention:", message: "Do you wish to update the URL for \(serverToUpdate) to: \(jamfProServer_textfield.stringValue)", secondButton: "Cancel")
let updateReply = Alert.shared.display(header: "Attention:", message: "Do you wish to update the URL for \(serverToUpdate) to: \(jamfProServer_textfield.stringValue)", secondButton: "Cancel")
if updateReply != "Cancel" && serverToUpdate != "Add Server..." {
// update server URL
availableServersDict[serverToUpdate]?["server"] = jamfProServer_textfield.stringValue as AnyObject
Expand All @@ -216,7 +215,7 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
dismiss(self)
} else {
if displayName_TextField.stringValue == "" {
let nameReply = Alert().display(header: "Attention:", message: "Display name cannot be blank.\nUse \(jamfProServer_textfield.stringValue.fqdnFromUrl)?", secondButton: "Cancel")
let nameReply = Alert.shared.display(header: "Attention:", message: "Display name cannot be blank.\nUse \(jamfProServer_textfield.stringValue.fqdnFromUrl)?", secondButton: "Cancel")
if nameReply == "Cancel" {
spinner_PI.stopAnimation(self)
return
Expand Down Expand Up @@ -287,7 +286,7 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
login_action("Login")
} else {
spinner_PI.stopAnimation(self)
_ = Alert().display(header: "Attention:", message: "Failed to generate token. HTTP status code: \(statusCode)", secondButton: "")
_ = Alert.shared.display(header: "Attention:", message: "Failed to generate token. HTTP status code: \(statusCode)", secondButton: "")
}
}
}
Expand Down Expand Up @@ -533,7 +532,6 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {

jamfProServer_textfield.delegate = self
jamfProUsername_textfield.delegate = self
// jamfProPassword_textfield.delegate = self

lastServer = defaults.string(forKey: "currentServer") ?? ""
print("[viewDidLoad] lastServer: \(lastServer)")
Expand Down Expand Up @@ -633,5 +631,13 @@ class LoginVC: NSViewController, URLSessionDelegate, NSTextFieldDelegate {
NSApplication.shared.activate(ignoringOtherApps: true)
}

override func viewWillDisappear() {
// prevents controlTextDidEndEditing from being called
jamfProServer_textfield.abortEditing()
jamfProUsername_textfield.abortEditing()
jamfProPassword_textfield.abortEditing()
displayName_TextField.abortEditing()
}

}

2 changes: 1 addition & 1 deletion SYM-Helper/NewConfigVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NewConfigVC: NSViewController {
delegate?.sendNewConfigInfo(newConfig: newConfigName_TextField.stringValue)
dismiss(self)
} else {
_ = alert.display(header: "Attention:", message: "\(newConfigName_TextField.stringValue) already exists, or is blank. Please edit the name so that it is unique.", secondButton: "")
_ = Alert.shared.display(header: "Attention:", message: "\(newConfigName_TextField.stringValue) already exists, or is blank. Please edit the name so that it is unique.", secondButton: "")
}
}

Expand Down
Loading

0 comments on commit 3f87664

Please sign in to comment.