From a1da2971623cd443d3ecda864bae0fe94c74917f Mon Sep 17 00:00:00 2001 From: Aldino Kemal Date: Sat, 3 Dec 2022 23:08:17 +0700 Subject: [PATCH] feat: update frontend --- src/config/settings.go | 2 +- src/views/index.html | 132 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 8 deletions(-) diff --git a/src/config/settings.go b/src/config/settings.go index 5e9989d..094a56f 100644 --- a/src/config/settings.go +++ b/src/config/settings.go @@ -6,7 +6,7 @@ import ( ) var ( - AppVersion = "v4.2.0" + AppVersion = "v4.3.0" AppPort = "3000" AppDebug = false AppOs = fmt.Sprintf("AldinoKemal") diff --git a/src/views/index.html b/src/views/index.html index b437a5b..28f3d16 100644 --- a/src/views/index.html +++ b/src/views/index.html @@ -124,6 +124,15 @@ +
+
+ Send +
Send Location
+
+ Send location to any whatsapp number +
+
+
Revoke @@ -274,7 +283,7 @@
- +
@@ -322,7 +331,7 @@
+ aria-label="caption">
@@ -379,7 +388,7 @@
- +
@@ -426,12 +435,12 @@
+ aria-label="contact name">
+ aria-label="contact phone">
@@ -444,6 +453,48 @@
+ + + @@ -1112,6 +1163,69 @@ } } + const sendLocation = { + data() { + return { + location_type: 'user', + location_phone: '', + location_latitude: '', + location_longitude: '', + location_loading: false, + } + }, + computed: { + location_phone_id() { + return this.location_type === 'user' ? `${this.location_phone}@${this.type_user}` : `${this.location_phone}@${this.type_group}` + } + }, + methods: { + sendLocationModal() { + $('#modalSendLocation').modal({ + onApprove: function () { + return false; + } + }).modal('show'); + }, + async sendLocationProcess() { + try { + let response = await this.sendLocationApi() + showSuccessInfo(response) + $('#modalSendLocation').modal('hide'); + } catch (err) { + showErrorInfo(err) + } + }, + sendLocationApi() { + return new Promise(async (resolve, reject) => { + try { + this.location_loading = true; + let payload = new FormData(); + payload.append("phone", this.location_phone_id) + payload.append("latitude", this.location_latitude) + payload.append("longitude", this.location_longitude) + let response = await http.post(`/send/location`, payload) + this.sendLocationReset(); + resolve(response.data.message) + } catch (error) { + if (error.response) { + reject(error.response.data.message) + } else { + reject(error.message) + } + } finally { + this.location_loading = false; + } + }) + }, + sendLocationReset() { + this.location_phone = ''; + this.location_latitude = ''; + this.location_longitude = ''; + this.location_type = 'user'; + }, + } + } + const userGroups = { data() { return { @@ -1352,7 +1466,11 @@ return tanggal.format('LLL'); } }, - mixins: [login, logout, reconnect, sendMessage, sendImage, sendFile, sendVideo, sendContact, sendRevoke, userGroups, userPrivacy, userAvatar, userInfo] + mixins: [ + login, logout, reconnect, + sendMessage, sendImage, sendFile, sendVideo, sendContact, sendRevoke, sendLocation, + userGroups, userPrivacy, userAvatar, userInfo + ] }).mount('#app')