summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2023-12-12 19:51:54 -0500
committerShav Kinderlehrer <[email protected]>2023-12-12 19:51:54 -0500
commit3994a6f408905049a5c280a303e30fe636b07968 (patch)
treeca06fab6088483deb3ab6bd422bca8647348c094
parent9ccd37f754db33a190a9867bd5a310dfe5f4d17c (diff)
downloadjel-3994a6f408905049a5c280a303e30fe636b07968.tar.gz
jel-3994a6f408905049a5c280a303e30fe636b07968.zip
Add logger + log console
-rw-r--r--Jel.xcodeproj/project.pbxproj32
-rw-r--r--Jel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved9
-rw-r--r--Jel/Controllers/AuthStateController.swift8
-rw-r--r--Jel/Controllers/JellyfinClientController.swift3
-rw-r--r--Jel/Views/ConsoleSheetView.swift43
-rw-r--r--Jel/Views/ContentView.swift34
6 files changed, 117 insertions, 12 deletions
diff --git a/Jel.xcodeproj/project.pbxproj b/Jel.xcodeproj/project.pbxproj
index 20b4838..c40e64e 100644
--- a/Jel.xcodeproj/project.pbxproj
+++ b/Jel.xcodeproj/project.pbxproj
@@ -11,6 +11,9 @@
3D1015DC2B27F5D300F5C29A /* Model.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 3D1015DA2B27F5D300F5C29A /* Model.xcdatamodeld */; };
3D1015DE2B27F79900F5C29A /* DatamodelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D1015DD2B27F79900F5C29A /* DatamodelController.swift */; };
3D1015E42B28000E00F5C29A /* AuthStateController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D1015E32B28000E00F5C29A /* AuthStateController.swift */; };
+ 3D7709392B29139700199889 /* Pulse in Frameworks */ = {isa = PBXBuildFile; productRef = 3D7709382B29139700199889 /* Pulse */; };
+ 3D77093B2B29139700199889 /* PulseUI in Frameworks */ = {isa = PBXBuildFile; productRef = 3D77093A2B29139700199889 /* PulseUI */; };
+ 3D77093D2B29350700199889 /* ConsoleSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D77093C2B29350700199889 /* ConsoleSheetView.swift */; };
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9063CA2B279A310063DD2A /* JelApp.swift */; };
3D9063CD2B279A310063DD2A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9063CC2B279A310063DD2A /* ContentView.swift */; };
3D9063CF2B279A320063DD2A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D9063CE2B279A320063DD2A /* Assets.xcassets */; };
@@ -61,6 +64,7 @@
3D1015DB2B27F5D300F5C29A /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = "<group>"; };
3D1015DD2B27F79900F5C29A /* DatamodelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatamodelController.swift; sourceTree = "<group>"; };
3D1015E32B28000E00F5C29A /* AuthStateController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthStateController.swift; sourceTree = "<group>"; };
+ 3D77093C2B29350700199889 /* ConsoleSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleSheetView.swift; sourceTree = "<group>"; };
3D9063C72B279A310063DD2A /* Jel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Jel.app; sourceTree = BUILT_PRODUCTS_DIR; };
3D9063CA2B279A310063DD2A /* JelApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JelApp.swift; sourceTree = "<group>"; };
3D9063CC2B279A310063DD2A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -84,6 +88,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 3D77093B2B29139700199889 /* PulseUI in Frameworks */,
+ 3D7709392B29139700199889 /* Pulse in Frameworks */,
3D9064592B27E4C70063DD2A /* JellyfinKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -110,6 +116,7 @@
children = (
3D9063CC2B279A310063DD2A /* ContentView.swift */,
3D91FDC52B28C28900919017 /* SignIn */,
+ 3D77093C2B29350700199889 /* ConsoleSheetView.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -223,6 +230,8 @@
name = Jel;
packageProductDependencies = (
3D9064582B27E4C70063DD2A /* JellyfinKit */,
+ 3D7709382B29139700199889 /* Pulse */,
+ 3D77093A2B29139700199889 /* PulseUI */,
);
productName = Jel;
productReference = 3D9063C72B279A310063DD2A /* Jel.app */;
@@ -297,6 +306,7 @@
);
mainGroup = 3D9063BE2B279A310063DD2A;
packageReferences = (
+ 3D7709372B29139700199889 /* XCRemoteSwiftPackageReference "Pulse" */,
);
productRefGroup = 3D9063C82B279A310063DD2A /* Products */;
projectDirPath = "";
@@ -346,6 +356,7 @@
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */,
+ 3D77093D2B29350700199889 /* ConsoleSheetView.swift in Sources */,
3D1015DC2B27F5D300F5C29A /* Model.xcdatamodeld in Sources */,
3D91FDC92B28C62800919017 /* SignInView.swift in Sources */,
3D91FDCB2B28CA2500919017 /* SignInToServerView.swift in Sources */,
@@ -713,7 +724,28 @@
};
/* End XCConfigurationList section */
+/* Begin XCRemoteSwiftPackageReference section */
+ 3D7709372B29139700199889 /* XCRemoteSwiftPackageReference "Pulse" */ = {
+ isa = XCRemoteSwiftPackageReference;
+ repositoryURL = "https://github.com/kean/Pulse";
+ requirement = {
+ kind = upToNextMinorVersion;
+ minimumVersion = 4.0.5;
+ };
+ };
+/* End XCRemoteSwiftPackageReference section */
+
/* Begin XCSwiftPackageProductDependency section */
+ 3D7709382B29139700199889 /* Pulse */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 3D7709372B29139700199889 /* XCRemoteSwiftPackageReference "Pulse" */;
+ productName = Pulse;
+ };
+ 3D77093A2B29139700199889 /* PulseUI */ = {
+ isa = XCSwiftPackageProductDependency;
+ package = 3D7709372B29139700199889 /* XCRemoteSwiftPackageReference "Pulse" */;
+ productName = PulseUI;
+ };
3D9064582B27E4C70063DD2A /* JellyfinKit */ = {
isa = XCSwiftPackageProductDependency;
productName = JellyfinKit;
diff --git a/Jel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Jel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
index e005bb5..e1e75ae 100644
--- a/Jel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
+++ b/Jel.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
@@ -11,6 +11,15 @@
}
},
{
+ "package": "Pulse",
+ "repositoryURL": "https://github.com/kean/Pulse",
+ "state": {
+ "branch": null,
+ "revision": "d647e99f06abc94d63579e335ad4ce368195c149",
+ "version": "4.0.5"
+ }
+ },
+ {
"package": "URLQueryEncoder",
"repositoryURL": "https://github.com/CreateAPI/URLQueryEncoder",
"state": {
diff --git a/Jel/Controllers/AuthStateController.swift b/Jel/Controllers/AuthStateController.swift
index 93dbee3..35283bd 100644
--- a/Jel/Controllers/AuthStateController.swift
+++ b/Jel/Controllers/AuthStateController.swift
@@ -11,15 +11,17 @@ class AuthStateController: ObservableObject {
@Published var loggedIn: Bool
@Published var serverUrl: URL?
@Published var authToken: String?
+ @Published var userId: String?
private let defaults = UserDefaults.standard
static let shared = AuthStateController()
- init(loggedIn: Bool = false, serverUrl: URL? = nil, authToken: String? = nil) {
+ init(loggedIn: Bool = false, serverUrl: URL? = nil, authToken: String? = nil, userId: String? = nil) {
self.loggedIn = loggedIn
self.serverUrl = serverUrl
self.authToken = authToken
+ self.userId = userId
}
func load() {
@@ -30,11 +32,15 @@ class AuthStateController: ObservableObject {
if let oldAuthToken = defaults.string(forKey: "AuthState_authToken") {
self.authToken = oldAuthToken
}
+ if let oldUserId = defaults.string(forKey: "AuthState_userId") {
+ self.userId = oldUserId
+ }
}
func save() {
defaults.set(self.loggedIn, forKey: "AuthState_loggedIn")
defaults.set(self.serverUrl, forKey: "AuthState_serverUrl")
defaults.set(self.authToken, forKey: "AuthState_authToken")
+ defaults.set(self.userId, forKey: "AuthState_userId")
}
}
diff --git a/Jel/Controllers/JellyfinClientController.swift b/Jel/Controllers/JellyfinClientController.swift
index a80b908..24d4615 100644
--- a/Jel/Controllers/JellyfinClientController.swift
+++ b/Jel/Controllers/JellyfinClientController.swift
@@ -8,6 +8,7 @@
import Foundation
import Get
import JellyfinKit
+import Pulse
struct AuthHeaders: Codable {
var Client: String
@@ -56,6 +57,8 @@ class JellyfinClientController: ObservableObject {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601withFractionalSeconds
$0.decoder = decoder
+
+ $0.sessionDelegate = Pulse.URLSessionProxyDelegate()
})
}
diff --git a/Jel/Views/ConsoleSheetView.swift b/Jel/Views/ConsoleSheetView.swift
new file mode 100644
index 0000000..4d9ba32
--- /dev/null
+++ b/Jel/Views/ConsoleSheetView.swift
@@ -0,0 +1,43 @@
+//
+// ConsoleSheetView.swift
+// Jel
+//
+// Created by zerocool on 12/12/23.
+//
+
+import SwiftUI
+import PulseUI
+
+struct ConsoleSheetView: View {
+ @Binding var showingConsoleSheet: Bool
+
+ var body: some View {
+ NavigationStack {
+ List {
+ NavigationLink {
+ ConsoleView(mode: .network)
+ .closeButtonHidden()
+ } label: {
+ Text("Network Console")
+ }
+ NavigationLink {
+ ConsoleView(mode: .logs)
+ .closeButtonHidden()
+ } label: {
+ Text("Logs Console")
+ }
+ }
+ .toolbar {
+ Button {
+ showingConsoleSheet.toggle()
+ } label: {
+ Text("Done")
+ }
+ }
+ }
+ }
+}
+
+#Preview {
+ ConsoleSheetView(showingConsoleSheet: .constant(true))
+}
diff --git a/Jel/Views/ContentView.swift b/Jel/Views/ContentView.swift
index 356615d..91d5c7c 100644
--- a/Jel/Views/ContentView.swift
+++ b/Jel/Views/ContentView.swift
@@ -6,23 +6,35 @@
//
import SwiftUI
+import PulseUI
struct ContentView: View {
@ObservedObject var authState: AuthStateController
+
+ @State var showingConsoleSheet: Bool = false
var body: some View {
- VStack {
- if !authState.loggedIn {
- SignInView(authState: authState)
- } else {
- Text("Logged in")
- Button("Log out") {
- authState.loggedIn = false
- authState.save()
- }
- }
+ VStack {
+ Button {
+ showingConsoleSheet.toggle()
+ } label: {
+ Label("Console", systemImage: "network")
+ }
+ .sheet(isPresented: $showingConsoleSheet) {
+ ConsoleSheetView(showingConsoleSheet: $showingConsoleSheet)
+ }
+
+ if !authState.loggedIn {
+ SignInView(authState: authState)
+ } else {
+ Text("Logged in")
+ Button("Log out") {
+ authState.loggedIn = false
+ authState.save()
}
- .padding()
+ }
}
+ .padding()
+ }
}
#Preview {