Skip to content

Commit

Permalink
[sankey][7.10.2] Update the Plugin to Kibana's new Platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ch-bas committed Feb 19, 2021
1 parent 604747a commit 8ac7a8b
Show file tree
Hide file tree
Showing 29 changed files with 1,138 additions and 246 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
/build
/local
/target
29 changes: 29 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
env:
browser: true
es6: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 2018
sourceType: module
rules:
"prettier/prettier": off
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-trailing-spaces:
- 2
- skipBlankLines: false
no-console: error
overrides:
- files: ['index.js']
env:
node: true
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
node_modules/*
.nyc_output
node_modules/
build/
target/
local
npm-debug.log*
package-lock.json
yarn.lock
.project
*.zip
3 changes: 0 additions & 3 deletions .jshintrc

This file was deleted.

11 changes: 0 additions & 11 deletions index.js

This file was deleted.

16 changes: 16 additions & 0 deletions kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "kbnSankeyVis",
"version": "7.10.2",
"server": false,
"ui": true,
"requiredPlugins": [
"visualizations",
"data",
"inspector",
"kibanaLegacy"
],
"requiredBundles": [
"kibanaUtils",
"visDefaultEditor"
]
}
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "kbn_sankey_vis",
"version": "7.6.3",
"name": "kbn-sankey-vis",
"version": "7.10.2",
"kibana": {
"version": "kibana"
},
"authors": [
"Chenryn <rao.chenlin@gmail.com>",
"Ch-bas <bassem.chagra@uniberg.com>"
Expand All @@ -11,14 +14,17 @@
"repository": "https://github.com/uniberg/kbn_sankey_vis.git",
"main": "index.js",
"scripts": {
"test": "nyc --all mocha"
"start": "cd ../.. && node scripts/kibana --dev --oss",
"test": "nyc --all mocha",
"build": "yarn plugin-helpers build",
"plugin-helpers": "node ../../scripts/plugin_helpers"
},
"dependencies": {
"d3-plugins-sankey": "https://github.com/uniberg/d3-plugins-sankey.git",
"json-stable-stringify": "^1.0.1"
},
"devDependencies": {
"@fortawesome/fontawesome-free": "^5.10.2",
"@fortawesome/fontawesome-free": "5.15.2",
"mocha": "~5.0.4",
"nyc": "^13.3.0"
}
Expand Down
24 changes: 24 additions & 0 deletions public/components/sankey_options.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 React from 'react';
// For the current version of the Sankey Diagram, we do not need any option
// returning a react component is required
export const SankeyOptions = () => (
<></>
);
13 changes: 13 additions & 0 deletions public/enhanced-table-vis-params.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.enhanced-table-vis-params {

.computed-columns .euiButtonIcon {
font-size: 0.8rem;
min-width: 12px;
padding: 0px;
}

.ng-invalid.ng-touched .form-control, .ng-invalid.display-error .form-control {
border-color: #BD271E;
}
}

11 changes: 11 additions & 0 deletions public/field_formatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getFormatService } from './services';
import { IAggConfig, IFieldFormat, FieldFormatsContentType } from '../../../src/plugins/data/public';

/**
* Returns the fieldFormatter function associated to aggConfig, for the requested contentType (html or text).
* Returned fieldFormatter is a function, whose prototype is: fieldFormatter(value, options?)
*/
export function fieldFormatter(aggConfig: IAggConfig, contentType: FieldFormatsContentType) {
const fieldFormat: IFieldFormat = getFormatService().deserialize(aggConfig.toSerializedFieldFormat());
return fieldFormat.getConverterFor(contentType);
}
83 changes: 83 additions & 0 deletions public/get_inner_angular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.
*/

// inner angular imports
// these are necessary to bootstrap the local angular.
// They can stay even after NP cutover
import angular from 'angular';
// required for `ngSanitize` angular module
import 'angular-sanitize';
import 'angular-recursion';
import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
import { CoreStart, IUiSettingsClient, PluginInitializerContext } from 'kibana/public';
import {
initAngularBootstrap,
PaginateDirectiveProvider,
PaginateControlsDirectiveProvider,
PrivateProvider,
watchMultiDecorator,
KbnAccessibleClickProvider,
} from '../../../src/plugins/kibana_legacy/public';

initAngularBootstrap();

const thirdPartyAngularDependencies = ['ngSanitize', 'ui.bootstrap', 'RecursionHelper'];

export function getAngularModule(name: string, core: CoreStart, context: PluginInitializerContext) {
const uiModule = getInnerAngular(name, core);
return uiModule;
}

let initialized = false;

export function getInnerAngular(name = 'kibana/kbn_sankey_vis', core: CoreStart) {
if (!initialized) {
createLocalPrivateModule();
createLocalConfigModule(core.uiSettings);
initialized = true;
}
return angular
.module(name, [
...thirdPartyAngularDependencies,
'tableVisConfig',
'tableVisPrivate',
])
.config(watchMultiDecorator)
.directive('kbnAccessibleClick', KbnAccessibleClickProvider);
}

function createLocalPrivateModule() {
angular.module('tableVisPrivate', []).provider('Private', PrivateProvider);
}

function createLocalConfigModule(uiSettings: IUiSettingsClient) {
angular.module('tableVisConfig', []).provider('config', function () {
return {
$get: () => ({
get: (value: string) => {
return uiSettings ? uiSettings.get(value) : undefined;
},
// set method is used in agg_table mocha test
set: (key: string, value: string) => {
return uiSettings ? uiSettings.set(key, value) : undefined;
},
}),
};
});
}
19 changes: 19 additions & 0 deletions public/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
visualization.enhanced-table {
padding: 0px 5px;
}

.enhanced-table-vis {
$euiColorLightestShade: #F5F7FA;
@import 'agg_table/index';
@import 'paginated_table/index';
@import 'enhanced-table-vis';
}

.theme-dark.enhanced-table-vis {
$euiColorLightestShade: #25262E;
@import 'agg_table/index';
@import 'paginated_table/index';
@import 'enhanced-table-vis';
}

@import 'enhanced-table-vis-params';
24 changes: 24 additions & 0 deletions public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 { PluginInitializerContext } from 'kibana/public';
import { EnhancedTablePlugin as Plugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
return new Plugin(initializerContext);
}
44 changes: 32 additions & 12 deletions public/kbn_sankey_vis.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
<div ng-controller="KbnSankeyVisController" class="kbn-sankey" style="
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
position: relative;
padding: 8px;
">
<div class="table-vis-error" ng-if="emptyGraph">
<h2 aria-hidden="true"><i class="fa fa-meh-o" aria-hidden="true"></i></h2>
<h4>No results found</h4>
<div ng-controller="KbnSankeyVisController" class="kbn-sankey">

<div ng-if="!hasSomeRows && hasSomeRows !== null" class="visError">
<div class="euiText euiText--extraSmall euiTextColor euiTextColor--subdued">
<icon type="'visualizeApp'" size="'m'" color="'subdued'"></icon>

<br>
<br>

<p
i18n-id="visTypeTable.vis.noResultsFoundTitle"
i18n-default-message="No results found">
</p>
</div>
</div>

<div ng-if="hasSomeRows" class="table-vis-container" ng-class="tableVisContainerClass" data-test-subj="tableVis">
pppppp {{hasSomeRows}}
<kbn-enhanced-agg-table-group
filter="vis.API.events.filter"
group="tableGroups"
export-title="visState.title"
per-page="visState.params.perPage"
sort="sort"
show-total="visState.params.showTotal"
total-func="visState.params.totalFunc"
csv-export-with-total="visState.params.csvExportWithTotal && visState.params.showTotal"
csv-full-export="visState.params.csvFullExport && visState.params.computedColumns.length === 0 && !visState.params.linesComputedFilter && !visState.params.hiddenColumns && !visState.params.csvExportWithTotal && !visState.params.addRowNumberColumn"
csv-encoding="visState.params.csvEncoding || 'utf-8'"
field-columns="visState.params.fieldColumns">

</kbn-enhanced-agg-table-group>
</div>
<div class="metric-container" ng-model="metrics"></div>
</div>
Loading

0 comments on commit 8ac7a8b

Please sign in to comment.