diff --git a/src/views/apps.html b/src/views/apps.html index 03de4307e..400acf83c 100644 --- a/src/views/apps.html +++ b/src/views/apps.html @@ -101,7 +101,7 @@
- +
{{appConfigure.error.label}}
@@ -109,6 +109,14 @@ +
+ + Reset +
+ + +
+
diff --git a/src/views/apps.js b/src/views/apps.js index 1724d65df..4615debe3 100644 --- a/src/views/apps.js +++ b/src/views/apps.js @@ -50,6 +50,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location ssoAuth: false, tags: '', label: '', + icon: { data: null }, action: 'general', @@ -119,6 +120,22 @@ angular.module('Application').controller('AppsController', ['$scope', '$location // translate for tag-input $scope.appConfigure.tags = app.tags ? app.tags.join(',') : ''; + $('#iconFileInput').get(0).onchange = function (event) { + var fr = new FileReader(); + fr.onload = function () { + $scope.$apply(function () { + var tmp = { + file: event.target.files[0], + data: fr.result, + url: null + }; + + $scope.appConfigure.icon = tmp; + }); + }; + fr.readAsDataURL(event.target.files[0]); + }; + $('#appConfigureModal').modal('show'); }, @@ -179,6 +196,14 @@ angular.module('Application').controller('AppsController', ['$scope', '$location data.mailboxName = ''; } + if ($scope.appConfigure.icon) { + if ($scope.appConfigure.icon.data) { + data.icon = $scope.appConfigure.icon.data.replace(/^data:image\/[a-z]+;base64,/, ''); + } else { // reset the icon + data.icon = ''; + } + } + Client.configureApp($scope.appConfigure.app.id, data, function (error) { let tab = 'advanced'; // the tab to switch to @@ -227,6 +252,10 @@ angular.module('Application').controller('AppsController', ['$scope', '$location $scope.reset(); }); + }, + + showCustomIconSelector: function () { + $('#iconFileInput').click(); } };