Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [iOS] Admin Dashboard Enhancements #1271

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions Shared/Coordinators/AdminDashboardCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import JellyfinAPI
import PulseUI
import Stinsen
import SwiftUI

final class AdminDashboardCoordinator: NavigationCoordinatable {
let stack = NavigationStack(initial: \AdminDashboardCoordinator.start)

@Root
var start = makeStart

@Route(.push)
var activeSessions = makeActiveSessions
@Route(.push)
var activeDeviceDetails = makeActiveDeviceDetails
@Route(.push)
var devices = makeDevices
@Route(.push)
var tasks = makeTasks
@Route(.push)
var users = makeUsers
@Route(.push)
var userDetails = makeUserDetails
@Route(.push)
var editScheduledTask = makeEditScheduledTask
@Route(.modal)
var addScheduledTaskTrigger = makeAddScheduledTaskTrigger
@Route(.push)
var serverLogs = makeServerLogs

@ViewBuilder
func makeActiveSessions() -> some View {
ActiveSessionsView()
}

@ViewBuilder
func makeActiveDeviceDetails(box: BindingBox<SessionInfo?>) -> some View {
ActiveSessionDetailView(box: box)
}

@ViewBuilder
func makeDevices() -> some View {
DevicesView()
}

@ViewBuilder
func makeTasks() -> some View {
ScheduledTasksView()
}

@ViewBuilder
func makeUsers() -> some View {
UserAdministrationView()
}

@ViewBuilder
func makeUserDetails(observer: UserAdministrationObserver) -> some View {
UserAdministrationDetailView(observer: observer)
}

@ViewBuilder
func makeEditScheduledTask(observer: ServerTaskObserver) -> some View {
EditScheduledTaskView(observer: observer)
}

func makeAddScheduledTaskTrigger(observer: ServerTaskObserver) -> NavigationViewCoordinator<BasicNavigationViewCoordinator> {
NavigationViewCoordinator {
AddTaskTriggerView(observer: observer)
}
}

@ViewBuilder
func makeServerLogs() -> some View {
ServerLogsView()
}

@ViewBuilder
func makeStart() -> some View {
AdminDashboardView()
}
}
6 changes: 6 additions & 0 deletions Shared/Coordinators/MainCoordinator/iOSMainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ final class MainCoordinator: NavigationCoordinatable {
var liveVideoPlayer = makeLiveVideoPlayer
@Route(.modal)
var settings = makeSettings
@Route(.modal)
var adminDashboard = makeAdminDashboard
@Route(.fullScreen)
var videoPlayer = makeVideoPlayer

Expand Down Expand Up @@ -134,6 +136,10 @@ final class MainCoordinator: NavigationCoordinatable {
NavigationViewCoordinator(SettingsCoordinator())
}

func makeAdminDashboard() -> NavigationViewCoordinator<AdminDashboardCoordinator> {
NavigationViewCoordinator(AdminDashboardCoordinator())
}

func makeMainTab() -> MainTabCoordinator {
MainTabCoordinator()
}
Expand Down
47 changes: 4 additions & 43 deletions Shared/Coordinators/SettingsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ final class SettingsCoordinator: NavigationCoordinatable {
var photoPicker = makePhotoPicker
@Route(.push)
var userProfile = makeUserProfileSettings

@Route(.push)
var customizeViewsSettings = makeCustomizeViewsSettings
@Route(.push)
Expand All @@ -45,26 +44,14 @@ final class SettingsCoordinator: NavigationCoordinatable {
var indicatorSettings = makeIndicatorSettings
@Route(.push)
var serverConnection = makeServerConnection
@Route(.modal)
var adminDashboard = makeAdminDashboard
@Route(.push)
var videoPlayerSettings = makeVideoPlayerSettings
@Route(.push)
var customDeviceProfileSettings = makeCustomDeviceProfileSettings

@Route(.push)
var userDashboard = makeUserDashboard
@Route(.push)
var activeSessions = makeActiveSessions
@Route(.push)
var activeDeviceDetails = makeActiveDeviceDetails
@Route(.modal)
var itemOverviewView = makeItemOverviewView
@Route(.push)
var tasks = makeTasks
@Route(.push)
var editScheduledTask = makeEditScheduledTask
@Route(.push)
var serverLogs = makeServerLogs

@Route(.modal)
var editCustomDeviceProfile = makeEditCustomDeviceProfile
@Route(.modal)
Expand Down Expand Up @@ -162,19 +149,8 @@ final class SettingsCoordinator: NavigationCoordinatable {
EditServerView(server: server)
}

@ViewBuilder
func makeUserDashboard() -> some View {
UserDashboardView()
}

@ViewBuilder
func makeActiveSessions() -> some View {
ActiveSessionsView()
}

@ViewBuilder
func makeActiveDeviceDetails(box: BindingBox<SessionInfo?>) -> some View {
ActiveSessionDetailView(box: box)
func makeAdminDashboard() -> NavigationViewCoordinator<AdminDashboardCoordinator> {
NavigationViewCoordinator(AdminDashboardCoordinator())
}

func makeItemOverviewView(item: BaseItemDto) -> NavigationViewCoordinator<BasicNavigationViewCoordinator> {
Expand All @@ -183,21 +159,6 @@ final class SettingsCoordinator: NavigationCoordinatable {
}
}

@ViewBuilder
func makeTasks() -> some View {
ScheduledTasksView()
}

@ViewBuilder
func makeEditScheduledTask(observer: ServerTaskObserver) -> some View {
EditScheduledTaskView(observer: observer)
}

@ViewBuilder
func makeServerLogs() -> some View {
ServerLogsView()
}

func makeItemFilterDrawerSelector(selection: Binding<[ItemFilterType]>) -> some View {
OrderedSectionSelectorView(selection: selection, sources: ItemFilterType.allCases)
.navigationTitle(L10n.filters)
Expand Down
24 changes: 24 additions & 0 deletions Shared/Extensions/JellyfinAPI/DayOfWeek.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import Foundation
import JellyfinAPI

extension DayOfWeek {

var displayTitle: String? {
let newLineRemoved = self.rawValue.replacingOccurrences(of: "\n", with: "")

guard let index = DateFormatter().weekdaySymbols.firstIndex(of: newLineRemoved) else {
return nil
}

let localCal = Calendar.current
return localCal.weekdaySymbols[index].localizedCapitalized
}
}
24 changes: 24 additions & 0 deletions Shared/Extensions/JellyfinAPI/TaskInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import Foundation
import JellyfinAPI

extension TaskState {

var displayTitle: String {
switch self {
case .idle:
return L10n.taskStateIdle
case .cancelling:
return L10n.taskStateCancelling
case .running:
return L10n.taskStateRunning
}
}
}
45 changes: 45 additions & 0 deletions Shared/Extensions/TaskTriggerType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
//

import Foundation

// TODO: move to SDK as patch file

enum TaskTriggerType: String, Codable, CaseIterable, Displayable, SystemImageable {

case daily = "DailyTrigger"
case weekly = "WeeklyTrigger"
case interval = "IntervalTrigger"
case startup = "StartupTrigger"

var displayTitle: String {
switch self {
case .daily:
return L10n.daily
case .weekly:
return L10n.weekly
case .interval:
return L10n.interval
case .startup:
return L10n.onApplicationStartup
}
}

var systemImage: String {
switch self {
case .daily:
return "clock"
case .weekly:
return "calendar"
case .interval:
return "timer"
case .startup:
return "power"
}
}
}
Loading