redash/client/app/services/query-snippet.js
2016-11-27 12:00:22 +02:00

22 lines
498 B
JavaScript

function QuerySnippet($resource) {
const resource = $resource('api/query_snippets/:id', { id: '@id' });
resource.prototype.getSnippet = function 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);
}