From dcdab20f503a2ca8f5d3ddaa30c39564d67929cf Mon Sep 17 00:00:00 2001 From: raxelsen Date: Fri, 23 Feb 2018 16:17:33 +0100 Subject: [PATCH] TT#20532 As a Customer, I want to download a single Fax What has been done: - TT#34559, Conversations: Implement error handling - TT#34558, Conversations: Implement store action - TT#34557, Conversations: Implement the download button in the vue component CscConversation - TT#34550, Conversations: Implement download method in api layer Change-Id: I10ea9b084b4f5a4fc8e1c9d22a0554e66fcdac84 --- .gitignore | 1 + src/api/conversations.js | 18 +++++-- src/components/CscConversation.vue | 14 ++++- src/components/pages/Conversations.vue | 39 +++++++++++++- src/locales/en.json | 9 +++- src/store/conversations.js | 72 +++++++++++++++++++------- t/api/conversations.js | 3 +- 7 files changed, 127 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 6875b75c..8fe3ba69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .thumbs.db +.vscode node_modules/ dist/ npm-debug.log* diff --git a/src/api/conversations.js b/src/api/conversations.js index ab29cb23..1ce448f9 100644 --- a/src/api/conversations.js +++ b/src/api/conversations.js @@ -18,9 +18,6 @@ export function getConversations(id, page, rows) { let inputString = `${item.type}${item.call_type}${item.id}`; let id = crypto.createHash('sha256').update(inputString).digest('base64'); item._id = id; - if (item._links['ngcp:voicemailrecordings']) { - item.voicemail = item._links['ngcp:voicemailrecordings'].href; - } delete item._links; if (item.type == 'call') { item.type = item.call_type != 'call' ? 'callforward' @@ -39,7 +36,6 @@ export function getConversations(id, page, rows) { }); } - export function downloadVoiceMail(id) { return new Promise((resolve, reject)=>{ Vue.http.get('/api/voicemailrecordings/' + id, { responseType: 'blob' }) @@ -54,6 +50,20 @@ export function downloadVoiceMail(id) { }); } +export function downloadFax(id) { + return new Promise((resolve, reject)=>{ + Vue.http.get('/api/faxrecordings/' + id, { responseType: 'blob' }) + .then(res => { + return res.blob(); + }).then(fax => { + saveAs(fax, "fax-" + id + '.tif'); + resolve(); + }).catch((err)=>{ + reject(err); + }); + }); +} + diff --git a/src/components/CscConversation.vue b/src/components/CscConversation.vue index 30ba056c..f1938d8b 100644 --- a/src/components/CscConversation.vue +++ b/src/components/CscConversation.vue @@ -50,7 +50,7 @@ {{ $t('pages.conversations.buttons.videoCall') }} - + @@ -58,6 +58,15 @@ +
+ + + + {{ $t('pages.conversations.buttons.download') }} + + +
@@ -90,6 +99,9 @@ downloadVoiceMail(id) { this.$store.dispatch('conversations/downloadVoiceMail', id); }, + downloadFax(id) { + this.$store.dispatch('conversations/downloadFax', id); + }, call(localMedia) { let conversation = this.conversation; let number = conversation.direction == 'out' ? diff --git a/src/components/pages/Conversations.vue b/src/components/pages/Conversations.vue index 87364c10..1bcfc9ad 100644 --- a/src/components/pages/Conversations.vue +++ b/src/components/pages/Conversations.vue @@ -5,8 +5,11 @@