Skip to content

Instantly share code, notes, and snippets.

@kenjox
Forked from ralfbecher/mashupEnigmaRequire.js
Created October 2, 2018 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenjox/1aa52af03319eee69ca419dd347dc97b to your computer and use it in GitHub Desktop.
Save kenjox/1aa52af03319eee69ca419dd347dc97b to your computer and use it in GitHub Desktop.
Qlik Sense Mashup with Enigma.js - the official way
var prefix = window.location.pathname.substr(0, window.location.pathname.toLowerCase().lastIndexOf("/extensions") + 1);
var config = {
host: window.location.hostname,
prefix: prefix,
port: window.location.port,
isSecure: window.location.protocol === "https:"
};
require.config({
baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
});
require(['js/qlik'], function (qlik) {
require(['enigma', 'autogenerated/qix/engine-api'], function (enigma, schema) {
var cfg = {
schema: schema,
session: {
host: window.location.hostname,
port: window.location.port || undefined,
prefix: undefined,
unsecure: window.location.protocol !== "https:",
reloadURI: undefined
}
};
enigma.getService('qix', cfg).then(function (qix) {
console.log('Do something!', qix);
qix.global.getDocList().then(function(docs){
console.log(docs);
});
}).catch(function (err) {
console.error('Something went wrong!', err);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment