5 changed files with 214 additions and 59 deletions
-
60docs/openapi.yaml
-
101readme.md
-
2src/config/settings.go
-
106src/views/components/MessageDelete.js
-
4src/views/index.html
@ -0,0 +1,106 @@ |
|||||
|
export default { |
||||
|
name: 'DeleteMessage', |
||||
|
data() { |
||||
|
return { |
||||
|
type: 'user', |
||||
|
phone: '', |
||||
|
message_id: '', |
||||
|
loading: false, |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
phone_id() { |
||||
|
return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}` |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
openModal() { |
||||
|
$('#modalMessageDelete').modal({ |
||||
|
onApprove: function () { |
||||
|
return false; |
||||
|
} |
||||
|
}).modal('show'); |
||||
|
}, |
||||
|
async handleSubmit() { |
||||
|
try { |
||||
|
let response = await this.submitApi() |
||||
|
showSuccessInfo(response) |
||||
|
$('#modalMessageDelete').modal('hide'); |
||||
|
} catch (err) { |
||||
|
showErrorInfo(err) |
||||
|
} |
||||
|
}, |
||||
|
async submitApi() { |
||||
|
this.loading = true; |
||||
|
try { |
||||
|
const payload = {phone: this.phone_id, message: this.new_message} |
||||
|
|
||||
|
let response = await window.http.post(`/message/${this.message_id}/delete`, payload) |
||||
|
this.handleReset(); |
||||
|
return response.data.message; |
||||
|
} catch (error) { |
||||
|
if (error.response) { |
||||
|
throw new Error(error.response.data.message); |
||||
|
} |
||||
|
throw new Error(error.message); |
||||
|
} finally { |
||||
|
this.loading = false; |
||||
|
} |
||||
|
}, |
||||
|
handleReset() { |
||||
|
this.type = 'user'; |
||||
|
this.phone = ''; |
||||
|
this.message_id = ''; |
||||
|
this.new_message = ''; |
||||
|
this.loading = false; |
||||
|
}, |
||||
|
}, |
||||
|
template: `
|
||||
|
<div class="red card" @click="openModal()" style="cursor: pointer"> |
||||
|
<div class="content"> |
||||
|
<a class="ui red right ribbon label">Message</a> |
||||
|
<div class="header">Delete Message</div> |
||||
|
<div class="description"> |
||||
|
Delete your sent message |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<!-- Modal MessageDelete --> |
||||
|
<div class="ui small modal" id="modalMessageDelete"> |
||||
|
<i class="close icon"></i> |
||||
|
<div class="header"> |
||||
|
Delete Message |
||||
|
</div> |
||||
|
<div class="content"> |
||||
|
<form class="ui form"> |
||||
|
<div class="field"> |
||||
|
<label>Type</label> |
||||
|
<select name="type" v-model="type" aria-label="type"> |
||||
|
<option value="group">Group Message</option> |
||||
|
<option value="user">Private Message</option> |
||||
|
</select> |
||||
|
</div> |
||||
|
<div class="field"> |
||||
|
<label>Phone / Group ID</label> |
||||
|
<input v-model="phone" type="text" placeholder="6289..." |
||||
|
aria-label="phone"> |
||||
|
<input :value="phone_id" disabled aria-label="whatsapp_id"> |
||||
|
</div> |
||||
|
<div class="field"> |
||||
|
<label>Message ID</label> |
||||
|
<input v-model="message_id" type="text" placeholder="Please enter your message id" |
||||
|
aria-label="message id"> |
||||
|
</div> |
||||
|
</form> |
||||
|
</div> |
||||
|
<div class="actions"> |
||||
|
<div class="ui approve positive right labeled icon button" :class="{'loading': this.loading}" |
||||
|
@click="handleSubmit"> |
||||
|
Delete |
||||
|
<i class="send icon"></i> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
`
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue