Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Mashup - open connection

Hi all!

which is the best way to know if there is an open connection between the html client and the sense server?

what i want to do is to show a spinner, or something like that, to notify the user that something is going on behind the scene.

and i want only a spinner for the whole application.

thanks.

Loris

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

You would need to use the events for that. The Validated event occurs when there is valid data in the object, Invalidated occurs when a selection has been made.

This would be something like this:

app.getObject( 'QV01', id ).then( function ( model ) {

  //initial display here

  model.Invalidated.bind(function(){

   //data is invalid:show spinner

  });

  model.Validated.bind(function(){

   //data is valid:hide spinner

  });

});

In many cases this will happen very quickly, and you might want some sort of delay before showing your spinner to avoid showing it for very short calculation times.

Hope this helps

Erik

Please mark the appropriate replies as correct or helpful so our team and other members know that your question has been answered to your satisfaction.

View solution in original post

5 Replies
ErikWetterberg

Hi Loris,

depends on what you mean by open connection. openApp will open a web socket to the engine immediately, and this will be pretty fast (depends on authentication). Then the QIX engine will load the app if its not already loaded.

When you then do getObject (or createCube or something) engine will calculate values for the object and send to the client. You know that this is ready when the promise that getObject (and createCube) resolves. So if you want to hide your spinner when you have got the visualizations you could use this, something like this:

app.getObject( 'QV01', id ).then( function ( model ) {

  //we have the visualization

  hideSpinner();

});

If you want to wait for several (all??) your objects this will be a bit more complicated: you could use some sort of counter or, if you need the models for something, save them and check in hideSpinner() if you have got them all.

Hope this helps

Erik

Please mark the appropriate replies as correct or helpful so our team and other members know that your question has been answered to your satisfaction.

Not applicable
Author

Hi Erik,

suppose, for simplicity, that i have an application showing only an object and a list for selecting values.

i will show the spinner when the browser finish to load the page, then i will open the app and get the obj after, when the promise is resolved, the spinner will be hided according to your code.

but then the user select a value on the list, no spinner is shown, i cant get the action (i guess) and increment a counter or what else.

More over in a real scenario the user can filter data from different objs or by app.field(dim).toggleSelect(value) , i want a single point for checking the request for new calculation.

so my question is: there is a way to get requests for new calculation to the server indipendently from the obj that throw it, in order to increment something (or show magicmaterialsuperspinner.gif )  ?


Thanks.

ErikWetterberg

Hi,

You would need to use the events for that. The Validated event occurs when there is valid data in the object, Invalidated occurs when a selection has been made.

This would be something like this:

app.getObject( 'QV01', id ).then( function ( model ) {

  //initial display here

  model.Invalidated.bind(function(){

   //data is invalid:show spinner

  });

  model.Validated.bind(function(){

   //data is valid:hide spinner

  });

});

In many cases this will happen very quickly, and you might want some sort of delay before showing your spinner to avoid showing it for very short calculation times.

Hope this helps

Erik

Please mark the appropriate replies as correct or helpful so our team and other members know that your question has been answered to your satisfaction.

Not applicable
Author

Thanks Erik!

it Works perfectly!

paulcalvet
Partner - Specialist
Partner - Specialist

Hello Eric,

I have a dashbard with a page that contains 6 hypercybes of 5 KPI.

When the user made a selection, he doesn't see if qlik engine work or not.

I want to add a blur effect on the page as long as the engine is performing calculations.

 

Here is an example of my code :

cda.controller( "dashboard", ['$scope', function ( $scope ) {
   if ( !app ) {
      app = getQlikApp();
   }

   function GetBudget(reply, app){
   var output = reply.qHyperCube.qDataPages[0].qMatrix[0][0].qText;
   $("#GetBudget").text(output);

   var output1 = reply.qHyperCube.qDataPages[0].qMatrix[0][1].qText;
   $("#GetBudgetEvol").text(output1);

   var output2 = reply.qHyperCube.qDataPages[0].qMatrix[0][2].qText;
   $("#GetBudgetVSObj").text(output2);

   var output3 = reply.qHyperCube.qDataPages[0].qMatrix[0][3].qText;
   $("#GetBudgetOnline").text(output3);

   var output4 = reply.qHyperCube.qDataPages[0].qMatrix[0][4].qText;
   $("#GetBudgetOnlineEvol").text(output4);

   var output5 = reply.qHyperCube.qDataPages[0].qMatrix[0][5].qText;
   $("#GetBudgetOnlineVSObj").text(output5);

   var output6 = reply.qHyperCube.qDataPages[0].qMatrix[0][6].qText;
   $("#GetBudgetOffline").text(output6);

   var output7 = reply.qHyperCube.qDataPages[0].qMatrix[0][7].qText;
   $("#GetBudgetOfflineEvol").text(output7);

   var output8 = reply.qHyperCube.qDataPages[0].qMatrix[0][8].qText;
   $("#GetBudgetOfflineVSObj").text(output8);
   }

   // CreateXKPI return an hypercube

   CreateXKPI(app,"GetBudget",GetBudget,
   "$(vCosts_Y(Channel={'SEA'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_GROW_Y(Channel={'SEA'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_VSOBJ_RATE_Y(Channel={'SEA'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",

   "$(vCosts_Y(Channel={'Display'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_GROW_Y(Channel={'Display'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_VSOBJ_RATE_Y(Channel={'Display'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",

   "$(vCosts_Y(Channel={'Paid Social'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_GROW_Y(Channel={'Paid Social'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_VSOBJ_RATE_Y(Channel={'Paid Social'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",

   "$(vCosts_Y(Channel={'Retail Media'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_GROW_Y(Channel={'Retail Media'},[Phase]={\"*\"},[Online/Offline]={'Online'}))",
   "$(vCosts_VSOBJ_RATE_Y(Channel={'Retail Media'},[Phase]={\"*\"},[Online/Offline]={'Online'}))"
);

 

   ... others hypercubes...

   qlik.resize();

}] );

 

I don't know how to add the event in order to manage my blur effect.

Can you help me ?

Thanks,

Paul