-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29453ba
commit abb73fe
Showing
11 changed files
with
205 additions
and
97 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
{ | ||
"id": "countryFlag", | ||
"version": "7.6.2", | ||
"server": false, | ||
"ui": true, | ||
"requiredPlugins": [ | ||
"data" | ||
], | ||
"optionalPlugins": [] | ||
} |
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 _ from 'lodash'; | ||
|
||
import { FieldFormat, KBN_FIELD_TYPES } from '../../../src/plugins/data/public'; | ||
|
||
// Include CSS file from [flag-icon-css](https://www.npmjs.com/package/flag-icon-css) | ||
import 'flag-icon-css/css/flag-icon.css'; | ||
|
||
// Create a new FieldFormat type and inherit FieldFormat | ||
export class CountryFlagFieldFormat extends FieldFormat { | ||
// The id of this field format | ||
static id = 'countryFlag'; | ||
// The title of the field format, shown to the user | ||
static title = 'Country Flag'; | ||
// An array of types, which this field formatter can be used for. | ||
// You can only apply this field formatter to fields, that have one | ||
// of the here specified types. Possible types are: | ||
// number, boolean, date, ip, attachment, geo_point, geo_shape, string, murmur3 | ||
// murmur3 (Murmur3 plugin hashes), unknown (unknown field type), | ||
// conflict (fields that have different types in different indices matched by the index pattern) | ||
static fieldType = [ | ||
KBN_FIELD_TYPES.STRING, | ||
KBN_FIELD_TYPES.UNKNOWN | ||
]; | ||
|
||
textConvert = (value: string) => { | ||
return value; | ||
}; | ||
|
||
htmlConvert = (value: string) => { | ||
var html = '<span class="flag-icon flag-icon-' + value.toLowerCase() + '" tooltip="' + value + '"></span>'; | ||
return html; | ||
} | ||
}; |
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,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 { CountryFlagFieldFormatsPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new CountryFlagFieldFormatsPlugin(); | ||
} | ||
|
||
export { CountryFlagFieldFormatsPluginSetup, CountryFlagFieldFormatsPluginStart } from './types'; |
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,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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 { | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
PluginInitializerContext, | ||
} from '../../../src/core/public'; | ||
import { | ||
DataPublicPluginStart, | ||
DataPublicPluginSetup | ||
} from '../../../src/plugins/data/public'; | ||
|
||
import { CountryFlagFieldFormat } from './country-flag'; | ||
|
||
import { CountryFlagFieldFormatsPluginSetup, CountryFlagFieldFormatsPluginStart } from './types'; | ||
|
||
interface CountryFlagFieldFormatsPluginSetupDeps { | ||
data: DataPublicPluginSetup; | ||
} | ||
|
||
interface CountryFlagFieldFormatsPluginStartDeps { | ||
data: DataPublicPluginStart; | ||
} | ||
|
||
export class CountryFlagFieldFormatsPlugin | ||
implements Plugin<CountryFlagFieldFormatsPluginSetupDeps, CountryFlagFieldFormatsPluginStartDeps> { | ||
|
||
initializerContext: PluginInitializerContext; | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.initializerContext = initializerContext; | ||
} | ||
|
||
public setup( | ||
core: CoreSetup, | ||
{ data }: CountryFlagFieldFormatsPluginSetupDeps | ||
): CountryFlagFieldFormatsPluginSetup { | ||
data.fieldFormats.register([CountryFlagFieldFormat]); | ||
|
||
return {}; | ||
} | ||
|
||
public start( | ||
core: CoreStart, | ||
{ data }: CountryFlagFieldFormatsPluginStartDeps | ||
): CountryFlagFieldFormatsPluginStart { | ||
data.fieldFormats.getType('countryFlag'); | ||
|
||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
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,21 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF 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. | ||
*/ | ||
|
||
export interface CountryFlagFieldFormatsPluginSetup {} | ||
export interface CountryFlagFieldFormatsPluginStart {} |
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,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [ | ||
"server/**/*", | ||
"public/**/*" | ||
] | ||
} |