diff --git a/ui/app/components/clients/history.js b/ui/app/components/clients/history.js index 56e63507d578..94c6761ad0ae 100644 --- a/ui/app/components/clients/history.js +++ b/ui/app/components/clients/history.js @@ -1,6 +1,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; +import { format } from 'date-fns'; export default class HistoryComponent extends Component { max_namespaces = 10; @@ -77,6 +78,19 @@ export default class HistoryComponent extends Component { return results; } + // Return csv filename with start and end dates + get getCsvFileName() { + let defaultFileName = `clients-by-namespace`, + startDate = + this.args.model.queryStart || `${format(new Date(this.args.model.activity.startTime), 'MM-yyyy')}`, + endDate = + this.args.model.queryEnd || `${format(new Date(this.args.model.activity.endTime), 'MM-yyyy')}`; + if (startDate && endDate) { + defaultFileName += `-${startDate}-${endDate}`; + } + return defaultFileName; + } + // Get the namespace by matching the path from the namespace list getNamespace(path) { return this.args.model.activity.byNamespace.find(ns => { diff --git a/ui/app/templates/components/clients/history.hbs b/ui/app/templates/components/clients/history.hbs index 8963e9f61980..0199ed7f4904 100644 --- a/ui/app/templates/components/clients/history.hbs +++ b/ui/app/templates/components/clients/history.hbs @@ -145,7 +145,7 @@ (hash key='distinct_entities' label='Unique entities') }} > - +