npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

playground-js-api

v1.0.5

Published

A JavaScript API for use when connecting to the <a href='http://playground.qlik.com' target="_blank">Qlik Playground</a>

Downloads

40

Readme

Qlik Playground JavaScript API

A JavaScript API for use when connecting to the Qlik Playground

##Installation

npm install playground-js-api

##Usage

<link rel="stylesheet" href="/node_modules/playground-js-api/dist/playground-ui.min.css" media="screen" title="no title" charset="utf-8">
<script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-js-api.min.js"></script>
<script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-ui.min.js"></script>

Loading the JavaScript files will create a new global object called Playground.

##API The main API consists of the following methods - ###authenticate() The Authenticate method is a promise that accepts the following parameters -

  • config - contains all of the information require to authenticate and create a connection
  • connectionMethod (optional) - determines the behaviour of the authentication workflow

####Authentication for qSocks

var config = {...};
Playground.authenticate(config, "qsocks").then(function(ticket){

});

When using qSocks the promise returns a ticket which can then be added to your config object and used to create an authenticate connection to the Qlik Sense Engine.

var config = {...};
Playground.authenticate(config, "qsocks").then(function(ticket){
  config.ticket = ticket
  qsocks.ConnectOpenApp(config).then(function(result){
    //we're now connected
  });
});

####Authentication for the Qlik Sense Capability APIs In order to consume content from the Qlik Sense Capability APIs you first need to establish a valid Qlik Sense session. Calling Playground.authenticate() will automatically redirect the page in order to establish the session. If successful you will be redirected back to localhost:8000/main. This means that your project should have a separate page to initialize the authentication flow.

######Authentication Page

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" href="/node_modules/playground-js-api/dist/playground-ui.min.css" media="screen" title="no title" charset="utf-8">
  </head>
  <body>
    <script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-js-api.min.js"></script>
    <script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-ui.min.js"></script>
    <script type="text/javascript" src="/resources/script.js"></script>
    <script type="text/javascript">
      authenticate();
    </script>
  </body>
</html>

######Triggering authentication On page load of our authenticate.html we call the authenticate() function.

var config = {...};
function authenticate(){
  Playground.authenticate(config);
}

If authentication was successful we're redirected to the main.html page. To load the necessary resources for the Qlik Sense Capability APIs we also need to include script tags to load RequireJS library from the Qlik Playground instance. ######Main Page

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" href="/node_modules/playground-js-api/dist/playground-ui.min.css" media="screen" title="no title" charset="utf-8">
  </head>
  <body>
    <script type="text/javascript" src="https://playground.qlik.com/playground/resources/assets/external/requirejs/require.js"></script>
    <script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-js-api.min.js"></script>
    <script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-ui.min.js"></script>
    <script type="text/javascript" src="/resources/script.js"></script>
    <script type="text/javascript">
      main();
    </script>
  </body>
</html>

######Connecting to the Qlik Sense Capability APIs

On page load of our main.html we call the main() function

var config = {...};
function authenticate(){
  Playground.authenticate(config);
}
function main(){
  require.config({
    baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port: "") + config.prefix + "resources",
  });

  require(['js/qlik'], function(qlik) {
    //we're now connected
  );
}

##UI Components The Qlik Playground JavaScript API also contains UI components which you can use to simplify development. ###Notifier A simple notification control to add visual cues during interactions with the API, for example, the authentication progress. ####Usage

<playground component="notifier" id='myNotifier' class="notifier-cover"></playground>

The notifier will listen for any messages sent to it by the Qlik Playground JavaScript API but it is also possible to deliver your own messages. ####Playground.notification.deliver() This method accepts the following parameters -

  • sentiment - defaults to 'info'. This will set the data-sentiment attribute on the control.
  • title - sets the main text on the notification.
  • message - sets the sub text on the notification.
  • duration (optional) - if set will close the notification after the specified number of milliseconds, otherwise the notification will be shown indefinitely
Playground.notification.deliver({
	title: "Please wait...",
	message: "Connecting"
});