Refactor project structure and API
This commit is contained in:
62
Views/Tabs/ServicesView.swift
Normal file
62
Views/Tabs/ServicesView.swift
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// ServicesView.swift
|
||||
// iKeyMon
|
||||
//
|
||||
// Created by tracer on 31.03.25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
|
||||
struct ServicesView: View {
|
||||
@Binding var server: Server
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
if let ports = server.info?.ports {
|
||||
Table(ports) {
|
||||
|
||||
TableColumn("Service") { port in
|
||||
Text(port.service)
|
||||
}
|
||||
|
||||
TableColumn("Status") { port in
|
||||
Text(port.status)
|
||||
.foregroundColor(
|
||||
port.status.lowercased() == "online" ? .green : .red
|
||||
)
|
||||
}
|
||||
|
||||
TableColumn("Port") { port in
|
||||
Text("\(port.port) \(port.proto.uppercased())")
|
||||
}
|
||||
|
||||
TableColumn("Protocol") { port in
|
||||
Text("\(port.proto.uppercased())")
|
||||
.monospacedDigit()
|
||||
}
|
||||
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.padding(0)
|
||||
} else {
|
||||
Text("No service information available")
|
||||
.foregroundColor(.secondary)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
.navigationTitle("Service/port monitoring")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
struct PreviewWrapper: View {
|
||||
@State var previewServer = Server(hostname: "example.com", info: .placeholder)
|
||||
|
||||
var body: some View {
|
||||
ServicesView(server: $previewServer)
|
||||
}
|
||||
}
|
||||
|
||||
return PreviewWrapper()
|
||||
}
|
||||
Reference in New Issue
Block a user