datagrok-api
Advanced tools
Comparing version 0.89.27 to 0.89.28
{ | ||
"name": "datagrok-api", | ||
"version": "0.89.27", | ||
"version": "0.89.28", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -682,3 +682,3 @@ import { | ||
return new Promise((resolve, reject) => | ||
grok_Dapi_UserFiles_Move(toDart(files), newPath, () => resolve(), (e) => reject(e))); | ||
grok_Dapi_UserFiles_Move(files, newPath, () => resolve(), (e) => reject(e))); | ||
} | ||
@@ -732,3 +732,3 @@ | ||
* @param {File | String} file | ||
* @param String data | ||
* @param string data | ||
* @returns {Promise} */ | ||
@@ -740,1 +740,24 @@ writeAsText(file, data) { | ||
} | ||
export class Logger { | ||
constructor(putCallback) { | ||
this.putCallback = putCallback; | ||
} | ||
/** Saves audit record to Datagrok back-end | ||
* @param {string} message | ||
* @param {object} params | ||
* @param {string} type = 'log' | ||
* */ | ||
log(message, params, type) { | ||
if (type == null) | ||
type = 'log'; | ||
let msg = {message: message, params: params, type: type}; | ||
if (this.putCallback != null) | ||
this.putCallback(msg); | ||
grok_Audit(msg.type, msg.message, toDart(msg.params)); | ||
} | ||
} |
@@ -20,25 +20,90 @@ import * as rxjs from 'rxjs'; | ||
class MapProxy { | ||
constructor(d) { | ||
this.d = d; | ||
return new Proxy({}, { | ||
get: function (target, prop) { | ||
return DG.toJs(grok_Map_Get(d, prop)); | ||
}, | ||
set: function (target, prop, value) { | ||
grok_Map_Set(d, prop, DG.toDart(value)); | ||
return true; | ||
}, | ||
deleteProperty: function (target, prop) { | ||
grok_Map_Delete(d, DG.toDart(prop)); | ||
return true; | ||
}, | ||
has: function (target, prop) { | ||
return grok_Map_Has(d, DG.toDart(prop)); | ||
/** | ||
* Proxies a Dart Map, API-compliant to ES 2015+ | ||
*/ | ||
const MapProxy = new Proxy(class { | ||
constructor(d) { | ||
this.d = d; | ||
} | ||
keys() { | ||
return _toIterable(grok_Map_Keys(this.d)); | ||
} | ||
values() { | ||
return _toIterable(grok_Map_Values(this.d)); | ||
} | ||
* [Symbol.iterator] () { | ||
for (let key of this.keys()) { | ||
const value = DG.toJs(grok_Map_Get(this.d, key)); | ||
yield [key, value]; | ||
} | ||
}); | ||
} | ||
entries() { | ||
return this; | ||
} | ||
forEach(callback) { | ||
for (const [key, value] of this) { | ||
callback(key, value); | ||
} | ||
} | ||
delete(key) { | ||
return DG.toJs(grok_Map_Delete(this.d, DG.toDart(key))); | ||
} | ||
get(key) { | ||
return DG.toJs(grok_Map_Get(this.d, key)); | ||
} | ||
has(key) { | ||
return grok_Map_Has(this.d, DG.toDart(key)); | ||
} | ||
set(key, value) { | ||
grok_Map_Set(this.d, key, DG.toDart(value)); | ||
return this; | ||
} | ||
clear() { | ||
grok_Map_Clear(this.d); | ||
} | ||
size() { | ||
return DG.toJs(grok_Map_Size(this.d)); | ||
} | ||
}, { | ||
construct(target, args) { | ||
return new Proxy(new target(...args), { | ||
get: function (target, prop) { | ||
const val = target[prop]; | ||
if (typeof val === 'function') { | ||
return function (...args) { | ||
return val.apply(target, args); | ||
}; | ||
} /* else if (typeof val === 'number') { | ||
// for the case of a getter like name | ||
return val; | ||
} */ else { | ||
return DG.toJs(grok_Map_Get(target.d, prop)); | ||
} | ||
}, | ||
set: function (target, prop, value) { | ||
grok_Map_Set(target.d, prop, DG.toDart(value)); | ||
return true; | ||
}, | ||
deleteProperty: function (target, prop) { | ||
grok_Map_Delete(target.d, DG.toDart(prop)); | ||
return true; | ||
}, | ||
has: function (target, prop) { | ||
return grok_Map_Has(target.d, DG.toDart(prop)); | ||
}, | ||
getOwnPropertyDescriptor(target, prop) { | ||
return { | ||
enumerable: true, | ||
configurable: true | ||
}; | ||
}, | ||
ownKeys: function (target) { | ||
return Array.from(target.keys()); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
); | ||
/** | ||
@@ -45,0 +110,0 @@ * DataFrame is a high-performance, easy to use tabular structure with |
@@ -262,11 +262,2 @@ import {DataFrame} from "./dataframe"; | ||
/** Saves audit record to Datagrok back-end | ||
* @param {string} message | ||
* @param {object} params | ||
* @param {string} type = 'log'*/ | ||
log(message, params, type) { | ||
if (type == null) | ||
type = 'log'; | ||
grok_Audit(type, message, toDart(params)); | ||
} | ||
} | ||
@@ -273,0 +264,0 @@ |
@@ -634,2 +634,6 @@ import {VIEW_TYPE, VIEWER} from "./const"; | ||
static fromViewState(state) { | ||
return new ViewLayout(grok_ViewLayout_FromViewState(state)); | ||
} | ||
/** Only defined within the context of the OnViewLayoutXXX events */ | ||
@@ -636,0 +640,0 @@ get view() { |
@@ -737,3 +737,3 @@ /** | ||
/** Div flex-box container that positions child elements horizontally. | ||
/** Div flex-box container that positions child elements vertically. | ||
* @param {object[]} items */ | ||
@@ -740,0 +740,0 @@ export function splitV(items, options = null) { |
382196
11142