UNPKG

reveal-sdk-node

Version:

RevealBI Node.js SDK

118 lines (117 loc) 4.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RVDataSourceItem = void 0; const RVDashboardDataSource_1 = require("./RVDashboardDataSource"); /** * The basic class for data source items that can be used by visualizations to get data. * When getting data from a database for example, the data source object contains the information required to connect * to the database (like server host and database name) and the data source item contains * the information required to get the dataset itself (like table name or view name). */ class RVDataSourceItem { /** @hidden */ constructor(arg) { var _a, _b; this._defaultRefreshRate = null; this._title = null; this._subtitle = null; this._id = null; this._description = null; if (arg instanceof RVDashboardDataSource_1.RVDashboardDataSource) { this._dataSource = arg; } else { this._defaultRefreshRate = (_a = arg.Settings) === null || _a === void 0 ? void 0 : _a['DefaultRefreshRate']; this._id = arg['Id']; this._title = arg['Title']; this._description = arg['Description']; this._subtitle = arg['Subtitle']; this._dataSource = (_b = RVDataSourceItem.dataSourceFactory) === null || _b === void 0 ? void 0 : _b.call(RVDataSourceItem, arg['DataSource']); } } /** @hidden */ toJson() { var json = { _type: 'DataSourceItemType', 'DataSource': this._dataSource.toJson(), 'Properties': {}, 'Parameters': {} }; if (this._defaultRefreshRate != null) { var settings = json['Settings'] = {}; settings['DefaultRefreshRate'] = this._defaultRefreshRate; } json["Id"] = this._id; json["Title"] = this._title; json["Description"] = this._description; json["Subtitle"] = this._subtitle; return json; } /** The title of the item, as displayed to the user, it might be for example the name of the table in a database. */ get title() { return this._title; } set title(value) { this._title = value; } /** The subtitle of the data source, if not null will be displayed to users instead of connection information like host and database name. */ get subtitle() { return this._subtitle; } set subtitle(value) { this._subtitle = value; } /** The value that identifies this item in the data source, it might be for example the name of the schema concatenated with the table name. */ get id() { return this._id; } set id(value) { this._id = value; } /** Description of this data source item. */ get description() { return this._description; } set description(value) { this._description = value; } /** * Reference to the data source object this item belongs to. */ get dataSource() { return this._dataSource; } set dataSource(value) { this._dataSource = value; } /** * Default value to use for "Refresh Data" setting for visualizations created using this item, expressed in minutes (e.g. 1440 = 1 day). * A value of N means that whenever the visualization requests data, the engine will return data found in the cache if it's not older than N minutes -this means, if the engine fetched it from the datasource no more than N minutes before-. If not set it will use the default value set in the data source object. */ set defaultRefreshRate(v) { this._defaultRefreshRate = v; } get defaultRefreshRate() { return this._defaultRefreshRate; } /** @hidden */ _createWrapperInstance(isResourceBased = false) { if (isResourceBased) { return eval(`new $.ig.${this.getType()}Internal(0, this.resourceItem._getWrapper());`); } return eval(`new $.ig.${this.getType()}Internal(0, this.dataSource._getWrapper());`); } /** @hidden */ _getWrapper(isResourceBased = false) { let wrapper = this._createWrapperInstance(isResourceBased); wrapper.id(this.id); wrapper.title(this.title); wrapper.description(this.description); wrapper.subtitle(this.subtitle); if (this.defaultRefreshRate != null) { wrapper.defaultRefreshRate($.ig.NativeDataLayerUtility.prototype.wrapInt(this.defaultRefreshRate)); } return wrapper; } } exports.RVDataSourceItem = RVDataSourceItem;