diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index b67372062daf39c40d412b9c4925b3aaf8462438..0b32a18b1bdd3b7f7f077d17b238db483851f920 100644 --- a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift +++ b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift @@ -15,10 +15,6 @@ protocol LoginView: AnyObject { class LoginViewController: UIViewController { private let serverProtocol = "https://" - private var contextPath = "AgileWorks" - private var serverDirectory: String { - return "/" + self.contextPath - } private static let kValidServerPattern = try? NSRegularExpression(pattern: #"^[-a-z0-9]+(?:\.[-a-z0-9]+)*\.?(?::\d+)?$"#, options: .caseInsensitive) private static let kValidContextPattern = try? NSRegularExpression(pattern: #"^[a-z0-9]+"#, options: .caseInsensitive) @@ -53,10 +49,6 @@ class LoginViewController: UIViewController { let qrCodeReader = QRCodeReader() - struct LoginQr: Decodable { - var systemUrl: String - } - func inject( presenter: LoginPresenter ) { @@ -229,7 +221,7 @@ class LoginViewController: UIViewController { private func setLoginControlesEnabled(_ enabled: Bool) { disablingView.isHidden = enabled - let controls: [UIControl] = [serverTextField, loginButton, clientCertificateRemovalButton] + let controls: [UIControl] = [serverTextField, contextTextField, loginButton, clientCertificateRemovalButton, qrCodeStartupButton] for view in controls { view.isEnabled = enabled } @@ -320,12 +312,19 @@ extension LoginViewController: AVCaptureMetadataOutputObjectsDelegate { // JSON をパースする let loginQr = try JSONSerialization.jsonObject(with: jsonData) as! Dictionary print(loginQr["system_url"] as! String) - // サーバーテキストボックスに url をセット - let serverDomain = ((loginQr["system_url"] as? String)?.replacingOccurrences(of: self.serverProtocol, with: ""))?.replacingOccurrences(of: serverDirectory, with: "") - serverTextField.text = serverDomain + // サーバーテキストボックス / コンテキストパステキストボックスに 値をセット + let temp = (loginQr["system_url"] as? String)?.replacingOccurrences(of: self.serverProtocol, with: "") + let serverInfo: [String] = temp!.components(separatedBy: "/") + if !serverInfo.isEmpty { + serverTextField.text = serverInfo[0] + if serverInfo.count >= 2 { + contextTextField.text = serverInfo[1] + } + } // カメラ停止 qrCodeReader.stopRunning() } catch { + log.error(error) print(error) } print(qrStr)