-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-49474-add-enterprise-license
- Loading branch information
Showing
18 changed files
with
337 additions
and
326 deletions.
There are no files selected for viewing
116 changes: 0 additions & 116 deletions
116
src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.js
This file was deleted.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.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,118 @@ | ||
/* | ||
* 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 { SearchSourceContract } from 'ui/courier'; | ||
import { SavedObject, SavedObjectKibanaServices } from 'ui/saved_objects/types'; | ||
import { createSavedObjectClass } from 'ui/saved_objects/saved_object'; | ||
import { extractReferences, injectReferences } from './saved_dashboard_references'; | ||
import { createDashboardEditUrl } from '../dashboard_constants'; | ||
|
||
import { esFilters, Query, RefreshInterval } from '../../../../../../plugins/data/public'; | ||
|
||
export interface SavedObjectDashboard extends SavedObject { | ||
id?: string; | ||
timeRestore: boolean; | ||
timeTo?: string; | ||
timeFrom?: string; | ||
description?: string; | ||
panelsJSON: string; | ||
optionsJSON?: string; | ||
// TODO: write a migration to rid of this, it's only around for bwc. | ||
uiStateJSON?: string; | ||
lastSavedTitle: string; | ||
refreshInterval?: RefreshInterval; | ||
searchSource: SearchSourceContract; | ||
getQuery(): Query; | ||
getFilters(): esFilters.Filter[]; | ||
} | ||
|
||
// Used only by the savedDashboards service, usually no reason to change this | ||
export function createSavedDashboardClass(services: SavedObjectKibanaServices) { | ||
const SavedObjectClass = createSavedObjectClass(services); | ||
class SavedDashboard extends SavedObjectClass { | ||
// save these objects with the 'dashboard' type | ||
public static type = 'dashboard'; | ||
|
||
// if type:dashboard has no mapping, we push this mapping into ES | ||
public static mapping = { | ||
title: 'text', | ||
hits: 'integer', | ||
description: 'text', | ||
panelsJSON: 'text', | ||
optionsJSON: 'text', | ||
version: 'integer', | ||
timeRestore: 'boolean', | ||
timeTo: 'keyword', | ||
timeFrom: 'keyword', | ||
refreshInterval: { | ||
type: 'object', | ||
properties: { | ||
display: { type: 'keyword' }, | ||
pause: { type: 'boolean' }, | ||
section: { type: 'integer' }, | ||
value: { type: 'integer' }, | ||
}, | ||
}, | ||
}; | ||
public static fieldOrder = ['title', 'description']; | ||
public static searchSource = true; | ||
public showInRecentlyAccessed = true; | ||
|
||
constructor(id: string) { | ||
super({ | ||
type: SavedDashboard.type, | ||
mapping: SavedDashboard.mapping, | ||
searchSource: SavedDashboard.searchSource, | ||
extractReferences, | ||
injectReferences, | ||
|
||
// 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: '', | ||
hits: 0, | ||
description: '', | ||
panelsJSON: '[]', | ||
optionsJSON: JSON.stringify({ | ||
// for BWC reasons we can't default dashboards that already exist without this setting to true. | ||
useMargins: !id, | ||
hidePanelTitles: false, | ||
}), | ||
version: 1, | ||
timeRestore: false, | ||
timeTo: undefined, | ||
timeFrom: undefined, | ||
refreshInterval: undefined, | ||
}, | ||
}); | ||
this.getFullPath = () => `/app/kibana#${createDashboardEditUrl(String(this.id))}`; | ||
} | ||
|
||
getQuery() { | ||
return this.searchSource!.getOwnField('query') || { query: '', language: 'kuery' }; | ||
} | ||
|
||
getFilters() { | ||
return this.searchSource!.getOwnField('filter') || []; | ||
} | ||
} | ||
|
||
return SavedDashboard; | ||
} |
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
Oops, something went wrong.