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

[NP] Timelion #44039

Merged
merged 69 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6a249bf
Move index.js to index.ts
Aug 26, 2019
f8d6c16
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Aug 27, 2019
ce99228
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Aug 28, 2019
c11faa4
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Aug 28, 2019
a8bde3e
Migrate Vis, interpreter, home and 2 hacks to setup() and start()
Aug 28, 2019
69887c7
Move Timechart hack to start()
Aug 28, 2019
ca5bcc9
Add featureCatalogueRegistryProvider to an interface
Aug 28, 2019
446b96c
Add types to a server param
Aug 28, 2019
ec021e6
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Aug 29, 2019
4cb9c06
Move some .js to .ts
Aug 29, 2019
e7b5c07
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Aug 30, 2019
ffd604c
Add ExpressionFunction<> to interpreter
Aug 30, 2019
1369f6d
Remove Feature Provider
Aug 30, 2019
1716d1d
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 2, 2019
8c178f2
Remove extra export
Sep 2, 2019
630e0b0
Add an interface to a timelion response
Sep 2, 2019
e40b399
Add an inteface to the panel
Sep 2, 2019
a621257
Add IPrivate interface
Sep 2, 2019
0abd64d
Make nit notes
Sep 2, 2019
fc89dd0
Edit uiCapabilities() type
Sep 3, 2019
63b5bcc
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 3, 2019
1738161
Shim Timelion plugin
Sep 3, 2019
a482260
Shim start() plugin method
Sep 3, 2019
8672082
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 4, 2019
5308ca7
Change InternalCoreStart to LegacyCoreStart
Sep 4, 2019
29eea85
Move Angular dependencies to a separate module
Sep 4, 2019
8a0a6bc
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 4, 2019
4ae00b7
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 5, 2019
eae077a
Change visualizations import path due to recent changes
Sep 5, 2019
1573bb3
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 6, 2019
b8bd9ea
Rename directives
Sep 6, 2019
60f2a5d
Take a common property out
Sep 6, 2019
afe69c4
Get rid of require in schema
Sep 6, 2019
8539357
Use core.uiSettings
Sep 6, 2019
81fde15
Refactor timelion request handler
Sep 6, 2019
a967b0f
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 9, 2019
c505be3
Remove Private from tests
Sep 9, 2019
78680f1
Remove redundant dependencies from tests
Sep 9, 2019
013712d
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 9, 2019
5ab195f
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 10, 2019
c4abb62
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 11, 2019
b51082b
Update visualizations paths
Sep 11, 2019
74f5888
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 12, 2019
fab6f32
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 13, 2019
c215ac3
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 13, 2019
bb3b87d
Change expressions paths due to expessions movement
Sep 13, 2019
0506a34
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 16, 2019
45db215
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 17, 2019
fff5604
Refactoring according to reviews
Sep 17, 2019
186f39f
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 19, 2019
6ff49f6
Add a comment over the uiCapabilities field
Sep 19, 2019
db2d6e1
Merge branch 'timelion-new-platform' of github.com:Avinar-24/kibana i…
Sep 19, 2019
8300bf9
Edit the comment
Sep 19, 2019
2bad9c1
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 20, 2019
a8821c2
Ignore uiCapabilities issue
Sep 20, 2019
a6d3bfc
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 23, 2019
3d12714
Take angular controller out
Sep 23, 2019
c90c7a0
Get rid of
Sep 23, 2019
7a8ff51
Get rid of config
Sep 23, 2019
9653ddb
Get rid of config in start
Sep 23, 2019
feed318
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 24, 2019
7b4b104
Unwrap handler from redundant promise
Sep 24, 2019
68ae787
Move npSetup npStart dependencies in a high level
Sep 24, 2019
bb3ec7a
Rename some details
Sep 24, 2019
9708804
Fix reviews
Sep 24, 2019
dff86b3
fix CI
alexwizp Sep 24, 2019
f37d54c
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 25, 2019
68f7127
Merge remote-tracking branch 'upstream/master' into timelion-new-plat…
Sep 26, 2019
bb28ce8
Take visFactory out
Sep 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,40 @@

import { resolve } from 'path';
import { i18n } from '@kbn/i18n';
import { Legacy } from 'kibana';
import { LegacyPluginApi, LegacyPluginInitializer } from 'src/legacy/plugin_discovery/types';
import { CoreSetup, PluginInitializerContext } from 'src/core/server';
import { plugin } from './server';
import { CustomCoreSetup } from './server/plugin';

const experimentalLabel = i18n.translate('timelion.uiSettings.experimentalLabel', {
defaultMessage: 'experimental',
});

export default function (kibana) {
return new kibana.Plugin({
const timelionPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
require: ['kibana', 'elasticsearch'],

config(Joi) {
config(Joi: any) {
return Joi.object({
enabled: Joi.boolean().default(true),
ui: Joi.object({
enabled: Joi.boolean().default(false),
}).default(),
graphiteUrls: Joi.array().items(
Joi.string().uri({ scheme: ['http', 'https'] }),
).default([]),
graphiteUrls: Joi.array()
.items(Joi.string().uri({ scheme: ['http', 'https'] }))
.default([]),
}).default();
},

// @ts-ignore
// https://github.com/elastic/kibana/pull/44039#discussion_r326582255
uiCapabilities() {
return {
timelion: {
save: true,
},
};
},

publicDir: resolve(__dirname, 'public'),
uiExports: {
app: {
title: 'Timelion',
Expand All @@ -58,11 +62,7 @@ export default function (kibana) {
main: 'plugins/timelion/app',
},
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
hacks: [
'plugins/timelion/hacks/toggle_app_link_in_nav',
'plugins/timelion/lib/panel_registry',
'plugins/timelion/panels/timechart/timechart',
],
hacks: [resolve(__dirname, 'public/legacy')],
injectDefaultVars(server) {
const config = server.config();

Expand All @@ -71,13 +71,6 @@ export default function (kibana) {
kbnIndex: config.get('kibana.index'),
};
},
visTypes: [
'plugins/timelion/vis',
],
interpreter: ['plugins/timelion/timelion_vis_fn'],
home: [
'plugins/timelion/register_feature',
],
mappings: require('./mappings.json'),
uiSettingDefaults: {
'timelion:showTutorial': {
Expand Down Expand Up @@ -159,29 +152,32 @@ export default function (kibana) {
value: '1ms',
description: i18n.translate('timelion.uiSettings.minimumIntervalDescription', {
defaultMessage: 'The smallest interval that will be calculated when using "auto"',
description: '"auto" is a technical value in that context, that should not be translated.',
description:
'"auto" is a technical value in that context, that should not be translated.',
}),
category: ['timelion'],
},
'timelion:graphite.url': {
name: i18n.translate('timelion.uiSettings.graphiteURLLabel', {
defaultMessage: 'Graphite URL',
description: 'The URL should be in the form of https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite',
description:
'The URL should be in the form of https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite',
}),
value: (server) => {
const urls = server.config().get('timelion.graphiteUrls');
value: (server: Legacy.Server) => {
const urls = server.config().get('timelion.graphiteUrls') as string[];
if (urls.length === 0) {
return null;
} else {
return urls[0];
}
},
description: i18n.translate('timelion.uiSettings.graphiteURLDescription', {
defaultMessage: '{experimentalLabel} The <a href="https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite" target="_blank" rel="noopener">URL</a> of your graphite host',
defaultMessage:
'{experimentalLabel} The <a href="https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite" target="_blank" rel="noopener">URL</a> of your graphite host',
values: { experimentalLabel: `<em>[${experimentalLabel}]</em>` },
}),
type: 'select',
options: (server) => (server.config().get('timelion.graphiteUrls')),
options: (server: Legacy.Server) => server.config().get('timelion.graphiteUrls'),
category: ['timelion'],
},
'timelion:quandl.key': {
Expand All @@ -197,11 +193,13 @@ export default function (kibana) {
},
},
},
init: (server) => {
const initializerContext = {};
const core = { http: { server } };
init: (server: Legacy.Server) => {
const initializerContext = {} as PluginInitializerContext;
const core = { http: { server } } as CoreSetup & CustomCoreSetup;

plugin(initializerContext).setup(core);
},
});
}

// eslint-disable-next-line import/no-default-export
export default timelionPluginInitializer;
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,53 @@
*/

import expect from '@kbn/expect';
import ngMock from 'ng_mock';
describe('Tick Generator', function () {
import { generateTicksProvider } from '../panels/timechart/tick_generator';

describe('Tick Generator', function () {
let generateTicks;
const axes = [
{
min: 0,
max: 5000,
delta: 100
},
{
min: 0,
max: 50000,
delta: 2000
},
{
min: 4096,
max: 6000,
delta: 250
}
];
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
generateTicks = Private(require('plugins/timelion/panels/timechart/tick_generator'));
}));

it('returns a function', function () {
expect(generateTicks).to.be.a('function');
beforeEach(function () {
generateTicks = generateTicksProvider();
});

describe('generateTicksProvider()', function () {
it('should return a function', function () {
expect(generateTicks).to.be.a('function');
});
});

axes.forEach(axis => {
it(`generates ticks from ${axis.min} to ${axis.max}`, function () {
const ticks = generateTicks(axis);
let n = 1;
while (Math.pow(2, n) < axis.delta) n++;
const expectedDelta = Math.pow(2, n);
const expectedNr = parseInt((axis.max - axis.min) / expectedDelta) + 2;
expect(ticks instanceof Array).to.be(true);
expect(ticks.length).to.be(expectedNr);
expect(ticks[0]).to.equal(axis.min);
expect(ticks[parseInt(ticks.length / 2)]).to.equal(axis.min + expectedDelta * parseInt(ticks.length / 2));
expect(ticks[ticks.length - 1]).to.equal(axis.min + expectedDelta * (ticks.length - 1));
describe('generateTicks()', function () {
const axes = [
{
min: 0,
max: 5000,
delta: 100
},
{
min: 0,
max: 50000,
delta: 2000
},
{
min: 4096,
max: 6000,
delta: 250
}
];

axes.forEach(axis => {
it(`generates ticks from ${axis.min} to ${axis.max}`, function () {
const ticks = generateTicks(axis);
let n = 1;
while (Math.pow(2, n) < axis.delta) n++;
const expectedDelta = Math.pow(2, n);
const expectedNr = parseInt((axis.max - axis.min) / expectedDelta) + 2;
expect(ticks instanceof Array).to.be(true);
expect(ticks.length).to.be(expectedNr);
expect(ticks[0]).to.equal(axis.min);
expect(ticks[parseInt(ticks.length / 2)]).to.equal(axis.min + expectedDelta * parseInt(ticks.length / 2));
expect(ticks[ticks.length - 1]).to.equal(axis.min + expectedDelta * (ticks.length - 1));
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@
*/

import expect from '@kbn/expect';
import ngMock from 'ng_mock';
describe('Tick Formatters', function () {
import { tickFormatters } from '../../services/tick_formatters';

let tickFormatters;
describe('Tick Formatters', function () {
let formatters;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
tickFormatters = Private(require('plugins/timelion/services/tick_formatters'));
}));
beforeEach(function () {
formatters = tickFormatters();
});

describe('Bits mode', function () {
let bitFormatter;
beforeEach(function () {
bitFormatter = tickFormatters.bits;
bitFormatter = formatters.bits;
});

it('is a function', function () {
Expand All @@ -56,7 +55,7 @@ describe('Tick Formatters', function () {
describe('Bits/s mode', function () {
let bitsFormatter;
beforeEach(function () {
bitsFormatter = tickFormatters['bits/s'];
bitsFormatter = formatters['bits/s'];
});

it('is a function', function () {
Expand All @@ -81,7 +80,7 @@ describe('Tick Formatters', function () {
describe('Bytes mode', function () {
let byteFormatter;
beforeEach(function () {
byteFormatter = tickFormatters.bytes;
byteFormatter = formatters.bytes;
});

it('is a function', function () {
Expand All @@ -106,7 +105,7 @@ describe('Tick Formatters', function () {
describe('Bytes/s mode', function () {
let bytesFormatter;
beforeEach(function () {
bytesFormatter = tickFormatters['bytes/s'];
bytesFormatter = formatters['bytes/s'];
});

it('is a function', function () {
Expand All @@ -131,7 +130,7 @@ describe('Tick Formatters', function () {
describe('Currency mode', function () {
let currencyFormatter;
beforeEach(function () {
currencyFormatter = tickFormatters.currency;
currencyFormatter = formatters.currency;
});

it('is a function', function () {
Expand Down Expand Up @@ -163,7 +162,7 @@ describe('Tick Formatters', function () {
describe('Percent mode', function () {
let percentFormatter;
beforeEach(function () {
percentFormatter = tickFormatters.percent;
percentFormatter = formatters.percent;
});

it('is a function', function () {
Expand Down Expand Up @@ -197,7 +196,7 @@ describe('Tick Formatters', function () {
describe('Custom mode', function () {
let customFormatter;
beforeEach(function () {
customFormatter = tickFormatters.custom;
customFormatter = formatters.custom;
});

it('is a function', function () {
Expand Down
Loading