mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 01:45:59 +00:00
copy as yaml
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chartjs-adapter-moment": "^1.0.0",
|
"chartjs-adapter-moment": "^1.0.0",
|
||||||
"diff": "^5.0.0",
|
"diff": "^5.0.0",
|
||||||
"diff2html": "^3.4.13"
|
"diff2html": "^3.4.13",
|
||||||
|
"js-yaml": "^4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { arrayToHexString } from 'dbgate-tools';
|
import { arrayToHexString } from 'dbgate-tools';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
|
||||||
export function copyTextToClipboard(text) {
|
export function copyTextToClipboard(text) {
|
||||||
const oldFocus = document.activeElement;
|
const oldFocus = document.activeElement;
|
||||||
@@ -96,6 +97,10 @@ const clipboardJsonFormatter = () => (columns, rows) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clipboardYamlFormatter = () => (columns, rows) => {
|
||||||
|
return yaml.dump(rows.map(row => _.pick(row, columns)));
|
||||||
|
};
|
||||||
|
|
||||||
const clipboardJsonLinesFormatter = () => (columns, rows) => {
|
const clipboardJsonLinesFormatter = () => (columns, rows) => {
|
||||||
return rows.map(row => JSON.stringify(_.pick(row, columns))).join('\r\n');
|
return rows.map(row => JSON.stringify(_.pick(row, columns))).join('\r\n');
|
||||||
};
|
};
|
||||||
@@ -165,6 +170,11 @@ export const copyRowsFormatDefs = {
|
|||||||
name: 'JSON lines',
|
name: 'JSON lines',
|
||||||
formatter: clipboardJsonLinesFormatter(),
|
formatter: clipboardJsonLinesFormatter(),
|
||||||
},
|
},
|
||||||
|
yaml: {
|
||||||
|
label: 'Copy as YAML',
|
||||||
|
name: 'YAML',
|
||||||
|
formatter: clipboardYamlFormatter(),
|
||||||
|
},
|
||||||
inserts: {
|
inserts: {
|
||||||
label: 'Copy as SQL INSERTs',
|
label: 'Copy as SQL INSERTs',
|
||||||
name: 'SQL INSERTs',
|
name: 'SQL INSERTs',
|
||||||
|
|||||||
Reference in New Issue
Block a user