Interval, date format

This commit is contained in:
Gerrit Linnemann 2016-12-16 12:51:22 +01:00
parent c23853ebe7
commit a16f2e124d
7 changed files with 35 additions and 3 deletions

View File

@ -19,6 +19,7 @@
857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22B1DF974F500CCA941 /* Ticket.swift */; }; 857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22B1DF974F500CCA941 /* Ticket.swift */; };
857EB22F1DF9845200CCA941 /* TicketExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22E1DF9845200CCA941 /* TicketExtension.swift */; }; 857EB22F1DF9845200CCA941 /* TicketExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 857EB22E1DF9845200CCA941 /* TicketExtension.swift */; };
85DB9C401E03F73E0073EDE4 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85DB9C3F1E03F73E0073EDE4 /* WindowController.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 */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy 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 = "<group>"; }; 857EB22B1DF974F500CCA941 /* Ticket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Ticket.swift; path = Model/Ticket.swift; sourceTree = "<group>"; };
857EB22E1DF9845200CCA941 /* TicketExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TicketExtension.swift; path = Model/Extension/TicketExtension.swift; sourceTree = "<group>"; }; 857EB22E1DF9845200CCA941 /* TicketExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TicketExtension.swift; path = Model/Extension/TicketExtension.swift; sourceTree = "<group>"; };
85DB9C3F1E03F73E0073EDE4 /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; }; 85DB9C3F1E03F73E0073EDE4 /* WindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
85DB9C421E040A550073EDE4 /* Date.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Date.swift; path = Extension/Date.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -88,6 +90,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
8505EACE1E01441F002A0BFB /* ViewControllerExtension.swift */, 8505EACE1E01441F002A0BFB /* ViewControllerExtension.swift */,
85DB9C421E040A550073EDE4 /* Date.swift */,
); );
name = Extension; name = Extension;
sourceTree = "<group>"; sourceTree = "<group>";
@ -312,6 +315,7 @@
857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */, 857EB22C1DF974F500CCA941 /* Ticket.swift in Sources */,
85DB9C401E03F73E0073EDE4 /* WindowController.swift in Sources */, 85DB9C401E03F73E0073EDE4 /* WindowController.swift in Sources */,
854A87B01DF6BD9A00904B3E /* AppDelegate.swift in Sources */, 854A87B01DF6BD9A00904B3E /* AppDelegate.swift in Sources */,
85DB9C431E040A550073EDE4 /* Date.swift in Sources */,
854A87DB1DF6C22C00904B3E /* Constants.swift in Sources */, 854A87DB1DF6C22C00904B3E /* Constants.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

View File

@ -14,6 +14,9 @@ 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
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. // 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, *) { if #available(OSX 10.12.2, *) {
@ -42,5 +45,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
OTRS.sharedInstance.reload(que: que) OTRS.sharedInstance.reload(que: que)
} }
} }
// MARK: Timer functions
func otrsTimerAction() {
getTicketsFromOTRS()
}
} }

View File

@ -704,7 +704,7 @@
<rect key="frame" x="0.0" y="0.0" width="738" height="479"/> <rect key="frame" x="0.0" y="0.0" width="738" height="479"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<tabView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zi9-hf-1KA"> <tabView fixedFrame="YES" initialItem="MIJ-kl-tQe" translatesAutoresizingMaskIntoConstraints="NO" id="Zi9-hf-1KA">
<rect key="frame" x="13" y="2" width="712" height="463"/> <rect key="frame" x="13" y="2" width="712" height="463"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>

View File

@ -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)
}
}

View File

@ -34,7 +34,7 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
if tableColumn == self.ticketTableView.tableColumns[0] { if tableColumn == self.ticketTableView.tableColumns[0] {
cellIdentifier = CellIdentifiers.OTRSTicketNumber cellIdentifier = CellIdentifiers.OTRSTicketNumber
image = nil image = nil
text = item.created.description text = item.created.toString()
} else if tableColumn == self.ticketTableView.tableColumns[1] { } else if tableColumn == self.ticketTableView.tableColumns[1] {
cellIdentifier = CellIdentifiers.OTRSTicketDetails cellIdentifier = CellIdentifiers.OTRSTicketDetails
image = nil image = nil
@ -58,7 +58,7 @@ extension ViewController: NSTableViewDataSource, NSTableViewDelegate {
let row = ticketTableView.selectedRow let row = ticketTableView.selectedRow
let myTableViewFromNotification = notification.object as! NSTableView let myTableViewFromNotification = notification.object as! NSTableView
print(myTableViewFromNotification) print(OTRS.sharedInstance.ticketDictionary[row].title)
} }
} }

View File

@ -19,6 +19,7 @@ class ViewController: NSViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
ticketTableView.delegate = self ticketTableView.delegate = self
ticketTableView.dataSource = self ticketTableView.dataSource = self