Skip to content

Commit f9de722

Browse files
committed
Code restructure
1 parent 6dd44be commit f9de722

File tree

22 files changed

+5529
-418
lines changed

22 files changed

+5529
-418
lines changed

.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
---
22
extends: "@elastic/kibana"
3+
4+
settings:
5+
import/resolver:
6+
'@elastic/eslint-import-resolver-kibana':
7+
rootPackageName: 'indices_view'

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
npm-debug.log*
22
node_modules
33
/build/
4-
package-lock.json

.kibana-plugin-helpers.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"styleSheetToCompile": "public/app.scss"
3+
}

README.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# indies_view
1+
# indices_view
2+
3+
> An awesome kibana plugin for view indies!
4+
5+
---
6+
27
## Language
38
- [EN](./README.md)
49
- [中文](./README_ZH.md)
@@ -13,41 +18,56 @@
1318
## Reg pattern
1419

1520
```
16-
1. /[^a-z]+$/
17-
2. /[\d]{4}[-|\.|/][\d]{1,2}[-|\.|/][\d]{1,2}/
21+
1. [^a-z]+$
22+
2. [\d]{4}[-|\.|/][\d]{1,2}[-|\.|/][\d]{1,2}
23+
```
24+
25+
## Config
26+
kibana.yml
27+
28+
1. mergePattern
29+
30+
merge pattern,default value is '[^a-z]+$'. you can edit it. like:
31+
```
32+
indices_view.mergePattern: '[\d]{4}[-|\.|/][\d]{1,2}[-|\.|/][\d]{1,2}'
1833
```
1934
## Development
2035

21-
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. Once you have completed that, use the following npm tasks.
36+
See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. Once you have completed that, use the following yarn scripts.
37+
38+
- `yarn kbn bootstrap`
2239

23-
- `npm start`
40+
Install dependencies and crosslink Kibana and all projects/plugins.
2441

25-
Start kibana and have it include this plugin
42+
> ***IMPORTANT:*** Use this script instead of `yarn` to install dependencies when switching branches, and re-run it whenever your dependencies change.
2643
27-
- `npm start -- --config kibana.yml`
44+
- `yarn start`
2845

29-
You can pass any argument that you would normally send to `bin/kibana` by putting them after `--` when running `npm start`
46+
Start kibana and have it include this plugin. You can pass any arguments that you would normally send to `bin/kibana`
3047

31-
- `npm run build`
48+
```
49+
yarn start --elasticsearch.url http://localhost:9220
50+
```
3251
33-
Build a distributable archive
52+
- `yarn build`
3453
35-
- `npm run test:browser`
54+
Build a distributable archive of your plugin.
3655
37-
Run the browser tests in a real web browser
56+
- `yarn test:browser`
3857
39-
- `npm run test:server`
58+
Run the browser tests in a real web browser.
4059
41-
Run the server tests using mocha
60+
- `yarn test:server`
4261
43-
For more information about any of these commands run `npm run ${task} -- --help`.
62+
Run the server tests using mocha.
4463
64+
For more information about any of these commands run `yarn ${task} --help`. For a full list of tasks checkout the `package.json` file, or run `yarn run`.
4565
## Deploy
4666
4767
**important** : edit this plugin version and kibana.version to you kibana version in package.json
4868
49-
- `npm install`
50-
- `npm run build`
69+
- `yarn kbn bootstrap`
70+
- `yarn build`
5171
5272
Build a distributable archive
5373

README_ZH.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,53 @@
1919
1. /[^a-z]+$/
2020
2. /[\d]{4}[-|\.|/][\d]{1,2}[-|\.|/][\d]{1,2}/
2121
```
22+
## 配置
23+
kibana.yml
24+
25+
1. mergePattern
26+
27+
默认值是 '[^a-z]+$'. 你可以按如下格式修改:
28+
```
29+
indices_view.mergePattern: '[\d]{4}[-|\.|/][\d]{1,2}[-|\.|/][\d]{1,2}'
30+
```
2231
## 开发流程
2332

24-
查看[kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) 官方文档,构建开发环境,搭建好环境后,按以下步骤进行。
33+
查看 [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) 官方文档,构建开发环境,搭建好环境后,按以下步骤进行。
34+
35+
- `yarn kbn bootstrap`
36+
37+
安装所有依赖,并建立所有插件与kibana连接。
2538

26-
- `npm start`
39+
> ***重要:*** 使用 `yarn` 代替安装依赖,无论是切换分支还是其他需要重新下载依赖的情况.
2740
28-
启动kibana
41+
- `yarn start`
2942

30-
- `npm start -- --config kibana.yml`
43+
Start kibana and have it include this plugin. You can pass any arguments that you would normally send to `bin/kibana`
3144

32-
可以通过这个命令指定kibana 配置文件
45+
```
46+
yarn start --elasticsearch.url http://localhost:9220
47+
```
3348
34-
- `npm run build`
49+
- `yarn build`
3550
3651
生成编译包
3752
38-
- `npm run test:browser`
53+
- `yarn test:browser`
3954
4055
在web 浏览器中测试
4156
42-
- `npm run test:server`
57+
- `yarn test:server`
4358
4459
用mocha 测试服务端
4560
46-
更多信息执行`npm run ${task} -- --help`.
61+
更多信息执行`yarn ${task} --help`. 完整任务列表查看`package.json` 文件, 或者运行 `yarn run`.
4762
4863
## 部署
4964
5065
**重要** : 修改这个插件的版本kibana.version 和你在kibana package.json 中的版本保持一致!
5166
52-
- `npm install`
53-
- `npm run build`
67+
- `yarn kbn bootstrap`
68+
- `yarn build`
5469
5570
按以上步骤生成安装包。
5671

TRANSLATION.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

gather-info.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

index.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
1-
2-
import serverRoute from './server/routes/server';
1+
import serverRoute from './server/routes/serverRoute';
2+
const elasticsearch = require('elasticsearch');
33
export default function (kibana) {
44
return new kibana.Plugin({
55
require: ['elasticsearch'],
66
name: 'indices_view',
77
uiExports: {
8-
98
app: {
109
title: 'Indices View',
11-
description: 'An awesome kibana plugin for view indices!',
10+
description: 'An awesome kibana plugin for view indies!',
11+
main: 'plugins/indices_view/app',
1212
icon: 'plugins/indices_view/icon.svg',
13-
main: 'plugins/indices_view/app'
13+
styleSheetPath: require('path').resolve(__dirname, 'public/app.scss'),
1414
},
15+
injectDefaultVars: function (server) {
16+
const config = server.config();
17+
const pattern = config.get('indices_view.mergePattern');
18+
return {
19+
mergePattern: pattern,
20+
};
21+
}
1522
},
1623

24+
config(Joi) {
25+
return Joi.object({
26+
enabled: Joi.boolean().default(true),
27+
mergePattern: Joi.string().default('[^a-z]+$'),
28+
}).default();
29+
},
1730

18-
init(server) {
31+
init(server, options) { // eslint-disable-line no-unused-vars
1932
// Add server routes and initialize the plugin here
20-
serverRoute(server);
33+
const config = server.config();
34+
const client = new elasticsearch.Client({
35+
host: config.get('elasticsearch.url'),
36+
//log: 'trace'
37+
requestTimeout: 120000
38+
});
39+
serverRoute(server, client);
2140
}
22-
23-
2441
});
25-
}
42+
}

package.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,34 @@
55
"main": "index.js",
66
"kibana": {
77
"version": "kibana",
8-
"templateVersion": "7.2.3"
8+
"templateVersion": "1.0.0"
99
},
1010
"scripts": {
11-
"lint": "eslint",
11+
"preinstall": "node ../../kibana/preinstall_check",
12+
"kbn": "node ../../kibana/scripts/kbn",
13+
"lint": "eslint .",
1214
"start": "plugin-helpers start",
1315
"test:server": "plugin-helpers test:server",
1416
"test:browser": "plugin-helpers test:browser",
15-
"build": "plugin-helpers build",
16-
"postinstall": "plugin-helpers postinstall",
17-
"gather-info": "node gather-info.js"
17+
"build": "plugin-helpers build"
1818
},
1919
"devDependencies": {
20-
"@elastic/eslint-config-kibana": "^0.6.1",
21-
"@elastic/plugin-helpers": "^7.0.2",
22-
"babel-eslint": "^7.2.3",
23-
"eslint": "^3.19.0",
20+
"@elastic/eslint-config-kibana": "link:../../kibana/packages/eslint-config-kibana",
21+
"@elastic/eslint-import-resolver-kibana": "link:../../kibana/packages/kbn-eslint-import-resolver-kibana",
22+
"@kbn/plugin-helpers": "link:../../kibana/packages/kbn-plugin-helpers",
23+
"babel-eslint": "^8.0.2",
24+
"eslint": "^4.11.0",
2425
"eslint-plugin-babel": "^4.1.1",
2526
"eslint-plugin-import": "^2.3.0",
27+
"eslint-plugin-jest": "^21.3.2",
2628
"eslint-plugin-mocha": "^4.9.0",
29+
"eslint-plugin-no-unsanitized": "^3.0.2",
30+
"eslint-plugin-prefer-object-spread": "^1.2.1",
2731
"eslint-plugin-react": "^7.0.1",
2832
"expect.js": "^0.3.1"
2933
},
3034
"dependencies": {
31-
"angular-ui-bootstrap": "^2.5.6",
32-
"elasticsearch": "^14.1.0"
35+
"axios": "^0.18.0",
36+
"elasticsearch": "^15.1.1"
3337
}
34-
}
38+
}

public/app.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)