@datagrok/api-samples
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "@datagrok/api-samples", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": { | ||
"name": "Alexander Paramonov", | ||
"email": "aparamonov@datagrok.ai" | ||
}, | ||
"dependencies": { | ||
"@datagrok-libraries/utils": "^1.15.5", | ||
"cash-dom": "^8.1.1", | ||
"datagrok-api": "^1.12.0", | ||
"dayjs": "latest", | ||
"rxjs": "^6.6.7", | ||
"wu": "latest" | ||
}, | ||
"devDependencies": { | ||
"@types/wu": "^2.1.42", | ||
"@typescript-eslint/eslint-plugin": "^5.26.0", | ||
"@typescript-eslint/parser": "^5.26.0", | ||
"datagrok-tools": "^4.7.2", | ||
"eslint": "^8.16.0", | ||
"eslint-config-google": "^0.14.0", | ||
"@types/js-yaml": "^4.0.5", | ||
"js-yaml": "^4.1.0", | ||
"puppeteer": "^13.7.0", | ||
"root-require": "latest", | ||
"ts-loader": "^9.2.6", | ||
"typescript": "^4.4.4", | ||
"webpack": "^5.59.1", | ||
"webpack-cli": "^4.9.1", | ||
"@types/node-fetch": "^2.6.2", | ||
"node-fetch": "^2.6.7" | ||
}, | ||
"friendlyName": "API Samples", | ||
@@ -13,4 +43,8 @@ "description": "API Samples", | ||
"scripts": { | ||
"samples-upload": "datagrok-upload http://localhost:8082 deploy", | ||
"publish samples local": "grok publish local" | ||
"publish samples local": "grok publish local", | ||
"publish samples localhost": "grok publish localhost", | ||
"build": "webpack", | ||
"test": "grok test", | ||
"test-dev": "grok test --host dev", | ||
"test-local": "grok test --host localhost" | ||
}, | ||
@@ -23,3 +57,3 @@ "canEdit": [ | ||
], | ||
"category": "Dev" | ||
"category": "Development" | ||
} |
@@ -9,3 +9,3 @@ ApiSamples is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform. | ||
* [data-frame](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/data-access) | ||
: directory with [table (data frame)](https://datagrok.ai/help/overview/table) manipulations | ||
: directory with [table (data frame)](https://datagrok.ai/help/datagrok/table) manipulations | ||
* [domains](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/domains) | ||
@@ -18,3 +18,3 @@ : directory with domain specific examples: [bioinformatics](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/domains/bio), | ||
* [functions](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/functions) | ||
: directory with examples how to work with [functions](https://datagrok.ai/help/overview/functions/function) | ||
: directory with examples how to work with [functions](https://datagrok.ai/help/datagrok/functions/function) | ||
* [grid](https://github.com/datagrok-ai/public/tree/master/packages/ApiSamples/scripts/grid) | ||
@@ -21,0 +21,0 @@ : directory with examples how to work with [table grid](https://datagrok.ai/help/visualize/viewers/grid) |
//tags: Project | ||
//help-url: https://datagrok.ai/help/overview/project | ||
//help-url: https://datagrok.ai/help/datagrok/project | ||
// gets #demo project list and shows them in the view | ||
@@ -4,0 +4,0 @@ |
let user = DG.User.create(); | ||
user.login = 'newlogin'; | ||
user.status = USER_STATUS.STATUS_NEW; | ||
user.firstName = 'new'; | ||
@@ -5,0 +4,0 @@ user.lastName = 'user'; |
@@ -7,3 +7,3 @@ // Different ways for creating and populating columns with qualified numbers. | ||
manual.set(1, DG.Qnum.exact(5)); | ||
manual.set(1, DG.Qnum.less(5)); | ||
manual.set(2, DG.Qnum.less(5)); | ||
@@ -10,0 +10,0 @@ // Method 2: initialize with exact values (last parameter set to true) |
@@ -6,2 +6,2 @@ // This virtual column behaves like a normal int column. | ||
table.columns.addNewVirtual('car', (i) => i * 2, DG.TYPE.INT); | ||
grok.shell.add(table); | ||
grok.shell.addTableView(table); |
@@ -1,2 +0,2 @@ | ||
// Bitwise AND, OR, XOR, and AND_OR opetations | ||
// Bitwise AND, OR, XOR, and AND_NOT operations | ||
@@ -8,3 +8,3 @@ let bs1 = DG.BitSet.fromString('11100'); | ||
b1: ${bs1.toBinaryString()} | ||
b2: ${bs1.toBinaryString()} | ||
b2: ${bs2.toBinaryString()} | ||
and: ${bs1.clone().and(bs2).toBinaryString()} | ||
@@ -11,0 +11,0 @@ or: ${bs1.clone().or(bs2).toBinaryString()} |
@@ -5,3 +5,3 @@ // Selecting or filtering rows by predicates | ||
let selection = demog.selection; | ||
grok.shell.add(demog); | ||
grok.shell.addTableView(demog); | ||
@@ -8,0 +8,0 @@ // method 1: init(predicate) |
@@ -11,4 +11,4 @@ //tags: DataFrame, construction | ||
Tesla, Roadster, , 1.6, 100000 | ||
Tesla, Model S, , 1.6, 120000`, {columnImportOptions: [{name: 'model', semType: 'carModel'}]});); | ||
Tesla, Model S, , 1.6, 120000`, {columnImportOptions: [{name: 'model', semType: 'carModel'}]}); | ||
grok.shell.addTableView(table); |
@@ -6,2 +6,2 @@ // Selecting or filtering rows by predicates | ||
demog.rows.filter((row) => row.age > 42); | ||
grok.shell.add(demog); | ||
grok.shell.addTableView(demog); |
@@ -21,4 +21,3 @@ // The following demo shows, how to work with dynamically changing data in Datagrok. | ||
let addMilliseconds = function (time, ms) { | ||
time.setMilliseconds(time.getMilliseconds() + ms); | ||
return time; | ||
return dayjs(time).add(ms, 'millisecond').toDate(); | ||
}; | ||
@@ -34,3 +33,3 @@ | ||
let upDown = () => Math.random() > 0.5 ? '▲' : '▼'; | ||
let getValues = (symbol, time) => [symbol, DG.DateTime.fromDate(time).d, next(symbol), Math.round(Math.random() * 10000), upDown()]; | ||
let getValues = (symbol, time) => [symbol, dayjs(time).toDate().toLocaleString('en-US'), next(symbol), Math.round(Math.random() * 10000), upDown()]; | ||
@@ -37,0 +36,0 @@ let addTick = function (time) { |
@@ -1,45 +0,11 @@ | ||
//name: testSubstructureSearch | ||
//description: Substructure search via RDKit | ||
//name: testSubstructureSearchLibrary | ||
//language: javascript | ||
async function time(name, n, f) { | ||
let start = new Date(); | ||
for (let k = 0; k < n; ++k) { | ||
await f(); | ||
} | ||
let stop = new Date(); | ||
console.log(`${name}: ${(stop - start) / n} ms`); | ||
} | ||
// An example of using substructure search | ||
(async () => { | ||
const n = 5; | ||
const N = 2000; | ||
let searchFor = ['c1ccccc1', 'C1CCCCC1', 'CC']; | ||
let df = await grok.data.getDemoTable('chem/zbb/99_p3_4.5-6.csv'); | ||
if (N < df.rowCount) | ||
df.rows.removeAt(N, df.rowCount - N, false); | ||
let col = df.col('smiles'); | ||
console.log('Substructure search microbenchmark'); | ||
await time(`Graph-based search on ${df.rowCount} molecules`, n, async () => { | ||
for (let s of searchFor) { | ||
let result = await grok.chem.searchSubstructure(col, s, {substructLibrary: false}); | ||
// console.log(s + ": " + result.toString()); | ||
} | ||
}); | ||
await time(`Building a library for ${df.rowCount} molecules`, 1, async () => { | ||
await grok.chem.searchSubstructure(col); | ||
}); | ||
await time(`Searching the library on ${searchFor.length} molecules`, n, async () => { | ||
for (let s of searchFor) { | ||
let result = await grok.chem.searchSubstructure(col, s); | ||
// console.log(s + ": " + result.toString()); | ||
} | ||
}); | ||
})(); | ||
grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv') | ||
.then(t => grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1') | ||
.then(function (bs) { | ||
t.filter.copyFrom(bs); | ||
grok.shell.addTableView(t); | ||
})); |
//tags: Func | ||
//help-url: https://datagrok.ai/help/overview/functions/function | ||
//help-url: https://datagrok.ai/help/datagrok/functions/function | ||
// Executing functions | ||
@@ -4,0 +4,0 @@ |
@@ -8,3 +8,5 @@ //tags: Func | ||
p.onLogUpdated.subscribe((line) => console.log(line)); | ||
p.update(50, "Loading foo.csv"); | ||
grok.functions.call("Discovery:countToTen", | ||
@@ -11,0 +13,0 @@ {s: "a"}, true, p) |
@@ -6,6 +6,6 @@ // This examples shows how to register a function that becomes a first-class | ||
// The code below registers two functions, "jsConcat" and "jsWidget". To test | ||
// jsConcat, enter "jsConcat(42, 33)" in the console(https://datagrok.ai/help/overview/navigation#console). | ||
// jsConcat, enter "jsConcat(42, 33)" in the console(https://datagrok.ai/help/datagrok/navigation#console). | ||
// To test jsWidget, create a new Dashboard, and click on "Widget" under "Widgets". | ||
// | ||
// See also https://datagrok.ai/help/overview/functions/function, | ||
// See also https://datagrok.ai/help/datagrok/functions/function, | ||
// https://datagrok.ai/help/develop/js-api#registering-functions | ||
@@ -12,0 +12,0 @@ |
@@ -9,2 +9,10 @@ let t = grok.data.demo.demog(); | ||
grok.shell.info(`Column 'subj' color coding: ${t.col('subj').meta.colors.getType()}`); // Off | ||
grok.shell.info(`Column 'height' color coding: ${t.col('height').meta.colors.getType()}`); // Conditional | ||
grok.shell.info(`Column 'age' color coding: ${t.col('age').meta.colors.getType()}`); // Linear | ||
t.col('site').meta.colors.setCategorical({'New York': DG.Color.orange}); | ||
t.col('started').meta.colors.setLinear([DG.Color.white, DG.Color.red]); | ||
t.col('weight').meta.colors.setConditional({'<100': DG.Color.green, '100-200': '#ff0000'}); | ||
grok.shell.addTableView(t); |
// HTML-based grid cells with the markup-driven content. | ||
// For code-driven rendering, check out "html-dynamic-cell.js" sample. | ||
// See also: https://datagrok.ai/help/overview/markup | ||
// See also: https://datagrok.ai/help/datagrok/markup | ||
@@ -5,0 +5,0 @@ let view = grok.shell.addTableView(grok.data.demo.demog()); |
@@ -8,2 +8,3 @@ // controlling the visibility of the UI parts | ||
.add(ui.boolInput('toolbox', windows.showToolbox, (x) => windows.showToolbox = x)) | ||
.add(ui.boolInput('status bar', windows.showStatusBar, (x) => windows.showStatusBar = x)) | ||
.add(ui.boolInput('console', windows.showConsole, (x) => windows.showConsole = x)) | ||
@@ -10,0 +11,0 @@ .add(ui.boolInput('properties', windows.showProperties, (x) => windows.showProperties = x)) |
// Creating custom dialogs | ||
var dlg = ui.dialog('Windows'); | ||
var dlg = ui.dialog({title: 'Boo', helpUrl: 'https://wikipedia.org'}); | ||
dlg | ||
@@ -6,0 +6,0 @@ .add(ui.span(['People of Earth, your attention, please… '])) |
@@ -1,8 +0,6 @@ | ||
// Creating custom dialogs | ||
// Custom dialogs | ||
ui.dialog('Windows') | ||
.add(ui.span(['People of Earth, your attention, please… '])) | ||
.onOK(() => { | ||
grok.shell.info('OK!'); | ||
}) | ||
.showModal(); | ||
ui.dialog({ showHeader: false, showFooter: false }) | ||
.add(ui.span(['Full-screen mode with no header or footer; click on the background, or press ESC to close.'])) | ||
.onOK(() => grok.shell.info('OK!')) | ||
.showModal(true); |
@@ -8,3 +8,3 @@ let v = grok.shell.newView('demo: inputs-events'); | ||
let sex = ui.choiceInput('Sex', 'Male', ['Male', 'Female'], v => msg(v)); | ||
let date = ui.dateInput('Birthday', DG.DateTime.fromDate(new Date(1970, 5, 10)), v => msg(v)); | ||
let date = ui.dateInput('Birthday', dayjs('1970-5-10'), v => msg(v)); | ||
let alien = ui.boolInput('Alien', false, v => msg(v)); | ||
@@ -11,0 +11,0 @@ let friends = ui.multiChoiceInput('Friends', |
@@ -0,7 +1,36 @@ | ||
// Different input types | ||
// Adding an icon to each input that lets you inspect the value | ||
// grok.events.onInputCreated.subscribe( | ||
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value))); | ||
// Different input types | ||
// Adding an icon to each input that lets you inspect the value | ||
// grok.events.onInputCreated.subscribe( | ||
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value))); | ||
let v = grok.shell.newView('demo: inputs'); | ||
let type = ui.choiceInput('Form type', 'Default', ['Default', 'Left', 'Wide', 'Condensed'], (x)=>{ | ||
switch (x){ | ||
case 'Default': | ||
form.className = 'ui-form'; | ||
break; | ||
case 'Left': | ||
form.className = 'ui-form ui-form-left'; | ||
break; | ||
case 'Wide': | ||
form.className = 'ui-form ui-form-wide'; | ||
break; | ||
case 'Condensed': | ||
form.className = 'ui-form ui-form-condensed'; | ||
break; | ||
default: form.className = '.ui-form'; | ||
} | ||
}); | ||
let name = ui.stringInput('Name', 'Arthur Dent'); | ||
let age = ui.intInput('Age', 30); | ||
let sex = ui.choiceInput('Sex', 'Male', ['Male', 'Female']); | ||
let date = ui.dateInput('Birthday', DG.DateTime.fromDate(new Date(1970, 5, 10))); | ||
let date = ui.dateInput('Birthday', dayjs('1970-5-10')); | ||
let alien = ui.boolInput('Alien', false); | ||
@@ -11,10 +40,8 @@ let friends = ui.multiChoiceInput('Friends', ['Ford', 'Fenchurch'], ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast']); | ||
let color = ui.colorInput('Favorite color', '#ff0000'); | ||
let data = ui.tableInput('Details', null); | ||
let memo = ui.textInput('Memo', ''); | ||
let inputs = [name, age, sex, date, alien, friends, active]; | ||
let container = ui.div(); | ||
v.append(container); | ||
container.appendChild(ui.inputs(inputs)); | ||
let form = ui.form([type, name, age, date, alien, friends, active, color, data, memo]); | ||
container.appendChild(ui.bigButton('POST', () => { | ||
grok.shell.info(inputs.map((i) => `${i.caption}: ${i.stringValue}`).join('<br>')); | ||
})); | ||
form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info(form.className)})])); | ||
v.append(form); |
@@ -16,3 +16,2 @@ // Demonstrates handling of Grok-originated events | ||
grok.events.onProjectSaved.subscribe(p => info(`${p.name}: saved`)); | ||
grok.events.onProjectUploaded.subscribe(p => info(`${p.name}: uploaded`)); | ||
@@ -19,0 +18,0 @@ grok.events.onCurrentProjectChanged.subscribe(p => info(`Current project changed: ${grok.shell.project.name}`)); |
@@ -5,5 +5,5 @@ let view = grok.shell.addTableView(grok.data.demo.geo(10000)); | ||
latitudeColumnName: 'lat', | ||
longitudeColumnName: 'lon' | ||
longitudeColumnName: 'lng' | ||
}); | ||
grok.shell.info(leaflet.props.getProperties().map((p) => p.name).join(', ')); |
@@ -18,2 +18,4 @@ //tags: View | ||
v.statusBarPanels = [ui.divText('Mission Accomplished')]; | ||
let acc = ui.accordion(); | ||
@@ -20,0 +22,0 @@ acc.addPane('header 1', () => ui.divText('Dynamic content')); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
381802
340
0
6548
1
6
16
+ Addedcash-dom@^8.1.1
+ Addeddatagrok-api@^1.12.0
+ Addeddayjs@latest
+ Addedrxjs@^6.6.7
+ Addedwu@latest
+ Added@datagrok-libraries/chem-meta@1.2.8(transitive)
+ Added@datagrok-libraries/utils@1.19.4(transitive)
+ Added@fast-csv/format@4.3.5(transitive)
+ Added@fast-csv/parse@4.3.6(transitive)
+ Added@types/node@14.18.63(transitive)
+ Added@types/prop-types@15.7.13(transitive)
+ Added@types/react@18.3.12(transitive)
+ Added@types/wu@2.1.44(transitive)
+ Addedarchiver@5.3.2(transitive)
+ Addedarchiver-utils@2.1.03.0.4(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64-arraybuffer@1.0.2(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbig-integer@1.6.52(transitive)
+ Addedbinary@0.3.0(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbluebird@3.4.7(transitive)
+ Addedbrace-expansion@1.1.112.0.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-indexof-polyfill@1.0.2(transitive)
+ Addedbuffers@0.1.1(transitive)
+ Addedcash-dom@8.1.5(transitive)
+ Addedchainsaw@0.1.0(transitive)
+ Addedcompress-commons@4.1.2(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcrc-32@1.2.2(transitive)
+ Addedcrc32-stream@4.0.3(transitive)
+ Addedcss-line-break@2.1.0(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addeddatagrok-api@1.22.2(transitive)
+ Addeddayjs@1.11.13(transitive)
+ Addedduplexer2@0.1.4(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexceljs@4.4.0(transitive)
+ Addedfast-csv@4.3.6(transitive)
+ Addedfast-sha256@1.3.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfstream@1.0.12(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhtml2canvas@1.4.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedimmediate@3.0.6(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjszip@3.10.1(transitive)
+ Addedlazystream@1.0.1(transitive)
+ Addedlie@3.3.0(transitive)
+ Addedlistenercount@1.0.1(transitive)
+ Addedlodash.defaults@4.2.0(transitive)
+ Addedlodash.difference@4.5.0(transitive)
+ Addedlodash.escaperegexp@4.1.2(transitive)
+ Addedlodash.flatten@4.4.0(transitive)
+ Addedlodash.groupby@4.6.0(transitive)
+ Addedlodash.isboolean@3.0.3(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
+ Addedlodash.isfunction@3.0.9(transitive)
+ Addedlodash.isnil@4.0.0(transitive)
+ Addedlodash.isplainobject@4.0.6(transitive)
+ Addedlodash.isundefined@3.0.1(transitive)
+ Addedlodash.union@4.6.0(transitive)
+ Addedlodash.uniq@4.5.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedminimatch@3.1.25.1.6(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedopenchemlib@7.5.0(transitive)
+ Addedpako@1.0.11(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreadable-stream@2.3.83.6.2(transitive)
+ Addedreaddir-glob@1.1.3(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedrxjs@6.6.7(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsaxes@5.0.1(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedtext-segmentation@1.0.3(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedtraverse@0.3.9(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtypeahead-standalone@4.14.1(transitive)
+ Addedunzipper@0.10.14(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedutrie@1.0.2(transitive)
+ Addeduuid@8.3.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedwu@2.1.0(transitive)
+ Addedxmlchars@2.2.0(transitive)
+ Addedzip-stream@4.1.1(transitive)