You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/12/03 02:38:42 UTC
[GitHub] [trafficcontrol] ocket8888 opened a new pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
ocket8888 opened a new pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400
This updates the "Cache Stats" Traffic Portal page to use AG-Grid instead of JQuery datatables. It's mostly a drop-in replacement, except for two things.
- A column for server IP address has been added - the data was always available but just not shown previously. It's hidden by default to preserve the old table's structure a bit more.
- All values for "Mbps out" were coerced from kbps to Mbps with "commas" added as needed to be able to read large numbers. The new display has no single unit, and instead shows values in bps, kbps, Mbps, Gbps, and Tbps as appropriate based on the value. CSV export uses the original kbps values returned from the API.
<hr/>
## Which Traffic Control components are affected by this PR?
- Traffic Portal
## What is the best way to verify this PR?
Make sure all the TP tests pass, make sure the new table looks okay. By default, CDN-in-a-Box only shows numbers on the scale of a few dozen kbps; to check the conversion to Mbps appropriately occurs when those go over 1000, I left a few processes running `while true; do curl -skvL https://video.demo1.mycdn.ciab.test/ > /dev/null; done;` and was able to observe a couple dozen Mbps being shown in the table shortly after.
## PR submission checklist
- [ ] This PR has tests
- [ ] This PR has documentation
- [x] This PR has a CHANGELOG.md entry
- [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762084121
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
I tried adding that, it says that `CGC.ColumnDefiniition` is still `any`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus merged pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus merged pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762395415
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
I added the type anyway
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#issuecomment-1025983619
Rebase please (has CiaB fix)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762025113
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
`/** @typedef { import('./relative/path/to/CommonGridController').CGC } CGC */
` at the top of the file.
Your IDE probably doesn't pick it up since it's just an empty extension of ag-grids `ColDef`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762003265
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
Review comment:
why is this class not nested but `CacheStatsSSHCellRenderer` is?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762018354
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
+ $scope.columns = [
+ {
+ headerName: "Cache Group",
+ field: "cachegroup",
+ hide: false
+ },
+ {
+ headerName: "Connections",
+ field: "connections",
+ hide: false,
+ filter: "agNumberColumnFilter"
+ },
+ {
+ cellRenderer: CacheStatsHealthyCellRenderer,
+ headerName: "Healthy",
+ field: "healthy",
+ hide: false
+ },
+ {
+ cellRenderer: CacheStatsSSHCellRenderer,
+ headerName: "Host",
+ field: "hostname",
+ hide: false
+ },
+ {
+ cellRenderer: CacheStatsSSHCellRenderer,
+ headerName: "IP",
+ field: "ip",
+ hide: true,
+ },
+ {
+ headerName: "Data out rate",
+ field: "kbps",
+ filter: "agNumberColumnFilter",
+ hide: false,
+ /**
+ * Formats the kbps metric.
+ * @param {{value: number}} value Some AG Grid params containing the raw value to be formatted.
+ * @returns {string} The formatted value.
+ */
+ valueFormatter: ({value}) => {
+ console.log("formatting a kbps:", value);
Review comment:
I don't think this is needed, but if you want to keep it it should probably be `console.debug`
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
not very important but this can be a `CGC.ColumnDefinition[]`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762023065
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
+ $scope.columns = [
+ {
+ headerName: "Cache Group",
+ field: "cachegroup",
+ hide: false
+ },
+ {
+ headerName: "Connections",
+ field: "connections",
+ hide: false,
+ filter: "agNumberColumnFilter"
+ },
+ {
+ cellRenderer: CacheStatsHealthyCellRenderer,
+ headerName: "Healthy",
+ field: "healthy",
+ hide: false
+ },
+ {
+ cellRenderer: CacheStatsSSHCellRenderer,
+ headerName: "Host",
+ field: "hostname",
+ hide: false
+ },
+ {
+ cellRenderer: CacheStatsSSHCellRenderer,
+ headerName: "IP",
+ field: "ip",
+ hide: true,
+ },
+ {
+ headerName: "Data out rate",
+ field: "kbps",
+ filter: "agNumberColumnFilter",
+ hide: false,
+ /**
+ * Formats the kbps metric.
+ * @param {{value: number}} value Some AG Grid params containing the raw value to be formatted.
+ * @returns {string} The formatted value.
+ */
+ valueFormatter: ({value}) => {
+ console.log("formatting a kbps:", value);
Review comment:
I do not. I was trying to figure out the type of that argument without reading the docs :P
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762035013
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
Review comment:
Missing semicolon
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762022653
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
Review comment:
Because `CacheStatsSSHCellRenderer` needs access to the injected `userModel` service, but `CacheStatsHealthyCellRenderer` is pure functional
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762025113
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
`/** @typedef { import('./relative/path/to/CommonGridController').CGC } CGC */
` at the top of the file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762023668
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: boolean;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ this.eGui = document.createElement("span");
+ this.eGui.setAttribute("class", params.value ? "green" : "red");
+ this.eGui.textContent = String(params.value);
+ }
- $scope.cacheStats = cacheStats;
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+}
- $scope.ssh = serverUtils.ssh;
+/**
+ *
+ * @param {CacheStat[]} cacheStats
+ * @param {{user: {username: string}}} userModel
+ */
+var CacheStatsController = function(cacheStats, $scope, userModel) {
- $scope.bandwidth = function(kbps, unit) {
- return numberUtils.addCommas(numberUtils.convertTo(kbps, unit));
- };
+ class CacheStatsSSHCellRenderer {
+ /** @type HTMLAnchorElement | Text */
+ eGui;
- $scope.connections = function(amt) {
- return numberUtils.addCommas(amt);
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
+ * eGridCell: HTMLElement;
+ * eParentOfValue: HTMLElement;
+ * formatValue: function;
+ * fullWidth: boolean;
+ * getValue: function;
+ * node: any;
+ * pinned: string | null;
+ * refreshCell: function;
+ * registerRowDragger: function;
+ * rowIndex: number;
+ * setValue: function;
+ * value: string;
+ * valueFormatted: null;
+ * $scope: null;
+ * }} params
+ */
+ init(params) {
+ if (params.data.ip === null) {
+ this.eGui = document.createTextNode(params.value);
+ return;
+ }
+ this.eGui = document.createElement("a");
+ this.eGui.href = `ssh://${userModel.user.username}@${params.data.ip}`;
+ this.eGui.setAttribute("class", "link");
+ this.eGui.textContent = params.value;
+ }
- $scope.refresh = function() {
- $state.reload(); // reloads all the resolves for the view
- };
+ /**
+ * Gets a rendered cell. Parameters are available, but not currently used.
+ *
+ * @returns {HTMLElement | Text} A rendered cell element.
+ */
+ getGui() {
+ return this.eGui;
+ }
+ }
- $scope.$on("$destroy", function() {
- killInterval();
- });
+ /** The columns of the ag-grid table */
Review comment:
JSDoc doesn't resolve those references for me, dunno if I'm missing some kind of `@import` or something
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [trafficcontrol] shamrickus commented on a change in pull request #6400: Upgrade Cache Stats Traffic Portal view to use AG-Grid tables
Posted by GitBox <gi...@apache.org>.
shamrickus commented on a change in pull request #6400:
URL: https://github.com/apache/trafficcontrol/pull/6400#discussion_r762034575
##########
File path: traffic_portal/app/src/modules/private/cacheStats/CacheStatsController.js
##########
@@ -17,60 +17,218 @@
* under the License.
*/
-var CacheStatsController = function(cacheStats, $scope, $state, $interval, numberUtils, serverUtils) {
+/**
+ * @typedef CacheStat
+ * @property {string} cachegroup
+ * @property {number} connections
+ * @property {boolean} healthy
+ * @property {string} hostname
+ * @property {string | null} ip
+ * @property {number} kbps
+ * @property {string} profile
+ * @property {string} status
+ */
- var cacheStatsInterval,
- autoRefresh = false,
- refreshRateInMS = 10000;
- var createInterval = function() {
- killInterval();
- cacheStatsInterval = $interval(function() { $scope.refresh() }, refreshRateInMS );
- };
+class CacheStatsHealthyCellRenderer {
+ /** @type HTMLSpanElement */
+ eGui;
- var killInterval = function() {
- if (angular.isDefined(cacheStatsInterval)) {
- $interval.cancel(cacheStatsInterval);
- cacheStatsInterval = undefined;
- }
- };
+ /**
+ * Called by AG-Grid as a pseudo constructor, used when a renderer is
+ * instantiated.
+ *
+ * @param {{
+ * api: any;
+ * colDef: any;
+ * column: any;
+ * columnApi: any;
+ * context: any;
+ * data: CacheStat
Review comment:
Missing semicolon
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org