diff --git a/OTRS-Watch.xcodeproj/project.pbxproj b/OTRS-Watch.xcodeproj/project.pbxproj index 5dcd8a5..8dd5448 100644 --- a/OTRS-Watch.xcodeproj/project.pbxproj +++ b/OTRS-Watch.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22B1DF974F500CCA941 /* Ticket.swift */; }; 857EB22F1DF9845200CCA941 /* TicketExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22E1DF9845200CCA941 /* TicketExtension.swift */; }; 85DB9C401E03F73E0073EDE4 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85DB9C3F1E03F73E0073EDE4 /* WindowController.swift */; }; + 85DB9C431E040A550073EDE4 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85DB9C421E040A550073EDE4 /* Date.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -57,6 +58,7 @@ 857EB22B1DF974F500CCA941 /* Ticket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Ticket.swift; path = Model/Ticket.swift; sourceTree = ""; }; 857EB22E1DF9845200CCA941 /* TicketExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TicketExtension.swift; path = Model/Extension/TicketExtension.swift; sourceTree = ""; }; 85DB9C3F1E03F73E0073EDE4 /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = ""; }; + 85DB9C421E040A550073EDE4 /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Date.swift; path = Extension/Date.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -88,6 +90,7 @@ isa = PBXGroup; children = ( 8505EACE1E01441F002A0BFB /* ViewControllerExtension.swift */, + 85DB9C421E040A550073EDE4 /* Date.swift */, ); name = Extension; sourceTree = ""; @@ -312,6 +315,7 @@ 857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */, 85DB9C401E03F73E0073EDE4 /* WindowController.swift in Sources */, 854A87B01DF6BD9A00904B3E /* AppDelegate.swift in Sources */, + 85DB9C431E040A550073EDE4 /* Date.swift in Sources */, 854A87DB1DF6C22C00904B3E /* Constants.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate index f04cf72..768bec5 100644 Binary files a/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate and b/OTRS-Watch.xcodeproj/project.xcworkspace/xcuserdata/linnemann.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/OTRS-Watch/AppDelegate.swift b/OTRS-Watch/AppDelegate.swift index a1aea68..24bb1cd 100644 --- a/OTRS-Watch/AppDelegate.swift +++ b/OTRS-Watch/AppDelegate.swift @@ -14,6 +14,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application + var otrsTimer: Timer! + otrsTimer = Timer.scheduledTimer(timeInterval: 60, target: self, selector: #selector(otrsTimerAction), userInfo: nil, repeats: true) + // Here we just opt-in for allowing our instance of the NSTouchBar class to be customized throughout the app. if #available(OSX 10.12.2, *) { @@ -42,5 +45,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { OTRS.sharedInstance.reload(que: que) } } + + + // MARK: Timer functions + + func otrsTimerAction() { + getTicketsFromOTRS() + } } diff --git a/OTRS-Watch/Base.lproj/Main.storyboard b/OTRS-Watch/Base.lproj/Main.storyboard index 617e2a7..1042293 100644 --- a/OTRS-Watch/Base.lproj/Main.storyboard +++ b/OTRS-Watch/Base.lproj/Main.storyboard @@ -704,7 +704,7 @@ - + diff --git a/OTRS-Watch/Extension/Date.swift b/OTRS-Watch/Extension/Date.swift new file mode 100644 index 0000000..8aeada0 --- /dev/null +++ b/OTRS-Watch/Extension/Date.swift @@ -0,0 +1,17 @@ +// +// Date.swift +// OTRS-Watch +// +// Created by Gerrit Linnemann on 16.12.16. +// Copyright © 2016 Adawim UG (haftungsbeschränkt). All rights reserved. +// + +import Foundation + +extension Date { + func toString() -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "dd.MM.yyyy hh:mm" + return dateFormatter.string(from: self) + } +} diff --git a/OTRS-Watch/Extension/ViewControllerExtension.swift b/OTRS-Watch/Extension/ViewControllerExtension.swift index 0df5f73..e789d87 100644 --- a/OTRS-Watch/Extension/ViewControllerExtension.swift +++ b/OTRS-Watch/Extension/ViewControllerExtension.swift @@ -34,7 +34,7 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate { if tableColumn == self.ticketTableView.tableColumns[0] { cellIdentifier = CellIdentifiers.OTRSTicketNumber image = nil - text = item.created.description + text = item.created.toString() } else if tableColumn == self.ticketTableView.tableColumns[1] { cellIdentifier = CellIdentifiers.OTRSTicketDetails image = nil @@ -58,7 +58,7 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate { let row = ticketTableView.selectedRow let myTableViewFromNotification = notification.object as! NSTableView - print(myTableViewFromNotification) + print(OTRS.sharedInstance.ticketDictionary[row].title) } } diff --git a/OTRS-Watch/ViewController.swift b/OTRS-Watch/ViewController.swift index 3641221..23c5fbf 100644 --- a/OTRS-Watch/ViewController.swift +++ b/OTRS-Watch/ViewController.swift @@ -19,6 +19,7 @@ class ViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() + ticketTableView.delegate = self ticketTableView.dataSource = self