mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-932: Migrate home to connection list directive.
This commit is contained in:
@@ -26,15 +26,12 @@
|
|||||||
angular.module('home').controller('homeController', ['$scope', '$injector',
|
angular.module('home').controller('homeController', ['$scope', '$injector',
|
||||||
function homeController($scope, $injector) {
|
function homeController($scope, $injector) {
|
||||||
|
|
||||||
// The parameter name for getting the history from local storage
|
// Get required types
|
||||||
var GUAC_HISTORY_STORAGE_KEY = "GUAC_HISTORY";
|
var ConnectionGroup = $injector.get("ConnectionGroup");
|
||||||
|
|
||||||
// Get the dependencies commonJS style
|
// Get required services
|
||||||
var legacyConnectionGroupService = $injector.get("legacyConnectionGroupService");
|
var connectionGroupService = $injector.get("connectionGroupService"),
|
||||||
var guacHistory = $injector.get("guacHistory");
|
guacHistory = $injector.get("guacHistory");
|
||||||
|
|
||||||
// All the connections and connection groups in root
|
|
||||||
$scope.connectionsAndGroups = [];
|
|
||||||
|
|
||||||
// All valid recent connections
|
// All valid recent connections
|
||||||
$scope.recentConnections = [];
|
$scope.recentConnections = [];
|
||||||
@@ -42,54 +39,13 @@ angular.module('home').controller('homeController', ['$scope', '$injector',
|
|||||||
// 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;
|
||||||
|
|
||||||
/* Fetch all connections and groups, then find which recent connections
|
// Retrieve root group and all descendants
|
||||||
* still refer to valid connections and groups.
|
connectionGroupService.getConnectionGroupTree(ConnectionGroup.ROOT_IDENTIFIER)
|
||||||
*/
|
.success(function rootGroupRetrieved(rootConnectionGroup) {
|
||||||
legacyConnectionGroupService.getAllGroupsAndConnections($scope.connectionsAndGroups)
|
|
||||||
.then(function findRecentConnections() {
|
|
||||||
|
|
||||||
// TODONT: Munch the guacHistory recentConnections list into a legacy-style object
|
|
||||||
var recentConnections = {};
|
|
||||||
for (var i=0; i < guacHistory.recentConnections.length; i++) {
|
|
||||||
var entry = guacHistory.recentConnections[i];
|
|
||||||
recentConnections[encodeURIComponent(entry.id)] = {
|
|
||||||
id : entry.id,
|
|
||||||
thumbnail : entry.thumbnail
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out which recent connection entries are valid
|
|
||||||
$scope.connectionsAndGroups.forEach(function findValidEntries (connectionOrGroup) {
|
|
||||||
|
|
||||||
var type = connectionOrGroup.isConnection ? "c" : "g";
|
|
||||||
|
|
||||||
// Find the unique ID to index into the recent connections
|
|
||||||
var uniqueId = encodeURIComponent(
|
|
||||||
type + "/" + connectionOrGroup.identifier
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If it's a valid recent connection, add it to the list,
|
|
||||||
* along with enough information to make a connection url.
|
|
||||||
*/
|
|
||||||
var recentConnection = recentConnections[uniqueId];
|
|
||||||
if(recentConnection) {
|
|
||||||
recentConnection.type = type;
|
|
||||||
recentConnection.id = connectionOrGroup.identifier;
|
|
||||||
$scope.recentConnections.push(recentConnection);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
$scope.rootConnectionGroup = rootConnectionGroup;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggle the open/closed status of the connectionGroup.
|
|
||||||
*
|
|
||||||
* @param {object} connectionGroup The connection group to toggle.
|
|
||||||
*/
|
|
||||||
$scope.toggleExpanded = function toggleExpanded(connectionGroup) {
|
|
||||||
connectionGroup.expanded = !connectionGroup.expanded;
|
|
||||||
};
|
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
@@ -20,4 +20,4 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('home', ['history', 'rest']);
|
angular.module('home', ['history', 'groupList', 'rest']);
|
||||||
|
@@ -20,31 +20,6 @@
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script type="text/ng-template" id="nestedGroup.html">
|
|
||||||
<div class="connection" ng-show="item.isConnection">
|
|
||||||
<a ng-href="#/client/c/{{item.identifier}}">
|
|
||||||
<div class="caption">
|
|
||||||
<div class="protocol">
|
|
||||||
<div class="icon type" ng-class="item.protocol"></div>
|
|
||||||
</div>
|
|
||||||
<span class="name">{{item.name}}</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="group" ng-show="!item.isConnection">
|
|
||||||
<div class="caption">
|
|
||||||
<div class="icon group type" ng-click="toggleExpanded(item)" ng-class="{expanded: item.expanded, empty: !item.children.length, balancer: item.balancer && !item.children.length}"></div>
|
|
||||||
<span class="name">
|
|
||||||
<a ng-show="item.balancer" ng-href="#/client/g/{{item.identifier}}">{{item.name}}</a>
|
|
||||||
<span ng-show="!item.balancer">{{item.name}}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="children" ng-show="item.expanded">
|
|
||||||
<div class="list-item" ng-repeat="item in item.children | orderBy : 'name'" ng-include="'nestedGroup.html'">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="connection-list-ui">
|
<div class="connection-list-ui">
|
||||||
|
|
||||||
<div class="logout-panel">
|
<div class="logout-panel">
|
||||||
@@ -73,6 +48,7 @@
|
|||||||
<!-- All connections for this user -->
|
<!-- All connections for this user -->
|
||||||
<h2>{{'home.allConnections' | translate}}</h2>
|
<h2>{{'home.allConnections' | translate}}</h2>
|
||||||
<div class="all-connections" ng-class="{loading: loading}">
|
<div class="all-connections" ng-class="{loading: loading}">
|
||||||
<div class="list-item" ng-repeat="item in connectionsAndGroups | orderBy : 'name'" ng-include="'nestedGroup.html'"></div>
|
<guac-group-list connection-group="rootConnectionGroup"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
Reference in New Issue
Block a user