mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			709 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			709 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { capitalize } from '@ember/string';
 | |
| import Component from '@ember/component';
 | |
| import { computed } from '@ember/object';
 | |
| import columnify from 'columnify';
 | |
| 
 | |
| export function stringifyObjectValues(data) {
 | |
|   Object.keys(data).forEach((item) => {
 | |
|     let val = data[item];
 | |
|     if (typeof val !== 'string') {
 | |
|       val = JSON.stringify(val);
 | |
|     }
 | |
|     data[item] = val;
 | |
|   });
 | |
| }
 | |
| 
 | |
| export default Component.extend({
 | |
|   content: null,
 | |
|   columns: computed('content', function () {
 | |
|     const data = this.content;
 | |
|     stringifyObjectValues(data);
 | |
| 
 | |
|     return columnify(data, {
 | |
|       preserveNewLines: true,
 | |
|       headingTransform: function (heading) {
 | |
|         return capitalize(heading);
 | |
|       },
 | |
|     });
 | |
|   }),
 | |
| });
 | 
