-
Notifications
You must be signed in to change notification settings - Fork 19
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
root
committed
Apr 30, 2016
0 parents
commit 77dadab
Showing
9 changed files
with
238 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2015 Sylvain Beynard | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,46 @@ | ||
|
||
kibana-plugin-traffic | ||
===================== | ||
|
||
|
||
Introduction | ||
------------- | ||
|
||
Ce plugin permet la création d'un graphique de type feu tricolor sur Kibana Version 4.2.2, 4.3.0, 4.4.0, 4.5.0: | ||
|
||
* Définition du label | ||
* Définition des niveaux | ||
|
||
Contenu | ||
------- | ||
``` | ||
. | ||
├── index.js | ||
├── package.json | ||
├── public | ||
│ ├── traffic_sg_controller.js | ||
│ ├── traffic_sg.html | ||
│ ├── traffic_sg.js | ||
│ ├── traffic_sg.less | ||
│ └── traffic_sg_params.html | ||
└── README.md | ||
``` | ||
Le plugin a été créé à partir des librairies Kibana et basé sur le framework Angularjs. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
``` | ||
$ cd <path>/kibana/installedPlugins | ||
$ git clone <depot> traffic-sg | ||
``` | ||
|
||
|
||
Désinstallation | ||
--------------- | ||
|
||
``` | ||
$ bin/kibana plugin --remove traffic_sg | ||
``` | ||
|
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,12 @@ | ||
'use strict'; | ||
|
||
module.exports = function (kibana) { | ||
|
||
return new kibana.Plugin({ | ||
|
||
uiExports: { | ||
visTypes: ['plugins/traffic_sg/traffic_sg'] | ||
} | ||
|
||
}); | ||
}; |
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,4 @@ | ||
{ | ||
"name": "traffic_sg", | ||
"version": "0.0.1" | ||
} |
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,13 @@ | ||
<div ng-controller="KbnTrafficVisController" class="traffic-vis"> | ||
<div class="traffic-container" ng-repeat="metric in metrics"> | ||
<div class="traffic-light-container" ng-style="{'width': vis.params.width+'px', 'height': (2.68 * vis.params.width)+'px' }"> | ||
<div class="traffic-light"> | ||
<div class="light red" ng-class="{'on': metric.value <= vis.params.redThreshold && !vis.params.invertScale, 'oninvert': metric.value >= vis.params.redThreshold && vis.params.invertScale }"></div> | ||
<div class="light yellow" ng-class="{'on': metric.value > vis.params.redThreshold && metric.value < vis.params.greenThreshold && !vis.params.invertScale, 'oninvert': vis.params.redThreshold > metric.value && metric.value > vis.params.greenThreshold && vis.params.invertScale}"></div> | ||
<div class="light green" ng-class="{'on': metric.value >= vis.params.greenThreshold && !vis.params.invertScale, 'oninvert': metric.value <= vis.params.greenThreshold && vis.params.invertScale }"></div> | ||
</div> | ||
</div> | ||
<br/> | ||
<div>{{title}}</div> | ||
</div> | ||
</div> |
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,60 @@ | ||
define(function (require) { | ||
|
||
// we need to load the css ourselves | ||
require('plugins/traffic_sg/traffic_sg.less'); | ||
|
||
// we also need to load the controller and used by the template | ||
require('plugins/traffic_sg/traffic_sg_controller'); | ||
|
||
// register the provider with the visTypes registry | ||
require('ui/registry/vis_types').register(MetricVisProvider); | ||
|
||
function MetricVisProvider(Private) { | ||
var TemplateVisType = Private(require('ui/template_vis_type/TemplateVisType')); | ||
var Schemas = Private(require('ui/Vis/Schemas')); | ||
|
||
// return the visType object, which kibana will use to display and configure new | ||
// Vis object of this type. | ||
return new TemplateVisType({ | ||
name: 'traffic', | ||
title: 'Traffic', | ||
description: 'Chart display lights of a standard color green/yellow/red', | ||
icon: 'fa-thumbs-up', | ||
template: require('plugins/traffic_sg/traffic_sg.html'), | ||
params: { | ||
defaults: { | ||
titleTraffic: null, | ||
fontSize: 60, | ||
width: 50, | ||
redThreshold: 20, | ||
greenThreshold: 80, | ||
invertScale: null | ||
}, | ||
editor: require('plugins/traffic_sg/traffic_sg_params.html') | ||
}, | ||
schemas: new Schemas([ | ||
{ | ||
group: 'metrics', | ||
name: 'metric', | ||
title: 'Metric', | ||
min: 1, | ||
max: 1, | ||
defaults: [ | ||
{ type: 'count', schema: 'metric' } | ||
] | ||
}, | ||
{ | ||
group: 'buckets', | ||
name: 'segment', | ||
title: 'X-Axis', | ||
min: 0, | ||
max: 1, | ||
aggFilter: ['terms'] | ||
} | ||
]) | ||
}); | ||
} | ||
|
||
// export the provider so that the visType can be required with Private() | ||
return MetricVisProvider; | ||
}); |
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,45 @@ | ||
@import (reference) "~ui/styles/mixins.less"; | ||
|
||
|
||
.traffic-vis { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
justify-content: space-around; | ||
align-items: center; | ||
align-content: space-around; | ||
|
||
.traffic-container { | ||
text-align: center; | ||
padding: 1em; | ||
width:100%; | ||
position:relative; | ||
} | ||
|
||
.traffic-light-container { | ||
margin:0 auto; | ||
.traffic-light { | ||
display:inline-block; | ||
width:100%; height:100%; | ||
border-radius:10px; | ||
background-color:#333; | ||
.light { | ||
margin:16%; | ||
width: 68%; height:25%; | ||
border-radius:50%; | ||
background-color:#000; | ||
&.on { | ||
&.red { background-color:#d9534f; } | ||
&.yellow { background-color:#f0ad4e; } | ||
&.green { background-color:#5cb85c; } | ||
} | ||
&.oninvert { | ||
&.red { background-color:#d9534f; } | ||
&.yellow { background-color:#f0ad4e; } | ||
&.green { background-color:#5cb85c; } | ||
} | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
define(function (require) { | ||
|
||
var module = require('ui/modules').get('kibana/traffic_sg', ['kibana']); | ||
|
||
module.controller('KbnTrafficVisController', function ($scope, Private) { | ||
var tabifyAggResponse = Private(require('ui/agg_response/tabify/tabify')); | ||
var metrics = $scope.metrics = []; | ||
var title = null; | ||
|
||
$scope.processTableGroups = function (tableGroups) { | ||
tableGroups.tables.forEach(function (table) { | ||
table.columns.forEach(function (column, i) { | ||
var fieldFormatter = table.aggConfig(column).fieldFormatter(); | ||
metrics[0] = {label: column.title, value: table.rows[0][i]}; | ||
}); | ||
}); | ||
}; | ||
|
||
$scope.$watch('esResponse', function (resp) { | ||
if (resp) { | ||
metrics.length = 0; | ||
$scope.processTableGroups(tabifyAggResponse($scope.vis, resp)); | ||
title = ( !$scope.vis.params.titleTraffic ) ? $scope.metrics[0].label : $scope.vis.params.titleTraffic; | ||
$scope.title = title; | ||
} | ||
}); | ||
}); | ||
}); |
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,22 @@ | ||
<div class="form-group"> | ||
<label>Title</label> | ||
<input type="text" ng-model="vis.params.titleTraffic" class="form-control"/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Traffic light width - {{ vis.params.width }}px</label> | ||
<input type="range" ng-model="vis.params.width" class="form-control" min="30" max="120"/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Red threshold</label> | ||
<input type="number" ng-model="vis.params.redThreshold" class="form-control"/> | ||
</div> | ||
<div class="form-group"> | ||
<label>Green threshold</label> | ||
<input type="number" ng-model="vis.params.greenThreshold" class="form-control"/> | ||
</div> | ||
<div class="form-group"> | ||
<label> | ||
<input type="checkbox" ng-model="vis.params.invertScale"> | ||
Invert scale | ||
</label> | ||
</div> |