Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
Sync Update - 51021f1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakr233 committed Mar 11, 2022
1 parent 464e37a commit f9316f7
Show file tree
Hide file tree
Showing 24 changed files with 200 additions and 64 deletions.
5 changes: 5 additions & 0 deletions Application/Rayon/Extension/UIBridge/DoubleConfirm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
// Created by Lakr Aream on 2022/2/9.
//

import RayonModule
import SwiftUI

extension UIBridge {
static func requiresConfirmation(message: String, confirmation: @escaping (Bool) -> Void) {
if RayonStore.shared.disableConformation {
confirmation(true)
return
}
let alert = NSAlert()
alert.alertStyle = .critical
alert.messageText = message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct AuthenticateSessionView: View {
}
}
}
.requiresFrame()
}

var sheetBody: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct MainView: View {
var body: some View {
NavigationView {
SidebarView()
WelcomeView()
WelcomeView().requiresFrame()
}
.onAppear {
openLicenseIfNeeded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ struct SidebarView: View {
@EnvironmentObject var store: RayonStore
@EnvironmentObject var terminalManager: TerminalManager

@State var openServerSelector: Bool = false

var body: some View {
List {
NavigationLink {
WelcomeView()
WelcomeView().requiresFrame()
} label: {
Label("Welcome", systemImage: "sun.min.fill")
}
manager
session
recent
if store.storeRecent { recent }
}
.navigationTitle("Rayon")
.frame(minWidth: 200)
Expand All @@ -32,31 +30,31 @@ struct SidebarView: View {
var manager: some View {
Section("Manager") {
NavigationLink {
MachineManagerView()
MachineManagerView().requiresFrame()
} label: {
Label("Server", systemImage: "server.rack")
}
.badge(store.machineGroup.count)
NavigationLink {
IdentityManager()
IdentityManager().requiresFrame()
} label: {
Label("Identity", systemImage: "person.fill")
}
.badge(store.identityGroup.count)
NavigationLink {
SnippetManager()
SnippetManager().requiresFrame()
} label: {
Label("Snippet", systemImage: "arrow.right.doc.on.clipboard")
}
.badge(store.snippetGroup.count)
NavigationLink {
PortForwardManager()
PortForwardManager().requiresFrame()
} label: {
Label("Port Forward", systemImage: "arrowshape.turn.up.right.circle.fill")
}
.badge(store.portForwardGroup.count)
NavigationLink {
SettingView()
SettingView().requiresFrame()
} label: {
Label("Setting", systemImage: "gearshape.fill")
}
Expand All @@ -78,7 +76,7 @@ struct SidebarView: View {
} else {
ForEach(terminalManager.sessionContexts) { context in
NavigationLink {
TerminalView(context: context)
TerminalView(context: context).requiresFrame()
} label: {
if context.remoteType == .machine {
Label(context.machine.name, systemImage: "terminal")
Expand Down Expand Up @@ -125,22 +123,21 @@ struct SidebarView: View {
.expended()
}
Button {
openServerSelector = true
DispatchQueue.global().async {
let machines = RayonUtil.selectMachine(allowMany: true)
mainActor {
for machine in machines {
terminalManager.createSession(withMachineID: machine)
}
}
}
} label: {
HStack {
Label("Batch Startup", systemImage: "wind")
Spacer()
}
.background(Color.accentColor.opacity(0.0001))
}
.sheet(isPresented: $openServerSelector, onDismiss: nil, content: {
MachinePickerView(onComplete: { machines in
if machines.isEmpty { return }
for machine in machines {
terminalManager.createSession(withMachineID: machine)
}
}, allowSelectMany: true)
})
.buttonStyle(PlainButtonStyle())
.expended()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
//

import Colorful
import RayonModule
import SwiftUI

struct ThanksView: View {
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject var store: RayonStore

@State var openLicenseInfo: Bool = false

Expand Down Expand Up @@ -48,12 +50,16 @@ struct ThanksView: View {
}
.frame(width: 600, height: 250)
.background(
ColorfulView(
colors: [Color.accentColor],
colorCount: 4
)
.ignoresSafeArea()
.opacity(0.25)
Group {
if !store.reducedViewEffects {
ColorfulView(
colors: [Color.accentColor],
colorCount: 4
)
.ignoresSafeArea()
.opacity(0.25)
}
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,24 @@ struct WelcomeView: View {
.navigationTitle("Rayon")
.padding()
.expended()
.background(StarLinkView().ignoresSafeArea())
.background(
ColorfulView(
colors: [Color.accentColor],
colorCount: 4
)
.ignoresSafeArea()
.opacity(0.25)
Group {
if !store.reducedViewEffects {
StarLinkView().ignoresSafeArea()
}
}
)
.background(
Group {
if !store.reducedViewEffects {
ColorfulView(
colors: [Color.accentColor],
colorCount: 4
)
.ignoresSafeArea()
.opacity(0.25)
}
}
)
.overlay(
VStack {
Expand All @@ -123,7 +133,6 @@ struct WelcomeView: View {
}
.padding()
)
.requiresFrame()
.toolbar {
ToolbarItem {
Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct IdentityManager: View {
.expended()
}
}
.requiresFrame()
.toolbar {
ToolbarItem {
Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct MachineCreateView: View {
NSRemoteShell()
.setupConnectionHost(serverLocation)
.setupConnectionPort(NSNumber(value: Int(serverPort) ?? 0))
.setupConnectionTimeout(6)
.setupConnectionTimeout(RayonStore.shared.timeoutNumber)
.requestConnectAndWait()
}

Expand Down Expand Up @@ -205,7 +205,7 @@ struct MachineCreateView: View {
let remote = NSRemoteShell()
.setupConnectionHost(serverLocation)
.setupConnectionPort(NSNumber(value: Int(serverPort) ?? 0))
.setupConnectionTimeout(6)
.setupConnectionTimeout(RayonStore.shared.timeoutNumber)
.requestConnectAndWait()
identity.callAuthenticationWith(remote: remote)
debugPrint(remote.isAuthenicated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct MachineManagerView: View {
var body: some View {
Group {
collections
.requiresFrame()
.animation(.interactiveSpring(), value: hoverSelection)
.animation(.interactiveSpring(), value: selection)
.animation(.interactiveSpring(), value: store.machineGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PortForwardBackend: ObservableObject {
context.shell
.setupConnectionHost(context.machine.remoteAddress)
.setupConnectionPort(NSNumber(value: Int(context.machine.remotePort) ?? 0))
.setupConnectionTimeout(6)
.setupConnectionTimeout(RayonStore.shared.timeoutNumber)
.requestConnectAndWait()
guard context.shell.isConnected else {
self.putHint(for: context.info.id, with: "failed connect")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct PortForwardManager: View {
@State var searchText: String = ""
@State var selection: Set<RDPortForward.ID> = []
@State var sortOrder: [KeyPathComparator<RDPortForward>] = []

var startButtonCanWork: Bool {
for sel in selection {
if !backend.sessionExists(withPortForwardID: sel) {
Expand All @@ -46,7 +46,7 @@ struct PortForwardManager: View {
}
return false
}

var stopButtonCanWork: Bool {
for sel in selection {
if backend.sessionExists(withPortForwardID: sel) {
Expand All @@ -65,7 +65,17 @@ struct PortForwardManager: View {
table
}
}
.requiresFrame()
.onChange(of: selection) { newValue in
// bug when deletion
var rebuild = Set<RDPortForward.ID>()
for value in newValue {
let check = store.portForwardGroup.forwards.contains {
$0.id == value
}
if check { rebuild.insert(value) }
}
if selection != rebuild { selection = rebuild }
}
.toolbar {
ToolbarItem {
Button {
Expand Down Expand Up @@ -129,7 +139,10 @@ struct PortForwardManager: View {
}
} label: {
Text(backend.sessionExists(withPortForwardID: data.id) ? "Terminate" : "Open")
.foregroundColor(.accentColor)
.underline()
}
.buttonStyle(.borderless)
}
.width(80)
TableColumn("Status") { data in
Expand Down Expand Up @@ -180,6 +193,7 @@ struct PortForwardManager: View {
.width(65)
TableColumn("Target Host", value: \.targetHost) { data in
TextField("Host Address", text: $store.portForwardGroup[data.id].targetHost)
.disabled(backend.sessionExists(withPortForwardID: data.id))
}
TableColumn("Target Port", value: \.targetPort) { data in
TextField("Target Port", text: .init(get: {
Expand All @@ -201,7 +215,7 @@ struct PortForwardManager: View {
}
}
}

func removeButtonTapped() {
UIBridge.requiresConfirmation(
message: "Are you sure you want to remove \(selection.count) items?"
Expand All @@ -211,6 +225,7 @@ struct PortForwardManager: View {
store.portForwardGroup.delete(selected)
backend.endSession(withPortForwardID: selected)
}
selection = []
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,60 @@
// Created by Lakr Aream on 2022/3/10.
//

import RayonModule
import SwiftUI

struct SettingView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
@EnvironmentObject var store: RayonStore

struct SettingView_Previews: PreviewProvider {
static var previews: some View {
SettingView()
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 10) {
Section {
Toggle("Reduced Effect", isOn: $store.reducedViewEffects)
.font(.system(.headline, design: .rounded))
Text("This option will remove animated blur background and star animation.")
.font(.system(.subheadline, design: .rounded))
Toggle("Disable Confirmation", isOn: $store.disableConformation)
.font(.system(.headline, design: .rounded))
Text("This option will remove the confirmation alert, use with caution.")
.font(.system(.subheadline, design: .rounded))
Toggle("Store Recent", isOn: $store.storeRecent)
.font(.system(.headline, design: .rounded))
Text("This option will save several most recent used machine.")
.font(.system(.subheadline, design: .rounded))
} header: {
Text("Application")
.font(.system(.headline, design: .rounded))
} footer: {
Divider()
}
Section {
Slider(value: Binding<Double>.init(get: {
Double(store.timeout)
}, set: { newValue in
store.timeout = Int(exactly: newValue) ?? 5
}), in: 2 ... 30, step: 1) { Group {} }
Text("SSH will report invalid connection after \(store.timeout) seconds.")
.font(.system(.subheadline, design: .rounded))
Slider(value: Binding<Double>.init(get: {
Double(store.monitorInterval)
}, set: { newValue in
store.monitorInterval = Int(exactly: newValue) ?? 5
}), in: 5 ... 60, step: 5) { Group {} }
Text("Server monitor will update information \(store.monitorInterval) seconds after last attempt.")
.font(.system(.subheadline, design: .rounded))
} header: {
Text("Connection")
.font(.system(.headline, design: .rounded))
} footer: {
Divider()
}
Label("EOF", systemImage: "text.append")
.font(.system(.caption2, design: .rounded))
}
.padding()
}
.navigationTitle("Setting")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ struct SnippetManager: View {
var body: some View {
Group {
collections
.requiresFrame()
.animation(.interactiveSpring(), value: hoverSelection)
.animation(.interactiveSpring(), value: selection)
.animation(.interactiveSpring(), value: store.machineGroup)
Expand Down
Loading

0 comments on commit f9316f7

Please sign in to comment.