mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-963: Store name in ManagedClient. Show name in menu. Add back buttons.
This commit is contained in:
@@ -31,9 +31,8 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
var ScrollState = $injector.get('ScrollState');
|
||||
|
||||
// Required services
|
||||
var connectionGroupService = $injector.get('connectionGroupService');
|
||||
var connectionService = $injector.get('connectionService');
|
||||
var guacClientManager = $injector.get('guacClientManager');
|
||||
var $location = $injector.get('$location');
|
||||
var guacClientManager = $injector.get('guacClientManager');
|
||||
|
||||
/**
|
||||
* The minimum number of pixels a drag gesture must move to result in the
|
||||
@@ -143,13 +142,22 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
};
|
||||
|
||||
/**
|
||||
* The reconnect action to be provided along with the object sent to
|
||||
* showStatus.
|
||||
* Action which returns the user to the home screen.
|
||||
*/
|
||||
var NAVIGATE_BACK_ACTION = {
|
||||
name : "CLIENT.ACTION_NAVIGATE_BACK",
|
||||
className : "back button",
|
||||
callback : function navigateBackCallback() {
|
||||
$location.path('/');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Action which replaces the current client with a newly-connected client.
|
||||
*/
|
||||
var RECONNECT_ACTION = {
|
||||
name : "CLIENT.ACTION_RECONNECT",
|
||||
// Handle reconnect action
|
||||
callback : function reconnectCallback() {
|
||||
name : "CLIENT.ACTION_RECONNECT",
|
||||
callback : function reconnectCallback() {
|
||||
$scope.client = guacClientManager.replaceManagedClient(uniqueId, $routeParams.params);
|
||||
$scope.showStatus(false);
|
||||
}
|
||||
@@ -195,25 +203,6 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
var uniqueId = $routeParams.type + '/' + $routeParams.id;
|
||||
$scope.client = guacClientManager.getManagedClient(uniqueId, $routeParams.params);
|
||||
|
||||
// Pull connection name from server
|
||||
switch ($routeParams.type) {
|
||||
|
||||
// Connection
|
||||
case 'c':
|
||||
connectionService.getConnection($routeParams.id).success(function (connection) {
|
||||
$scope.connectionName = $scope.page.title = connection.name;
|
||||
});
|
||||
break;
|
||||
|
||||
// Connection group
|
||||
case 'g':
|
||||
connectionGroupService.getConnectionGroup($routeParams.id).success(function (group) {
|
||||
$scope.connectionName = $scope.page.title = group.name;
|
||||
});
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
var keysCurrentlyPressed = {};
|
||||
|
||||
/*
|
||||
@@ -391,6 +380,11 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
delete keysCurrentlyPressed[keysym];
|
||||
});
|
||||
|
||||
// Update page title when client name is received
|
||||
$scope.$watch('client.name', function clientNameChanged(name) {
|
||||
$scope.page.title = name;
|
||||
});
|
||||
|
||||
// Show status dialog when connection status changes
|
||||
$scope.$watch('client.clientState.connectionState', function clientStateChanged(connectionState) {
|
||||
|
||||
@@ -427,7 +421,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
||||
text: "CLIENT.ERROR_CLIENT_" + errorName,
|
||||
countdown: countdown,
|
||||
actions: [ RECONNECT_ACTION ]
|
||||
actions: [ NAVIGATE_BACK_ACTION, RECONNECT_ACTION ]
|
||||
});
|
||||
|
||||
}
|
||||
@@ -447,7 +441,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
title: "CLIENT.DIALOG_HEADER_CONNECTION_ERROR",
|
||||
text: "CLIENT.ERROR_TUNNEL_" + errorName,
|
||||
countdown: countdown,
|
||||
actions: [ RECONNECT_ACTION ]
|
||||
actions: [ NAVIGATE_BACK_ACTION, RECONNECT_ACTION ]
|
||||
});
|
||||
|
||||
}
|
||||
@@ -457,7 +451,7 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams
|
||||
$scope.showStatus({
|
||||
title: "CLIENT.DIALOG_HEADER_DISCONNECTED",
|
||||
text: "CLIENT.TEXT_CLIENT_STATUS_" + connectionState.toUpperCase(),
|
||||
actions: [ RECONNECT_ACTION ]
|
||||
actions: [ NAVIGATE_BACK_ACTION, RECONNECT_ACTION ]
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@
|
||||
<a class="back button" href="#/">{{'CLIENT.ACTION_NAVIGATE_BACK' | translate}}</a>
|
||||
<a class="disconnect danger button" ng-click="disconnect()">{{'CLIENT.ACTION_DISCONNECT' | translate}}</a>
|
||||
</div>
|
||||
<h2>NAME</h2>
|
||||
<h2>{{client.name}}</h2>
|
||||
|
||||
<h3>{{'CLIENT.SECTION_HEADER_CLIPBOARD' | translate}}</h3>
|
||||
<div class="content" id="clipboard-settings">
|
||||
|
@@ -32,12 +32,14 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
var ManagedDisplay = $injector.get('ManagedDisplay');
|
||||
|
||||
// Required services
|
||||
var $window = $injector.get('$window');
|
||||
var $document = $injector.get('$document');
|
||||
var authenticationService = $injector.get('authenticationService');
|
||||
var guacAudio = $injector.get('guacAudio');
|
||||
var guacHistory = $injector.get('guacHistory');
|
||||
var guacVideo = $injector.get('guacVideo');
|
||||
var $window = $injector.get('$window');
|
||||
var $document = $injector.get('$document');
|
||||
var authenticationService = $injector.get('authenticationService');
|
||||
var connectionGroupService = $injector.get('connectionGroupService');
|
||||
var connectionService = $injector.get('connectionService');
|
||||
var guacAudio = $injector.get('guacAudio');
|
||||
var guacHistory = $injector.get('guacHistory');
|
||||
var guacVideo = $injector.get('guacVideo');
|
||||
|
||||
/**
|
||||
* Object which serves as a surrogate interface, encapsulating a Guacamole
|
||||
@@ -83,8 +85,8 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
this.managedDisplay = template.managedDisplay;
|
||||
|
||||
/**
|
||||
* The name returned via the Guacamole protocol for this connection, if
|
||||
* any.
|
||||
* The name returned associated with the connection or connection
|
||||
* group in use.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
@@ -326,13 +328,6 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
});
|
||||
};
|
||||
|
||||
// Update stored name if name changes
|
||||
client.onname = function clientNameChanged(name) {
|
||||
$rootScope.$apply(function updateName() {
|
||||
managedClient.name = name;
|
||||
});
|
||||
};
|
||||
|
||||
// Disconnect and update status when the client receives an error
|
||||
client.onerror = function clientError(status) {
|
||||
$rootScope.$apply(function handleClientError() {
|
||||
@@ -415,6 +410,25 @@ angular.module('client').factory('ManagedClient', ['$rootScope', '$injector',
|
||||
// Connect the Guacamole client
|
||||
client.connect(getConnectString(id, connectionParameters));
|
||||
|
||||
// Determine type of connection
|
||||
var typePrefix = id.substring(0, 2);
|
||||
|
||||
// If using a connection, pull connection name
|
||||
if (typePrefix === 'c/') {
|
||||
connectionService.getConnection(id.substring(2))
|
||||
.success(function connectionRetrieved(connection) {
|
||||
managedClient.name = connection.name;
|
||||
});
|
||||
}
|
||||
|
||||
// If using a connection group, pull connection name
|
||||
else if (typePrefix === 'g/') {
|
||||
connectionGroupService.getConnectionGroup(id.substring(2))
|
||||
.success(function connectionGroupRetrieved(group) {
|
||||
managedClient.name = group.name;
|
||||
});
|
||||
}
|
||||
|
||||
return managedClient;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user