Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion root/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"js_files": [
"js/main.js"
],
"entrypoint": "{%= entrypoint %}",
"license": "{%= licenses %}",
"longdescription": "DESCRIPTION.md",
"name": "{%= name %}",
Expand Down
2 changes: 0 additions & 2 deletions root/src/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@
<script src="js/main.js"/>
</scripts>

<entrypoint name="{%= entrypoint %}" />

</operator>
16 changes: 10 additions & 6 deletions root/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
*/

/* exported {%= entrypoint %} */
/* global Wirecloud */

(function () {
(function (script) {

"use strict";

class {%= entrypoint %} {
class Operator {
constructor(MashupPlatform, extra) {
this.MashupPlatform = MashupPlatform;

Expand All @@ -22,11 +22,15 @@
}
}

// We define the class as part of the window object so that it can be instantiated by Wirecloud
window.{%= entrypoint %} = {%= entrypoint %};
if (!('Wirecloud' in window)) {
// For testing purposes
window.Operator = Operator;
} else {
Wirecloud.registerOperatorClass(script, Operator);
}

/* test-code */

/* end-test-code */

})();
})(document.currentScript);
5 changes: 2 additions & 3 deletions root/src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import MashupPlatform = require("MashupPlatform");
{% if (ngsi) { %}import NGSI = require("NGSI");{% }%}
/* end-import-block */

export class {%= entrypoint %} {
export class Operator {
private MashupPlatform: MashupPlatform;
{% if (ngsi) { %}private NGSI: NGSI;{% }%}

Expand All @@ -32,5 +32,4 @@ export class {%= entrypoint %} {
}
}

// We define the class as part of the window object so that it can be instantiated by Wirecloud
(<any>window)["{%= entrypoint %}"] = {%= entrypoint %};
(<any>window).Wirecloud.registerOperatorClass((<any>document).currentScript, Operator);
8 changes: 0 additions & 8 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ var capitalizeAndRemoveUnderscore = function capitalizeAndRemoveUnderscore(old)
return t.charAt(0).toUpperCase() + t.slice(1);
};

var getEntrypointName = function getEntrypointName(vendor, name) {
// Remove all non-alphanumeric characters. Replace spaces with underscores.
vendor = vendor.replace(/[^a-zA-Z0-9]/g, '').replace(/\s/g, '_');
name = name.replace(/[^a-zA-Z0-9]/g, '').replace(/\s/g, '_');
return vendor + '_' + name;
}

// The actual init template.
exports.template = function(grunt, init, done) {
init.process([
Expand Down Expand Up @@ -131,7 +124,6 @@ exports.template = function(grunt, init, done) {
], function(err, props){
var exportsOverride = {};
props.jsname = capitalizeAndRemoveUnderscore(props.name);
props.entrypoint = getEntrypointName(props.vendor, props.name);
props.bower = props.jquery; // Change way to determine bower?
props.ngsi = false; // ??
var bowerdeps = {};
Expand Down