-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Expose NP FieldFormats service to server side #55419
Changes from 3 commits
08c845d
7752b6e
02df835
e86b069
0be4619
b763a66
9bb6300
cd12136
0b1985f
73ee1e6
8162165
380a921
9f0cf97
223738e
81414fb
1aa0097
3d4adc3
b25d81a
32388e4
d76ceb3
369b1c0
91e6d12
74d5735
b205ba6
523d4b5
7ff4c2d
5072086
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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 { has } from 'lodash'; | ||
import { FieldFormats } from './field_formats'; | ||
import { IFieldFormatType } from '../../common/field_formats'; | ||
import { IUiSettingsClient } from '../../../../core/server'; | ||
|
||
import { | ||
UrlFormat, | ||
StringFormat, | ||
NumberFormat, | ||
BytesFormat, | ||
TruncateFormat, | ||
RelativeDateFormat, | ||
PercentFormat, | ||
IpFormat, | ||
DurationFormat, | ||
DateNanosFormat, | ||
DateFormat, | ||
ColorFormat, | ||
BoolFormat, | ||
SourceFormat, | ||
StaticLookupFormat, | ||
} from '../../common/field_formats'; | ||
|
||
export class FieldFormatsService { | ||
lizozom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private readonly fieldFormatClasses: IFieldFormatType[] = [ | ||
UrlFormat, | ||
StringFormat, | ||
NumberFormat, | ||
BytesFormat, | ||
TruncateFormat, | ||
RelativeDateFormat, | ||
PercentFormat, | ||
IpFormat, | ||
DurationFormat, | ||
DateNanosFormat, | ||
DateFormat, | ||
ColorFormat, | ||
BoolFormat, | ||
SourceFormat, | ||
StaticLookupFormat, | ||
]; | ||
|
||
public setup() { | ||
return { | ||
registerFieldFormat: (customFieldFormat: IFieldFormatType) => | ||
this.fieldFormatClasses.push(customFieldFormat), | ||
}; | ||
} | ||
|
||
public start() { | ||
return { | ||
fieldFormatServiceFactory: async (uiSettings: IUiSettingsClient) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function needs refactoring - (a) we can get Changing this would make the interfaces of the FE\BE plugins the same. |
||
const uiConfigs = await uiSettings.getAll(); | ||
const registeredUiSettings = uiSettings.getRegistered(); | ||
|
||
Object.keys(registeredUiSettings).forEach(key => { | ||
if (has(uiConfigs, key) && registeredUiSettings[key].type === 'json') { | ||
uiConfigs[key] = JSON.parse(uiConfigs[key]); | ||
} | ||
}); | ||
|
||
return new FieldFormats(this.fieldFormatClasses, (key: string) => uiConfigs[key]); | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
export type FieldFormatsServiceSetup = ReturnType<FieldFormatsService['setup']>; | ||
export type FieldFormatsServiceStart = ReturnType<FieldFormatsService['start']>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified to add support for:
x-pack/legacy/plugins/reporting/export_types/csv/server/