mirror of
https://github.com/yggdrasil-network/yggdrasil-ios.git
synced 2025-04-28 06:05:09 +03:00
Updates for 0.5.x
This commit is contained in:
parent
b58f8e3852
commit
838e37b928
4 changed files with 89 additions and 110 deletions
|
@ -68,17 +68,34 @@ class PeersViewController: UITableViewController {
|
|||
case 0:
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "discoveredPeerPrototype", for: indexPath)
|
||||
let peers = app.yggdrasilPeers.sorted { (a, b) -> Bool in
|
||||
return (a["Port"] as! Int) < (b["Port"] as! Int)
|
||||
return (a["URI"] as! String) < (b["URI"] as! String)
|
||||
}
|
||||
|
||||
if indexPath.row < peers.count {
|
||||
let value = peers[indexPath.row]
|
||||
let up = value["Up"] as? Bool ?? false
|
||||
let proto = value["Protocol"] as? String ?? "tcp"
|
||||
let remote = value["Remote"] as? String ?? "unknown"
|
||||
let prio = value["Priority"] as? Int ?? 0
|
||||
let uri = value["URI"] as? String ?? "unknown"
|
||||
let uptime = value["Uptime"] as? UInt64 ?? 0
|
||||
|
||||
cell.textLabel?.text = "\(value["IP"] ?? "(unknown)")"
|
||||
cell.detailTextLabel?.text = "\(proto.uppercased()): \(remote)"
|
||||
if !up {
|
||||
cell.textLabel?.text = uri
|
||||
cell.detailTextLabel?.text = "Not connected"
|
||||
|
||||
cell.textLabel?.textColor = .systemGray
|
||||
cell.detailTextLabel?.textColor = .systemGray
|
||||
} else {
|
||||
let formatter = DateComponentsFormatter()
|
||||
formatter.allowedUnits = [.hour, .minute, .second]
|
||||
formatter.unitsStyle = .short
|
||||
let uptime = formatter.string(from: TimeInterval(uptime / 1000 / 1000 / 1000))!
|
||||
|
||||
cell.textLabel?.text = uri
|
||||
cell.detailTextLabel?.text = "Connected via \(proto.uppercased()), uptime \(uptime)"
|
||||
|
||||
cell.textLabel?.textColor = .label
|
||||
cell.detailTextLabel?.textColor = .label
|
||||
}
|
||||
}
|
||||
return cell
|
||||
case 1:
|
||||
|
@ -167,18 +184,11 @@ class PeersViewController: UITableViewController {
|
|||
switch section {
|
||||
case 0:
|
||||
if self.app.yggdrasilPeers.count > 0 {
|
||||
return "Connected Peers"
|
||||
return "Peer Status"
|
||||
}
|
||||
return "No peers currently connected"
|
||||
return "No Configured Peers"
|
||||
case 1:
|
||||
if let config = self.app.yggdrasilConfig {
|
||||
if let peers = config.get("Peers") as? [String] {
|
||||
if peers.count > 0 {
|
||||
return "Configured Peers"
|
||||
}
|
||||
}
|
||||
}
|
||||
return "No peers currently configured"
|
||||
return "Configured Peers"
|
||||
case 2:
|
||||
return "Peer Connectivity"
|
||||
default: return "(Unknown)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue