Skip to content

Commit

Permalink
adds job links to the today view
Browse files Browse the repository at this point in the history
  • Loading branch information
aapis committed Feb 2, 2023
1 parent 9ef005a commit 67e54d7
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 70 deletions.
8 changes: 6 additions & 2 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
53218D6124B7F6EC0088ABE9 /* DLPrototypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53218D6024B7F6EC0088ABE9 /* DLPrototypeTests.swift */; };
53218D6C24B7F6EC0088ABE9 /* DLPrototypeUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53218D6B24B7F6EC0088ABE9 /* DLPrototypeUITests.swift */; };
53218D8224B8195D0088ABE9 /* Screenshots in Resources */ = {isa = PBXBuildFile; fileRef = 53218D8124B8195D0088ABE9 /* Screenshots */; };
5330EEB7298B6418004FC38A /* JobRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5330EEB6298B6418004FC38A /* JobRow.swift */; };
5335A5AE296CFF83000051B1 /* FileHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5AD296CFF83000051B1 /* FileHelper.swift */; };
5335A5B3296D17EB000051B1 /* TaskDashboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5B2296D17EB000051B1 /* TaskDashboard.swift */; };
5335A5B5296D1FA7000051B1 /* TaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5B4296D1FA7000051B1 /* TaskView.swift */; };
Expand Down Expand Up @@ -131,6 +132,7 @@
53218D6D24B7F6EC0088ABE9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
53218D8024B8094C0088ABE9 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
53218D8124B8195D0088ABE9 /* Screenshots */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Screenshots; sourceTree = "<group>"; };
5330EEB6298B6418004FC38A /* JobRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobRow.swift; sourceTree = "<group>"; };
5335A5AD296CFF83000051B1 /* FileHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileHelper.swift; sourceTree = "<group>"; };
5335A5B2296D17EB000051B1 /* TaskDashboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskDashboard.swift; sourceTree = "<group>"; };
5335A5B4296D1FA7000051B1 /* TaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -490,6 +492,7 @@
537AEBA0296287B900385787 /* LogRow.swift */,
53C6D0932965048500EA6129 /* DetailsRow.swift */,
53C6D09729654F4C00EA6129 /* DetailGroup.swift */,
5330EEB6298B6418004FC38A /* JobRow.swift */,
);
path = RowTypes;
sourceTree = "<group>";
Expand Down Expand Up @@ -708,6 +711,7 @@
53999C1F29669C4E00125E65 /* NoteCreate.swift in Sources */,
53759E0D2967ECAE00DCDC4B /* LogRecords.swift in Sources */,
53959A212973D3E5007A2549 /* CoreDataProjectConfiguration.swift in Sources */,
5330EEB7298B6418004FC38A /* JobRow.swift in Sources */,
53F10FE0296E77BE0048D040 /* CoreDataJob.swift in Sources */,
533E40652970DA640007785A /* ViewUpdater.swift in Sources */,
53EDDFA02963487A008D34C7 /* CustomPickerItem.swift in Sources */,
Expand Down Expand Up @@ -901,7 +905,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -932,7 +936,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 67;
CURRENT_PROJECT_VERSION = 68;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
81 changes: 38 additions & 43 deletions DLPrototype/Views/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,6 @@ struct Home: View {
var body: some View {
NavigationSplitView {
List(selection: $selected) {
NavigationLink {
Split(direction: $splitDirection)
.navigationTitle("Multitasking")
.environmentObject(recordsModel)
.navigationSplitViewColumnWidth(ideal: 300)
.toolbar {
Button(action: setSplitViewDirection, label: {
if !splitDirection {
Image(systemName: "rectangle.split.1x2")
} else {
Image(systemName: "rectangle.split.2x1")
}
})
.buttonStyle(.borderless)
.font(.title)

if showExperimentalFeatures {
Button(action: {}, label: {
Image(systemName: "arrow.triangle.2.circlepath")
})
.buttonStyle(.borderless)
.font(.title)
}
}
} label: {
Image(systemName: "rectangle.split.2x1")
.padding(.trailing, 10)
Text("Multitasking")
}

Divider()
.foregroundColor(.clear)

NavigationLink {
Today()
.navigationTitle("Today")
Expand All @@ -80,13 +47,12 @@ struct Home: View {
} label: {
Image(systemName: "doc.append.fill")
.padding(.trailing, 10)
Text("Today")
.font(.title)
}

NavigationLink {
NoteDashboard()
.navigationTitle("Notes")
.navigationSplitViewColumnWidth(ideal: 300)
.toolbar {
if showExperimentalFeatures {
Button(action: {}, label: {
Expand All @@ -99,7 +65,7 @@ struct Home: View {
} label: {
Image(systemName: "note.text")
.padding(.trailing, 10)
Text("Notes")
.font(.title)
}

NavigationLink {
Expand All @@ -119,7 +85,7 @@ struct Home: View {
} label: {
Image(systemName: "list.number")
.padding(.trailing, 10)
Text("Tasks")
.font(.title)
}

NavigationLink {
Expand All @@ -140,7 +106,7 @@ struct Home: View {
} label: {
Image(systemName: "folder")
.padding(.trailing, 10)
Text("Projects")
.font(.title)
}

NavigationLink {
Expand All @@ -159,16 +125,44 @@ struct Home: View {
} label: {
Image(systemName: "square.and.arrow.up.fill")
.padding(.trailing, 10)
Text("Import")
.font(.title)
}

if showExperimentalFeatures {
Divider()

NavigationLink {
Split(direction: $splitDirection)
.navigationTitle("Multitasking")
.environmentObject(recordsModel)
.toolbar {
Button(action: setSplitViewDirection, label: {
if !splitDirection {
Image(systemName: "rectangle.split.1x2")
} else {
Image(systemName: "rectangle.split.2x1")
}
})
.buttonStyle(.borderless)
.font(.title)

if showExperimentalFeatures {
Button(action: {}, label: {
Image(systemName: "arrow.triangle.2.circlepath")
})
.buttonStyle(.borderless)
.font(.title)
}
}
} label: {
Image(systemName: "rectangle.split.2x1")
.padding(.trailing, 10)
.font(.title)
}

NavigationLink {
Manage()
.navigationTitle("Manage")
.navigationSplitViewColumnWidth(ideal: 300)
.toolbar {
if showExperimentalFeatures {
Button(action: {}, label: {
Expand All @@ -181,7 +175,7 @@ struct Home: View {
} label: {
Image(systemName: "books.vertical")
.padding(.trailing, 10)
Text("Manage")
.font(.title)
}

NavigationLink {
Expand All @@ -190,7 +184,7 @@ struct Home: View {
} label: {
Image(systemName: "calendar")
.padding(.trailing, 10)
Text("Calendar")
.font(.title)
}


Expand All @@ -200,12 +194,13 @@ struct Home: View {
} label: {
Image(systemName: "cloud.fill")
.padding(.trailing, 10)
Text("Backup")
.font(.title)
}
}
}
} detail: {
Text("This dashboard is great, isn't it")

}
.navigationTitle("DailyLogger b.\(appVersion ?? "0")")
.onAppear(perform: updateName)
Expand Down
16 changes: 13 additions & 3 deletions DLPrototype/Views/Shared/Entry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,26 @@ public struct Entry: Identifiable, Equatable {
public var message: String
public var url: String = ""
public var colour: Color
public var jobObject: Job? = nil
public let id = UUID()

init(timestamp: String, job: String, message: String) {
public init(timestamp: String, job: String, message: String) {
self.timestamp = timestamp
self.job = job
self.message = message
self.url = ""
self.colour = Color.gray.opacity(0.2)
}

init(timestamp: String, job: String, message: String, colour: Color) {
public init(timestamp: String, job: String, message: String, colour: Color) {
self.timestamp = timestamp
self.job = job
self.message = message
self.url = ""
self.colour = colour
}

init(timestamp: String, url: String, message: String) {
public init(timestamp: String, url: String, message: String) {
self.timestamp = timestamp
self.url = url
self.job = ""
Expand All @@ -43,6 +44,15 @@ public struct Entry: Identifiable, Equatable {
setJobFromUrl()
}

public init(timestamp: String, job: Job, message: String) {
self.timestamp = timestamp
self.url = ""
self.job = job.jid.string
self.message = message
self.colour = Color.gray.opacity(0.2)
self.jobObject = job
}

mutating public func setColour(_ colour: Color) -> Void {
self.colour = colour
}
Expand Down
5 changes: 3 additions & 2 deletions DLPrototype/Views/Tasks/TaskDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ struct TaskDashboard: View {
@Environment(\.managedObjectContext) var moc

@FetchRequest(sortDescriptors: [SortDescriptor(\.jid, order: .reverse)]) public var jobs: FetchedResults<Job>
@FetchRequest(sortDescriptors: [SortDescriptor(\LogTask.id)]) public var tasks: FetchedResults<LogTask>
@FetchRequest(sortDescriptors: [SortDescriptor(\.id)]) public var tasks: FetchedResults<LogTask>
@FetchRequest(sortDescriptors: [SortDescriptor(\.pid)]) public var projects: FetchedResults<Project>

private var pickerItems: [CustomPickerItem] {
var items: [CustomPickerItem] = [CustomPickerItem(title: "Choose a job", tag: 0)]
Expand Down Expand Up @@ -63,7 +64,7 @@ struct TaskDashboard: View {
SearchBar(
text: $searchText,
disabled: false,
placeholder: "Search \(tasks.count) tasks across \(jobs.count) projects"
placeholder: "Search \(tasks.count) tasks across \(jobs.count) jobs in \(projects.count) projects"
)

if searchText != "" {
Expand Down
29 changes: 26 additions & 3 deletions DLPrototype/Views/Today/LogTable/ColumnTypes/EditableColumn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct EditableColumn: View {
@Binding public var isDeleting: Bool
@Binding public var text: String

public var shouldUnderline: Bool = false
public var url: URL?

@AppStorage("tigerStriped") private var tigerStriped = false

var body: some View {
Expand All @@ -36,9 +39,29 @@ struct EditableColumn: View {
.padding(10)
.foregroundColor(textColour)
} else {
Text(text)
.padding(10)
.foregroundColor(textColour)
if type == "job" {
if shouldUnderline {
Link(text, destination: url!)
.padding(10)
.foregroundColor(textColour)
.underline()
.onHover { inside in
if inside {
NSCursor.pointingHand.push()
} else {
NSCursor.pop()
}
}
} else {
Text(text)
.padding(10)
.foregroundColor(textColour)
}
} else {
Text(text)
.padding(10)
.foregroundColor(textColour)
}
}

}
Expand Down
24 changes: 13 additions & 11 deletions DLPrototype/Views/Today/LogTable/LogTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,19 @@ struct LogTable: View, Identifiable {

if records.count > 0 {
ForEach(records) { record in
let entry = Entry(
timestamp: LogRecords.timestampToString(record.timestamp!),
job: String(record.job?.jid ?? 0),
message: record.message!
)

LogRow(
entry: entry,
index: records.firstIndex(of: record),
colour: Color.fromStored((record.job?.colour) ?? Theme.rowColourAsDouble)
)
if record.job != nil {
let entry = Entry(
timestamp: LogRecords.timestampToString(record.timestamp!),
job: record.job!,
message: record.message!
)

LogRow(
entry: entry,
index: records.firstIndex(of: record),
colour: Color.fromStored((record.job?.colour) ?? Theme.rowColourAsDouble)
)
}
}.onAppear(perform: changeSort)
} else {
LogRowEmpty(message: "No records found for today", index: 0, colour: Theme.rowColour)
Expand Down
5 changes: 3 additions & 2 deletions DLPrototype/Views/Today/LogTable/LogTableDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ struct LogTableDetails: View {

if !statistics.contains(where: {$0.value == "\(colour)"}) {
statistics.append(
Statistic(
StatisticWithView(
key: record.job?.jid.string ?? "No ID",
value: "\(colour)",
colour: colour,
group: .jobs
group: .jobs,
view: AnyView(JobRow(job: record.job!, colour: colour))
)
)
}
Expand Down
Loading

0 comments on commit 67e54d7

Please sign in to comment.