Multiple Queues
This commit is contained in:
parent
9550174427
commit
7764d94d76
Binary file not shown.
@ -10,12 +10,12 @@
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "OTRS-Watch/OTRS.swift"
|
||||
timestampString = "504524069.32379"
|
||||
timestampString = "504687476.967865"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "47"
|
||||
endingLineNumber = "47"
|
||||
landmarkName = "reload(que:)"
|
||||
startingLineNumber = "46"
|
||||
endingLineNumber = "46"
|
||||
landmarkName = "reload(queues:)"
|
||||
landmarkType = "7">
|
||||
<Locations>
|
||||
<Location
|
||||
@ -115,5 +115,21 @@
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "OTRS-Watch/OTRS.swift"
|
||||
timestampString = "504687476.967865"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "167"
|
||||
endingLineNumber = "167"
|
||||
landmarkName = "buildURLForGettingListByState(forState:queues:)"
|
||||
landmarkType = "7">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
||||
@ -41,8 +41,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
private func getTicketsFromOTRS() {
|
||||
|
||||
if let que:Int = Int(UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE)!) {
|
||||
OTRS.sharedInstance.reload(que: que)
|
||||
if let queues:String = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE) {
|
||||
OTRS.sharedInstance.reload(queues: queues)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,12 @@ struct Constants {
|
||||
static let ERROR = "nf::ticket::action::error"
|
||||
}
|
||||
}
|
||||
|
||||
struct TABLE {
|
||||
struct TICKTS {
|
||||
static let GET_COUNT = "nf::ticket::table::tickets::get::count"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TABS {
|
||||
|
||||
@ -18,6 +18,9 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
|
||||
}
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
NotificationCenter.default.post(name:Notification.Name(rawValue:Constants.NOTIFICATION.TABLE.TICKTS.GET_COUNT),
|
||||
object: nil,
|
||||
userInfo: ["message":OTRS.sharedInstance.ticketDictionary.count])
|
||||
return OTRS.sharedInstance.ticketDictionary.count
|
||||
}
|
||||
|
||||
@ -27,11 +30,16 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
|
||||
var text: String = ""
|
||||
var cellIdentifier: String = ""
|
||||
|
||||
guard row < OTRS.sharedInstance.ticketDictionary.count else {
|
||||
let tickets:Array<Ticket> = OTRS.sharedInstance.ticketDictionary
|
||||
let ticketCount = tickets.count
|
||||
|
||||
//print("🖥 Compare row \(row) with ticket count \(ticketCount) for displaying cell for row")
|
||||
|
||||
guard row < ticketCount else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let item:Ticket = OTRS.sharedInstance.ticketDictionary[row] as Ticket {
|
||||
if let item:Ticket = tickets[row] as Ticket {
|
||||
if tableColumn == self.ticketTableView.tableColumns[0] {
|
||||
cellIdentifier = CellIdentifiers.OTRSTicketNumber
|
||||
image = nil
|
||||
|
||||
@ -41,16 +41,15 @@ class OTRS {
|
||||
|
||||
//MARK: REST
|
||||
|
||||
func reload(que:Int) {
|
||||
let nc = NotificationCenter.default
|
||||
func reload(queues:String) {
|
||||
let config = URLSessionConfiguration.default // Session configuration
|
||||
let session = URLSession(configuration: config) // Load configuration into session
|
||||
let urlNew = URL(string: buildURLForGettingNew(queID: que))
|
||||
let urlOpen = URL(string: buildURLForGettingOpen(queID: que))
|
||||
let urlNew = URL(string: buildURLForGettingNew(queues: queues))
|
||||
let urlOpen = URL(string: buildURLForGettingOpen(queues: queues))
|
||||
|
||||
self.ticketDictionary.removeAll()
|
||||
|
||||
nc.post(name:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.ACTION.CONNECTED),
|
||||
NotificationCenter.default.post(name:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.ACTION.CONNECTED),
|
||||
object: nil,
|
||||
userInfo: ["message":""])
|
||||
|
||||
@ -154,16 +153,18 @@ class OTRS {
|
||||
|
||||
//MARK: Build urls
|
||||
|
||||
private func buildURLForGettingNew(queID:Int) -> String {
|
||||
return buildURLForGettingListByState(forState: "new", queID: queID)
|
||||
private func buildURLForGettingNew(queues:String) -> String {
|
||||
return buildURLForGettingListByState(forState: "new", queues: queues)
|
||||
}
|
||||
|
||||
private func buildURLForGettingOpen(queID:Int) -> String {
|
||||
return buildURLForGettingListByState(forState: "open", queID: queID)
|
||||
private func buildURLForGettingOpen(queues:String) -> String {
|
||||
return buildURLForGettingListByState(forState: "open", queues: queues)
|
||||
}
|
||||
|
||||
private func buildURLForGettingListByState(forState:String, queID:Int) -> String {
|
||||
return self.baseURL.appending("Ticket?UserLogin=\(self.username)&Password=\(self.password)&QueueIDs=\(queID)&States=\(forState)")
|
||||
private func buildURLForGettingListByState(forState:String, queues:String) -> String {
|
||||
let queuesQueryStr = queues.replacingOccurrences(of: ",", with: "&QueueIDs=")
|
||||
let requestURL = self.baseURL.appending("Ticket?UserLogin=\(self.username)&Password=\(self.password)&QueueIDs=\(queuesQueryStr)&States=\(forState)")
|
||||
return requestURL
|
||||
}
|
||||
|
||||
private func buildURLForGettingTicketInfo(ticketID:Int) -> String {
|
||||
|
||||
@ -40,14 +40,17 @@ class WindowController: NSWindowController {
|
||||
nc.addObserver(forName:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.LIST.UPDATED),
|
||||
object:nil, queue:nil,
|
||||
using:catchUpdateFinished)
|
||||
nc.addObserver(forName:Notification.Name(rawValue:Constants.NOTIFICATION.TABLE.TICKTS.GET_COUNT),
|
||||
object:nil, queue:nil,
|
||||
using:catchTableCountRequested)
|
||||
nc.addObserver(forName:Notification.Name(rawValue:Constants.NOTIFICATION.TICKET.ACTION.ERROR),
|
||||
object:nil, queue:nil,
|
||||
using:catchError)
|
||||
}
|
||||
|
||||
@IBAction func toolbarActionReload(_ sender: NSToolbarItem) {
|
||||
if let que:Int = Int(UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE)!) {
|
||||
OTRS.sharedInstance.reload(que: que)
|
||||
if let queues:String = UserDefaults.standard.string(forKey: Constants.USER_SETTINGS.OTRS.QUEUE) {
|
||||
OTRS.sharedInstance.reload(queues: queues)
|
||||
}
|
||||
|
||||
self.viewController.tabView.selectTabViewItem(at: Constants.TABS.TAB.OTRS)
|
||||
@ -94,17 +97,19 @@ class WindowController: NSWindowController {
|
||||
self.activity.stringValue = ""
|
||||
})
|
||||
|
||||
debugStatusBarContent()
|
||||
}
|
||||
|
||||
func catchTableCountRequested(notification:Notification) -> Void {
|
||||
guard let userInfo = notification.userInfo else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
DispatchQueue.main.async(execute: {
|
||||
if let ticketCount:Int = userInfo["count"] as? Int {
|
||||
if let ticketCount:Int = userInfo["message"] as? Int {
|
||||
self.ticketCount.title = "\(ticketCount)"
|
||||
}
|
||||
})
|
||||
|
||||
debugStatusBarContent()
|
||||
}
|
||||
|
||||
func catchError(notification:Notification) -> Void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user