Skip to content

some updates to visualize loader#14404

Merged
ppisljar merged 2 commits into
elastic:masterfrom
ppisljar:enh/visualizeLoader
Oct 15, 2017
Merged

some updates to visualize loader#14404
ppisljar merged 2 commits into
elastic:masterfrom
ppisljar:enh/visualizeLoader

Conversation

@ppisljar
Copy link
Copy Markdown
Contributor

@ppisljar ppisljar commented Oct 10, 2017

  • visualize loader now returns a promise, which is resolved when visualize is done rendering with a handler that has a destroy method (which cleans up the visualize scope)
  • visualize loader stops the vis:ready event propagation
  • visualize emits vis:ready on its scope (instead of broadcast on rootscope)
  • filter_manager add method was broken down in add and generate
  • filter_manager was added to vis.api

filter_handler generate method comes very handy for adding new filters, check https://docs.google.com/document/d/1U7mZuGOpLwFWrb6zWf62k57hA1MUXL0PFRYW8EdrTjQ/edit# Embedding a saved object paragraph

@ppisljar ppisljar added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review labels Oct 10, 2017
@thomasneirynck
Copy link
Copy Markdown
Contributor

thomasneirynck commented Oct 10, 2017

@rashidkpc made the comment that Kibana-Canvas doesn't have access to the Private-module loader

Maybe we can work-around that on our end, by making the module import itself. Stripping this from angular is not necessary imo, it would not be worth the effort.

I think we have a couple of ways of bootstrapping Private. I made a small suggestion here:

import $ from 'jquery';
import uiRoutes from 'ui/routes';

function VisualizeLoaderProvider($compile, $rootScope, savedVisualizations) {
....
  return {
    embedVisualizationWithId: async(el, savedVisualizationId, params) => {
      return new Promise((resolve) => {
        savedVisualizations.get(savedVisualizationId).then(savedObj => {
          const element = renderVis(el, savedObj, params);
          resolve(element);
        });
      });
    },
    embedVisualizationWithSavedObject: (el, savedObj, params) => {
      return renderVis(el, savedObj, params);
    }
  };
}


let visualizeLoader = null;
let pendingPromise = null;
let pendingResolve = null;
uiRoutes.addSetupWork(function (Private) {
  visualizeLoader = Private(VisualizeLoaderProvider);
  if (pendingResolve) {
    pendingResolve(visualizeLoader);
  }
});

export async function getVisualizeLoader() {
  if (!pendingResolve) {
    pendingPromise = new Promise((resolve)=> {
      pendingResolve = resolve;
    });
  }
  return pendingPromise;
};

and then from the client, you can use it as

import {getVisualizeLoader} from 'ui/visualize/loader`;

getVisualizeLoader()
.then(visualizeLoader) => {
    visualizeLoader.embedVisualizationWithId(...);
});

@ppisljar
Copy link
Copy Markdown
Contributor Author

Every kibana plugin has access to the Private module loader ...

@rashidkpc
Copy link
Copy Markdown
Contributor

We purposefully designed the Canvas element plugin API to enable rendering outside of the Kibana architecture.

While in theory we could use Redux to funnel Private down to a React component that exposes a DOM node as ref it would have the effect of breaking the exportability of Canvas elements which we don't want to do.

@thomasneirynck
Copy link
Copy Markdown
Contributor

failing on license error. needs rebase to include 2a14502.

@ppisljar ppisljar force-pushed the enh/visualizeLoader branch from 9eb75d0 to d23ea7d Compare October 12, 2017 14:58
Copy link
Copy Markdown
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with the a test-app, using both means of loading the visualizeLoader.

Works well IMO. Thx!

tagcloud and regionmap do give errors when filtering, but this is likely more a problem with how they do filtering. we can fix those separately.

@thomasneirynck
Copy link
Copy Markdown
Contributor

@rashidkpc

This proposes an additional way of loading the visualizationLoader. You will be able to call a function called getVisualizeLoader that will return the module. You can then use it as-is. This takes care of the wrapping for you, and you will not have to propagate the Private-boostrapper inside your Canvas code. Once this is merged, it be helpful if you could try it out in Canvas, and see if you run into problems using it.

Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ppisljar ppisljar merged commit e2f8e78 into elastic:master Oct 15, 2017
ppisljar added a commit that referenced this pull request Oct 15, 2017
* some updates to visualize loader

* auto load Private (suggestion by thomas)
ppisljar added a commit to ppisljar/kibana that referenced this pull request Oct 15, 2017
* some updates to visualize loader

* auto load Private (suggestion by thomas)
@ppisljar
Copy link
Copy Markdown
Contributor Author

ppisljar commented Oct 15, 2017

backport
6.x: edf4a54
6.0: 142db97

ppisljar added a commit that referenced this pull request Oct 17, 2017
* some updates to visualize loader

* auto load Private (suggestion by thomas)
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 6, 2026
* some updates to visualize loader

* auto load Private (suggestion by thomas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v6.0.0 v6.1.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants