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

[Build] restore timelion #390

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion src/core/server/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class UiSettingsClient implements IUiSettingsClient {
changes: Record<string, any>;
autoCreateOrUpgradeIfMissing?: boolean;
}) {
changes = this.translateChanges(changes, 'timeline', 'timelion');
try {
await this.savedObjectsClient.update(this.type, this.id, changes);
} catch (error) {
Expand Down Expand Up @@ -228,7 +229,7 @@ export class UiSettingsClient implements IUiSettingsClient {
}: ReadOptions = {}): Promise<Record<string, any>> {
try {
const resp = await this.savedObjectsClient.get<Record<string, any>>(this.type, this.id);
return resp.attributes;
return this.translateChanges(resp.attributes, 'timelion', 'timeline');
} catch (error) {
if (SavedObjectsErrorHelpers.isNotFoundError(error) && autoCreateOrUpgradeIfMissing) {
const failedUpgradeAttributes = await createOrUpgradeSavedConfig({
Expand Down Expand Up @@ -270,4 +271,13 @@ export class UiSettingsClient implements IUiSettingsClient {
(ignore401Errors && isNotAuthorizedError(error))
);
}

// TODO: [RENAMEME] Temporary code for backwards compatibility.
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/334
private translateChanges(changes: Record<string, any>, source: string, dest: string) {
return Object.keys(changes).reduce((translatedChanges: Record<string, any>, key: string) => {
translatedChanges[key.replace(source, dest)] = changes[key];
return translatedChanges;
}, {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ export const applicationUsageSchema = {
opensearch_dashboards: commonSchema, // It's a forward app so we'll likely never report it
management: commonSchema,
short_url_redirect: commonSchema, // It's a forward app so we'll likely never report it
timeline: commonSchema,
timelion: commonSchema,
visualize: commonSchema,
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'securitySolution:ipReputationLinks': { type: 'text' },
'csv:separator': { type: 'keyword' },
'visualization:tileMap:WMSdefaults': { type: 'text' },
'timeline:target_buckets': { type: 'long' },
'timeline:max_buckets': { type: 'long' },
'timeline:opensearch.timefield': { type: 'keyword' },
'timeline:min_interval': { type: 'keyword' },
'timeline:default_rows': { type: 'long' },
'timeline:default_columns': { type: 'long' },
'timeline:quandl.key': { type: 'keyword' },
'timeline:opensearch.default_index': { type: 'keyword' },
'timeline:showTutorial': { type: 'boolean' },
'timelion:target_buckets': { type: 'long' },
'timelion:max_buckets': { type: 'long' },
'timelion:es.timefield': { type: 'keyword' },
'timelion:min_interval': { type: 'keyword' },
'timelion:default_rows': { type: 'long' },
'timelion:default_columns': { type: 'long' },
'timelion:quandl.key': { type: 'keyword' },
'timelion:es.default_index': { type: 'keyword' },
'timelion:showTutorial': { type: 'boolean' },
'securitySolution:timeDefaults': { type: 'keyword' },
'securitySolution:defaultAnomalyScore': { type: 'long' },
'securitySolution:defaultIndex': { type: 'keyword' }, // it's an array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('getSavedObjectsCounts', () => {
search: { total: 0 },
index_pattern: { total: 0 },
graph_workspace: { total: 0 },
timeline_sheet: { total: 0 },
timelion_sheet: { total: 0 },
});
});

Expand All @@ -53,7 +53,7 @@ describe('getSavedObjectsCounts', () => {
types: {
buckets: [
{ key: 'dashboard', doc_count: 1 },
{ key: 'timeline-sheet', doc_count: 2 },
{ key: 'timelion-sheet', doc_count: 2 },
{ key: 'index-pattern', value: 2 }, // Malformed on purpose
{ key: 'graph_workspace', doc_count: 3 }, // already snake_cased
],
Expand All @@ -68,7 +68,7 @@ describe('getSavedObjectsCounts', () => {
search: { total: 0 },
index_pattern: { total: 0 },
graph_workspace: { total: 3 },
timeline_sheet: { total: 2 },
timelion_sheet: { total: 2 },
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const TYPES = [
'search',
'index-pattern',
'graph-workspace',
'timeline-sheet',
'timelion-sheet',
];

export interface OpenSearchDashboardsSavedObjectCounts {
Expand All @@ -57,7 +57,7 @@ export interface OpenSearchDashboardsSavedObjectCounts {
search: { total: number };
index_pattern: { total: number };
graph_workspace: { total: number };
timeline_sheet: { total: number };
timelion_sheet: { total: number };
}

export async function getSavedObjectsCounts(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('telemetry_opensearch_dashboards', () => {
search: { total: 0 },
index_pattern: { total: 0 },
graph_workspace: { total: 0 },
timeline_sheet: { total: 0 },
timelion_sheet: { total: 0 },
});
});

Expand All @@ -78,7 +78,7 @@ describe('telemetry_opensearch_dashboards', () => {
search: { total: 0 },
index_pattern: { total: 0 },
graph_workspace: { total: 0 },
timeline_sheet: { total: 0 },
timelion_sheet: { total: 0 },
};

expect(collector.formatForBulkUpload!(resultFromFetch)).toStrictEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function getOpenSearchDashboardsUsageCollector(
search: { total: { type: 'long' } },
index_pattern: { total: { type: 'long' } },
graph_workspace: { total: { type: 'long' } },
timeline_sheet: { total: { type: 'long' } },
timelion_sheet: { total: { type: 'long' } },
},
async fetch(callCluster) {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const uiMetricFromDataPluginSchema: MakeSchemaFrom<UIMetricUsage> = {
opensearch_dashboards: commonSchema, // It's a forward app so we'll likely never report it
management: commonSchema,
short_url_redirect: commonSchema, // It's a forward app so we'll likely never report it
timeline: commonSchema,
timelion: commonSchema,
visualize: commonSchema,
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@
"timeline:max_buckets": {
"type": "long"
},
"timeline:opensearch.timefield": {
"timeline:es.timefield": {
"type": "keyword"
},
"timeline:min_interval": {
Expand All @@ -1402,7 +1402,7 @@
"timeline:quandl.key": {
"type": "keyword"
},
"timeline:opensearch.default_index": {
"timeline:es.default_index": {
"type": "keyword"
},
"timeline:showTutorial": {
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/timeline/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ export function initTimelineApp(app, deps) {

function getStateDefaults() {
return {
sheet: savedSheet.timeline_sheet,
sheet: savedSheet.timelion_sheet,
selected: 0,
columns: savedSheet.timeline_columns,
rows: savedSheet.timeline_rows,
interval: savedSheet.timeline_interval,
columns: savedSheet.timelion_columns,
rows: savedSheet.timelion_rows,
interval: savedSheet.timelion_interval,
};
}

Expand All @@ -171,7 +171,7 @@ export function initTimelineApp(app, deps) {
const savedVisualizations = deps.plugins.visualizations.savedVisualizationsLoader;
const timezone = getTimezone(deps.core.uiSettings);

const defaultExpression = '.opensearch(*)';
const defaultExpression = '.es(*)';

$scope.topNavMenu = getTopNavMenu();

Expand Down Expand Up @@ -328,7 +328,7 @@ export function initTimelineApp(app, deps) {
testId: 'timelineDocsButton',
};

if (deps.core.application.capabilities.timeline.save) {
if (deps.core.application.capabilities.timelion.save) {
return [
newSheetAction,
addSheetAction,
Expand Down Expand Up @@ -609,7 +609,7 @@ export function initTimelineApp(app, deps) {
}

async function saveExpression(title) {
const vis = await deps.plugins.visualizations.createVis('timeline', {
const vis = await deps.plugins.visualizations.createVis('timelion', {
title,
params: {
expression: $scope.state.sheet[$scope.state.selected],
Expand Down Expand Up @@ -643,7 +643,7 @@ export function initTimelineApp(app, deps) {
$route.current.params.id ? getSavedSheetBreadcrumbs : getCreateBreadcrumbs
),
badge: () => {
if (deps.core.application.capabilities.timeline.save) {
if (deps.core.application.capabilities.timelion.save) {
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
For some reasons it doesn't work without it (even though the default role of
the element is textbox anyway). -->
<textarea data-expression-input role="textbox" rows="{{ rows }}" class="timExpressionInput kuiTextArea fullWidth"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.opensearch(*)' } } }}"
placeholder="{{ ::'timeline.expressionInputPlaceholder' | i18n: { defaultMessage: 'Try a query with {opensearchQuery}', values: { opensearchQuery: '.es(*)' } } }}"
ng-model="sheet" ng-focus="onFocusInput()" ng-keydown="onKeyDownInput($event)" ng-keyup="onKeyUpInput($event)"
ng-blur="onBlurInput()" ng-mousedown="onMouseDownInput()" ng-mouseup="onMouseUpInput()"
ng-click="onClickExpression()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ <h2 i18n-id="timeline.help.configuration.notValidTitle" i18n-default-message="Fi
and {opensearchTimefield} settings to match your indices."
i18n-values="{
html_advancedSettingsPath: '<strong>' + translations.notValidAdvancedSettingsPath + '</strong>',
html_opensearchDefaultIndex: '<code>timeline:opensearch.default_index</code>',
html_opensearchTimefield: '<code>timeline:opensearch.timefield</code>',
html_opensearchDefaultIndex: '<code>timeline:es.default_index</code>',
html_opensearchTimefield: '<code>timeline:es.timefield</code>',
}"></p>
<p i18n-id="timeline.help.configuration.notValid.paragraph2" i18n-default-message="You'll also see some other Timeline settings. For now, you don't need
to worry about them. Later, you'll see that you can set most of
Expand Down Expand Up @@ -164,7 +164,7 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
datasource, you can start submitting queries. For starters,
enter {opensearchPattern} in the input bar and hit enter."
i18n-values="{
html_opensearchPattern: '<code>.opensearch(*)</code>',
html_opensearchPattern: '<code>.es(*)</code>',
}"
></p>
<p>
Expand All @@ -176,8 +176,8 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
i18n-values="{
html_opensearchAsteriskQueryDescription: '<em>' + translations.opensearchAsteriskQueryDescription + '</em>',
html_html: '<em>html</em>',
html_htmlQuery: '<code>.opensearch(html)</code>',
html_bobQuery: '<code>.opensearch(\'user:bob AND bytes:>100\')</code>',
html_htmlQuery: '<code>.es(html)</code>',
html_bobQuery: '<code>.es(\'user:bob AND bytes:>100\')</code>',
html_bob: '<em>bob</em>',
html_user: '<code>user</code>',
html_bytes: '<code>bytes</code>',
Expand All @@ -193,7 +193,7 @@ <h2 i18n-id="timeline.help.queryingTitle" i18n-default-message="Querying the Ope
timeline.help.querying.paragraph2Part2"></a>
<span i18n-id="timeline.help.querying.paragraph2Part2"
i18n-default-message="as the first argument to the {opensearchQuery} function." i18n-values="{
html_opensearchQuery: '<code>.opensearch()</code>',
html_opensearchQuery: '<code>.es()</code>',
}" i18n-description="Part of composite text
timeline.help.querying.paragraph2Part1 +
timeline.help.querying.luceneQueryLinkText +
Expand All @@ -208,9 +208,9 @@ <h4 i18n-id="timeline.help.querying.passingArgumentsTitle" i18n-default-message=
For example, you can enter {opensearchLogstashQuery} to tell the OpenSearch datasource
{opensearchIndexQueryDescription}."
i18n-values="{
html_opensearchEmptyQuery: '<code>.opensearch()</code>',
html_opensearchStarQuery: '<code>.opensearch(*)</code>',
html_opensearchLogstashQuery: '<code>.opensearch(index=\'logstash-*\', q=\'*\')</code>',
html_opensearchEmptyQuery: '<code>.es()</code>',
html_opensearchStarQuery: '<code>.es(*)</code>',
html_opensearchLogstashQuery: '<code>.es(index=\'logstash-*\', q=\'*\')</code>',
html_opensearchIndexQueryDescription: '<em>' + translations.opensearchIndexQueryDescription + '</em>',
}"></p>
<h4 i18n-id="timeline.help.querying.countTitle" i18n-default-message="Beyond count"></h4>
Expand Down Expand Up @@ -240,8 +240,8 @@ <h4 i18n-id="timeline.help.querying.countTitle" i18n-default-message="Beyond cou
html_cardinality: '<code>cardinality</code>',
html_bytes: '<code>bytes</code>',
html_srcIp: '<code>src_ip</code>',
html_opensearchCardinalityQuery: '<code>.opensearch(*, metric=\'cardinality:src_ip\')</code>',
html_opensearchAvgQuery: '<code>.opensearch(metric=\'avg:bytes\')</code>',
html_opensearchCardinalityQuery: '<code>.es(*, metric=\'cardinality:src_ip\')</code>',
html_opensearchAvgQuery: '<code>.es(metric=\'avg:bytes\')</code>',
}" i18n-description="Part of composite text
timeline.help.querying.countTextPart1 +
timeline.help.querying.countMetricAggregationLinkText +
Expand Down Expand Up @@ -275,7 +275,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></p>
<table class="table table-condensed table-striped">
<tr>
<td><code>.opensearch(*), .opensearch(US)</code></td>
<td><code>.es(*), .es(US)</code></td>
<td i18n-id="timeline.help.expressions.examples.twoExpressionsDescription"
i18n-default-message="{descriptionTitle} Two expressions on the same chart."
i18n-values="{
Expand All @@ -284,7 +284,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></td>
</tr>
<tr>
<td><code>.opensearch(*).color(#f66), .opensearch(US).bars(1)</code></td>
<td><code>.es(*).color(#f66), .es(US).bars(1)</code></td>
<td
i18n-id="timeline.help.expressions.examples.customStylingDescription"
i18n-default-message="{descriptionTitle} Colorizes the first series red and
Expand All @@ -297,7 +297,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
<tr>
<td>
<code
>.opensearch(*).color(#f66).lines(fill=3), .opensearch(US).bars(1).points(radius=3,
>.es(*).color(#f66).lines(fill=3), .es(US).bars(1).points(radius=3,
weight=1)</code
>
</td>
Expand All @@ -310,7 +310,7 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
></td>
</tr>
<tr>
<td><code>(.opensearch(*), .opensearch(GB)).points()</code></td>
<td><code>(.es(*), .es(GB)).points()</code></td>
<td i18n-id="timeline.help.expressions.examples.groupedExpressionsDescription" i18n-default-message="{descriptionTitle} You can also chain groups of expressions to
functions. Here, both series are shown as points instead of lines." i18n-values="{
html_descriptionTitle: '<strong>' + translations.groupedExpressionsDescriptionTitle + '</strong>',
Expand Down Expand Up @@ -350,18 +350,18 @@ <h2 i18n-id="timeline.help.expressionsTitle" i18n-default-message="Expressing yo
our web traffic comes from the US?"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph2"
i18n-default-message="First, we need to find all events that contain US: {opensearchUsQuery}."
i18n-values="{ html_opensearchUsQuery: '<code>.opensearch(\'US\')</code>' }"></p>
i18n-values="{ html_opensearchUsQuery: '<code>.es(\'US\')</code>' }"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph3" i18n-default-message="Next, we want to calculate the ratio of US events to the whole.
To divide {us} by everything, we can use the {divide} function:
{divideDataQuery}."
i18n-values="{
html_us: '<code>\'US\'</code>',
html_divide: '<code>divide</code>',
html_divideDataQuery: '<code>.opensearch(\'US\').divide(.opensearch())</code>',
html_divideDataQuery: '<code>.es(\'US\').divide(.es())</code>',
}"></p>
<p i18n-id="timeline.help.dataTransforming.paragraph4" i18n-default-message="Not bad, but this gives us a number between 0 and 1. To convert it
to a percentage, simply multiply by 100: {multiplyDataQuery}."
i18n-values="{ html_multiplyDataQuery: '<code>.opensearch(\'US\').divide(.opensearch()).multiply(100)</code>' }">
i18n-values="{ html_multiplyDataQuery: '<code>.es(\'US\').divide(.es()).multiply(100)</code>' }">
</p>
<p i18n-id="timeline.help.dataTransforming.paragraph5" i18n-default-message="Now we know what percentage of our traffic comes from the US, and
can see how it has changed over time! Timeline has a number of
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/timeline/public/partials/load_sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
></h2>

<saved-object-finder
type="timeline-sheet"
type="timelion-sheet"
use-local-management="true"
></saved-object-finder>
</form>
2 changes: 1 addition & 1 deletion src/plugins/timeline/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class TimelinePlugin implements Plugin<void, void> {

initAngularBootstrap();
core.application.register({
id: 'timeline',
id: 'timelion',
title: 'Timeline',
order: 8000,
defaultPath: '#/',
Expand Down
Loading