Skip to content

Commit

Permalink
Update for Kibana 7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
nabilbendafi committed Oct 23, 2020
1 parent 29453ba commit abb73fe
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 97 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Older version:
### Usage
Installation steps:
```
$ cd KIBANA_HOME/plugins
$ git clone https://github.com/nabilbendafi/country-flag-fieldformatters.git country-flag-fieldformatters
$ cd country-flag-fieldformatters
$ npm install
$ git clone -b v7.6.2 https://github.com/elastic/kibana
$ cd kibana
$ git clone https://github.com/nabilbendafi/country-flag-fieldformatters.git plugins/country-flag-fieldformatters
$ cd plugins/country-flag-fieldformatters
$ yarn kbn bootstrap
$ yarn build
```
or
This will provide a `build/country-flag-fieldformatters-X.X.X.zip` ready to be installed

or install released plugin from Github.
```
$ bin/kibana-plugin install https://github.com/nabilbendafi/country-flag-fieldformatters/releases/download/v1.3.0/country-flag-fieldformatters-1.3.0.zip
```
Expand Down
Binary file modified images/configuration.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions index.js

This file was deleted.

10 changes: 10 additions & 0 deletions kibana.json
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": []
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"description": "Field formatters plugin for Kibana that display country flag based on its 'ISO 3166-1 alpha-2' code.",
"url": "https://github.com/nabilbendafi/country-flag-fieldformatters/issues",
"author": "Nabil Bendafi <nabil@bendafi.fr>",
"main": "public/index.ts",
"kibana": {
"version": "7.3.0"
},
"scripts": {
"kbn": "node ../../scripts/kbn",
"start": "plugin-helpers start",
"test:server": "plugin-helpers test:server",
"test:browser": "plugin-helpers test:browser",
Expand All @@ -21,14 +23,18 @@
"flag-icon-css": "2.8.0"
},
"devDependencies": {
"@elastic/eslint-config-kibana": "0.0.2",
"@elastic/plugin-helpers": "^6.0.0",
"@elastic/eslint-config-kibana": "link:../../packages/eslint-config-kibana",
"@kbn/plugin-helpers": "link:../../packages/kbn-plugin-helpers",
"babel-eslint": "^4.1.6",
"babel-preset-es2015": "^6.3.13",
"babel-register": "^6.4.3",
"bluebird": "^3.1.5",
"eslint": ">=4.18.2",
"eslint-plugin-mocha": "^1.1.0",
"lodash": "^4.0.1"
"lodash": "^4.0.1",
"typescript": "4.0.2"
},
"engines": {
"yarn": "^1.21.1"
}
}
80 changes: 0 additions & 80 deletions public/country-flag.js

This file was deleted.

52 changes: 52 additions & 0 deletions public/country-flag.ts
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;
}
};
26 changes: 26 additions & 0 deletions public/index.ts
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';
71 changes: 71 additions & 0 deletions public/plugin.ts
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() {}
}
21 changes: 21 additions & 0 deletions public/types.ts
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 {}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"include": [
"server/**/*",
"public/**/*"
]
}

0 comments on commit abb73fe

Please sign in to comment.