- Show stable group health in a fixed 2x2 metric grid - Add link-chain state to fleet cards and parse hardware/control/SIM/cellular - Replace the wrapped icon with a full-bleed app icon - Bump the IPA build number
82 lines
2.6 KiB
Swift
82 lines
2.6 KiB
Swift
import Foundation
|
|
|
|
enum DefaultContainer {
|
|
private static let credentials: any CredentialStore = FileCredentialStore(
|
|
location: documentFileURL("credentials.json")
|
|
)
|
|
|
|
private static let instanceGroups: any InstanceGroupStore = FileInstanceGroupStore(
|
|
location: documentFileURL("instance-groups.json")
|
|
)
|
|
|
|
private static let logStore: any LogStore = FileLogStore(
|
|
location: documentFileURL("log-center.json")
|
|
)
|
|
|
|
static func documentFileURL(_ name: String) -> URL {
|
|
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
return directory.appendingPathComponent(name)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeFleetModel() -> FleetViewModel {
|
|
FleetViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
probe: ConnectionProbe(client: SimAdminClient()),
|
|
credentials: credentials,
|
|
deviceService: DeviceService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
),
|
|
groupStore: instanceGroups
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeMessagesModel() -> MessagesViewModel {
|
|
MessagesViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: MessageService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
)
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeLogsModel(autoRefreshOnAppear: Bool = true) -> LogsViewModel {
|
|
let store = logStore
|
|
return LogsViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: LogCenterService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials,
|
|
store: store
|
|
),
|
|
store: store,
|
|
autoRefreshOnAppear: autoRefreshOnAppear
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeSettingsModel() -> SettingsViewModel {
|
|
SettingsViewModel(store: logStore)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeDeviceModel(instance: Instance) -> DeviceViewModel {
|
|
DeviceViewModel(
|
|
instance: instance,
|
|
service: DeviceService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
),
|
|
probe: ConnectionProbe(client: SimAdminClient())
|
|
)
|
|
}
|
|
}
|