mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-932: Restore recent connections through new guacRecentConnections directive.
This commit is contained in:
@@ -37,7 +37,8 @@ angular.module('history').factory('HistoryEntry', [function defineHistoryEntry()
|
|||||||
var HistoryEntry = function HistoryEntry(id, thumbnail) {
|
var HistoryEntry = function HistoryEntry(id, thumbnail) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the connection associated with this history entry.
|
* The ID of the connection associated with this history entry,
|
||||||
|
* including type prefix.
|
||||||
*/
|
*/
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
|
@@ -30,11 +30,7 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
|||||||
var ConnectionGroup = $injector.get("ConnectionGroup");
|
var ConnectionGroup = $injector.get("ConnectionGroup");
|
||||||
|
|
||||||
// Get required services
|
// Get required services
|
||||||
var connectionGroupService = $injector.get("connectionGroupService"),
|
var connectionGroupService = $injector.get("connectionGroupService");
|
||||||
guacHistory = $injector.get("guacHistory");
|
|
||||||
|
|
||||||
// All valid recent connections
|
|
||||||
$scope.recentConnections = [];
|
|
||||||
|
|
||||||
// Set status to loading until we have all the connections and groups loaded
|
// Set status to loading until we have all the connections and groups loaded
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
@@ -0,0 +1,115 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Glyptodon LLC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A directive which displays the contents of a connection group.
|
||||||
|
*/
|
||||||
|
angular.module('home').directive('guacRecentConnections', [function guacRecentConnections() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
restrict: 'E',
|
||||||
|
replace: true,
|
||||||
|
scope: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root connection group, and all visible descendants.
|
||||||
|
* Recent connections will only be shown if they exist within this
|
||||||
|
* hierarchy, regardless of their existence within the history.
|
||||||
|
*
|
||||||
|
* @type ConnectionGroup
|
||||||
|
*/
|
||||||
|
rootGroup : '='
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
templateUrl: 'app/home/templates/guacRecentConnections.html',
|
||||||
|
controller: ['$scope', '$injector', 'guacHistory', 'RecentConnection',
|
||||||
|
function guacGroupListController($scope, $injector, guacHistory, RecentConnection) {
|
||||||
|
|
||||||
|
var visibleObjects = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given connection to the internal set of visible
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* @param {Connection} connection
|
||||||
|
* The connection to add to the internal set of visible objects.
|
||||||
|
*/
|
||||||
|
var addVisibleConnection = function addVisibleConnection(connection) {
|
||||||
|
|
||||||
|
// Add given connection to set of visible objects
|
||||||
|
visibleObjects['c/' + connection.identifier] = connection;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given connection group to the internal set of visible
|
||||||
|
* objects, along with any descendants.
|
||||||
|
*
|
||||||
|
* @param {ConnectionGroup} connectionGroup
|
||||||
|
* The connection group to add to the internal set of visible
|
||||||
|
* objects, along with any descendants.
|
||||||
|
*/
|
||||||
|
var addVisibleConnectionGroup = function addVisibleConnectionGroup(connectionGroup) {
|
||||||
|
|
||||||
|
// Add given connection group to set of visible objects
|
||||||
|
visibleObjects['g/' + connectionGroup.identifier] = connectionGroup;
|
||||||
|
|
||||||
|
// Add all child connections
|
||||||
|
if (connectionGroup.childConnections)
|
||||||
|
connectionGroup.childConnections.forEach(addVisibleConnection);
|
||||||
|
|
||||||
|
// Add all child connection groups
|
||||||
|
if (connectionGroup.childConnectionGroups)
|
||||||
|
connectionGroup.childConnectionGroups.forEach(addVisibleConnectionGroup);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update visible objects when root group is set
|
||||||
|
$scope.$watch("rootGroup", function setRootGroup(rootGroup) {
|
||||||
|
|
||||||
|
$scope.recentConnections = [];
|
||||||
|
|
||||||
|
// Produce collection of visible objects
|
||||||
|
visibleObjects = {};
|
||||||
|
if (rootGroup)
|
||||||
|
addVisibleConnectionGroup(rootGroup);
|
||||||
|
|
||||||
|
// Add any recent connections that are visible
|
||||||
|
guacHistory.recentConnections.forEach(function addRecentConnection(historyEntry) {
|
||||||
|
|
||||||
|
// Add recent connections for history entries with associated visible objects
|
||||||
|
if (historyEntry.id in visibleObjects) {
|
||||||
|
|
||||||
|
var object = visibleObjects[historyEntry.id];
|
||||||
|
$scope.recentConnections.push(new RecentConnection(object.name, historyEntry));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}); // end rootGroup scope watch
|
||||||
|
|
||||||
|
}]
|
||||||
|
|
||||||
|
};
|
||||||
|
}]);
|
@@ -0,0 +1,44 @@
|
|||||||
|
<div>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2014 Glyptodon LLC
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Text displayed if no recent connections exist -->
|
||||||
|
<p class="no-recent" ng-hide="recentConnections.length">{{'home.noRecentConnections' | translate}}</p>
|
||||||
|
|
||||||
|
<!-- All recent connections -->
|
||||||
|
<div ng-repeat="recentConnection in recentConnections" class="connection">
|
||||||
|
<a href="#/client/{{recentConnection.entry.id}}/{{recentConnection.name}}">
|
||||||
|
|
||||||
|
<!-- Connection thumbnail -->
|
||||||
|
<div class="thumbnail">
|
||||||
|
<img alt="{{recentConnection.name}}" ng-src="{{recentConnection.entry.thumbnail}}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Connection name -->
|
||||||
|
<div class="caption">
|
||||||
|
<span class="name">{{recentConnection.name}}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
@@ -29,20 +29,8 @@
|
|||||||
|
|
||||||
<!-- The recent connections for this user -->
|
<!-- The recent connections for this user -->
|
||||||
<h2>{{'home.recentConnections' | translate}}</h2>
|
<h2>{{'home.recentConnections' | translate}}</h2>
|
||||||
<div class="recent-connections" ng-hide="recentConnections.length">
|
<div class="recent-connections">
|
||||||
<p class="no-recent">{{'home.noRecentConnections' | translate}}</p>
|
<guac-recent-connections root-group="rootConnectionGroup"/>
|
||||||
</div>
|
|
||||||
<div class="recent-connections" ng-show="recentConnections.length">
|
|
||||||
<div ng-repeat="recentConnection in recentConnections" class="connection">
|
|
||||||
<a href="#/client/{{recentConnection.type}}/{{recentConnection.id}}/{{recentConnection.name}}">
|
|
||||||
<div class="thumbnail">
|
|
||||||
<img alt="{{recentConnection.name}}" ng-src="{{recentConnection.thumbnail}}"/>
|
|
||||||
</div>
|
|
||||||
<div class="caption">
|
|
||||||
<span class="name">{{recentConnection.name}}</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- All connections for this user -->
|
<!-- All connections for this user -->
|
||||||
|
55
guacamole/src/main/webapp/app/home/types/RecentConnection.js
Normal file
55
guacamole/src/main/webapp/app/home/types/RecentConnection.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Glyptodon LLC
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the RecentConnection class used by the guacRecentConnections
|
||||||
|
* directive.
|
||||||
|
*/
|
||||||
|
angular.module('home').factory('RecentConnection', [function defineRecentConnection() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A recently-user connection, visible to the current user, with an
|
||||||
|
* associated history entry.
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
var RecentConnection = function RecentConnection(name, entry) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The human-readable name of this connection.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The history entry associated with this recent connection.
|
||||||
|
*
|
||||||
|
* @type HistoryEntry
|
||||||
|
*/
|
||||||
|
this.entry = entry;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return RecentConnection;
|
||||||
|
|
||||||
|
}]);
|
Reference in New Issue
Block a user