mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
* Added namespace search to client count - Used existing search select component for namespace search * Added changelog * Added download csv component - generate namespaces data in csv format - Show root in top 10 namespaces - Changed active direct tokens to non-entity tokens * Added test for checking graph render * Added documentation for the download csv component
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import layout from '../templates/components/download-csv';
|
|
import { setComponentTemplate } from '@ember/component';
|
|
import { action } from '@ember/object';
|
|
|
|
/**
|
|
* @module DownloadCsv
|
|
* Download csv component is used to display a link which initiates a csv file download of the data provided by it's parent component.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <DownloadCsv @label={{'Export all namespace data'}} @csvData={{"Namespace path,Active clients /n nsTest5/,2725"}} @fileName={{'client-count.csv'}} />
|
|
* ```
|
|
*
|
|
* @param {string} label - Label for the download link button
|
|
* @param {string} csvData - Data in csv format
|
|
* @param {string} fileName - Custom name for the downloaded file
|
|
*
|
|
*/
|
|
class DownloadCsvComponent extends Component {
|
|
@action
|
|
downloadCsv() {
|
|
let hiddenElement = document.createElement('a');
|
|
hiddenElement.setAttribute('href', 'data:text/csv;charset=utf-8,' + encodeURI(this.args.csvData));
|
|
hiddenElement.setAttribute('target', '_blank');
|
|
hiddenElement.setAttribute('download', this.args.fileName || 'vault-data.csv');
|
|
hiddenElement.click();
|
|
}
|
|
}
|
|
|
|
export default setComponentTemplate(layout, DownloadCsvComponent);
|