Skip to content

Commit

Permalink
Merge pull request #32 from cytoscape/UD-2656
Browse files Browse the repository at this point in the history
Resolve UD-2656 and updates for CW-138.
  • Loading branch information
jingjingbic authored Dec 4, 2023
2 parents ef3f201 + 1a4ae00 commit 8a3a768
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ndex-client/dist/ndexClient.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ndex-client/dist/ndexClient.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ndex-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js4cytoscape/ndex-client",
"version": "0.4.3-alpha.4",
"version": "0.4.3-alpha.6",
"description": "NDEx client library",
"repository": {
"type": "git",
Expand Down
25 changes: 21 additions & 4 deletions packages/ndex-client/src/NDEx.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ class NDEx {
}

_setAuthHeader(config) {

if (config['headers'] === undefined) {config['headers'] = {};}
config['headers']['setAuthHeader'] = false;

if (this._authType === 'b') {
config ['auth'] = { username: this.username,
password: this.password};
} else if (this.authenticationType === 'g') {
const idToken = this._getIdToken();

if (config['headers'] === undefined) {config['headers'] = {};}
config['headers']['Authorization'] = 'Bearer ' + idToken;
config['headers']['Authorization'] = 'Bearer ' + this._getIdToken();
}
}

Expand Down Expand Up @@ -393,6 +394,22 @@ class NDEx {
return this._httpGetV3ProtectedObj('networks/' + uuid + '/summary', parameters);
}

getAttributesOfSelectedNodes(uuid, {ids: nodeIds, attributeNames: names},accessKey) {
let parameters = {
};

if (accessKey != null) {
parameters ['accesskey'] = accessKey;
}

let data = {
"ids": nodeIds,
"attributeNames": names,
};

return this._httpPostV3ProtectedObj('/search/networks/' + uuid + '/nodes', parameters, data);
}

createNetworkFromRawCX(rawCX, parameters) {
return new Promise((resolve, reject) =>{
this._httpPostProtectedObj('network', parameters, rawCX).then(
Expand Down
8 changes: 8 additions & 0 deletions packages/ndex-client/test/ndex.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ describe('Anonymous test', () =>{
});
});

it('get name attribute on selected nodes', ()=> {
return ndex.getAttributesOfSelectedNodes('c81ea28a-bdc4-11e7-9235-06832d634f41',{ids:[64,66,68],attributeNames:["name"]})
.then((result) => {
expect(result["64"]["name"]).to.equal('Node 1');
expect(result["66"]["name"]).to.equal('Node 2');
expect(result["68"]["name"]).to.equal('Node 3');
});
});

/*
it('get network v3 summaries with name, description and properties only', ()=> {
Expand Down

0 comments on commit 8a3a768

Please sign in to comment.