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