Skip to content

Commit

Permalink
feat: adding possibiltiy to upload visualisations
Browse files Browse the repository at this point in the history
  • Loading branch information
batje committed May 28, 2020
1 parent d2df9a9 commit d1b4674
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 117 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ Returns **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/

### uploadExtension

uploadExtension - Uploads zipfile containing Cognos Extension. Only supports updating an existing module.
uploadExtension - Uploads zipfile containing Cognos Extension or visualisation. Only supports updating an existing module.
This function is only supported by Node.js. In the browser this function returns false;

#### Parameters

- `filename` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Path to the .zip file
- `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the module (as found in the spec.json)
- `type` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of upload. Default is 'extensions', for themes use 'themes'. (optional, default `'extensions'`)
- `name` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** name of the module (as found in the spec.json), for visualisations: id of the visualisation (as found in the package.json > meta > id)
- `type` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of upload. Default is 'extensions', for themes use 'themes' for visualisations 'visualisation'. (optional, default `'extensions'`)

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a string.

Expand Down
9 changes: 8 additions & 1 deletion dist/jcognos.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,14 @@ var Cognos = (function () {
? arguments[2]
: 'extensions';
var me = this;
var path = 'bi/v1/plugins/' + type + '/' + name;
var path = '';

if (type == 'visualisation') {
var path = 'bi/v1/visualizations/id/' + name;
} else {
var path = 'bi/v1/plugins/' + type + '/' + name;
}

var result = this.requester
.put(path, filename, false)
.then(function (response) {
Expand Down
9 changes: 8 additions & 1 deletion dist/jcognos.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,14 @@ var Cognos = (function () {
? arguments[2]
: 'extensions';
var me = this;
var path = 'bi/v1/plugins/' + type + '/' + name;
var path = '';

if (type == 'visualisation') {
var path = 'bi/v1/visualizations/id/' + name;
} else {
var path = 'bi/v1/plugins/' + type + '/' + name;
}

var result = this.requester
.put(path, filename, false)
.then(function (response) {
Expand Down
24 changes: 13 additions & 11 deletions dist/jcognos.js
Original file line number Diff line number Diff line change
Expand Up @@ -17162,17 +17162,19 @@
? arguments[2]
: 'extensions',
t = this,
i = 'bi/v1/plugins/' + o + '/' + a,
n = this.requester
.put(i, e, !1)
.then(function (e) {
t.log('New extension id =' + e.id);
})
.catch(function (e) {
throw (
(t.error('CognosRequest : Error in uploadExtension', e), e)
);
});
i = '';
if ('visualisation' == o) i = 'bi/v1/visualizations/id/' + a;
else i = 'bi/v1/plugins/' + o + '/' + a;
var n = this.requester
.put(i, e, !1)
.then(function (e) {
t.log('New extension id =' + e.id);
})
.catch(function (e) {
throw (
(t.error('CognosRequest : Error in uploadExtension', e), e)
);
});
return n;
},
},
Expand Down
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ <h3 class='fl m0' id='cognos'>



<p>uploadExtension - Uploads zipfile containing Cognos Extension. Only supports updating an existing module.
<p>uploadExtension - Uploads zipfile containing Cognos Extension or visualisation. Only supports updating an existing module.
This function is only supported by Node.js. In the browser this function returns false;</p>

<div class='pre p1 fill-light mt0'>uploadExtension(filename: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, type: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
Expand Down Expand Up @@ -1695,7 +1695,7 @@ <h3 class='fl m0' id='cognos'>
<div class='space-bottom0'>
<div>
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
name of the module (as found in the spec.json)
name of the module (as found in the spec.json), for visualisations: id of the visualisation (as found in the package.json > meta > id)

</div>

Expand All @@ -1705,7 +1705,7 @@ <h3 class='fl m0' id='cognos'>
<div>
<span class='code bold'>type</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>&#39;extensions&#39;</code>)</code>
type of upload. Default is 'extensions', for themes use 'themes'.
type of upload. Default is 'extensions', for themes use 'themes' for visualisations 'visualisation'.

</div>

Expand Down
Loading

0 comments on commit d1b4674

Please sign in to comment.