Skip to content

Commit

Permalink
Add method to fetch profile projection for an annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens committed May 19, 2020
1 parent fb2aeed commit d1adf1e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cytomine-uliege-js-client",
"version": "1.0.0-rc.2",
"version": "1.1.0",
"description": "Client to communicate with Cytomine API in javascript. For more information about Cytomine, go to http://www.cytomine.org.",
"browser": "dist/cytomine-client.min.js",
"unpkg": "dist/cytomine-client.min.js",
Expand Down
24 changes: 24 additions & 0 deletions src/models/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ export default class Annotation extends Model {
return this._profile;
}

/**
* Get the projections of the annotation profile, if available.
*
* @param {boolean} cache True if the result must be cached in the annotation object.
*
* @returns {Object} The annotation profile projection
*/
async fetchProfileProjections(cache=false) {
if(this.isNew()) {
throw new Error('Cannot get profile for an annotation with no ID.');
}

if (this._profileProjections && cache) {
return this._profileProjections;
}
else {
let {data} = await Cytomine.instance.api.get(`${this.callbackIdentifier}/${this.id}/profile/projections.json`);
if (cache) {
this._profileProjections = data;
}
return data;
}
}

/**
* Record an action performed on the annotation
*
Expand Down

0 comments on commit d1adf1e

Please sign in to comment.