-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
585 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
guacamole/src/main/frontend/src/app/client/directives/guacClientMessage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/** | ||
* Directive which displays a message for the client. | ||
*/ | ||
angular.module('client').directive('guacClientMessage', [function guacClientMessage() { | ||
|
||
return { | ||
restrict: 'E', | ||
replace: true, | ||
scope: { | ||
|
||
/** | ||
* The message to display to the client. | ||
* | ||
* @type {!ManagedClientMessage} | ||
*/ | ||
message : '=' | ||
|
||
}, | ||
|
||
templateUrl: 'app/client/templates/guacClientMessage.html', | ||
|
||
controller: ['$scope', '$injector', '$element', | ||
function guacClientMessageController($scope, $injector, $element) { | ||
|
||
// Required types | ||
const ManagedClientMessage = $injector.get('ManagedClientMessage'); | ||
|
||
// Required services | ||
var translationStringService = $injector.get('translationStringService'); | ||
|
||
/** | ||
* Uses the msgcode to retrieve the correct translation key for | ||
* the client message. | ||
* | ||
* @returns {string} | ||
*/ | ||
$scope.getMessageKey = function getMessageKey() { | ||
|
||
let msgString = "DEFAULT"; | ||
if (Object.values(Guacamole.Client.Message).includes($scope.message.msgcode)) | ||
msgString = Object.keys(Guacamole.Client.Message).find(key => Guacamole.Client.Message[key] === $scope.message.msgcode); | ||
|
||
return "CLIENT.MESSAGE_" + translationStringService.canonicalize(msgString); | ||
}; | ||
|
||
/** | ||
* Returns a set of key/value object pairs that represent the | ||
* arguments provided as part of the message in the form | ||
* "ARGS_0 = value". Guacamole's translation system relies on | ||
* the arguments being available in this format in order to be able | ||
* to handle substituting values for an arbitrary list of arguments. | ||
* | ||
* @returns {Object} | ||
*/ | ||
$scope.getMessageArgs = function getMessageArgs() { | ||
return $scope.message.args.reduce( | ||
function(acc, value, index) { | ||
acc[`ARGS_${index}`] = value; | ||
return acc; | ||
}, | ||
{} | ||
); | ||
}; | ||
|
||
}] | ||
|
||
}; | ||
}]); |
76 changes: 76 additions & 0 deletions
76
guacamole/src/main/frontend/src/app/client/directives/guacMessageDialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/** | ||
* Directive which displays all client messages. | ||
*/ | ||
angular.module('client').directive('guacMessageDialog', [function guacMessageDialog() { | ||
|
||
return { | ||
restrict: 'E', | ||
replace: true, | ||
scope: { | ||
|
||
/** | ||
* The client group whose messages should be managed by this | ||
* directive. | ||
* | ||
* @type ManagedClientGroup | ||
*/ | ||
clientGroup : '=' | ||
|
||
}, | ||
|
||
templateUrl: 'app/client/templates/guacMessageDialog.html', | ||
controller: ['$scope', '$injector', function guacMessageDialogController($scope, $injector) { | ||
|
||
// Required types | ||
const ManagedClient = $injector.get('ManagedClient'); | ||
const ManagedClientGroup = $injector.get('ManagedClientGroup'); | ||
|
||
/** | ||
* Removes all messages. | ||
*/ | ||
$scope.clearAllMessages = function clearAllMessages() { | ||
|
||
// Nothing to clear if no client group attached | ||
if (!$scope.clientGroup) | ||
return; | ||
|
||
// Remove each client's messages | ||
$scope.clientGroup.clients.forEach(client => { | ||
client.messages = []; | ||
}); | ||
|
||
}; | ||
|
||
/** | ||
* @borrows ManagedClientGroup.hasMultipleClients | ||
*/ | ||
$scope.hasMultipleClients = ManagedClientGroup.hasMultipleClients; | ||
|
||
/** | ||
* @borrows ManagedClient.hasMessages | ||
*/ | ||
$scope.hasMessages = ManagedClient.hasMessages; | ||
|
||
}] | ||
|
||
}; | ||
}]); |
Oops, something went wrong.