diff --git a/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js b/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js index 3364dfcb0..4ad156dd0 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/connectionEditModalController.js @@ -29,12 +29,14 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', var connectionEditModal = $injector.get('connectionEditModal'); var connectionService = $injector.get('connectionService'); var displayObjectPreparationService = $injector.get('displayObjectPreparationService'); + var Connection = $injector.get('Connection'); + var HistoryEntryWrapper = $injector.get('HistoryEntryWrapper'); // Make a copy of the old connection so that we can copy over the changes when done var oldConnection = $scope.connection; // Copy data into a new conection object in case the user doesn't want to save - $scope.connection = angular.copy($scope.connection); + $scope.connection = new Connection($scope.connection); var newConnection = !$scope.connection.identifier; if(newConnection) @@ -45,6 +47,13 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', if(!$scope.connection.protocol) $scope.connection.protocol = "vnc"; + $scope.historyEntryWrappers = []; + + // Wrap all the history entries + $scope.connection.history.forEach(function wrapHistoryEntry(historyEntry) { + $scope.historyEntryWrappers.push(new HistoryEntryWrapper(historyEntry)); + }); + /** * Close the modal. */ @@ -103,7 +112,8 @@ angular.module('manage').controller('connectionEditModalController', ['$scope', // Close the modal connectionEditModal.deactivate(); }); - } + }; + }]); diff --git a/guacamole/src/main/webapp/app/manage/directives/connectionParameter.js b/guacamole/src/main/webapp/app/manage/directives/connectionParameter.js index fcbd64cc1..f3f931017 100644 --- a/guacamole/src/main/webapp/app/manage/directives/connectionParameter.js +++ b/guacamole/src/main/webapp/app/manage/directives/connectionParameter.js @@ -24,7 +24,7 @@ /** * A directive that allows editing of a connection parameter. */ -angular.module('manage').directive('guacConnectionParameter', [function locationChooser() { +angular.module('manage').directive('guacConnectionParameter', [function connectionParameter() { return { // Element only @@ -41,14 +41,44 @@ angular.module('manage').directive('guacConnectionParameter', [function location $scope.parameterName = $scope.parameter.name; // Coerce numeric strings to numbers - if($scope.parameterType === 'NUMERIC') { - $scope.connectionParameters[$scope.parameterName] = - Number($scope.connectionParameters[$scope.parameterName]) || 0; - // Coerce boolean strings to boolean values - } else if($scope.parameterType === 'BOOLEAN') { - $scope.connectionParameters[$scope.parameterName] = - $scope.connectionParameters[$scope.parameterName] === 'true'; + if ($scope.parameterType === 'NUMERIC') { + + // If a value exists, coerce it to a number + if ($scope.connectionParameters[$scope.parameterName]) + $scope.parameterValue = Number($scope.connectionParameters[$scope.parameterName]); + else + $scope.parameterValue = null; + } + + // Coerce boolean strings to boolean values + else if ($scope.parameterType === 'BOOLEAN') { + // TODO: Use defined checked value from protocol description + $scope.parameterValue = $scope.connectionParameters[$scope.parameterName] === 'true'; + } + + // All other parameter types are represented internally as strings + else + $scope.parameterValue = $scope.connectionParameters[$scope.parameterName]; + + // Update internal representation as model is changed + $scope.$watch('parameterValue', function parameterValueChanges(value) { + + // Convert numeric values back into strings + if ($scope.parameterType === 'NUMERIC') { + if (value === null || typeof value === 'undefined') + $scope.connectionParameters[$scope.parameterName] = ''; + else + $scope.connectionParameters[$scope.parameterName] = value.toString(); + } + + // TODO: Transform BOOLEAN input fields back into strings based on protocol description + + // All other parameter types are already strings + else + $scope.connectionParameters[$scope.parameterName] = value; + + }); }] }; diff --git a/guacamole/src/main/webapp/app/manage/manageModule.js b/guacamole/src/main/webapp/app/manage/manageModule.js index 1f469b40c..9ea80c415 100644 --- a/guacamole/src/main/webapp/app/manage/manageModule.js +++ b/guacamole/src/main/webapp/app/manage/manageModule.js @@ -23,5 +23,5 @@ /** * The module for the administration functionality. */ -angular.module('manage', ['btford.modal', 'protocol', 'connectionGroup', 'util']); +angular.module('manage', ['btford.modal', 'protocol', 'connection', 'connectionGroup', 'util']); diff --git a/guacamole/src/main/webapp/app/manage/templates/connectionParameter.html b/guacamole/src/main/webapp/app/manage/templates/connectionParameter.html index 30cefd3db..4249f3a3a 100644 --- a/guacamole/src/main/webapp/app/manage/templates/connectionParameter.html +++ b/guacamole/src/main/webapp/app/manage/templates/connectionParameter.html @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - - - - - - + + + + + + \ No newline at end of file diff --git a/guacamole/src/main/webapp/app/manage/templates/editableConnection.html b/guacamole/src/main/webapp/app/manage/templates/editableConnection.html index 4a3755faa..2d8e5805a 100644 --- a/guacamole/src/main/webapp/app/manage/templates/editableConnection.html +++ b/guacamole/src/main/webapp/app/manage/templates/editableConnection.html @@ -94,12 +94,12 @@ THE SOFTWARE.