redash/frontend/app/services/query-snippet.js

22 lines
482 B
JavaScript

function QuerySnippet($resource) {
const resource = $resource('api/query_snippets/:id', { id: '@id' });
resource.prototype.getSnippet = () => {
let name = this.trigger;
if (this.description !== '') {
name = `${this.trigger}: ${this.description}`;
}
return {
name,
content: this.snippet,
tabTrigger: this.trigger,
};
};
return resource;
}
export default function (ngModule) {
ngModule.factory('QuerySnippet', QuerySnippet);
}