From 07c9e199f65aaf0ad3d2aedcbe7a1bd28a66e9e3 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 30 Dec 2018 20:53:18 +0100 Subject: Added button to refetch the icon from the target url Signed-off-by: fnuesse --- js/app/directives/iconpicker.js | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'js/app/directives/iconpicker.js') diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js index fafb1136..195ee35e 100644 --- a/js/app/directives/iconpicker.js +++ b/js/app/directives/iconpicker.js @@ -115,26 +115,40 @@ $('#iconPicker').dialog('close'); }; + scope.refreshUrlIcon = function(){ + var queryUrl = OC.generateUrl('apps/passman/api/v2/geticon/'+btoa(scope.credential.url)); + $http.get(queryUrl).then(function (response) { + + scope.customIcon = {}; + scope.customIcon.data='data:image/'+response.data.type+';base64,'+response.data.content; + console.log(scope.customIcon.data); + + if (response.data) { + return response.data; + } else { + return response; + } + }); + }; + scope.useIcon = function() { if(scope.customIcon){ var data = scope.customIcon.data; scope.credential.icon.type = data.substring(data.lastIndexOf(":")+1,data.lastIndexOf(";")); scope.credential.icon.content = data.substring(data.lastIndexOf(",")+1, data.length); - $('#iconPicker').dialog('close'); - return; + }else{ + $http.get(scope.selectedIcon.url).then(function(result) { + var base64Data = window.btoa(result.data); + var mimeType = 'svg+xml'; + if(!scope.credential.icon){ + scope.credential.icon = {}; + } + scope.credential.icon.type = mimeType; + scope.credential.icon.content = base64Data; + }); } - - $http.get(scope.selectedIcon.url).then(function(result) { - var base64Data = window.btoa(result.data); - var mimeType = 'svg+xml'; - if(!scope.credential.icon){ - scope.credential.icon = {}; - } - scope.credential.icon.type = mimeType; - scope.credential.icon.content = base64Data; - $('#iconPicker').dialog('close'); - }); + $('#iconPicker').dialog('close'); }; $(element).click(function() { -- cgit v1.2.3