-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.ts
66 lines (58 loc) Β· 2.51 KB
/
configuration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { workspace } from 'vscode';
import { Settings } from './settings';
import { ViewThemes } from '../views/viewThemes';
/**
* Extension id for tabular data configuration settings lookup.
*/
export const extensionId: string = 'tabular.data';
/**
* Data packages for the built-in Data Packages gallery
* and tabular.data.listDataPackages sample data picker command.
*/
export const dataPackages = require('./packages.json');
/**
* Gets tabular data configuration setting
* from global user or project workspace settings.
*
* @param settingName Configuration setting name/key.
* @returns Configuration setting value.
*/
export function get(settingName: string): any {
return workspace.getConfiguration(extensionId).get(settingName);
}
/**
* Data view type imports for table view html template.
*/
// TODO: refactor this later and switch to using JS modules and JSX for data view templates.
export const viewImports: any = {
tabulator: `<link href="https://unpkg.com/tabulator-tables@5.1.0/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@5.1.0/dist/js/tabulator.min.js"></script>`,
perspective: `<script type="text/javascript" src="https://unpkg.com/@finos/perspective@1.1.0/dist/umd/perspective.js"></script>
<script type="module" src="https://unpkg.com/@finos/perspective-viewer@1.1.0/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="https://unpkg.com/@finos/perspective-viewer-datagrid@1.1.0/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="https://unpkg.com/@finos/perspective-viewer-d3fc@1.1.0/dist/cdn/perspective-viewer-d3fc.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@finos/perspective-viewer@1.1.0/dist/css/material-dense.css" />`
};
/**
* Gets view imports for the specified data view type.
*
* @param dataViewType Tabular data view type.
* @returns JS and CSS imports to use for the tabular data webview html.
*/
export function getViewImports(dataViewType: string): string {
let imports: string = viewImports[dataViewType];
// get data UI theme preference
const uiTheme: string = <string>get(Settings.DataUiTheme);
if (uiTheme === ViewThemes.Dark) {
// reset imported stylesheets to dark
switch (dataViewType) {
case 'tabulator':
imports = imports.replace('tabulator.min.css', 'tabulator_midnight.min.css');
break;
case 'perspective':
imports = imports.replace('material-dense.css', 'material-dense.dark.css');
break;
}
}
return imports;
}