From 41b6f5f7b1a4b059268fbcffb6fead9428c7b1ad Mon Sep 17 00:00:00 2001 From: Gk40002148 Date: Tue, 15 Feb 2022 16:14:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?QR=E3=82=B3=E3=83=BC=E3=83=89=E3=82=88?= =?UTF-8?q?=E3=82=8A=E3=80=81=E3=82=B3=E3=83=B3=E3=83=86=E3=82=AD=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=91=E3=82=B9=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Login/View/LoginViewController.swift | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index b673720..3846f00 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,21 @@ 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: "") + // サーバーテキストボックス / コンテキストパステキストボックスに 値をセット + let temp = (loginQr["system_url"] as? String)?.replacingOccurrences(of: self.serverProtocol, with: "") + let serverInfo: [String] = temp!.components(separatedBy: "/") + var serverDomain: String = "" + var contextPath: String = "" + if serverInfo.count >= 2 { + serverDomain = serverInfo[0] + contextPath = serverInfo[1] + } serverTextField.text = serverDomain + contextTextField.text = contextPath // カメラ停止 qrCodeReader.stopRunning() } catch { + log.error(error) print(error) } print(qrStr) -- GitLab From fddd9f040a85bbd497253fce9f7e412c019f13d9 Mon Sep 17 00:00:00 2001 From: Gk40002148 Date: Thu, 17 Feb 2022 16:57:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?serverDomain=20/=20contextPath=20=E3=81=AE?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E6=96=B9=E6=B3=95=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AgileWorks/Login/View/LoginViewController.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift index 3846f00..0b32a18 100644 --- a/AgileWorks/AgileWorks/Login/View/LoginViewController.swift +++ b/AgileWorks/AgileWorks/Login/View/LoginViewController.swift @@ -315,14 +315,12 @@ extension LoginViewController: AVCaptureMetadataOutputObjectsDelegate { // サーバーテキストボックス / コンテキストパステキストボックスに 値をセット let temp = (loginQr["system_url"] as? String)?.replacingOccurrences(of: self.serverProtocol, with: "") let serverInfo: [String] = temp!.components(separatedBy: "/") - var serverDomain: String = "" - var contextPath: String = "" - if serverInfo.count >= 2 { - serverDomain = serverInfo[0] - contextPath = serverInfo[1] + if !serverInfo.isEmpty { + serverTextField.text = serverInfo[0] + if serverInfo.count >= 2 { + contextTextField.text = serverInfo[1] + } } - serverTextField.text = serverDomain - contextTextField.text = contextPath // カメラ停止 qrCodeReader.stopRunning() } catch { -- GitLab