diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index 256721a59..8fd69085c 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -204,7 +204,17 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', Client.prototype.installApp = function (id, manifest, title, config, callback) { var that = this; - var data = { appStoreId: id, manifest: manifest, location: config.location, portBindings: config.portBindings, accessRestriction: config.accessRestriction, oauthProxy: config.oauthProxy }; + var data = { + appStoreId: id, + manifest: manifest, + location: config.location, + portBindings: config.portBindings, + accessRestriction: config.accessRestriction, + oauthProxy: config.oauthProxy, + cert: config.cert, + key: config.key + }; + $http.post(client.apiOrigin + '/api/v1/apps/install', data).success(function (data, status) { if (status !== 202 || typeof data !== 'object') return defaultErrorHandler(callback); diff --git a/webadmin/src/views/appstore.html b/webadmin/src/views/appstore.html index e0d27d9c9..f315f5c6f 100644 --- a/webadmin/src/views/appstore.html +++ b/webadmin/src/views/appstore.html @@ -43,24 +43,24 @@ -
-
+
{{ appInstall.error.cert }}
+
- +
-
+
- + diff --git a/webadmin/src/views/appstore.js b/webadmin/src/views/appstore.js index 8b2c81811..b38b118cc 100644 --- a/webadmin/src/views/appstore.js +++ b/webadmin/src/views/appstore.js @@ -19,7 +19,11 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca portBindings: {}, accessRestriction: null, oauthProxy: false, - mediaLinks: [] + mediaLinks: [], + certificateFile: null, + certificateFileName: '', + keyFile: null, + keyFileName: '' }; $scope.appNotFound = { @@ -142,6 +146,11 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca $scope.appInstall.installFormVisible = false; $scope.appInstall.resourceConstraintVisible = false; $scope.appInstall.mediaLinks = []; + $scope.appInstall.certificateFile = null; + $scope.appInstall.certificateFileName = ''; + $scope.appInstall.keyFile = null; + $scope.appInstall.keyFileName = ''; + $('#collapseInstallForm').collapse('hide'); $('#collapseResourceConstraint').collapse('hide'); $('#collapseMediaLinksCarousel').collapse('show'); @@ -163,6 +172,34 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca } }; + document.getElementById('appInstallCertificateFileInput').onchange = function (event) { + $scope.$apply(function () { + $scope.appInstall.certificateFile = null; + $scope.appInstall.certificateFileName = event.target.files[0].name; + + var reader = new FileReader(); + reader.onload = function (result) { + if (!result.target || !result.target.result) return console.error('Unable to read local file'); + $scope.appInstall.certificateFile = result.target.result; + }; + reader.readAsText(event.target.files[0]); + }); + }; + + document.getElementById('appInstallKeyFileInput').onchange = function (event) { + $scope.$apply(function () { + $scope.appInstall.keyFile = null; + $scope.appInstall.keyFileName = event.target.files[0].name; + + var reader = new FileReader(); + reader.onload = function (result) { + if (!result.target || !result.target.result) return console.error('Unable to read local file'); + $scope.appInstall.keyFile = result.target.result; + }; + reader.readAsText(event.target.files[0]); + }); + }; + $scope.showInstall = function (app) { $scope.reset(); @@ -211,7 +248,16 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca users: [ $scope.appInstall.accessRestriction ] } : null; - Client.installApp($scope.appInstall.app.id, $scope.appInstall.app.manifest, $scope.appInstall.app.title, { location: $scope.appInstall.location || '', portBindings: finalPortBindings, accessRestriction: accessRestriction, oauthProxy: $scope.appInstall.oauthProxy }, function (error) { + var data = { + location: $scope.appInstall.location || '', + portBindings: finalPortBindings, + accessRestriction: accessRestriction, + oauthProxy: $scope.appInstall.oauthProxy, + cert: $scope.appConfigure.certificateFile, + key: $scope.appConfigure.keyFile, + }; + + Client.installApp($scope.appInstall.app.id, $scope.appInstall.app.manifest, $scope.appInstall.app.title, data, function (error) { if (error) { if (error.statusCode === 409 && (error.message.indexOf('is reserved') !== -1 || error.message.indexOf('is already in use') !== -1)) { $scope.appInstall.error.port = error.message;