Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfnuesse <felix.nuesse@t-online.de>2018-12-30 22:53:18 +0300
committerfnuesse <felix.nuesse@t-online.de>2018-12-30 22:53:18 +0300
commit07c9e199f65aaf0ad3d2aedcbe7a1bd28a66e9e3 (patch)
tree9864ce541cabdd637256ea7039044d46cff6f149
parentc86e4f87b5d066b88fe6bc93587d077cf55e968a (diff)
Added button to refetch the icon from the target url
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
-rw-r--r--appinfo/routes.php1
-rw-r--r--controller/iconcontroller.php22
-rw-r--r--js/app/directives/iconpicker.js40
-rw-r--r--templates/views/partials/icon-picker.html5
4 files changed, 53 insertions, 15 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index ab7d9152..37fb1fbe 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -78,6 +78,7 @@ return [
#Icons
+ ['name' => 'icon#getSingleIcon', 'url' => '/api/v2/geticon/{base64Url}', 'verb' => 'GET'],
['name' => 'icon#getIcon', 'url' => '/api/v2/icon/{base64Url}', 'verb' => 'GET'],
['name' => 'icon#getIcon', 'url' => '/api/v2/icon/{base64Url}/{credentialId}', 'verb' => 'GET'],
['name' => 'icon#getLocalIconList', 'url' => '/api/v2/icon/list', 'verb' => 'GET'],
diff --git a/controller/iconcontroller.php b/controller/iconcontroller.php
index 792b7742..97a24813 100644
--- a/controller/iconcontroller.php
+++ b/controller/iconcontroller.php
@@ -56,6 +56,28 @@ class IconController extends ApiController {
* @NoAdminRequired
* @NoCSRFRequired
*/
+ public function getSingleIcon($base64Url) {
+ $url = base64_decode(str_replace('_','/', $base64Url));
+ if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
+ $url = "http://" . $url;
+ }
+
+
+ $icon = new IconService($url);
+
+ if ($icon->icoExists) {
+ $icon_json['type']= $icon->icoType;
+ $icon_json['content']= base64_encode($icon->icoData);
+ return new JSONResponse($icon_json);
+ }
+
+ return new JSONResponse();
+ }
+
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
public function getIcon($base64Url, $credentialId) {
$url = base64_decode(str_replace('_','/', $base64Url));
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() {
diff --git a/templates/views/partials/icon-picker.html b/templates/views/partials/icon-picker.html
index 7ab33c6f..10aed43f 100644
--- a/templates/views/partials/icon-picker.html
+++ b/templates/views/partials/icon-picker.html
@@ -31,8 +31,9 @@
<br />
<button ng-click="useIcon()">{{ 'use.icon' | translate}}</button>
</div>
- <div ng-if="credential.icon">
- <button ng-click="deleteIcon()">{{ 'use.icon.delete' | translate}}</button>
+ <div >
+ <button ng-click="deleteIcon()" ng-if="credential.icon">{{ 'use.icon.delete' | translate}}</button>
+ <button ng-click="refreshUrlIcon()">{{ 'use.icon.refresh' | translate}}</button>
</div>
</div>
</div>