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