datagrok-tools 4.3.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +84 -84
  2. package/bin/_deprecated/migrate.js +83 -83
  3. package/bin/_deprecated/upload.js +161 -161
  4. package/bin/commands/create.js +21 -3
  5. package/bin/commands/help.js +1 -1
  6. package/bin/grok.js +26 -26
  7. package/config-template.yaml +11 -11
  8. package/entity-template/app.js +6 -6
  9. package/entity-template/connection.json +17 -17
  10. package/entity-template/function.js +9 -9
  11. package/entity-template/function.ts +9 -9
  12. package/entity-template/init.js +4 -4
  13. package/entity-template/panel.js +11 -11
  14. package/entity-template/panel.ts +11 -11
  15. package/entity-template/queries.sql +7 -7
  16. package/entity-template/sem-type-detector.js +11 -11
  17. package/entity-template/view-class.js +60 -60
  18. package/entity-template/view-class.ts +64 -64
  19. package/entity-template/view.js +10 -10
  20. package/entity-template/viewer-class.js +23 -23
  21. package/entity-template/viewer-class.ts +23 -23
  22. package/entity-template/viewer.js +8 -8
  23. package/package-template/.eslintrc.json +38 -38
  24. package/package-template/.vscode/launch.json +15 -15
  25. package/package-template/.vscode/tasks.json +9 -9
  26. package/package-template/README.md +2 -2
  27. package/package-template/detectors.js +9 -9
  28. package/package-template/gitignore +29 -29
  29. package/package-template/jest.config.js +33 -0
  30. package/package-template/npmignore +26 -0
  31. package/package-template/package.json +30 -29
  32. package/package-template/src/__jest__/remote.test.ts +49 -0
  33. package/package-template/src/__jest__/test-node.ts +96 -0
  34. package/package-template/src/package-test.js +11 -12
  35. package/package-template/src/package-test.ts +12 -13
  36. package/package-template/src/package.js +11 -11
  37. package/package-template/ts.webpack.config.js +36 -36
  38. package/package-template/tsconfig.json +71 -71
  39. package/package-template/webpack.config.js +27 -27
  40. package/package.json +51 -51
  41. package/script-template/javascript.js +6 -6
  42. package/script-template/julia.jl +8 -8
  43. package/script-template/node.js +8 -8
  44. package/script-template/octave.m +8 -8
  45. package/script-template/python.py +8 -8
  46. package/script-template/r.R +8 -8
  47. package/tsconfig.json +71 -71
@@ -55,6 +55,7 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
55
55
  var ide = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
56
56
  var ts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
57
57
  var eslint = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
58
+ var jest = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
58
59
 
59
60
  var filesToCreate = _fs["default"].readdirSync(templateDir);
60
61
 
@@ -108,6 +109,20 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
108
109
  'lint': "eslint src".concat(ts ? ' --ext .ts' : ''),
109
110
  'lint-fix': "eslint src".concat(ts ? ' --ext .ts' : '', " --fix")
110
111
  });
112
+ }
113
+
114
+ if (jest) {
115
+ Object.assign(_package.devDependencies, {
116
+ 'jest-html-reporter': '^3.5.0',
117
+ 'jest': '^27.0.0',
118
+ '@types/jest': '^27.0.0'
119
+ }, ts ? {
120
+ 'ts-jest': '^27.0.0',
121
+ 'puppeteer': 'latest'
122
+ } : {});
123
+ Object.assign(_package.scripts, {
124
+ 'test': 'jest'
125
+ });
111
126
  } // Save module names for installation prompt
112
127
 
113
128
 
@@ -127,6 +142,9 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
127
142
  if (file === 'package-test.ts' && !ts) return false;
128
143
  if (file === 'tsconfig.json' && !ts) return false;
129
144
  if (file === 'ts.webpack.config.js') return false;
145
+ if (file === 'remote.test.ts' && (!ts || !jest)) return false;
146
+ if (file === 'test-node.ts' && (!ts || !jest)) return false;
147
+ if (file === 'jest.config.js' && !jest) return false;
130
148
 
131
149
  if (file === '.eslintrc.json') {
132
150
  if (!eslint) return false;
@@ -151,7 +169,7 @@ function createDirectoryContents(name, config, templateDir, packageDir) {
151
169
  _fs["default"].mkdirSync(copyFilePath); // recursive call
152
170
 
153
171
 
154
- createDirectoryContents(name, config, origFilePath, copyFilePath, ide, ts);
172
+ createDirectoryContents(name, config, origFilePath, copyFilePath, ide, ts, eslint, jest);
155
173
  }
156
174
  });
157
175
  }
@@ -161,7 +179,7 @@ function create(args) {
161
179
  var nArgs = args['_'].length;
162
180
  if (nArgs > 2 || nOptions > 3) return false;
163
181
  if (nOptions && !Object.keys(args).slice(1).every(function (op) {
164
- return ['ide', 'ts', 'eslint'].includes(op);
182
+ return ['ide', 'ts', 'eslint', 'jest'].includes(op);
165
183
  })) return false; // Create `config.yaml` if it doesn't exist yet
166
184
 
167
185
  if (!_fs["default"].existsSync(grokDir)) _fs["default"].mkdirSync(grokDir);
@@ -198,7 +216,7 @@ function create(args) {
198
216
  return false;
199
217
  }
200
218
 
201
- createDirectoryContents(name, config, templateDir, packageDir, args.ide, args.ts, args.eslint);
219
+ createDirectoryContents(name, config, templateDir, packageDir, args.ide, args.ts, args.eslint, args.jest);
202
220
  console.log(_entHelpers.help["package"](name, args.ts));
203
221
  console.log("\nThe package has the following dependencies:\n".concat(dependencies.join(' '), "\n"));
204
222
  console.log('Running `npm install` to get the required dependencies...\n');
@@ -8,7 +8,7 @@ var HELP = "\nUsage: grok <command>\n\nDatagrok's package management tool\n\nCom
8
8
  var HELP_ADD = "\nUsage: grok add <entity> <name>\n\nAdd an object template to your package:\n\ngrok add app <name>\ngrok add connection <name>\ngrok add detector <semantic-type-name>\ngrok add function [tag] <name>\ngrok add query <name>\ngrok add script [tag] <language> <name>\ngrok add view <name>\ngrok add viewer <name>\n\nPlease note that entity names may only include letters and numbers\n\nSupported languages for scripts:\njavascript, julia, node, octave, python, r\n\nAvailable tags:\npanel, init\n";
9
9
  var HELP_API = "\nUsage: grok api\n\nCreate wrapper functions for package scripts and queries\n";
10
10
  var HELP_CONFIG = "\nUsage: grok config\n\nCreate or update a configuration file\n\nOptions:\n[--reset] [--server] [--alias] [--key]\n\n--reset Restore the default config file template\n--server Use to add a server to the config (`grok config add --alias alias --server url --key key`)\n--alias Use in conjunction with the `server` option to set the server name\n--key Use in conjunction with the `server` option to set the developer key\n--default Use in conjunction with the `server` option to set the added server as default\n";
11
- var HELP_CREATE = "\nUsage: grok create [name]\n\nCreate a package:\n\ngrok create Create a package in the current working directory\ngrok create <name> Create a package in a folder with the specified name\n\nPlease note that the package name may only include letters, numbers, underscores, or hyphens\n\nOptions:\n[--eslint] [--ide] [--ts]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--ts Create a TypeScript package\n";
11
+ var HELP_CREATE = "\nUsage: grok create [name]\n\nCreate a package:\n\ngrok create Create a package in the current working directory\ngrok create <name> Create a package in a folder with the specified name\n\nPlease note that the package name may only include letters, numbers, underscores, or hyphens\n\nOptions:\n[--eslint] [--ide] [--ts] [--jest]\n\n--eslint Add a configuration for eslint\n--ide Add an IDE-specific configuration for debugging (vscode)\n--ts Create a TypeScript package\n--jest Add a configuration for jest\n";
12
12
  var HELP_PUBLISH = "\nUsage: grok publish [host]\n\nUpload a package\n\nOptions:\n[--build|--rebuild] [--debug|--release] [--key] [--suffix]\n\nRunning `grok publish` is the same as running `grok publish defaultHost --build --debug`\n";
13
13
  var HELP_MIGRATE = "\nUsage: grok migrate\n\nSwitch to `grok` tools by copying your keys to the config\nfile and converting your scripts in the `package.json` file\n";
14
14
  var help = {
package/bin/grok.js CHANGED
@@ -1,26 +1,26 @@
1
- #!/usr/bin/env node
2
- const argv = require('minimist')(process.argv.slice(2), {alias: {k: 'key'}});
3
- const help = require('./commands/help').help;
4
-
5
- const commands = {
6
- add: require('./commands/add').add,
7
- api: require('./commands/api').api,
8
- config: require('./commands/config').config,
9
- create: require('./commands/create').create,
10
- publish: require('./commands/publish').publish,
11
- migrate: require('./_deprecated/migrate').migrate
12
- };
13
-
14
- const command = argv['_'][0];
15
- if (command in commands) {
16
- try {
17
- if (!commands[command](argv)) {
18
- console.log(help[command]);
19
- }
20
- } catch (err) {
21
- console.error(err);
22
- console.log(help[command]);
23
- }
24
- } else {
25
- console.log(help.help);
26
- }
1
+ #!/usr/bin/env node
2
+ const argv = require('minimist')(process.argv.slice(2), {alias: {k: 'key'}});
3
+ const help = require('./commands/help').help;
4
+
5
+ const commands = {
6
+ add: require('./commands/add').add,
7
+ api: require('./commands/api').api,
8
+ config: require('./commands/config').config,
9
+ create: require('./commands/create').create,
10
+ publish: require('./commands/publish').publish,
11
+ migrate: require('./_deprecated/migrate').migrate
12
+ };
13
+
14
+ const command = argv['_'][0];
15
+ if (command in commands) {
16
+ try {
17
+ if (!commands[command](argv)) {
18
+ console.log(help[command]);
19
+ }
20
+ } catch (err) {
21
+ console.error(err);
22
+ console.log(help[command]);
23
+ }
24
+ } else {
25
+ console.log(help.help);
26
+ }
@@ -1,11 +1,11 @@
1
- servers:
2
- dev:
3
- url: 'https://dev.datagrok.ai/api'
4
- key: ''
5
- public:
6
- url: 'https://public.datagrok.ai/api'
7
- key: ''
8
- local:
9
- url: 'http://127.0.0.1:8080/api'
10
- key: ''
11
- default: 'public'
1
+ servers:
2
+ dev:
3
+ url: 'https://dev.datagrok.ai/api'
4
+ key: ''
5
+ public:
6
+ url: 'https://public.datagrok.ai/api'
7
+ key: ''
8
+ local:
9
+ url: 'http://127.0.0.1:8080/api'
10
+ key: ''
11
+ default: 'public'
@@ -1,6 +1,6 @@
1
-
2
- //name: #{NAME}
3
- //tags: app
4
- export function #{NAME}() {
5
- grok.shell.info('Hello!');
6
- }
1
+
2
+ //name: #{NAME}
3
+ //tags: app
4
+ export function #{NAME}() {
5
+ grok.shell.info('Hello!');
6
+ }
@@ -1,17 +1,17 @@
1
- {
2
- "name": "#{NAME}",
3
- "#type": "DataConnection",
4
- "parameters": {
5
- "server": "#{GROK_DB_SERVER}",
6
- "db": "#{DB_NAME}"
7
- },
8
- "credentials" : {
9
- "parameters": {
10
- "login": "#{LOGIN}",
11
- "password": "#{PASSWORD}"
12
- }
13
- },
14
- "dataSource": "PostgreSQL",
15
- "description": "#{DB_NAME} db",
16
- "tags": ["demo"]
17
- }
1
+ {
2
+ "name": "#{NAME}",
3
+ "#type": "DataConnection",
4
+ "parameters": {
5
+ "server": "#{GROK_DB_SERVER}",
6
+ "db": "#{DB_NAME}"
7
+ },
8
+ "credentials" : {
9
+ "parameters": {
10
+ "login": "#{LOGIN}",
11
+ "password": "#{PASSWORD}"
12
+ }
13
+ },
14
+ "dataSource": "PostgreSQL",
15
+ "description": "#{DB_NAME} db",
16
+ "tags": ["demo"]
17
+ }
@@ -1,9 +1,9 @@
1
-
2
- //name: #{NAME}
3
- //input: string name
4
- //output: string greeting
5
- export function #{NAME}(name) {
6
- let greeting = 'Hello, ' + name;
7
- grok.shell.info(greeting);
8
- return greeting;
9
- }
1
+
2
+ //name: #{NAME}
3
+ //input: string name
4
+ //output: string greeting
5
+ export function #{NAME}(name) {
6
+ let greeting = 'Hello, ' + name;
7
+ grok.shell.info(greeting);
8
+ return greeting;
9
+ }
@@ -1,9 +1,9 @@
1
-
2
- //name: #{NAME}
3
- //input: string name
4
- //output: string greeting
5
- export function #{NAME}(name: string) {
6
- let greeting = 'Hello, ' + name;
7
- grok.shell.info(greeting);
8
- return greeting;
9
- }
1
+
2
+ //name: #{NAME}
3
+ //input: string name
4
+ //output: string greeting
5
+ export function #{NAME}(name: string) {
6
+ let greeting = 'Hello, ' + name;
7
+ grok.shell.info(greeting);
8
+ return greeting;
9
+ }
@@ -1,4 +1,4 @@
1
-
2
- //tags: init
3
- export async function #{NAME}() {
4
- }
1
+
2
+ //tags: init
3
+ export async function #{NAME}() {
4
+ }
@@ -1,11 +1,11 @@
1
-
2
- //name: #{NAME}
3
- //description: Creates an info panel
4
- //tags: panel
5
- //input: string smiles {semType: Molecule}
6
- //output: widget result
7
- //condition: true
8
- export function #{NAME}(smiles) {
9
- let mol = ui.div(grok.chem.svgMol(smiles));
10
- return DG.Widget.fromRoot(mol);
11
- }
1
+
2
+ //name: #{NAME}
3
+ //description: Creates an info panel
4
+ //tags: panel
5
+ //input: string smiles {semType: Molecule}
6
+ //output: widget result
7
+ //condition: true
8
+ export function #{NAME}(smiles) {
9
+ let mol = ui.div(grok.chem.svgMol(smiles));
10
+ return DG.Widget.fromRoot(mol);
11
+ }
@@ -1,11 +1,11 @@
1
-
2
- //name: #{NAME}
3
- //description: Creates an info panel
4
- //tags: panel
5
- //input: string smiles {semType: Molecule}
6
- //output: widget result
7
- //condition: true
8
- export function #{NAME}(smiles: string) {
9
- let mol = ui.div(grok.chem.svgMol(smiles));
10
- return DG.Widget.fromRoot(mol);
11
- }
1
+
2
+ //name: #{NAME}
3
+ //description: Creates an info panel
4
+ //tags: panel
5
+ //input: string smiles {semType: Molecule}
6
+ //output: widget result
7
+ //condition: true
8
+ export function #{NAME}(smiles: string) {
9
+ let mol = ui.div(grok.chem.svgMol(smiles));
10
+ return DG.Widget.fromRoot(mol);
11
+ }
@@ -1,7 +1,7 @@
1
-
2
- --name: #{NAME}
3
- --connection: #{CONNECTION}
4
- --input: int id
5
- --output: dataframe result
6
- select * from country where id = @id
7
- --end
1
+
2
+ --name: #{NAME}
3
+ --connection: #{CONNECTION}
4
+ --input: int id
5
+ --output: dataframe result
6
+ select * from country where id = @id
7
+ --end
@@ -1,11 +1,11 @@
1
-
2
- //tags: semTypeDetector
3
- //input: column col
4
- //output: string semType
5
- detect#{PACKAGE_DETECTORS_NAME}(col) {
6
- if (col.name.startsWith('#{NAME_PREFIX}')) {
7
- col.semType = '#{NAME}';
8
- return col.semType;
9
- }
10
- return null;
11
- }
1
+
2
+ //tags: semTypeDetector
3
+ //input: column col
4
+ //output: string semType
5
+ detect#{PACKAGE_DETECTORS_NAME}(col) {
6
+ if (col.name.startsWith('#{NAME_PREFIX}')) {
7
+ col.semType = '#{NAME}';
8
+ return col.semType;
9
+ }
10
+ return null;
11
+ }
@@ -1,60 +1,60 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as ui from 'datagrok-api/ui';
3
- import * as DG from 'datagrok-api/dg';
4
-
5
- // A sample class from the Notebooks package:
6
- // https://github.com/datagrok-ai/public/tree/master/packages/Notebooks
7
- // This class defines a new view for Jupyter Notebooks.
8
- export class #{NAME} extends DG.ViewBase {
9
- constructor(params, path) {
10
- super(params, path);
11
- this.TYPE = 'Notebook';
12
- this.PATH = '/notebook';
13
- }
14
-
15
- // Override basic methods
16
- get type() {
17
- return this.TYPE;
18
- }
19
-
20
- get helpUrl() {
21
- return '/help/develop/jupyter-notebook.md';
22
- }
23
-
24
- get name() {
25
- return 'Notebook';
26
- }
27
-
28
- get path() {
29
- return `${this.PATH}/${this.notebookId}`;
30
- }
31
-
32
- // Icon
33
- getIcon() {
34
- let img = document.createElement('img');
35
- img.src = '/images/entities/jupyter.png';
36
- img.height = 18;
37
- img.width = 18;
38
- return img;
39
- }
40
-
41
- // View state serialization/deserialization
42
- saveStateMap() {
43
- return {'notebookId': this.notebookId};
44
- }
45
-
46
- loadStateMap(stateMap) {
47
- open(stateMap['notebookId']);
48
- }
49
-
50
- // URL path handler
51
- handlePath(path) {
52
- let id = path.replace(`${this.PATH}/`, '');
53
- open(id);
54
- }
55
-
56
- // URL path checker
57
- acceptsPath(path) {
58
- return path.startsWith(this.PATH);
59
- }
60
- }
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ // A sample class from the Notebooks package:
6
+ // https://github.com/datagrok-ai/public/tree/master/packages/Notebooks
7
+ // This class defines a new view for Jupyter Notebooks.
8
+ export class #{NAME} extends DG.ViewBase {
9
+ constructor(params, path) {
10
+ super(params, path);
11
+ this.TYPE = 'Notebook';
12
+ this.PATH = '/notebook';
13
+ }
14
+
15
+ // Override basic methods
16
+ get type() {
17
+ return this.TYPE;
18
+ }
19
+
20
+ get helpUrl() {
21
+ return '/help/develop/jupyter-notebook.md';
22
+ }
23
+
24
+ get name() {
25
+ return 'Notebook';
26
+ }
27
+
28
+ get path() {
29
+ return `${this.PATH}/${this.notebookId}`;
30
+ }
31
+
32
+ // Icon
33
+ getIcon() {
34
+ let img = document.createElement('img');
35
+ img.src = '/images/entities/jupyter.png';
36
+ img.height = 18;
37
+ img.width = 18;
38
+ return img;
39
+ }
40
+
41
+ // View state serialization/deserialization
42
+ saveStateMap() {
43
+ return {'notebookId': this.notebookId};
44
+ }
45
+
46
+ loadStateMap(stateMap) {
47
+ open(stateMap['notebookId']);
48
+ }
49
+
50
+ // URL path handler
51
+ handlePath(path) {
52
+ let id = path.replace(`${this.PATH}/`, '');
53
+ open(id);
54
+ }
55
+
56
+ // URL path checker
57
+ acceptsPath(path) {
58
+ return path.startsWith(this.PATH);
59
+ }
60
+ }
@@ -1,64 +1,64 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as ui from 'datagrok-api/ui';
3
- import * as DG from 'datagrok-api/dg';
4
-
5
- // A sample class from the Notebooks package:
6
- // https://github.com/datagrok-ai/public/tree/master/packages/Notebooks
7
- // This class defines a new view for Jupyter Notebooks.
8
- export class #{NAME} extends DG.ViewBase {
9
- TYPE: string;
10
- PATH: string;
11
- notebookId: any;
12
-
13
- constructor(params: object | null, path: string) {
14
- super(params, path);
15
- this.TYPE = 'Notebook';
16
- this.PATH = '/notebook';
17
- }
18
-
19
- // Override basic methods
20
- get type() {
21
- return this.TYPE;
22
- }
23
-
24
- get helpUrl() {
25
- return '/help/compute/jupyter-notebook.md';
26
- }
27
-
28
- get name() {
29
- return 'Notebook';
30
- }
31
-
32
- get path() {
33
- return `${this.PATH}/${this.notebookId}`;
34
- }
35
-
36
- // Icon
37
- getIcon() {
38
- let img = document.createElement('img');
39
- img.src = '/images/entities/jupyter.png';
40
- img.height = 18;
41
- img.width = 18;
42
- return img;
43
- }
44
-
45
- // View state serialization/deserialization
46
- saveStateMap() {
47
- return {'notebookId': this.notebookId};
48
- }
49
-
50
- loadStateMap(stateMap: { [x: string]: string }) {
51
- open(stateMap['notebookId']);
52
- }
53
-
54
- // URL path handler
55
- handlePath(path: string) {
56
- let id = path.replace(`${this.PATH}/`, '');
57
- open(id);
58
- }
59
-
60
- // URL path checker
61
- acceptsPath(path: string) {
62
- return path.startsWith(this.PATH);
63
- }
64
- }
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ // A sample class from the Notebooks package:
6
+ // https://github.com/datagrok-ai/public/tree/master/packages/Notebooks
7
+ // This class defines a new view for Jupyter Notebooks.
8
+ export class #{NAME} extends DG.ViewBase {
9
+ TYPE: string;
10
+ PATH: string;
11
+ notebookId: any;
12
+
13
+ constructor(params: object | null, path: string) {
14
+ super(params, path);
15
+ this.TYPE = 'Notebook';
16
+ this.PATH = '/notebook';
17
+ }
18
+
19
+ // Override basic methods
20
+ get type() {
21
+ return this.TYPE;
22
+ }
23
+
24
+ get helpUrl() {
25
+ return '/help/compute/jupyter-notebook.md';
26
+ }
27
+
28
+ get name() {
29
+ return 'Notebook';
30
+ }
31
+
32
+ get path() {
33
+ return `${this.PATH}/${this.notebookId}`;
34
+ }
35
+
36
+ // Icon
37
+ getIcon() {
38
+ let img = document.createElement('img');
39
+ img.src = '/images/entities/jupyter.png';
40
+ img.height = 18;
41
+ img.width = 18;
42
+ return img;
43
+ }
44
+
45
+ // View state serialization/deserialization
46
+ saveStateMap() {
47
+ return {'notebookId': this.notebookId};
48
+ }
49
+
50
+ loadStateMap(stateMap: { [x: string]: string }) {
51
+ open(stateMap['notebookId']);
52
+ }
53
+
54
+ // URL path handler
55
+ handlePath(path: string) {
56
+ let id = path.replace(`${this.PATH}/`, '');
57
+ open(id);
58
+ }
59
+
60
+ // URL path checker
61
+ acceptsPath(path: string) {
62
+ return path.startsWith(this.PATH);
63
+ }
64
+ }
@@ -1,10 +1,10 @@
1
-
2
- //name: #{NAME}
3
- //description: Creates #{NAME} view
4
- //tags: view
5
- //input: map params
6
- //input: string path
7
- //output: view result
8
- export function _#{NAME}(params = null, path = '') {
9
- return new #{NAME}(params, path);
10
- }
1
+
2
+ //name: #{NAME}
3
+ //description: Creates #{NAME} view
4
+ //tags: view
5
+ //input: map params
6
+ //input: string path
7
+ //output: view result
8
+ export function _#{NAME}(params = null, path = '') {
9
+ return new #{NAME}(params, path);
10
+ }
@@ -1,23 +1,23 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as ui from 'datagrok-api/ui';
3
- import * as DG from 'datagrok-api/dg';
4
-
5
- // See also https://datagrok.ai/help/develop/how-to/develop-custom-viewer
6
- // This viewer does the following:
7
- // * listens to changes of filter and selection in the attached table,
8
- // * updates the number of filtered/selected rows accordingly.
9
- export class #{NAME} extends DG.JsViewer {
10
- onTableAttached() {
11
- this.subs.push(this.dataFrame.selection.onChanged.subscribe((_) => this.render()));
12
- this.subs.push(this.dataFrame.filter.onChanged.subscribe((_) => this.render()));
13
-
14
- this.render();
15
- }
16
-
17
- render() {
18
- this.root.innerHTML =
19
- `${this.dataFrame.toString()}<br>
20
- Selected: ${this.dataFrame.selection.trueCount}<br>
21
- Filtered: ${this.dataFrame.filter.trueCount}`;
22
- }
23
- }
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ // See also https://datagrok.ai/help/develop/how-to/develop-custom-viewer
6
+ // This viewer does the following:
7
+ // * listens to changes of filter and selection in the attached table,
8
+ // * updates the number of filtered/selected rows accordingly.
9
+ export class #{NAME} extends DG.JsViewer {
10
+ onTableAttached() {
11
+ this.subs.push(this.dataFrame.selection.onChanged.subscribe((_) => this.render()));
12
+ this.subs.push(this.dataFrame.filter.onChanged.subscribe((_) => this.render()));
13
+
14
+ this.render();
15
+ }
16
+
17
+ render() {
18
+ this.root.innerHTML =
19
+ `${this.dataFrame.toString()}<br>
20
+ Selected: ${this.dataFrame.selection.trueCount}<br>
21
+ Filtered: ${this.dataFrame.filter.trueCount}`;
22
+ }
23
+ }