Skip to content

Commit

Permalink
GUACAMOLE-377: Add extension for displaying render statistics in a to…
Browse files Browse the repository at this point in the history
…olbar.
  • Loading branch information
mike-jumper committed Jan 7, 2022
1 parent 6c41002 commit fecd14a
Show file tree
Hide file tree
Showing 12 changed files with 419 additions and 0 deletions.
1 change: 1 addition & 0 deletions extensions/guacamole-display-statistics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/main/resources/generated/
1 change: 1 addition & 0 deletions extensions/guacamole-display-statistics/.ratignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/main/resources/html/*.html
124 changes: 124 additions & 0 deletions extensions/guacamole-display-statistics/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-display-statistics</artifactId>
<packaging>jar</packaging>
<version>1.4.0</version>
<name>guacamole-display-statistics</name>
<url>http://guacamole.apache.org/</url>

<parent>
<groupId>org.apache.guacamole</groupId>
<artifactId>extensions</artifactId>
<version>1.4.0</version>
<relativePath>../</relativePath>
</parent>

<build>
<plugins>

<!-- Pre-cache Angular templates with maven-angular-plugin -->
<plugin>
<groupId>com.keithbranton.mojo</groupId>
<artifactId>angular-maven-plugin</artifactId>
<version>0.3.4</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>html2js</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDir>${basedir}/src/main/resources</sourceDir>
<include>**/*.html</include>
<target>${basedir}/src/main/resources/generated/templates-main/templates.js</target>
<prefix>app/ext/display-stats</prefix>
</configuration>
</plugin>

<!-- JS/CSS Minification Plugin -->
<plugin>
<groupId>com.github.buckelieg</groupId>
<artifactId>minify-maven-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<charset>UTF-8</charset>

<webappSourceDir>${basedir}/src/main/resources</webappSourceDir>
<webappTargetDir>${project.build.directory}/classes</webappTargetDir>

<cssSourceDir>/</cssSourceDir>
<cssTargetDir>/</cssTargetDir>
<cssFinalFile>display-stats.css</cssFinalFile>

<cssSourceFiles>
<cssSourceFile>license.txt</cssSourceFile>
</cssSourceFiles>

<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>

<jsSourceDir>/</jsSourceDir>
<jsTargetDir>/</jsTargetDir>
<jsFinalFile>display-stats.js</jsFinalFile>

<jsSourceFiles>
<jsSourceFile>license.txt</jsSourceFile>
</jsSourceFiles>

<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>

<!-- Do not minify and include tests -->
<jsSourceExcludes>
<jsSourceExclude>**/*.test.js</jsSourceExclude>
</jsSourceExcludes>
<jsEngine>CLOSURE</jsEngine>

<!-- Disable warnings for JSDoc annotations -->
<closureWarningLevels>
<misplacedTypeAnnotation>OFF</misplacedTypeAnnotation>
<nonStandardJsDocs>OFF</nonStandardJsDocs>
</closureWarningLevels>

</configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
53 changes: 53 additions & 0 deletions extensions/guacamole-display-statistics/src/main/assembly/dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">

<id>dist</id>
<baseDirectory>${project.artifactId}-${project.version}</baseDirectory>

<!-- Output tar.gz -->
<formats>
<format>tar.gz</format>
</formats>

<!-- Include licenses and extension .jar -->
<fileSets>

<!-- Include licenses -->
<fileSet>
<outputDirectory></outputDirectory>
<directory>target/licenses</directory>
</fileSet>

<!-- Include extension .jar -->
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>

</fileSets>

</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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.
*/

/**
* A directive which displays one or more Guacamole clients in an evenly-tiled
* view. The number of rows and columns used for the arrangement of tiles is
* automatically determined by the number of clients present.
*/
angular.module('client').directive('guacClientStatistics', [function guacClientStatistics() {

const directive = {
restrict: 'E',
templateUrl: 'app/ext/display-stats/templates/guacClientStatistics.html',
};

directive.scope = {

/**
* The group of Guacamole clients that should be displayed in an
* evenly-tiled grid arrangement.
*
* @type ManagedClientGroup
*/
client : '='

};

directive.controller = ['$scope', function guacClientStatisticsController($scope) {

var updateStatistics = function updateStatistics(stats) {
$scope.$apply(function statisticsChanged() {
$scope.statistics = stats;
});
};

$scope.hasValue = function hasValue(value) {
return value || value === 0;
};

$scope.round = function round(value) {
return Math.round(value * 100) / 100;
};

$scope.$watch('client', function clientChanged(client, oldClient) {

if (oldClient)
oldClient.managedDisplay.display.onstatistics = null;

client.managedDisplay.display.statisticWindow = 1000;
client.managedDisplay.display.onstatistics = updateStatistics;

});

$scope.$on('$destroy', function scopeDestroyed() {
if ($scope.client)
$scope.client.managedDisplay.display.onstatistics = null;
});

}];

return directive;

}]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{

"guacamoleVersion" : "1.4.0",

"name" : "Display Statistic Toolbar",
"namespace" : "display-stats",

"translations" : [
"translations/en.json"
],

"js" : [
"display-stats.min.js"
],

"css" : [
"display-stats.min.css"
],

"html" : [
"html/add-statistics.html"
],

"resources" : {
"templates/guacClientStatistics.html" : "text/html"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<meta name="after" content=".client-tile guac-client">

<!-- Guacamole display statistics -->
<guac-client-statistics client="client"></guac-client-statistics>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.
*/

guac-client-statistics {
font-size: 13px;
color: white;
background: #111;
}

guac-client-statistics dl.client-statistics {
display: table;
margin: 0;
padding: 0.25em;
}

guac-client-statistics dl.client-statistics dt,
guac-client-statistics dl.client-statistics dd {
display: table-cell;
padding: 0.25em;
}

guac-client-statistics dl.client-statistics dt {
padding-right: 0.5em;
padding-left: 1em;
}

guac-client-statistics dl.client-statistics dt:first-child {
padding-left: 0.5em;
}

guac-client-statistics dl.client-statistics dd {
min-width: 6em;
border: 1px solid rgba(255, 255, 255, 0.125);
border-radius: 3px;
background: black;
}

guac-client-statistics dl.client-statistics dd.no-value::before {
color: #888;
content: '-';
}

0 comments on commit fecd14a

Please sign in to comment.