Skip to content

Instantly share code, notes, and snippets.

{
"name": "apptofiles",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Tests?\" && exit 1"
},
"keywords": [],
"author": "",
const jwt = require('jsonwebtoken')
const fs = require('fs')
const path = require('path')
const request = require('request-promise') //Peer-dep to request
const QLIK_HOST = 'usrad-aklprobook'
const QLIK_VIRTUAL_PROXY_PREFIX = 'stratsys'
/**
* In this case we re-use the private cert from Qlik to sign our token
@mindspank
mindspank / sessionpage.js
Last active September 18, 2020 10:46
sessionpage
define(['qlik', 'qvangular'], function (qlik, qv) {
return {
initialProperties: {
version: 1,
qHyperCubeDef: {
qSuppressZero: true,
qSuppressMissing: true,
qInitialDataFetch: [{qTop: 0, qLeft: 0, qWidth: 2, qHeight: 200}]
}
},
@mindspank
mindspank / sessionpage.js
Created March 1, 2017 16:12
sessionpage
define(['qlik', 'qvangular'], function (qlik, qv) {
return {
initialProperties: {
version: 1,
qHyperCubeDef: {
qSuppressZero: true,
qSuppressMissing: true,
qInitialDataFetch: [{qTop: 0, qLeft: 0, qWidth: 2, qHeight: 200}]
}
},
@mindspank
mindspank / console.js
Last active April 18, 2018 19:26
Get object properties in Sense
document.addEventListener('click', function(e) {
(function recurse(scope) {
if(!scope.model) return recurse(scope.$parent);
scope.model.getProperties().then(properties => {
delete properties['qInfo'];
delete properties['qMetaDef'];
window.qliksenseobject = JSON.stringify(properties, null, 4);
console.log( JSON.stringify(properties, null, 4) )
})
})(angular.element(e.target).scope());
@mindspank
mindspank / mp3base64.js
Created December 25, 2016 11:23
Base64 in extensions
define(['jquery', './mp3source'], function($, defaultsound) {
return {
initialProperties: {
sound: [{ label: 'Default', value: defaultsound}]
},
paint: function($element, layout) {
$element.empty();
let audio = $(`<audio controls="controls" autobuffer="autobuffer"><source src="data:audio/mp3;base64,${layout.sound[0].value}"/></audio>`);
audio.appendTo($element)
}
@mindspank
mindspank / index.js
Last active December 21, 2016 13:26
Connect to Qlik Sense Desktop using enigma.js
const enigma = require('enigma.js');
const qixSchema = require('../node_modules/enigma.js/schemas/qix/3.1/schema.json');
const WebSocket = require('ws');
const config = {
schema: qixSchema,
session: {
unsecure: true,
port: 4848
},
define([], function() {
return {
initialProperties: {
version: 1.0,
qHyperCubeDef: {
qDimensions: [],
qMode: 'P',
qMeasures: [],
qInitialDataFetch: [{
qWidth: 3,
@mindspank
mindspank / 10session.js
Created September 16, 2016 15:15
10 session apps
var qsocks = require('qsocks');
var fs = require('fs');
var request = require('request');
// Set our request defaults, ignore unauthorized cert warnings as default QS certs are self-signed.
// Export the certificates from your Qlik Sense installation and refer to them
var r = request.defaults({
rejectUnauthorized: false,
host: 'localhost',
pfx: fs.readFileSync(__dirname + '\\client.pfx')
const qsocks = require('qsocks');
const fs = require('fs');
const Promise = require('bluebird');
var config = {
host: 'localhost',
port: 4747,
headers: {
'X-Qlik-User': 'UserDirectory=INTERNAL;UserId=sa_repository'
},