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 2020/10/05 16:07:26 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5086: TP: adds the ability to delete a job (aka invalidation request)

ocket8888 commented on a change in pull request #5086:
URL: https://github.com/apache/trafficcontrol/pull/5086#discussion_r499023211



##########
File path: traffic_portal/app/src/common/modules/table/jobs/TableJobsController.js
##########
@@ -17,10 +17,134 @@
  * under the License.
  */
 
-var TableJobsController = function(jobs, $scope, $state, locationUtils) {
+var TableJobsController = function(tableName, jobs, $document, $scope, $state, $uibModal, locationUtils, jobService, messageModel, dateUtils) {
+
+	/**
+	 * Gets value to display a default tooltip.
+	 */
+	function defaultTooltip(params) {
+		return params.value;
+	}
+
+	function dateCellFormatter(params) {
+		return params.value.toUTCString();
+	}
+
+	columns = [
+		{
+			headerName: "Delivery Service",
+			field: "deliveryService",
+			hide: false
+		},
+		{
+			headerName: "Asset URL",
+			field: "assetUrl",
+			hide: false
+		},
+		{
+			headerName: "Parameters",
+			field: "parameters",
+			hide: false
+		},
+		{
+			headerName: "Start (UTC)",
+			field: "startTime",
+			hide: false,
+			filter: "agDateColumnFilter",
+			tooltip: dateCellFormatter,
+			valueFormatter: dateCellFormatter
+		},
+		{
+			headerName: "Expires (UTC)",
+			field: "expires",
+			hide: false,
+			filter: "agDateColumnFilter",
+			tooltip: dateCellFormatter,
+			valueFormatter: dateCellFormatter
+		},
+		{
+			headerName: "Created By",
+			field: "createdBy",
+			hide: false
+		}
+	];
+
+	/** All of the jobs - startTime fields converted to actual Dates and derived expires field from TTL */
+	$scope.jobs = jobs.map(
+		function(x) {
+			// need to convert this to a date object for ag-grid filter to work properly
+			x.startTime = new Date(x.startTime.replace("+00", "Z"));
+
+			// going to derive the expires date from start + TTL (hours). Format: TTL:24h
+			let ttl = x.parameters.slice('TTL:'.length, x.parameters.length-1);
+			x.expires = new Date(x.startTime.getTime() + ttl*3600*1000);

Review comment:
       should use parseInt(ttl, 10) to avoid weird JS type coercion quirks




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org