Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with 7.5.1 #62

Open
srouthiau opened this issue Jan 9, 2020 · 20 comments
Open

Compatibility with 7.5.1 #62

srouthiau opened this issue Jan 9, 2020 · 20 comments

Comments

@srouthiau
Copy link

I have tried the plugin on 7.5.1

I have managed to solve loading issue in time.js but the component still don't work i have an error in timeController.js

commons.bundle.js:3 Uncaught (in promise) TypeError: emitter.on is not a function
at ChildScope._modules.uiModules.get.run.$rootScope.constructor.$listen (commons.bundle.js:3)
at Object. (commons.bundle.js:13)
at Object.invoke (vendors.bundle.dll.js:435)
at $controllerInit (vendors.bundle.dll.js:435)
at nodeLinkFn (vendors.bundle.dll.js:435)

Please help us.

Here's my modification of time.js

import 'ui/angular-bootstrap';
import 'plugins/kibana-time-plugin/lib/angular-bootstrap/css/btn-group.less';
import 'plugins/kibana-time-plugin/lib/angular-bootstrap/css/carousel.less';
import 'plugins/kibana-time-plugin/lib/angular-bootstrap/js/carousel.js';
import 'plugins/kibana-time-plugin/bower_components/bootstrap-addons/dist/css/bootstrap-addons.css';
import 'plugins/kibana-time-plugin/bower_components/bootstrap-addons/dist/js/bootstrap-addons.js';
import 'plugins/kibana-time-plugin/time.less';
import 'plugins/kibana-time-plugin/timeController';

import { AngularVisController } from 'ui/vis/vis_types/angular_vis_type';
import { visFactory } from 'ui/vis/vis_factory';
import { setup as visualizations } from '../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy';

import visTemplate from 'plugins/kibana-time-plugin/time.html';
import optionsTemplate from 'plugins/kibana-time-plugin/timeOptions.html';

// register the provider with the visTypes registry
visualizations.types.registerVisualization(TimeVisProvider);

function TimeVisProvider() {
return visFactory.createBaseVisualization({
name: 'time',
title: 'Time widget',
icon: 'clock',
description: 'Add time inputs to your dashboards.',
visualization: AngularVisController,
visConfig: {
template: visTemplate,
defaults: {
enable_quick: false,
enable_relative: false,
enable_absolut: true,
enable_animation: false,
}
},
editorConfig: {
optionsTemplate: optionsTemplate
},
requestHandler: 'none',
responseHandler: 'none'
});
}

@deepakmldeveloper
Copy link

Hi,

Are you able to resolve the issues?

Thanks

@nreese
Copy link
Owner

nreese commented Apr 30, 2020

There has been a lot of refactoring in Kibana between 7.0 and 7.5.

It looks like SimpleEmitter used at https://github.com/nreese/kibana-time-plugin/blob/master/public/timeController.js#L9 no longer exists in 7.5. Try replacing it with import EventEmitter from 'events';

@deepakmldeveloper
Copy link

deepakmldeveloper commented Apr 30, 2020 via email

@deepakmldeveloper
Copy link

Hi,

I made following changes:

//import { SimpleEmitter } from 'events';
import { EventEmitter } from 'events';

and

//const msearchEmitter = new SimpleEmitter();
const msearchEmitter = new EventEmitter();

in timeController.js file. But still following error is coming:

TypeError: emitter.on is not a function
listen.js:34
Detected an unhandled Promise rejection.
TypeError: emitter.on is not a function fatal_errors_service.tsx:118

Any suggestion?

Thanks

@nreese
Copy link
Owner

nreese commented May 2, 2020

try putting a break point in listen.js and seeing what is getting passed in.

@deepakmldeveloper
Copy link

deepakmldeveloper commented May 4, 2020 via email

@deepakmldeveloper
Copy link

Hi,

Did you get chance to work on this bug?

Thanks

@nreese
Copy link
Owner

nreese commented May 13, 2020

I have not had time to look into the issue

here is a guide for using chrome debugger to isolate the issue https://dzone.com/articles/debug-javascript-using-chrome-developer-tools

@deepakmldeveloper
Copy link

HI,

Following code is not executing:
$scope.$listen(timefilter, 'timeUpdate', () => {
$scope.$evalAsync(() => setTime());
});
it throws
message: "emitter.on is not a function"
stack: "TypeError: emitter.on is not a function↵ at ChildScope.$rootScope.constructor.$listen (http://localhost:5601/fya/bundles/commons.bundle.js:151308:13)↵ at Object. (http://localhost:5601/fya/bundles/commons.bundle.js:25847:10)↵ at Object.invoke (webpack://%5Bname%5D/./node_modules/angular/angular.js?:5143:19)↵ at $controllerInit (webpack://%5Bname%5D/./node_modules/angular/angular.js?:11707:34)↵ at nodeLinkFn (webpack://%5Bname%5D/./node_modules/angular/angular.js?:10520:33)↵ at compositeLinkFn (webpack://%5Bname%5D/./node_modules/angular/angular.js?:9835:13)↵ at publicLinkFn (webpack://%5Bname%5D/./node_modules/angular/angular.js?:9700:30)↵ at _callee$ (http://localhost:5601/fya/bundles/commons.bundle.js:183443:84)↵ at tryCatch (webpack://%5Bname%5D/./node_modules/regenerator-runtime/runtime.js?:45:40)↵ at Generator.invoke [as _invoke] (webpack://%5Bname%5D/./node_modules/regenerator-runtime/runtime.js?:271:22)"
proto: Error
constructor: ƒ TypeError()
message: ""
name: "TypeError"
toString: ƒ toString()
proto: Object

Let's know if you have any idea?

Thanks

@deepakmldeveloper
Copy link

deepakmldeveloper commented May 18, 2020

Hi,

I commented following function in timeContoller.js

/*
$scope.$listen(timefilter, 'timeUpdate', () => {
$scope.$evalAsync(() => setTime());
});
*/

After that plugin is getting displayed, but I don't know how it will affect the whole plugin. Please let me know what to do next? How should i re-rewrite this code?

Thanks

@nreese
Copy link
Owner

nreese commented May 19, 2020

After that plugin is getting displayed, but I don't know how it will affect the whole plugin. Please let me know what to do next? How should i re-rewrite this code?

I believe that subscript is to update the time slider when the Kibana global time picker changes. With that listen removed, does the time slider update when the global time picker changes?

If it does not, try adding the following, globalState is an angular service that gets injected in module.controller definition.

$scope.$listen(globalState, 'fetch_with_changes', diff => {
      if (diff.includes('time')) {
        setTime();
      }
});

@ch-bas
Copy link

ch-bas commented May 22, 2020

Hi folks,
if you make these changes, the plugin should work fine:
remove:

import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';

and replace it by:

import { AngularVisController } from 'ui/vis/vis_types/angular_vis_type';
import KbnTimeVisController  from './timeController'

import { setup as visualizations } from '../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy';
import { npSetup } from 'ui/new_platform';



  const timePickeerDefinition = {
    name: 'time',
    title: 'Time widget',
    icon: 'clock',
    visualization: AngularVisController,
    description: 'Add time inputs to your dashboards.',
    visConfig: {
      template: visTemplate,
      defaults: {
          enable_quick: true,
          enable_relative: true,
          enable_absolut: true,
          enable_animation: true,
      }
    },
    editorConfig: {
      optionsTemplate: optionsTemplate
    },
    requestHandler: 'none',
    responseHandler: 'none'
  };

npSetup.plugins.expressions.registerFunction(timePickeerDefinition);
visualizations.types.createBaseVisualization(timePickeerDefinition);

and then in timeController.js, comment this:
$scope.$listen(timefilter, 'timeUpdate', () => { $scope.$evalAsync(() => setTime()); });

@deepakmldeveloper
Copy link

deepakmldeveloper commented May 22, 2020 via email

@Arvin-developer
Copy link

Hi folks,
if you make these changes, the plugin should work fine:
remove:

import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';

and replace it by:

import { AngularVisController } from 'ui/vis/vis_types/angular_vis_type';
import KbnTimeVisController  from './timeController'

import { setup as visualizations } from '../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy';
import { npSetup } from 'ui/new_platform';



  const timePickeerDefinition = {
    name: 'time',
    title: 'Time widget',
    icon: 'clock',
    visualization: AngularVisController,
    description: 'Add time inputs to your dashboards.',
    visConfig: {
      template: visTemplate,
      defaults: {
          enable_quick: true,
          enable_relative: true,
          enable_absolut: true,
          enable_animation: true,
      }
    },
    editorConfig: {
      optionsTemplate: optionsTemplate
    },
    requestHandler: 'none',
    responseHandler: 'none'
  };

npSetup.plugins.expressions.registerFunction(timePickeerDefinition);
visualizations.types.createBaseVisualization(timePickeerDefinition);

and then in timeController.js, comment this:
$scope.$listen(timefilter, 'timeUpdate', () => { $scope.$evalAsync(() => setTime()); });

Thanks for your help !
I follow those setting on opendistro kibana 7.4.2 , the web error also exit and no diagram display :

vendors.bundle.dll.js:28 Uncaught TypeError: emitter.on is not a function
at ChildScope.$rootScope.constructor.$listen (commons.bundle.js:85)
at Object. (kibana.bundle.js:1)
at Object.invoke (vendors.bundle.dll.js:239)
at $controllerInit (vendors.bundle.dll.js:239)
at nodeLinkFn (vendors.bundle.dll.js:239)
at compositeLinkFn (vendors.bundle.dll.js:239)
at publicLinkFn (vendors.bundle.dll.js:239)
at commons.bundle.js:83
at new Promise ()
at AngularVisController.render (commons.bundle.js:83)

If you have any adivce , please help to reply , thanks !

@ch-bas
Copy link

ch-bas commented Jun 3, 2020

Hi @Arvin-developer , that was already answered, you should remove
$scope.$listen(timefilter, 'timeUpdate', () => { $scope.$evalAsync(() => setTime()); });

@Arvin-developer
Copy link

Hi @Arvin-developer , that was already answered, you should remove
$scope.$listen(timefilter, 'timeUpdate', () => { $scope.$evalAsync(() => setTime()); });

Thanks for your help !
I had remove this code on timeController.js , and restart the kibana ,but meet the new exception :

FATAL Error: Optimizations failure.
4579 modules

ERROR in ./plugins/kibana-time-plugin/public/time.js
Module not found: Error: Can't resolve '../../../src/legacy/core_plugins/vis

ualizations/public/np_ready/public/legacy' in 'C:\inetpub\odfe-1.4.0-kibana_DEV
plugins\kibana-time-plugin\public'

Is maybe kibana version different to 7.5 so that miss the js source ?

@ch-bas
Copy link

ch-bas commented Jun 3, 2020

Please make sure that you are pointing to the write destination, because the file does exist in Kibana 7.5.

@Arvin-developer
Copy link

Please make sure that you are pointing to the write destination, because the file does exist in Kibana 7.5.

Thanks @ch-bas
My kibana version is opendistro kibana 7.4.2 , there is no src\legacy\core_plugins\visualizations\public\np_ready\public\legacy.js file , so error happend .
Maybe we can not add this plugin on difference opendistro kibana 7.4.2 , it will need to modify many js code .

@prasinos
Copy link

prasinos commented Jun 5, 2020

Hi folks,
if you make these changes, the plugin should work fine:
remove:

import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';

and replace it by:

import { AngularVisController } from 'ui/vis/vis_types/angular_vis_type';
import KbnTimeVisController  from './timeController'

import { setup as visualizations } from '../../../src/legacy/core_plugins/visualizations/public/np_ready/public/legacy';
import { npSetup } from 'ui/new_platform';



  const timePickeerDefinition = {
    name: 'time',
    title: 'Time widget',
    icon: 'clock',
    visualization: AngularVisController,
    description: 'Add time inputs to your dashboards.',
    visConfig: {
      template: visTemplate,
      defaults: {
          enable_quick: true,
          enable_relative: true,
          enable_absolut: true,
          enable_animation: true,
      }
    },
    editorConfig: {
      optionsTemplate: optionsTemplate
    },
    requestHandler: 'none',
    responseHandler: 'none'
  };

npSetup.plugins.expressions.registerFunction(timePickeerDefinition);
visualizations.types.createBaseVisualization(timePickeerDefinition);

and then in timeController.js, comment this:
$scope.$listen(timefilter, 'timeUpdate', () => { $scope.$evalAsync(() => setTime()); });

Hi @ch-bas,

I modified time.js and timeController.js as you describe but I am getting the following error:

Version: 7.5.2 Build: 27675 Error: Register requires an function register@http://host.removed.com:5601/bundles/plugin/expressions.bundle.js:3:12420 registerFunction@http://host.removed.com:5601/bundles/plugin/expressions.bundle.js:3:7982 @http://host.removed.com:5601/bundles/commons.bundle.js:3:6403163 __webpack_require__@http://host.removed.com:5601/bundles/kibana.bundle.js:3:1463 @http://host.removed.com:5601/bundles/commons.bundle.js:3:796141 __webpack_require__@http://host.removed.com:5601/bundles/kibana.bundle.js:3:1463 __kbnBundles__.kibana<@http://host.removed.com:5601/bundles/kibana.bundle.js:3:739512 __webpack_require__@http://host.removed.com:5601/bundles/kibana.bundle.js:3:1463 requireLegacyFiles@http://host.removed.com:5601/bundles/kibana.bundle.js:3:739114 start@http://host.removed.com:5601/bundles/commons.bundle.js:3:2485247 _callee2$@http://host.removed.com:5601/bundles/commons.bundle.js:3:2480213 tryCatch@http://host.removed.com:5601/built_assets/dlls/vendors.bundle.dll.js:489:789856 invoke@http://host.removed.com:5601/built_assets/dlls/vendors.bundle.dll.js:489:793705 defineIteratorMethods/</prototype[method]@http://host.removed.com:5601/built_assets/dlls/vendors.bundle.dll.js:489:790980 asyncGeneratorStep@http://host.removed.com:5601/bundles/commons.bundle.js:3:2472100 _next@http://host.removed.com:5601/bundles/commons.bundle.js:3:2472411 notify/<@http://host.removed.com:5601/built_assets/dlls/vendors.bundle.dll.js:314:123090 flush@http://host.removed.com:5601/built_assets/dlls/vendors.bundle.dll.js:109:959249
I am using Kibana 7.5.2 on docker with the directory of the plugin mounted on /usr/share/kibana/plugins/kibana-time-plugin in the container.
Is there any other modification I should do? Thank you.

@ch-bas
Copy link

ch-bas commented Jun 5, 2020

Maybe this will help #64 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants