mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-932: Fully-working connection group editor.
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for the connection edit modal.
|
* The controller for editing or creating connections.
|
||||||
*/
|
*/
|
||||||
angular.module('manage').controller('manageConnectionController', ['$scope', '$injector',
|
angular.module('manage').controller('manageConnectionController', ['$scope', '$injector',
|
||||||
function manageConnectionController($scope, $injector) {
|
function manageConnectionController($scope, $injector) {
|
||||||
@@ -63,7 +63,6 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE)
|
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE)
|
||||||
.success(function connectionGroupReceived(rootGroup) {
|
.success(function connectionGroupReceived(rootGroup) {
|
||||||
$scope.rootGroup = rootGroup;
|
$scope.rootGroup = rootGroup;
|
||||||
$scope.loadingConnections = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get protocol metadata
|
// Get protocol metadata
|
||||||
@@ -135,12 +134,11 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action to be provided along with the object sent to showStatus which
|
* An action to be provided along with the object sent to showStatus which
|
||||||
* closes the currently-shown status dialog.
|
* immediately deletes the current connection.
|
||||||
*/
|
*/
|
||||||
var DELETE_ACTION = {
|
var DELETE_ACTION = {
|
||||||
name : "manage.edit.connection.delete",
|
name : "manage.edit.connection.delete",
|
||||||
@@ -204,6 +202,3 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
|||||||
};
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for the connection group edit modal.
|
* The controller for editing or creating connection groups.
|
||||||
*/
|
*/
|
||||||
angular.module('manage').controller('manageConnectionGroupController', ['$scope', '$injector',
|
angular.module('manage').controller('manageConnectionGroupController', ['$scope', '$injector',
|
||||||
function manageConnectionGroupController($scope, $injector) {
|
function manageConnectionGroupController($scope, $injector) {
|
||||||
@@ -31,28 +31,53 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
var PermissionSet = $injector.get('PermissionSet');
|
var PermissionSet = $injector.get('PermissionSet');
|
||||||
|
|
||||||
// Required services
|
// Required services
|
||||||
var connectionGroupService = $injector.get('connectionGroupService');
|
var $location = $injector.get('$location');
|
||||||
var $routeParams = $injector.get('$routeParams');
|
var $routeParams = $injector.get('$routeParams');
|
||||||
|
var connectionGroupService = $injector.get('connectionGroupService');
|
||||||
|
|
||||||
// Copy data into a new conection group object in case the user doesn't want to save
|
/**
|
||||||
|
* An action to be provided along with the object sent to showStatus which
|
||||||
|
* closes the currently-shown status dialog.
|
||||||
|
*/
|
||||||
|
var ACKNOWLEDGE_ACTION = {
|
||||||
|
name : "manage.error.action.acknowledge",
|
||||||
|
// Handle action
|
||||||
|
callback : function acknowledgeCallback() {
|
||||||
|
$scope.showStatus(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of the connection group being edited. If a new connection
|
||||||
|
* group is being created, this will not be defined.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
var identifier = $routeParams.id;
|
var identifier = $routeParams.id;
|
||||||
|
|
||||||
// Pull connection group data
|
// Pull connection group hierarchy
|
||||||
|
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE)
|
||||||
|
.success(function connectionGroupReceived(rootGroup) {
|
||||||
|
$scope.rootGroup = rootGroup;
|
||||||
|
});
|
||||||
|
|
||||||
|
// If we are editing an existing connection group, pull its data
|
||||||
if (identifier) {
|
if (identifier) {
|
||||||
connectionGroupService.getConnectionGroup(identifier).success(function connectionGroupReceived(connectionGroup) {
|
connectionGroupService.getConnectionGroup(identifier).success(function connectionGroupReceived(connectionGroup) {
|
||||||
$scope.connectionGroup = connectionGroup;
|
$scope.connectionGroup = connectionGroup;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are creating a new connection group, populate skeleton connection group data
|
||||||
else
|
else
|
||||||
$scope.connectionGroup = new ConnectionGroup();
|
$scope.connectionGroup = new ConnectionGroup();
|
||||||
|
|
||||||
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER, PermissionSet.ObjectPermissionType.UPDATE)
|
/**
|
||||||
.success(function connectionGroupReceived(rootGroup) {
|
* Available connection group types, as translation string / internal value
|
||||||
$scope.rootGroup = rootGroup;
|
* pairs.
|
||||||
$scope.loadingConnections = false;
|
*
|
||||||
});
|
* @type Object[]
|
||||||
|
*/
|
||||||
$scope.types = [
|
$scope.types = [
|
||||||
{
|
{
|
||||||
label: "organizational",
|
label: "organizational",
|
||||||
@@ -65,59 +90,99 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the modal.
|
* Cancels all pending edits, returning to the management page.
|
||||||
*/
|
*/
|
||||||
$scope.close = function close() {
|
$scope.cancel = function cancel() {
|
||||||
connectionGroupEditModal.deactivate();
|
$location.path('/manage/');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the connection group, creating a new connection group or updating
|
||||||
|
* the existing connection group.
|
||||||
|
*/
|
||||||
|
$scope.saveConnectionGroup = function saveConnectionGroup() {
|
||||||
|
|
||||||
|
// Save the connection
|
||||||
|
connectionGroupService.saveConnectionGroup($scope.connectionGroup)
|
||||||
|
.success(function savedConnectionGroup() {
|
||||||
|
$location.path('/manage/');
|
||||||
|
})
|
||||||
|
|
||||||
|
// Notify of any errors
|
||||||
|
.error(function connectionGroupSaveFailed(error) {
|
||||||
|
$scope.showStatus({
|
||||||
|
'className' : 'error',
|
||||||
|
'title' : 'manage.error.title',
|
||||||
|
'text' : error.message,
|
||||||
|
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the connection and close the modal.
|
* An action to be provided along with the object sent to showStatus which
|
||||||
|
* immediately deletes the current connection group.
|
||||||
*/
|
*/
|
||||||
$scope.save = function save() {
|
var DELETE_ACTION = {
|
||||||
connectionGroupService.saveConnectionGroup($scope.connectionGroup).success(function successfullyUpdatedConnectionGroup() {
|
name : "manage.edit.connectionGroup.delete",
|
||||||
|
className : "danger",
|
||||||
var oldParentID = oldConnectionGroup.parentIdentifier;
|
// Handle action
|
||||||
var newParentID = $scope.connectionGroup.parentIdentifier;
|
callback : function deleteCallback() {
|
||||||
|
deleteConnectionGroupImmediately();
|
||||||
// Copy the data back to the original model
|
$scope.showStatus(false);
|
||||||
angular.extend(oldConnectionGroup, $scope.connectionGroup);
|
}
|
||||||
|
|
||||||
// New groups are created by default in root - don't try to move it if it's already there.
|
|
||||||
if(newConnectionGroup && newParentID === $scope.rootGroup.identifier) {
|
|
||||||
$scope.moveItem($scope.connectionGroup, oldParentID, newParentID);
|
|
||||||
} else {
|
|
||||||
connectionGroupService.moveConnectionGroup($scope.connectionGroup).then(function moveConnectionGroup() {
|
|
||||||
$scope.moveItem($scope.connectionGroup, oldParentID, newParentID);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the modal
|
|
||||||
connectionGroupEditModal.deactivate();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the connection and close the modal.
|
* An action to be provided along with the object sent to showStatus which
|
||||||
|
* closes the currently-shown status dialog.
|
||||||
*/
|
*/
|
||||||
$scope['delete'] = function deleteConnectionGroup() {
|
var CANCEL_ACTION = {
|
||||||
|
name : "manage.edit.connectionGroup.cancel",
|
||||||
// Nothing to delete if the connection is new
|
// Handle action
|
||||||
if(newConnectionGroup)
|
callback : function cancelCallback() {
|
||||||
// Close the modal
|
$scope.showStatus(false);
|
||||||
connectionGroupEditModal.deactivate();
|
}
|
||||||
|
};
|
||||||
connectionGroupService.deleteConnectionGroup($scope.connectionGroup).success(function successfullyDeletedConnectionGroup() {
|
|
||||||
var oldParentID = oldConnectionGroup.parentIdentifier;
|
/**
|
||||||
|
* Immediately deletes the current connection group, without prompting the
|
||||||
// We have to remove this connection group from the heirarchy
|
* user for confirmation.
|
||||||
$scope.moveItem($scope.connectionGroup, oldParentID);
|
*/
|
||||||
|
var deleteConnectionGroupImmediately = function deleteConnectionGroupImmediately() {
|
||||||
// Close the modal
|
|
||||||
connectionGroupEditModal.deactivate();
|
// Delete the connection group
|
||||||
|
connectionGroupService.deleteConnectionGroup($scope.connectionGroup)
|
||||||
|
.success(function deletedConnectionGroup() {
|
||||||
|
$location.path('/manage/');
|
||||||
|
})
|
||||||
|
|
||||||
|
// Notify of any errors
|
||||||
|
.error(function connectionGroupDeletionFailed(error) {
|
||||||
|
$scope.showStatus({
|
||||||
|
'className' : 'error',
|
||||||
|
'title' : 'manage.error.title',
|
||||||
|
'text' : error.message,
|
||||||
|
'actions' : [ ACKNOWLEDGE_ACTION ]
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the connection group, prompting the user first to confirm that
|
||||||
|
* deletion is desired.
|
||||||
|
*/
|
||||||
|
$scope.deleteConnectionGroup = function deleteConnectionGroup() {
|
||||||
|
|
||||||
|
// Confirm deletion request
|
||||||
|
$scope.showStatus({
|
||||||
|
'title' : 'manage.edit.connectionGroup.confirmDelete.title',
|
||||||
|
'text' : 'manage.edit.connectionGroup.confirmDelete.text',
|
||||||
|
'actions' : [ DELETE_ACTION, CANCEL_ACTION]
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for the connection edit modal.
|
* The controller for editing users.
|
||||||
*/
|
*/
|
||||||
angular.module('manage').controller('manageUserController', ['$scope', '$injector',
|
angular.module('manage').controller('manageUserController', ['$scope', '$injector',
|
||||||
function manageUserController($scope, $injector) {
|
function manageUserController($scope, $injector) {
|
||||||
|
@@ -25,10 +25,8 @@ THE SOFTWARE.
|
|||||||
<a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a>
|
<a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Connection name -->
|
<!-- Main property editor -->
|
||||||
<h2>{{'manage.edit.connection.title' | translate}}</h2>
|
<h2>{{'manage.edit.connection.title' | translate}}</h2>
|
||||||
|
|
||||||
<!-- Main connection edit section -->
|
|
||||||
<div class="properties">
|
<div class="properties">
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
@@ -61,31 +59,28 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
<!-- Connection parameters -->
|
<!-- Connection parameters -->
|
||||||
<h2>{{'manage.edit.connection.parameters' | translate}}</h2>
|
<h2>{{'manage.edit.connection.parameters' | translate}}</h2>
|
||||||
|
|
||||||
<div class="properties" ng-class="{loading: !parameters}">
|
<div class="properties" ng-class="{loading: !parameters}">
|
||||||
<table class="fields">
|
<table class="fields">
|
||||||
|
|
||||||
<!-- All the different possible editable field types -->
|
<!-- All the different possible editable field types -->
|
||||||
<tr ng-repeat="parameter in protocols[connection.protocol].parameters">
|
<tr ng-repeat="parameter in protocols[connection.protocol].parameters">
|
||||||
<th>{{'protocol.' + connection.protocol + '.parameters.' + parameter.name + '.label' | translate}}:</th>
|
<th>{{'protocol.' + connection.protocol + '.parameters.' + parameter.name + '.label' | translate}}:</th>
|
||||||
<td>
|
<td>
|
||||||
<guac-connection-parameter protocol="protocols[connection.protocol]" name="parameter.name" parameters="parameters"/>
|
<guac-connection-parameter protocol="protocols[connection.protocol]" name="parameter.name" parameters="parameters"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Form action buttons -->
|
<!-- Form action buttons -->
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button ng-click="saveConnection()">{{'manage.edit.connection.save' | translate}}</button>
|
<button ng-click="saveConnection()">{{'manage.edit.connection.save' | translate}}</button>
|
||||||
<button ng-click="cancel()">{{'manage.edit.connection.cancel' | translate}}</button>
|
<button ng-click="cancel()">{{'manage.edit.connection.cancel' | translate}}</button>
|
||||||
<button ng-click="deleteConnection()" class="danger">{{'manage.edit.connection.delete' | translate}}</button>
|
<button ng-click="deleteConnection()" class="danger">{{'manage.edit.connection.delete' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- History connection area -->
|
<!-- Connection history -->
|
||||||
<h2>{{'manage.edit.connection.history.usageHistory' | translate}}</h2>
|
<h2>{{'manage.edit.connection.history.usageHistory' | translate}}</h2>
|
||||||
|
|
||||||
<!-- History connection list -->
|
|
||||||
<div class="history" ng-class="{loading: !historyEntryWrappers}">
|
<div class="history" ng-class="{loading: !historyEntryWrappers}">
|
||||||
<p ng-hide="historyEntryWrappers.length">{{'manage.edit.connection.history.connectionNotUsed' | translate}}</p>
|
<p ng-hide="historyEntryWrappers.length">{{'manage.edit.connection.history.connectionNotUsed' | translate}}</p>
|
||||||
<table ng-show="historyEntryWrappers.length">
|
<table ng-show="historyEntryWrappers.length">
|
||||||
|
@@ -25,8 +25,8 @@ THE SOFTWARE.
|
|||||||
<a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a>
|
<a class="logout button" ng-click="logout()">{{'home.logout' | translate}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Connection group name -->
|
<!-- Main property editor -->
|
||||||
<h2>{{connectionGroup.name}}</h2>
|
<h2>{{'manage.edit.connectionGroup.title' | translate}}</h2>
|
||||||
<div class="properties">
|
<div class="properties">
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ THE SOFTWARE.
|
|||||||
<th>{{'manage.edit.connectionGroup.location' | translate}}</th>
|
<th>{{'manage.edit.connectionGroup.location' | translate}}</th>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<location-chooser value="connectionGroup.parentIdentifier" root-group="rootGroup"/>
|
<location-chooser value="connectionGroup.parentIdentifier" root-group="rootGroup"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
@@ -57,9 +57,9 @@ THE SOFTWARE.
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Control buttons -->
|
<!-- Form action buttons -->
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button ng-click="save()">{{'manage.edit.connectionGroup.save' | translate}}</button>
|
<button ng-click="saveConnectionGroup()">{{'manage.edit.connectionGroup.save' | translate}}</button>
|
||||||
<button ng-click="close()">{{'manage.edit.connectionGroup.cancel' | translate}}</button>
|
<button ng-click="cancel()">{{'manage.edit.connectionGroup.cancel' | translate}}</button>
|
||||||
<button ng-click="delete()" class="danger">{{'manage.edit.connectionGroup.delete' | translate}}</button>
|
<button ng-click="deleteConnectionGroup()" class="danger">{{'manage.edit.connectionGroup.delete' | translate}}</button>
|
||||||
</div>
|
</div>
|
@@ -64,9 +64,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"connectionGroup": {
|
"connectionGroup": {
|
||||||
|
"title" : "Edit Connection Group",
|
||||||
"cancel" : "Cancel",
|
"cancel" : "Cancel",
|
||||||
"save" : "Save",
|
"save" : "Save",
|
||||||
"delete" : "Delete",
|
"delete" : "Delete",
|
||||||
|
"confirmDelete" : {
|
||||||
|
"title" : "Delete Connection",
|
||||||
|
"text" : "Connection groups cannot be restored after they have been deleted. Are you sure you want to delete this connection group?"
|
||||||
|
},
|
||||||
"usageHistory" : "Usage History:",
|
"usageHistory" : "Usage History:",
|
||||||
"type" : {
|
"type" : {
|
||||||
"label" : "Type",
|
"label" : "Type",
|
||||||
|
Reference in New Issue
Block a user