mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-31 09:35:39 -05:00
Export to Markdown (#20661)
* Give saveAsExcel its own config options * Wired up correctly * Merge conflicts * PR comments 1 Co-authored-by: Ben Russell <russellben@microsoft.com>
This commit is contained in:
55
src/sql/base/browser/ui/table/media/saveMarkdown.svg
Normal file
55
src/sql/base/browser/ui/table/media/saveMarkdown.svg
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg228"
|
||||
sodipodi:docname="saveMarkdown.svg"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs232" /><sodipodi:namedview
|
||||
id="namedview230"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="90.509668"
|
||||
inkscape:cx="5.7065727"
|
||||
inkscape:cy="6.9605824"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1529"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg228" /><style
|
||||
id="style221">.icon-canvas-transparent{opacity:0;fill:#f6f6f6}.icon-vs-out{fill:#f6f6f6}.icon-vs-bg{fill:#424242}.icon-vs-fg{fill:#f0eff1}.icon-vs-action-blue{fill:#00539c}</style><path
|
||||
class="icon-canvas-transparent"
|
||||
d="M16 16H0V0h16v16z"
|
||||
id="canvas" /><path
|
||||
class="icon-vs-out"
|
||||
d="M14 4.552V13c-.028.825-.593 2-2.035 2h-8C3.012 15 2 14.299 2 13V8H.586l2-2H0V2h2.586l-2-2h4.828l1 1h3.608L14 4.552z"
|
||||
id="outline"
|
||||
style="display: none;" /><path
|
||||
class="icon-vs-fg"
|
||||
d="M9 3.586L8.414 3H9v.586zM12 6h-2v7h2V6zm-6 7V7.414L5.414 8H4v5h2zm1 0h2V4.414l-1 1V6h-.586L7 6.414V13z"
|
||||
id="iconFg"
|
||||
style="display: none;" /><path
|
||||
class="icon-vs-action-blue"
|
||||
d="M8 4L5 7H3l2-2H1V3h4L3 1h2l3 3z"
|
||||
id="colorAction" /><path
|
||||
id="rect298"
|
||||
style="color:#000000;fill:#424242;fill-opacity:1"
|
||||
d="M 8.5234375 3.8164062 L 8.7070312 4 L 8.2382812 4.46875 L 13.816406 4.46875 C 14.00308 4.46875 14.142578 4.6102013 14.142578 4.796875 L 14.142578 11.201172 C 14.142578 11.387846 14.00308 11.527344 13.816406 11.527344 L 2.1835938 11.527344 C 1.9969199 11.527344 1.8574219 11.387846 1.8574219 11.201172 L 1.8574219 7 L 1.203125 7 L 1.203125 11.201172 C 1.203125 11.738585 1.6461799 12.181641 2.1835938 12.181641 L 13.816406 12.181641 C 14.353821 12.181641 14.796874 11.738585 14.796875 11.201172 L 14.796875 4.796875 C 14.796875 4.2594611 14.353821 3.8164063 13.816406 3.8164062 L 8.5234375 3.8164062 z " /><path
|
||||
id="path300"
|
||||
style="fill:#424242;fill-opacity:1;stroke-width:0.0653511"
|
||||
d="M 6.9296875 5.7773438 L 6.5605469 6.1464844 L 5.5488281 7.4121094 L 5.4355469 7.2714844 L 5.2070312 7.5 L 2.9355469 7.5 L 2.9355469 10.222656 L 4.2421875 10.222656 L 4.2421875 7.6738281 L 5.5488281 9.3066406 L 6.8554688 7.6738281 L 6.8554688 10.222656 L 8.1640625 10.222656 L 8.1640625 5.7773438 L 6.9296875 5.7773438 z M 10.451172 5.7773438 L 10.451172 8.0644531 L 9.1445312 8.0644531 L 11.103516 10.222656 L 13.064453 8.0644531 L 11.757812 8.0644531 L 11.757812 5.7773438 L 10.451172 5.7773438 z " /><path
|
||||
style="color:#000000;fill:#00539c;-inkscape-stroke:none"
|
||||
d="M 8,4 5,7 H 3 L 5,5 H 1 V 3 H 5 L 3,1 h 2 z"
|
||||
id="path1824" /></svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
55
src/sql/base/browser/ui/table/media/saveMarkdown_inverse.svg
Normal file
55
src/sql/base/browser/ui/table/media/saveMarkdown_inverse.svg
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg228"
|
||||
sodipodi:docname="saveMarkdown_inverse.svg"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs232" /><sodipodi:namedview
|
||||
id="namedview230"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
showgrid="false"
|
||||
inkscape:zoom="64"
|
||||
inkscape:cx="12.460937"
|
||||
inkscape:cy="5.828125"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1529"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg228" /><style
|
||||
id="style221">.icon-canvas-transparent{opacity:0;fill:#f6f6f6}.icon-vs-out{fill:#f6f6f6}.icon-vs-bg{fill:#424242}.icon-vs-fg{fill:#f0eff1}.icon-vs-action-blue{fill:#00539c}</style><path
|
||||
class="icon-canvas-transparent"
|
||||
d="M16 16H0V0h16v16z"
|
||||
id="canvas" /><path
|
||||
class="icon-vs-out"
|
||||
d="M14 4.552V13c-.028.825-.593 2-2.035 2h-8C3.012 15 2 14.299 2 13V8H.586l2-2H0V2h2.586l-2-2h4.828l1 1h3.608L14 4.552z"
|
||||
id="outline"
|
||||
style="display: none;" /><path
|
||||
class="icon-vs-fg"
|
||||
d="M9 3.586L8.414 3H9v.586zM12 6h-2v7h2V6zm-6 7V7.414L5.414 8H4v5h2zm1 0h2V4.414l-1 1V6h-.586L7 6.414V13z"
|
||||
id="iconFg"
|
||||
style="display: none;" /><path
|
||||
class="icon-vs-action-blue"
|
||||
d="M8 4L5 7H3l2-2H1V3h4L3 1h2l3 3z"
|
||||
id="colorAction" /><path
|
||||
id="rect298"
|
||||
style="color:#000000;fill:#c5c5c5;fill-opacity:1"
|
||||
d="M 8.5234375 3.8164062 L 8.7070312 4 L 8.2382812 4.46875 L 13.816406 4.46875 C 14.00308 4.46875 14.142578 4.6102013 14.142578 4.796875 L 14.142578 11.201172 C 14.142578 11.387846 14.00308 11.527344 13.816406 11.527344 L 2.1835938 11.527344 C 1.9969199 11.527344 1.8574219 11.387846 1.8574219 11.201172 L 1.8574219 7 L 1.203125 7 L 1.203125 11.201172 C 1.203125 11.738585 1.6461799 12.181641 2.1835938 12.181641 L 13.816406 12.181641 C 14.353821 12.181641 14.796874 11.738585 14.796875 11.201172 L 14.796875 4.796875 C 14.796875 4.2594611 14.353821 3.8164063 13.816406 3.8164062 L 8.5234375 3.8164062 z " /><path
|
||||
id="path300"
|
||||
style="fill:#c5c5c5;fill-opacity:1;stroke-width:0.0653511"
|
||||
d="M 6.9296875 5.7773438 L 6.5605469 6.1464844 L 5.5488281 7.4121094 L 5.4355469 7.2714844 L 5.2070312 7.5 L 2.9355469 7.5 L 2.9355469 10.222656 L 4.2421875 10.222656 L 4.2421875 7.6738281 L 5.5488281 9.3066406 L 6.8554688 7.6738281 L 6.8554688 10.222656 L 8.1640625 10.222656 L 8.1640625 5.7773438 L 6.9296875 5.7773438 z M 10.451172 5.7773438 L 10.451172 8.0644531 L 9.1445312 8.0644531 L 11.103516 10.222656 L 13.064453 8.0644531 L 11.757812 8.0644531 L 11.757812 5.7773438 L 10.451172 5.7773438 z " /><path
|
||||
style="color:#000000;fill:#75beff;-inkscape-stroke:none;fill-opacity:1"
|
||||
d="M 8,4 5,7 H 3 L 5,5 H 1 V 3 H 5 L 3,1 h 2 z"
|
||||
id="path1824" /></svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
@@ -63,6 +63,11 @@
|
||||
background-image: url("saveExcel.svg");
|
||||
}
|
||||
|
||||
.vs .codicon.saveMarkdown {
|
||||
/* ResultToMarkdown_16x_vscode */
|
||||
background-image: url("saveMarkdown.svg");
|
||||
}
|
||||
|
||||
.vs .codicon.saveXml {
|
||||
/* ResultToXML_16x_vscode */
|
||||
background-image: url("saveXml.svg");
|
||||
@@ -172,6 +177,12 @@
|
||||
background-image: url("saveExcel_inverse.svg");
|
||||
}
|
||||
|
||||
.vs-dark .codicon.saveMarkdown,
|
||||
.hc-black .codicon.saveMarkdown {
|
||||
/* ResultToMarkdown_16x_vscode_inverse.svg */
|
||||
background-image: url("saveMarkdown_inverse.svg");
|
||||
}
|
||||
|
||||
.vs-dark .codicon.saveXml,
|
||||
.hc-black .codicon.saveXml {
|
||||
/* ResultToXml_16x_vscode_inverse.svg */
|
||||
|
||||
@@ -15,6 +15,11 @@ export interface IQueryEditorConfiguration {
|
||||
readonly saveAsExcel: {
|
||||
readonly includeHeaders: boolean,
|
||||
},
|
||||
readonly saveAsMarkdown: {
|
||||
readonly encoding: string,
|
||||
readonly includeHeaders: boolean,
|
||||
readonly lineSeparator: string,
|
||||
}
|
||||
readonly saveAsXml: {
|
||||
readonly formatted: boolean,
|
||||
readonly encoding: string
|
||||
|
||||
@@ -14,6 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
|
||||
export const GRID_SAVECSV_ID = 'grid.saveAsCsv';
|
||||
export const GRID_SAVEJSON_ID = 'grid.saveAsJson';
|
||||
export const GRID_SAVEMARKDOWN_ID = 'grid.saveAsMarkdown';
|
||||
export const GRID_SAVEEXCEL_ID = 'grid.saveAsExcel';
|
||||
export const GRID_SAVEXML_ID = 'grid.saveAsXml';
|
||||
export const GRID_COPY_ID = 'grid.copySelection';
|
||||
@@ -46,6 +47,7 @@ export class GridActionProvider {
|
||||
const actions: IAction[] = [];
|
||||
actions.push(this._instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveFormat.CSV, this._dataService));
|
||||
actions.push(this._instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveFormat.JSON, this._dataService));
|
||||
actions.push(this._instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveFormat.MARKDOWN, this._dataService));
|
||||
actions.push(this._instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveFormat.EXCEL, this._dataService));
|
||||
actions.push(this._instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveFormat.XML, this._dataService));
|
||||
actions.push(this._instantiationService.createInstance(SelectAllGridAction, SelectAllGridAction.ID, SelectAllGridAction.LABEL, this._selectAllCallback));
|
||||
@@ -63,6 +65,9 @@ class SaveResultAction extends Action {
|
||||
public static SAVEJSON_ID = GRID_SAVEJSON_ID;
|
||||
public static SAVEJSON_LABEL = localize('saveAsJson', "Save As JSON");
|
||||
|
||||
public static SAVEMARKDOWN_ID = GRID_SAVEMARKDOWN_ID;
|
||||
public static SAVEMARKDOWN_LABEL = localize('saveAsMarkdown', "Save As Markdown");
|
||||
|
||||
public static SAVEEXCEL_ID = GRID_SAVEEXCEL_ID;
|
||||
public static SAVEEXCEL_LABEL = localize('saveAsExcel', "Save As Excel");
|
||||
|
||||
|
||||
@@ -63,6 +63,10 @@ export const saveAsJson = (accessor: ServicesAccessor) => {
|
||||
runActionOnActiveResultsEditor(accessor, GridContentEvents.SaveAsJSON);
|
||||
};
|
||||
|
||||
export const saveAsMarkdown = (accessor: ServicesAccessor) => {
|
||||
runActionOnActiveResultsEditor(accessor, GridContentEvents.SaveAsMarkdown);
|
||||
};
|
||||
|
||||
export const saveAsExcel = (accessor: ServicesAccessor) => {
|
||||
runActionOnActiveResultsEditor(accessor, GridContentEvents.SaveAsExcel);
|
||||
};
|
||||
|
||||
@@ -139,6 +139,9 @@ export abstract class GridParentComponent extends Disposable {
|
||||
case GridContentEvents.SaveAsJSON:
|
||||
self.sendSaveRequest(SaveFormat.JSON);
|
||||
break;
|
||||
case GridContentEvents.SaveAsMarkdown:
|
||||
self.sendSaveRequest(SaveFormat.MARKDOWN);
|
||||
break;
|
||||
case GridContentEvents.SaveAsExcel:
|
||||
self.sendSaveRequest(SaveFormat.EXCEL);
|
||||
break;
|
||||
@@ -313,6 +316,9 @@ export abstract class GridParentComponent extends Disposable {
|
||||
'SaveAsJSON': () => {
|
||||
this.sendSaveRequest(SaveFormat.JSON);
|
||||
},
|
||||
'SaveAsMarkdown': () => {
|
||||
this.sendSaveRequest(SaveFormat.MARKDOWN);
|
||||
},
|
||||
'SaveAsExcel': () => {
|
||||
this.sendSaveRequest(SaveFormat.EXCEL);
|
||||
},
|
||||
@@ -341,6 +347,9 @@ export abstract class GridParentComponent extends Disposable {
|
||||
case 'savejson':
|
||||
this.dataService.sendSaveRequest({ batchIndex: event.batchId, resultSetNumber: event.resultId, format: SaveFormat.JSON, selection: event.selection });
|
||||
break;
|
||||
case 'saveMarkdown':
|
||||
this.dataService.sendSaveRequest({ batchIndex: event.batchId, resultSetNumber: event.resultId, format: SaveFormat.MARKDOWN, selection: event.selection });
|
||||
break;
|
||||
case 'saveexcel':
|
||||
this.dataService.sendSaveRequest({ batchIndex: event.batchId, resultSetNumber: event.resultId, format: SaveFormat.EXCEL, selection: event.selection });
|
||||
break;
|
||||
|
||||
@@ -276,6 +276,7 @@ class DataResourceTable extends GridTableBase<any> {
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveResultAction.SAVECSV_ICON, SaveFormat.CSV),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveResultAction.SAVEEXCEL_ICON, SaveFormat.EXCEL),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveResultAction.SAVEJSON_ICON, SaveFormat.JSON),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveResultAction.SAVEMARKDOWN_ICON, SaveFormat.MARKDOWN),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveResultAction.SAVEXML_ICON, SaveFormat.XML),
|
||||
this.instantiationService.createInstance(NotebookChartAction, this)
|
||||
];
|
||||
|
||||
@@ -52,6 +52,10 @@ export class SaveResultAction extends Action {
|
||||
public static SAVEJSON_LABEL = localize('saveAsJson', "Save As JSON");
|
||||
public static SAVEJSON_ICON = 'saveJson';
|
||||
|
||||
public static SAVEMARKDOWN_ID = 'grid.saveAsMarkdown';
|
||||
public static SAVEMARKDOWN_LABEL = localize('saveAsMarkdown', "Save As Markdown");
|
||||
public static SAVEMARKDOWN_ICON = 'saveMarkdown';
|
||||
|
||||
public static SAVEEXCEL_ID = 'grid.saveAsExcel';
|
||||
public static SAVEEXCEL_LABEL = localize('saveAsExcel', "Save As Excel");
|
||||
public static SAVEEXCEL_ICON = 'saveExcel';
|
||||
|
||||
@@ -953,6 +953,7 @@ class GridTable<T> extends GridTableBase<T> {
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveResultAction.SAVECSV_ICON, SaveFormat.CSV),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveResultAction.SAVEEXCEL_ICON, SaveFormat.EXCEL),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveResultAction.SAVEJSON_ICON, SaveFormat.JSON),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveResultAction.SAVEMARKDOWN_ICON, SaveFormat.MARKDOWN),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveResultAction.SAVEXML_ICON, SaveFormat.XML),
|
||||
this.instantiationService.createInstance(ChartDataAction)
|
||||
);
|
||||
@@ -969,6 +970,7 @@ class GridTable<T> extends GridTableBase<T> {
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveResultAction.SAVECSV_ICON, SaveFormat.CSV),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveResultAction.SAVEEXCEL_ICON, SaveFormat.EXCEL),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveResultAction.SAVEJSON_ICON, SaveFormat.JSON),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveResultAction.SAVEMARKDOWN_ICON, SaveFormat.MARKDOWN),
|
||||
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveResultAction.SAVEXML_ICON, SaveFormat.XML),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -287,6 +287,14 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
handler: gridCommands.saveAsJson
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: gridActions.GRID_SAVEMARKDOWN_ID,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: ResultsGridFocusCondition,
|
||||
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyR, KeyMod.CtrlCmd | KeyCode.KeyM),
|
||||
handler: gridCommands.saveAsMarkdown
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: gridActions.GRID_SAVEEXCEL_ID,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
@@ -384,6 +392,21 @@ const queryEditorConfiguration: IConfigurationNode = {
|
||||
'description': localize('queryEditor.results.saveAsCsv.encoding', "File encoding used when saving results as CSV"),
|
||||
'default': 'utf-8'
|
||||
},
|
||||
'queryEditor.results.saveAsMarkdown.encoding': {
|
||||
'type': 'string',
|
||||
'description': localize('queryEditor.results.saveAsMarkdown.encoding', "File encoding used when saving results as Markdown"),
|
||||
'default': 'utf-8'
|
||||
},
|
||||
'queryEditor.results.saveAsMarkdown.includeHeaders': {
|
||||
'type': 'boolean',
|
||||
'description': localize('queryEditor.results.saveAsMarkdown.includeHeaders', "When true, column headers are included when saving results as a Markdown file"),
|
||||
'default': true
|
||||
},
|
||||
'queryEditor.results.saveAsMarkdown.lineSeparator': {
|
||||
'type': 'string',
|
||||
'description': localize('queryEditor.results.saveAsMarkdown.lineSeparator', "Character(s) to use to separate lines when exporting to Markdown, defaults to system line endings"),
|
||||
'default': null
|
||||
},
|
||||
'queryEditor.results.saveAsXml.formatted': {
|
||||
'type': 'boolean',
|
||||
'description': localize('queryEditor.results.saveAsXml.formatted', "When true, XML output will be formatted when saving results as XML"),
|
||||
|
||||
@@ -14,6 +14,7 @@ export const SelectAll = 'SelectAll';
|
||||
export const SelectAllMessages = 'SelectAllMessages';
|
||||
export const SaveAsCsv = 'SaveAsCSV';
|
||||
export const SaveAsJSON = 'SaveAsJSON';
|
||||
export const SaveAsMarkdown = 'SaveAsMarkdown';
|
||||
export const SaveAsExcel = 'SaveAsExcel';
|
||||
export const SaveAsXML = 'SaveAsXML';
|
||||
export const ViewAsChart = 'ViewAsChart';
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface SaveResultsResponse {
|
||||
export enum SaveFormat {
|
||||
CSV = 'csv',
|
||||
JSON = 'json',
|
||||
MARKDOWN = 'markdown',
|
||||
EXCEL = 'excel',
|
||||
XML = 'xml'
|
||||
}
|
||||
@@ -128,6 +129,9 @@ export class ResultSerializer {
|
||||
case SaveFormat.JSON:
|
||||
fileName = fileName + '.json';
|
||||
break;
|
||||
case SaveFormat.MARKDOWN:
|
||||
fileName = fileName + '.md';
|
||||
break;
|
||||
case SaveFormat.EXCEL:
|
||||
fileName = fileName + '.xlsx';
|
||||
break;
|
||||
@@ -153,6 +157,10 @@ export class ResultSerializer {
|
||||
fileFilter.name = nls.localize('resultsSerializer.saveAsFileExtensionJSONTitle', "JSON");
|
||||
fileFilter.extensions = ['json'];
|
||||
break;
|
||||
case SaveFormat.MARKDOWN:
|
||||
fileFilter.name = nls.localize('resultsSerializer.saveAsFileExtensionMarkdownTitle', "Markdown");
|
||||
fileFilter.extensions = ['md'];
|
||||
break;
|
||||
case SaveFormat.EXCEL:
|
||||
fileFilter.name = nls.localize('resultsSerializer.saveAsFileExtensionExcelTitle', "Excel Workbook");
|
||||
fileFilter.extensions = ['xlsx'];
|
||||
@@ -170,22 +178,21 @@ export class ResultSerializer {
|
||||
return fileFilters;
|
||||
}
|
||||
|
||||
public getBasicSaveParameters(format: string): SaveResultsRequestParams {
|
||||
let saveResultsParams: SaveResultsRequestParams;
|
||||
|
||||
if (format === SaveFormat.CSV) {
|
||||
saveResultsParams = this.getConfigForCsv();
|
||||
} else if (format === SaveFormat.JSON) {
|
||||
saveResultsParams = this.getConfigForJson();
|
||||
} else if (format === SaveFormat.EXCEL) {
|
||||
saveResultsParams = this.getConfigForExcel();
|
||||
} else if (format === SaveFormat.XML) {
|
||||
saveResultsParams = this.getConfigForXml();
|
||||
public getBasicSaveParameters(format: SaveFormat): SaveResultsRequestParams {
|
||||
switch (format) {
|
||||
case SaveFormat.CSV:
|
||||
return this.getConfigForCsv();
|
||||
case SaveFormat.EXCEL:
|
||||
return this.getConfigForExcel();
|
||||
case SaveFormat.JSON:
|
||||
return this.getConfigForJson();
|
||||
case SaveFormat.MARKDOWN:
|
||||
return this.getConfigForMarkdown();
|
||||
case SaveFormat.XML:
|
||||
return this.getConfigForXml();
|
||||
}
|
||||
return saveResultsParams!; // this could be unsafe
|
||||
}
|
||||
|
||||
|
||||
private getConfigForCsv(): SaveResultsRequestParams {
|
||||
let saveResultsParams = <SaveResultsRequestParams>{ resultFormat: SaveFormat.CSV as string };
|
||||
|
||||
@@ -219,6 +226,26 @@ export class ResultSerializer {
|
||||
return <SaveResultsRequestParams>{ resultFormat: SaveFormat.JSON as string };
|
||||
}
|
||||
|
||||
private getConfigForMarkdown(): SaveResultsRequestParams {
|
||||
let saveResultsParams = <SaveResultsRequestParams>{ resultFormat: SaveFormat.MARKDOWN as string };
|
||||
|
||||
// Get config from VSCode config and build params with it if user has set config
|
||||
const saveConfig = this._configurationService.getValue<IQueryEditorConfiguration>('queryEditor').results.saveAsMarkdown;
|
||||
if (saveConfig) {
|
||||
if (saveConfig.encoding) {
|
||||
saveResultsParams.encoding = saveConfig.encoding;
|
||||
}
|
||||
if (saveConfig.includeHeaders !== undefined) {
|
||||
saveResultsParams.includeHeaders = saveConfig.includeHeaders;
|
||||
}
|
||||
if (saveConfig.lineSeparator !== undefined) {
|
||||
saveResultsParams.lineSeperator = saveConfig.lineSeparator;
|
||||
}
|
||||
}
|
||||
|
||||
return saveResultsParams;
|
||||
}
|
||||
|
||||
private getConfigForExcel(): SaveResultsRequestParams {
|
||||
let saveResultsParams = <SaveResultsRequestParams>{ resultFormat: SaveFormat.EXCEL as string };
|
||||
|
||||
@@ -260,7 +287,7 @@ export class ResultSerializer {
|
||||
filePath: URI,
|
||||
batchIndex: number,
|
||||
resultSetNo: number,
|
||||
format: string,
|
||||
format: SaveFormat,
|
||||
selection?: Slick.Range
|
||||
): SaveResultsRequestParams {
|
||||
let saveResultsParams = this.getBasicSaveParameters(format);
|
||||
|
||||
Reference in New Issue
Block a user