From 5efe046328fb395668a2235abad37caf249a4f3c Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sun, 14 Jul 2024 08:59:00 +0700 Subject: [PATCH] feat: add ui getting pair code --- src/internal/rest/app.go | 1 - src/views/components/AppLoginWithCode.js | 101 +++++++++++++++++++++++ src/views/index.html | 4 +- 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/views/components/AppLoginWithCode.js diff --git a/src/internal/rest/app.go b/src/internal/rest/app.go index e9e087a..467fc00 100644 --- a/src/internal/rest/app.go +++ b/src/internal/rest/app.go @@ -49,7 +49,6 @@ func (handler *App) LoginWithCode(c *fiber.Ctx) error { "login_code": loginCode, }, }) - } func (handler *App) Logout(c *fiber.Ctx) error { diff --git a/src/views/components/AppLoginWithCode.js b/src/views/components/AppLoginWithCode.js new file mode 100644 index 0000000..e573c78 --- /dev/null +++ b/src/views/components/AppLoginWithCode.js @@ -0,0 +1,101 @@ +export default { + name: 'AppLoginWithCode', + props: { + connected: null, + }, + data: () => { + return { + phone: '', + submitting: false, + pair_code: null, + }; + }, + methods: { + async openModal() { + try { + $('#modalLoginWithCode').modal({ + onApprove: function() { + return false; + }, + }).modal('show'); + } catch (err) { + showErrorInfo(err); + } + }, + async handleSubmit() { + if (this.submitting) return; + try { + this.submitting = true; + const { response } = await this.submitApi(); + this.pair_code = response.pair_code; + } catch (err) { + showErrorInfo(err); + } finally { + this.submitting = false; + } + }, + + async submitApi() { + try { + return http.get(`/app/login-with-code`, { + params: { + phone: this.phone, + }, + }); + } catch (error) { + if (error.response) { + throw Error(error.response.data.message); + } + throw Error(error.message); + } + + }, + }, + template: ` +
+
+
Login with Code
+
+ Login with pairing code to get access to your devices +
+
+
+ + + + `, +}; \ No newline at end of file diff --git a/src/views/index.html b/src/views/index.html index cc01cc4..7e6a082 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -44,6 +44,7 @@ +
@@ -127,6 +128,7 @@