mirror of
https://github.com/valitydev/redash.git
synced 2024-11-08 09:53:59 +00:00
28 lines
676 B
JavaScript
28 lines
676 B
JavaScript
import truncate from 'underscore.string/truncate';
|
|
|
|
function Widget($resource, Query) {
|
|
const WidgetResource = $resource('api/widgets/:id', { id: '@id' });
|
|
|
|
WidgetResource.prototype.getQuery = function getQuery() {
|
|
if (!this.query && this.visualization) {
|
|
this.query = new Query(this.visualization.query);
|
|
}
|
|
|
|
return this.query;
|
|
};
|
|
|
|
WidgetResource.prototype.getName = function getName() {
|
|
if (this.visualization) {
|
|
return `${this.visualization.query.name} (${this.visualization.name})`;
|
|
}
|
|
return truncate(this.text, 20);
|
|
};
|
|
|
|
return WidgetResource;
|
|
}
|
|
|
|
|
|
export default function (ngModule) {
|
|
ngModule.factory('Widget', Widget);
|
|
}
|