URL via settings
This commit is contained in:
parent
38212fa196
commit
88163e3e53
Binary file not shown.
@ -10,11 +10,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "OTRS-Watch/OTRS.swift"
|
filePath = "OTRS-Watch/OTRS.swift"
|
||||||
timestampString = "503498994.361076"
|
timestampString = "503499740.022029"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "58"
|
startingLineNumber = "60"
|
||||||
endingLineNumber = "58"
|
endingLineNumber = "60"
|
||||||
landmarkName = "reload(que:)"
|
landmarkName = "reload(que:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -26,11 +26,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "OTRS-Watch/OTRS.swift"
|
filePath = "OTRS-Watch/OTRS.swift"
|
||||||
timestampString = "503498994.361076"
|
timestampString = "503499740.022029"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "66"
|
startingLineNumber = "68"
|
||||||
endingLineNumber = "66"
|
endingLineNumber = "68"
|
||||||
landmarkName = "reload(que:)"
|
landmarkName = "reload(que:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -42,11 +42,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "OTRS-Watch/OTRS.swift"
|
filePath = "OTRS-Watch/OTRS.swift"
|
||||||
timestampString = "503498994.361076"
|
timestampString = "503499740.022029"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "43"
|
startingLineNumber = "45"
|
||||||
endingLineNumber = "43"
|
endingLineNumber = "45"
|
||||||
landmarkName = "reload(que:)"
|
landmarkName = "reload(que:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
<Locations>
|
<Locations>
|
||||||
@ -90,12 +90,12 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "OTRS-Watch/OTRS.swift"
|
filePath = "OTRS-Watch/OTRS.swift"
|
||||||
timestampString = "503498201.457531"
|
timestampString = "503499740.022029"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "30"
|
startingLineNumber = "32"
|
||||||
endingLineNumber = "30"
|
endingLineNumber = "32"
|
||||||
landmarkName = "configure(username_:password_:)"
|
landmarkName = "configure(baseURL_:username_:password_:)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
</BreakpointProxy>
|
</BreakpointProxy>
|
||||||
|
|||||||
@ -14,9 +14,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
// Insert code here to initialize your application
|
// Insert code here to initialize your application
|
||||||
|
|
||||||
OTRS.sharedInstance.configure(username_: UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.CREDENTIALS.USER)!, password_: UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.CREDENTIALS.PASSWORD)!)
|
if let baseURL = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.BASE_URL) {
|
||||||
|
OTRS.sharedInstance.configure(baseURL_: baseURL, username_: UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.CREDENTIALS.USER)!, password_: UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.CREDENTIALS.PASSWORD)!)
|
||||||
|
|
||||||
getTicketsFromOTRS()
|
getTicketsFromOTRS()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
|
|||||||
@ -933,6 +933,24 @@
|
|||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
|
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="J3Z-8V-Igs">
|
||||||
|
<rect key="frame" x="148" y="23" width="508" height="22"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="1zj-BK-0pr">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mkK-OH-aIw">
|
||||||
|
<rect key="frame" x="18" y="26" width="30" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URL" id="3PK-C3-jeV">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
</subviews>
|
</subviews>
|
||||||
</view>
|
</view>
|
||||||
</box>
|
</box>
|
||||||
@ -945,6 +963,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="ticketTableView" destination="uqq-D2-JrZ" id="Csb-WI-8ex"/>
|
<outlet property="ticketTableView" destination="uqq-D2-JrZ" id="Csb-WI-8ex"/>
|
||||||
|
<outlet property="txtBaseURL" destination="J3Z-8V-Igs" id="MNC-l0-bgU"/>
|
||||||
<outlet property="txtPassword" destination="dBq-YZ-1Lb" id="zcP-17-bRV"/>
|
<outlet property="txtPassword" destination="dBq-YZ-1Lb" id="zcP-17-bRV"/>
|
||||||
<outlet property="txtQueue" destination="l3M-cB-NAW" id="ljI-tu-VOS"/>
|
<outlet property="txtQueue" destination="l3M-cB-NAW" id="ljI-tu-VOS"/>
|
||||||
<outlet property="txtUsername" destination="CWI-hQ-L71" id="3oJ-D0-5fl"/>
|
<outlet property="txtUsername" destination="CWI-hQ-L71" id="3oJ-D0-5fl"/>
|
||||||
|
|||||||
@ -22,6 +22,7 @@ struct Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct OTRS {
|
struct OTRS {
|
||||||
|
static let BASE_URL = "user::setting::otrs::url::base"
|
||||||
static let QUEUE = "user::setting::otrs::queue"
|
static let QUEUE = "user::setting::otrs::queue"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ class OTRS {
|
|||||||
return Singleton.instance
|
return Singleton.instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var baseURL : String = "";
|
||||||
var username : String = "";
|
var username : String = "";
|
||||||
var password : String = "";
|
var password : String = "";
|
||||||
|
|
||||||
@ -26,7 +27,8 @@ class OTRS {
|
|||||||
|
|
||||||
//MARK: init
|
//MARK: init
|
||||||
|
|
||||||
func configure(username_:String, password_:String) {
|
func configure(baseURL_:String, username_:String, password_:String) {
|
||||||
|
self.baseURL = baseURL_
|
||||||
self.username = username_
|
self.username = username_
|
||||||
self.password = password_
|
self.password = password_
|
||||||
}
|
}
|
||||||
@ -126,10 +128,11 @@ class OTRS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func buildURLForGettingListByState(forState:String, queID:Int) -> String {
|
private func buildURLForGettingListByState(forState:String, queID:Int) -> String {
|
||||||
return "http://saeotrs01.sae.intra/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=\(self.username)&Password=\(self.password)&QueueIDs=\(queID)&States=\(forState)"
|
// example base url: http://saeotrs01.sae.intra/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/
|
||||||
|
return self.baseURL.appending("Ticket?UserLogin=\(self.username)&Password=\(self.password)&QueueIDs=\(queID)&States=\(forState)")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func buildURLForGettingTicketInfo(ticketID:Int) -> String {
|
private func buildURLForGettingTicketInfo(ticketID:Int) -> String {
|
||||||
return "http://saeotrs01.sae.intra/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/\(ticketID)?UserLogin=\(self.username)&Password=\(self.password)"
|
return self.baseURL.appending("Ticket/\(ticketID)?UserLogin=\(self.username)&Password=\(self.password)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ class ViewController: NSViewController {
|
|||||||
@IBOutlet weak var txtUsername: NSTextField!
|
@IBOutlet weak var txtUsername: NSTextField!
|
||||||
@IBOutlet weak var txtPassword: NSSecureTextField!
|
@IBOutlet weak var txtPassword: NSSecureTextField!
|
||||||
@IBOutlet weak var txtQueue: NSTextField!
|
@IBOutlet weak var txtQueue: NSTextField!
|
||||||
|
@IBOutlet weak var txtBaseURL: NSTextField!
|
||||||
@IBOutlet weak var ticketTableView: NSTableView!
|
@IBOutlet weak var ticketTableView: NSTableView!
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -35,6 +36,10 @@ class ViewController: NSViewController {
|
|||||||
txtQueue.stringValue = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE)!
|
txtQueue.stringValue = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.BASE_URL) != nil {
|
||||||
|
txtBaseURL.stringValue = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.BASE_URL)!
|
||||||
|
}
|
||||||
|
|
||||||
let nc = NotificationCenter.default
|
let nc = NotificationCenter.default
|
||||||
nc.addObserver(forName:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.IN),
|
nc.addObserver(forName:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.IN),
|
||||||
object:nil, queue:nil,
|
object:nil, queue:nil,
|
||||||
@ -59,6 +64,8 @@ class ViewController: NSViewController {
|
|||||||
UserDefaults.standard.setValue(txtPassword.stringValue, forKey: Constants.USER_SETTINGS.CREDENTIALS.PASSWORD)
|
UserDefaults.standard.setValue(txtPassword.stringValue, forKey: Constants.USER_SETTINGS.CREDENTIALS.PASSWORD)
|
||||||
|
|
||||||
UserDefaults.standard.setValue(txtQueue.stringValue, forKey: Constants.USER_SETTINGS.OTRS.QUEUE)
|
UserDefaults.standard.setValue(txtQueue.stringValue, forKey: Constants.USER_SETTINGS.OTRS.QUEUE)
|
||||||
|
|
||||||
|
UserDefaults.standard.setValue(txtBaseURL.stringValue, forKey: Constants.USER_SETTINGS.OTRS.BASE_URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user