forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Timelion] deangularize and typescriptify saved_object usage (elastic…
- Loading branch information
Showing
5 changed files
with
103 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 0 additions & 82 deletions
82
src/legacy/core_plugins/timelion/public/services/_saved_sheet.js
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
src/legacy/core_plugins/timelion/public/services/_saved_sheet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { createSavedObjectClass } from 'ui/saved_objects/saved_object'; | ||
import { SavedObjectKibanaServices } from 'ui/saved_objects/types'; | ||
import { IUiSettingsClient } from 'kibana/public'; | ||
|
||
// Used only by the savedSheets service, usually no reason to change this | ||
export function createSavedSheetClass( | ||
services: SavedObjectKibanaServices, | ||
config: IUiSettingsClient | ||
) { | ||
const SavedObjectClass = createSavedObjectClass(services); | ||
|
||
class SavedSheet extends SavedObjectClass { | ||
static type = 'timelion-sheet'; | ||
|
||
// if type:sheet has no mapping, we push this mapping into ES | ||
static mapping = { | ||
title: 'text', | ||
hits: 'integer', | ||
description: 'text', | ||
timelion_sheet: 'text', | ||
timelion_interval: 'keyword', | ||
timelion_other_interval: 'keyword', | ||
timelion_chart_height: 'integer', | ||
timelion_columns: 'integer', | ||
timelion_rows: 'integer', | ||
version: 'integer', | ||
}; | ||
|
||
// Order these fields to the top, the rest are alphabetical | ||
static fieldOrder = ['title', 'description']; | ||
// SavedSheet constructor. Usually you'd interact with an instance of this. | ||
// ID is option, without it one will be generated on save. | ||
constructor(id: string) { | ||
super({ | ||
type: SavedSheet.type, | ||
mapping: SavedSheet.mapping, | ||
|
||
// if this is null/undefined then the SavedObject will be assigned the defaults | ||
id, | ||
|
||
// default values that will get assigned if the doc is new | ||
defaults: { | ||
title: 'New TimeLion Sheet', | ||
hits: 0, | ||
description: '', | ||
timelion_sheet: ['.es(*)'], | ||
timelion_interval: 'auto', | ||
timelion_chart_height: 275, | ||
timelion_columns: config.get('timelion:default_columns') || 2, | ||
timelion_rows: config.get('timelion:default_rows') || 2, | ||
version: 1, | ||
}, | ||
}); | ||
this.showInRecentlyAccessed = true; | ||
this.getFullPath = () => `/app/timelion#/${this.id}`; | ||
} | ||
} | ||
|
||
return SavedSheet; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters