diff --git a/Dockerfile b/Dockerfile index 4b8839b..a42037a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,6 +46,5 @@ ICAgICAgIAo=" COPY playbooks /opt/apb/actions COPY roles /opt/ansible/roles COPY vars /opt/ansible/vars -RUN yum install epel-release -y && yum install jq -y RUN chmod -R g=u /opt/{ansible,apb} USER apb diff --git a/roles/bind-metrics-apb/tasks/main.yml b/roles/bind-metrics-apb/tasks/main.yml index ba85058..61092b9 100644 --- a/roles/bind-metrics-apb/tasks/main.yml +++ b/roles/bind-metrics-apb/tasks/main.yml @@ -23,7 +23,7 @@ # Annotate the mobile client - name: Get metrics service instance name - shell: oc get serviceinstances -n {{ namespace }} -o json | jq '.items[] | select(.spec.externalID=="{{ _apb_service_instance_id }}") | .metadata.name' | cut -f2 -d'"' + shell: oc get serviceinstances -n {{ namespace }} -o jsonpath='{.items[?(@.spec.externalID=="{{ _apb_service_instance_id }}")].metadata.name}' register: metrics_si_name - set_fact: @@ -32,7 +32,7 @@ - set_fact: metricsEndpointAnnotation: "org.aerogear.binding.{{ metricsInstanceName }}/metrics_endpoint" grafanaUrlAnnotation: "org.aerogear.binding.{{ metricsInstanceName }}/grafana_url" - + - name: Annotate client {{ CLIENT_ID }} shell: 'oc annotate mobileclient {{ CLIENT_ID }} {{ item }} --overwrite=true -n {{ namespace }}' ignore_errors: yes @@ -54,4 +54,4 @@ - { name: clientId, value: '{{ CLIENT_ID }}' } - { name: metricsInstanceName, value: '{{ metricsInstanceName }}' } when: not encode_asb_binding - no_log: yes \ No newline at end of file + no_log: yes diff --git a/roles/provision-metrics-apb/defaults/main.yml b/roles/provision-metrics-apb/defaults/main.yml index 17b4cef..ea80e23 100644 --- a/roles/provision-metrics-apb/defaults/main.yml +++ b/roles/provision-metrics-apb/defaults/main.yml @@ -1,12 +1,12 @@ # Prometheus Values prometheus_image: "registry.access.redhat.com/openshift3/prometheus" -prometheus_version: "v3.9" +prometheus_version: "v3.11" prometheus_port: 9090 prometheus_proxy_port: 4180 # Grafana values -grafana_image: "docker.io/aerogear/grafana" -grafana_version: "v5.0.0-pre1" +grafana_image: "registry.access.redhat.com/openshift3/grafana" +grafana_version: "v3.11" grafana_port: 3000 grafana_proxy_port: 4181 grafana_log_level: debug @@ -26,5 +26,5 @@ postgres_password: "{{ POSTGRES_PASSWORD | default(lookup('password', '/tmp/pass postgres_database: "aerogear_mobile_metrics" # OAuth Proxy values -proxy_image: "docker.io/openshift/oauth-proxy" -proxy_version: "v1.1.0" +proxy_image: "registry.access.redhat.com/openshift3/oauth-proxy" +proxy_version: "v3.11" diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/.gitignore b/roles/provision-metrics-apb/files/grafana-piechart-panel/.gitignore new file mode 100644 index 0000000..00448a2 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/.gitignore @@ -0,0 +1,34 @@ +node_modules +npm-debug.log +coverage/ +.aws-config.json +awsconfig +/emails/dist +/public_gen +/tmp +vendor/phantomjs/phantomjs + +docs/AWS_S3_BUCKET +docs/GIT_BRANCH +docs/VERSION +docs/GITCOMMIT +docs/changed-files +docs/changed-files + +# locally required config files +public/css/*.min.css + +# Editor junk +*.sublime-workspace +*.swp +.idea/ +*.iml + +/data/* +/bin/* + +conf/custom.ini +fig.yml +profile.cov +grafana +.notouch diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/Gruntfile.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/Gruntfile.js new file mode 100644 index 0000000..29c79c2 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/Gruntfile.js @@ -0,0 +1,60 @@ +module.exports = function(grunt) { + + require('load-grunt-tasks')(grunt); + + grunt.loadNpmTasks('grunt-execute'); + grunt.loadNpmTasks('grunt-contrib-clean'); + + grunt.initConfig({ + + clean: ["dist"], + + copy: { + src_to_dist: { + cwd: 'src', + expand: true, + src: ['**/*', '**/*.js', '!**/*.scss'], + dest: 'dist' + }, + img_to_dist: { + cwd: 'src', + expand: true, + src: ['img/*'], + dest: 'dist/src/' + }, + pluginDef: { + expand: true, + src: [ 'plugin.json', 'README.md' ], + dest: 'dist', + } + }, + + watch: { + rebuild_all: { + files: ['src/**/*', 'plugin.json'], + tasks: ['default'], + options: {spawn: false} + }, + }, + + babel: { + options: { + sourceMap: true, + presets: ["es2015"], + plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"], + }, + dist: { + files: [{ + cwd: 'src', + expand: true, + src: ['*.js'], + dest: 'dist', + ext:'.js' + }] + }, + }, + + }); + + grunt.registerTask('default', ['clean', 'copy:src_to_dist', 'copy:img_to_dist', 'copy:pluginDef', 'babel']); +}; diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/LICENSE b/roles/provision-metrics-apb/files/grafana-piechart-panel/LICENSE new file mode 100644 index 0000000..4644c8c --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Grafana + +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. diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/README.md b/roles/provision-metrics-apb/files/grafana-piechart-panel/README.md new file mode 100644 index 0000000..afe5aee --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/README.md @@ -0,0 +1,74 @@ +Use the new grafana-cli tool to install piechart-panel from the commandline: + +``` +grafana-cli plugins install grafana-piechart-panel +``` + +The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins if you installed the grafana package. + +More instructions on the cli tool can be found [here](http://docs.grafana.org/v3.0/plugins/installation/). + +You need the lastest grafana build for Grafana 3.0 to enable plugin support. You can get it here : http://grafana.org/download/builds.html + +## Alternative installation method + +It is also possible to clone this repo directly into your plugins directory. + +Afterwards restart grafana-server and the plugin should be automatically detected and used. + +``` +git clone https://github.com/grafana/piechart-panel.git +sudo service grafana-server restart +``` + + +## Clone into a directory of your choice + +If the plugin is cloned to a directory that is not the default plugins directory then you need to edit your grafana.ini config file (Default location is at /etc/grafana/grafana.ini) and add this: + +```ini +[plugin.piechart] +path = /home/your/clone/dir/piechart-panel +``` + +Note that if you clone it into the grafana plugins directory you do not need to add the above config option. That is only +if you want to place the plugin in a directory outside the standard plugins directory. Be aware that grafana-server +needs read access to the directory. + +# Changelog + +## 1.3.3 + +* Fix legend sorting: [#145](https://github.com/grafana/piechart-panel/issues/145) + +## 1.3.2 + +* Automatically set legend width if Internet Explorer 11 and positioned to the right: [#148](https://github.com/grafana/piechart-panel/issues/148) + +## 1.3.1 + +* Fix scrolling and legend issues in Internet Explorer 11: [#143](https://github.com/grafana/piechart-panel/issues/143) + +## 1.3.0 + +* Fixes for legend and piechart rendering and sorting: [#138](https://github.com/grafana/piechart-panel/pull/138), [#136](https://github.com/grafana/piechart-panel/pull/136) +* Fix for decimal field for percentages [#108](https://github.com/grafana/piechart-panel/pull/108) + +## 1.1.5 + +* Fix for color picker in legend +* Fix for - [Values in legend are displayed raw, not with the correct unit](https://github.com/grafana/piechart-panel/issues/51). Thanks, [@conet](https://github.com/conet) +* Fix for - [Legend overlaps with graphs](https://github.com/grafana/piechart-panel/issues/34). Thanks, [@smalik03](https://github.com/smalik03) + +## 1.1.4 +* Add support for combining small slices (https://github.com/grafana/piechart-panel/pull/43) +* Add option to show percentage in legend https://github.com/grafana/piechart-panel/pull/41 + +## 1.0.2 + +* Add piechart piece divider setting +* Remove Unused code +* Adds fontsize option for labels on graph +* Only show the displaied piechart value in legend +* Add possibility to pick stat to use for piechart + diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/README.md b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/README.md new file mode 100644 index 0000000..afe5aee --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/README.md @@ -0,0 +1,74 @@ +Use the new grafana-cli tool to install piechart-panel from the commandline: + +``` +grafana-cli plugins install grafana-piechart-panel +``` + +The plugin will be installed into your grafana plugins directory; the default is /var/lib/grafana/plugins if you installed the grafana package. + +More instructions on the cli tool can be found [here](http://docs.grafana.org/v3.0/plugins/installation/). + +You need the lastest grafana build for Grafana 3.0 to enable plugin support. You can get it here : http://grafana.org/download/builds.html + +## Alternative installation method + +It is also possible to clone this repo directly into your plugins directory. + +Afterwards restart grafana-server and the plugin should be automatically detected and used. + +``` +git clone https://github.com/grafana/piechart-panel.git +sudo service grafana-server restart +``` + + +## Clone into a directory of your choice + +If the plugin is cloned to a directory that is not the default plugins directory then you need to edit your grafana.ini config file (Default location is at /etc/grafana/grafana.ini) and add this: + +```ini +[plugin.piechart] +path = /home/your/clone/dir/piechart-panel +``` + +Note that if you clone it into the grafana plugins directory you do not need to add the above config option. That is only +if you want to place the plugin in a directory outside the standard plugins directory. Be aware that grafana-server +needs read access to the directory. + +# Changelog + +## 1.3.3 + +* Fix legend sorting: [#145](https://github.com/grafana/piechart-panel/issues/145) + +## 1.3.2 + +* Automatically set legend width if Internet Explorer 11 and positioned to the right: [#148](https://github.com/grafana/piechart-panel/issues/148) + +## 1.3.1 + +* Fix scrolling and legend issues in Internet Explorer 11: [#143](https://github.com/grafana/piechart-panel/issues/143) + +## 1.3.0 + +* Fixes for legend and piechart rendering and sorting: [#138](https://github.com/grafana/piechart-panel/pull/138), [#136](https://github.com/grafana/piechart-panel/pull/136) +* Fix for decimal field for percentages [#108](https://github.com/grafana/piechart-panel/pull/108) + +## 1.1.5 + +* Fix for color picker in legend +* Fix for - [Values in legend are displayed raw, not with the correct unit](https://github.com/grafana/piechart-panel/issues/51). Thanks, [@conet](https://github.com/conet) +* Fix for - [Legend overlaps with graphs](https://github.com/grafana/piechart-panel/issues/34). Thanks, [@smalik03](https://github.com/smalik03) + +## 1.1.4 +* Add support for combining small slices (https://github.com/grafana/piechart-panel/pull/43) +* Add option to show percentage in legend https://github.com/grafana/piechart-panel/pull/41 + +## 1.0.2 + +* Add piechart piece divider setting +* Remove Unused code +* Adds fontsize option for labels on graph +* Only show the displaied piechart value in legend +* Add possibility to pick stat to use for piechart + diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.dark.css b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.dark.css new file mode 100644 index 0000000..7bda621 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.dark.css @@ -0,0 +1,277 @@ +.piechart-panel { + display: flex; + flex-direction: column; + height: 100%; +} + +.piechart-panel--legend-right { + flex-direction: row; +} + +.piechart-panel--legend-right .piechart-legend { + flex: 0 1 10px; + height: 100%; +} + +.piechart-panel--legend-right .piechart-legend-series { + display: block; + padding-left: 0px; +} + +.piechart-panel--legend-right .piechart-legend-table .piechart-legend-series { + display: table-row; +} + +.piechart-legend__container { + height: 100%; +} + +.piechart-panel__chart { + position: relative; + cursor: crosshair; + flex-grow: 1; + top: 10px; +} + +.datapoints-warning { + pointer: none; + position: absolute; + top: 50%; + left: 50%; + z-index: 10; + margin-top: -50px; + margin-left: -100px; + width: 200px; + text-align: center; + cursor: auto; + padding: 10px; +} + +.piechart-legend { + flex: 0 1 auto; + margin: 0 1rem; + text-align: center; + padding-top: 6px; + position: relative; +} + +.piechart-legend .popover-content { + padding: 0; +} + +.piechart-legend-icon { + position: relative; + padding-right: 4px; + top: 1px; +} + +.piechart-legend-icon, +.piechart-legend-alias, +.piechart-legend-value { + cursor: pointer; + float: left; + white-space: nowrap; + font-size: 85%; + text-align: left; + color: #d8d9da; +} + +.piechart-legend-icon.current::before { + content: "Current: "; +} + +.piechart-legend-icon.max::before { + content: "Max: "; +} + +.piechart-legend-icon.min::before { + content: "Min: "; +} + +.piechart-legend-icon.total::before { + content: "Total: "; +} + +.piechart-legend-icon.avg::before { + content: "Avg: "; +} + +.piechart-legend-alias.current::before { + content: "Current: "; +} + +.piechart-legend-alias.max::before { + content: "Max: "; +} + +.piechart-legend-alias.min::before { + content: "Min: "; +} + +.piechart-legend-alias.total::before { + content: "Total: "; +} + +.piechart-legend-alias.avg::before { + content: "Avg: "; +} + +.piechart-legend-value.current::before { + content: "Current: "; +} + +.piechart-legend-value.max::before { + content: "Max: "; +} + +.piechart-legend-value.min::before { + content: "Min: "; +} + +.piechart-legend-value.total::before { + content: "Total: "; +} + +.piechart-legend-value.avg::before { + content: "Avg: "; +} + +.piechart-legend-icon .fa { + font-size: 135%; + position: relative; + top: 1px; +} + +.piechart-legend-series { + float: left; + white-space: nowrap; + padding-left: 10px; +} + +.piechart-legend-series--right-y { + float: right; +} + +.piechart-legend-value { + padding-left: 6px; +} + +.piechart-legend-table tbody { + display: block; + overflow-y: auto; + overflow-x: hidden; + height: 100%; + padding-bottom: 1px; + padding-right: 5px; +} + +.piechart-legend-table .piechart-legend-series { + display: table-row; + float: none; + padding-left: 0; +} + +.piechart-legend-table .piechart-legend-series--right-y { + float: none; +} + +.piechart-legend-table .piechart-legend-series--right-y .piechart-legend-alias::after { + content: "(right-y)"; + padding: 0 5px; + color: #8e8e8e; +} + +.piechart-legend-table td, +.piechart-legend-alias, +.piechart-legend-icon, +.piechart-legend-value { + float: none; + display: table-cell; + white-space: nowrap; + padding: 2px 10px; + text-align: right; +} + +.piechart-legend-table .piechart-legend-icon { + width: 5px; + padding: 0; + top: 0; +} + +.piechart-legend-table .piechart-legend-icon .fa { + top: 4px; +} + +.piechart-legend-table .piechart-legend-value { + padding-left: 15px; +} + +.piechart-legend-table .piechart-legend-alias { + padding-left: 7px; + text-align: left; + width: 95%; + max-width: 650px; + text-overflow: ellipsis; + overflow: hidden; +} + +.piechart-legend-table .piechart-legend-series:nth-child(odd) { + background: #262628; +} + +.piechart-legend-table .piechart-legend-value.current::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.max::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.min::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.total::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.avg::before { + content: ""; +} + +.piechart-legend-table th { + text-align: right; + padding: 0px 10px 1px 0; + font-weight: bold; + color: #33b5e5; + font-size: 85%; + white-space: nowrap; +} + +.piechart-legend-series-hidden .piechart-legend-value, +.piechart-legend-series-hidden .piechart-legend-alias { + color: #8e8e8e; +} + +.piechart-tooltip { + white-space: nowrap; + font-size:12px; + background-color: #141414; + color: #d8d9da; +} + +.piechart-tooltip .piechart-tooltip-time { + text-align: center; + position: relative; + top: -3px; + padding: 0.2rem; + font-weight: bold; + color: #d8d9da; +} + +.piechart-tooltip .piechart-tooltip-value { + display: table-cell; + font-weight: bold; + padding-left: 15px; + text-align: right; +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.light.css b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.light.css new file mode 100644 index 0000000..4ba0f6e --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/css/piechart.light.css @@ -0,0 +1,281 @@ +.piechart-panel { + display: flex; + flex-direction: column; + height: 100%; +} + +.piechart-panel--legend-right { + flex-direction: row; +} + +.piechart-panel--legend-right .piechart-legend { + flex: 0 1 10px; + height: 100%; +} + +_:-ms-fullscreen, :root .piechart-panel--legend-right .piechart-legend { + flex: 0 1 200px; +} + +.piechart-panel--legend-right .piechart-legend-series { + display: block; + padding-left: 0px; +} + +.piechart-panel--legend-right .piechart-legend-table .piechart-legend-series { + display: table-row; +} + +.piechart-legend__container { + height: 100%; +} + +.piechart-panel__chart { + position: relative; + cursor: crosshair; + flex-grow: 1; + top: 10px; +} + +.datapoints-warning { + pointer: none; + position: absolute; + top: 50%; + left: 50%; + z-index: 10; + margin-top: -50px; + margin-left: -100px; + width: 200px; + text-align: center; + cursor: auto; + padding: 10px; +} + +.piechart-legend { + flex: 0 1 auto; + margin: 0 1rem; + text-align: center; + padding-top: 6px; + position: relative; +} + +.piechart-legend .popover-content { + padding: 0; +} + +.piechart-legend-icon { + position: relative; + padding-right: 4px; + top: 1px; +} + +.piechart-legend-icon, +.piechart-legend-alias, +.piechart-legend-value { + cursor: pointer; + float: left; + white-space: nowrap; + font-size: 85%; + text-align: left; + color: 52545c; +} + +.piechart-legend-icon.current::before { + content: "Current: "; +} + +.piechart-legend-icon.max::before { + content: "Max: "; +} + +.piechart-legend-icon.min::before { + content: "Min: "; +} + +.piechart-legend-icon.total::before { + content: "Total: "; +} + +.piechart-legend-icon.avg::before { + content: "Avg: "; +} + +.piechart-legend-alias.current::before { + content: "Current: "; +} + +.piechart-legend-alias.max::before { + content: "Max: "; +} + +.piechart-legend-alias.min::before { + content: "Min: "; +} + +.piechart-legend-alias.total::before { + content: "Total: "; +} + +.piechart-legend-alias.avg::before { + content: "Avg: "; +} + +.piechart-legend-value.current::before { + content: "Current: "; +} + +.piechart-legend-value.max::before { + content: "Max: "; +} + +.piechart-legend-value.min::before { + content: "Min: "; +} + +.piechart-legend-value.total::before { + content: "Total: "; +} + +.piechart-legend-value.avg::before { + content: "Avg: "; +} + +.piechart-legend-icon .fa { + font-size: 135%; + position: relative; + top: 1px; +} + +.piechart-legend-series { + float: left; + white-space: nowrap; + padding-left: 10px; +} + +.piechart-legend-series--right-y { + float: right; +} + +.piechart-legend-value { + padding-left: 6px; +} + +.piechart-legend-table tbody { + display: block; + overflow-y: auto; + overflow-x: hidden; + height: 100%; + padding-bottom: 1px; + padding-right: 5px; +} + +.piechart-legend-table .piechart-legend-series { + display: table-row; + float: none; + padding-left: 0; +} + +.piechart-legend-table .piechart-legend-series--right-y { + float: none; +} + +.piechart-legend-table .piechart-legend-series--right-y .piechart-legend-alias::after { + content: "(right-y)"; + padding: 0 5px; + color: #767980; +} + +.piechart-legend-table td, +.piechart-legend-alias, +.piechart-legend-icon, +.piechart-legend-value { + float: none; + display: table-cell; + white-space: nowrap; + padding: 2px 10px; + text-align: right; +} + +.piechart-legend-table .piechart-legend-icon { + width: 5px; + padding: 0; + top: 0; +} + +.piechart-legend-table .piechart-legend-icon .fa { + top: 4px; +} + +.piechart-legend-table .piechart-legend-value { + padding-left: 15px; +} + +.piechart-legend-table .piechart-legend-alias { + padding-left: 7px; + text-align: left; + width: 95%; + max-width: 650px; + text-overflow: ellipsis; + overflow: hidden; +} + +.piechart-legend-table .piechart-legend-series:nth-child(odd) { + background: #dde4ed; +} + +.piechart-legend-table .piechart-legend-value.current::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.max::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.min::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.total::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.avg::before { + content: ""; +} + +.piechart-legend-table th { + text-align: right; + padding: 0px 10px 1px 0; + font-weight: bold; + color: #61c2f2; + font-size: 85%; + white-space: nowrap; +} + +.piechart-legend-series-hidden .piechart-legend-value, +.piechart-legend-series-hidden .piechart-legend-alias { + color: #acb6bf; +} + +.piechart-tooltip { + white-space: nowrap; + font-size: 12px; + background-color: #dde4ed; + color: #35373f; +} + +.piechart-tooltip .piechart-tooltip-time { + text-align: center; + position: relative; + top: -3px; + padding: 0.2rem; + font-weight: bold; + color: #35373f; +} + +.piechart-tooltip .piechart-tooltip-value { + display: table-cell; + font-weight: bold; + padding-left: 15px; + text-align: right; +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/editor.html b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/editor.html new file mode 100644 index 0000000..6ee2e2c --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/editor.html @@ -0,0 +1,89 @@ +
+
+
General
+
+ Type +
+ +
+
+
+ Unit +
+
+
+
+ Value +
+ +
+
+
+ Divider width + +
+
+ +
+
Legend
+ +
+ Position +
+ +
+
+
+ + +
+
+ Legend Breakpoint +
+ +
+
+
+ Font size +
+ +
+
+ +
+ Values Header + +
+
+ Values Decimals + +
+ +
+ Percentage Decimals + +
+
+ +
+
Combine
+
+ Threshold: + + Combines all slices that are smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will + combine all slices 3% or less into one slice). +
+
+ Label + + Label text for the combined slice. +
+
+
diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-donut.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-donut.png new file mode 100644 index 0000000..8e54878 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-donut.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-on-graph.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-on-graph.png new file mode 100644 index 0000000..51dfcbc Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-on-graph.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-rhs.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-rhs.png new file mode 100644 index 0000000..9b018c3 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-rhs.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-under.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-under.png new file mode 100644 index 0000000..3284511 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-legend-under.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-options.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-options.png new file mode 100644 index 0000000..117962e Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart-options.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_large.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_large.png new file mode 100644 index 0000000..21b7ab4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_large.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_small.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_small.png new file mode 100644 index 0000000..10d49e4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/img/piechart_logo_small.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js new file mode 100644 index 0000000..27af457 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js @@ -0,0 +1,282 @@ +"use strict"; + +System.register(["angular", "app/core/utils/kbn", "jquery", "jquery.flot", "jquery.flot.time", "./lib/perfect-scrollbar.min"], function (_export, _context) { + "use strict"; + + var angular, kbn, $, PerfectScrollbar; + return { + setters: [function (_angular) { + angular = _angular.default; + }, function (_appCoreUtilsKbn) { + kbn = _appCoreUtilsKbn.default; + }, function (_jquery) { + $ = _jquery.default; + }, function (_jqueryFlot) {}, function (_jqueryFlotTime) {}, function (_libPerfectScrollbarMin) { + PerfectScrollbar = _libPerfectScrollbarMin.default; + }], + execute: function () { + + angular.module("grafana.directives").directive("piechartLegend", function (popoverSrv, $timeout) { + return { + link: function link(scope, elem) { + var $container = $('
'); + var firstRender = true; + var ctrl = scope.ctrl; + var panel = ctrl.panel; + var data; + var seriesList; + var dataList; + var i; + var legendScrollbar; + + scope.$on("$destroy", function () { + if (legendScrollbar) { + legendScrollbar.destroy(); + } + }); + + ctrl.events.on("render", function () { + data = ctrl.series; + if (data) { + for (var i in data) { + data[i].color = ctrl.data[i].color; + } + render(); + } + }); + + function getSeriesIndexForElement(el) { + return el.parents("[data-series-index]").data("series-index"); + } + + function toggleSeries(e) { + var el = $(e.currentTarget); + var index = getSeriesIndexForElement(el); + var seriesInfo = dataList[index]; + var scrollPosition = $($container.children("tbody")).scrollTop(); + ctrl.toggleSeries(seriesInfo); + $($container.children("tbody")).scrollTop(scrollPosition); + } + + function sortLegend(e) { + var el = $(e.currentTarget); + var stat = el.data("stat"); + + if (stat !== panel.legend.sort) { + panel.legend.sortDesc = null; + } + + // if already sort ascending, disable sorting + if (panel.legend.sortDesc === false) { + panel.legend.sort = null; + panel.legend.sortDesc = null; + ctrl.render(); + return; + } + + panel.legend.sortDesc = !panel.legend.sortDesc; + panel.legend.sort = stat; + ctrl.render(); + } + + function getLegendHeaderHtml(statName) { + var name = statName; + + if (panel.legend.header) { + name = panel.legend.header; + } + + var html = '' + name; + + if (panel.legend.sort === statName) { + var cssClass = panel.legend.sortDesc ? "fa fa-caret-down" : "fa fa-caret-up"; + html += ' '; + } + + return html + ""; + } + + function getLegendPercentageHtml(statName) { + var name = "percentage"; + var html = '' + name; + + if (panel.legend.sort === statName) { + var cssClass = panel.legend.sortDesc ? "fa fa-caret-down" : "fa fa-caret-up"; + html += ' '; + } + + return html + ""; + } + + function openColorSelector(e) { + // if we clicked inside poup container ignore click + if ($(e.target).parents(".popover").length) { + return; + } + + var el = $(e.currentTarget).find(".fa-minus"); + var index = getSeriesIndexForElement(el); + var series = seriesList[index]; + + $timeout(function () { + popoverSrv.show({ + element: el[0], + position: "bottom center", + template: '' + "", + openOn: "hover", + model: { + autoClose: true, + series: series, + toggleAxis: function toggleAxis() {}, + colorSelected: function colorSelected(color) { + ctrl.changeSeriesColor(series, color); + } + } + }); + }); + } + + function render() { + if (panel.legendType === "On graph" || !panel.legend.show) { + $container.empty(); + elem.find(".piechart-legend").css("padding-top", 0); + return; + } else { + elem.find(".piechart-legend").css("padding-top", 6); + } + + if (firstRender) { + elem.append($container); + $container.on("click", ".piechart-legend-icon", openColorSelector); + $container.on("click", ".piechart-legend-alias", toggleSeries); + $container.on("click", "th", sortLegend); + firstRender = false; + } + + seriesList = data; + dataList = ctrl.data; + + $container.empty(); + + var width = panel.legendType == "Right side" && panel.legend.sideWidth ? panel.legend.sideWidth + "px" : ""; + var ieWidth = panel.legendType == "Right side" && panel.legend.sideWidth ? panel.legend.sideWidth - 1 + "px" : ""; + elem.css("min-width", width); + elem.css("width", ieWidth); + + var showValues = panel.legend.values || panel.legend.percentage; + var tableLayout = (panel.legendType === "Under graph" || panel.legendType === "Right side") && showValues; + + $container.toggleClass("piechart-legend-table", tableLayout); + + var legendHeader; + if (tableLayout) { + var header = ''; + if (panel.legend.values) { + header += getLegendHeaderHtml(ctrl.panel.valueName); + } + if (panel.legend.percentage) { + header += getLegendPercentageHtml(ctrl.panel.valueName); + } + header += ""; + legendHeader = $(header); + } + + if (panel.legend.percentage) { + var total = 0; + for (i = 0; i < seriesList.length; i++) { + total += seriesList[i].stats[ctrl.panel.valueName]; + } + } + + var seriesShown = 0; + var seriesElements = []; + + for (i = 0; i < seriesList.length; i++) { + var series = seriesList[i]; + var seriesData = dataList[i]; + + // ignore empty series + if (panel.legend.hideEmpty && series.allIsNull) { + continue; + } + // ignore series excluded via override + if (!series.legend) { + continue; + } + + var decimal = 0; + if (ctrl.panel.legend.percentageDecimals) { + decimal = ctrl.panel.legend.percentageDecimals; + } + + var html = '
'; + html += ''; + html += ''; + html += ""; + + html += '' + seriesData.label + ""; + + if (showValues && tableLayout) { + var value = seriesData.legendData; + if (panel.legend.values) { + html += '
' + ctrl.formatValue(value) + "
"; + } + if (total) { + var pvalue = (value / total * 100).toFixed(decimal) + "%"; + html += '
' + pvalue + "
"; + } + } + + html += "
"; + + seriesElements.push($(html)); + seriesShown++; + } + if (tableLayout) { + var topPadding = 6; + var tbodyElem = $(""); + // tbodyElem.css("max-height", maxHeight - topPadding); + tbodyElem.append(legendHeader); + tbodyElem.append(seriesElements); + $container.append(tbodyElem); + } else { + $container.append(seriesElements); + } + + if (panel.legendType === "Under graph") { + addScrollbar(); + } else { + destroyScrollbar(); + } + } + function addScrollbar() { + var scrollbarOptions = { + // Number of pixels the content height can surpass the container height without enabling the scroll bar. + scrollYMarginOffset: 2, + suppressScrollX: true + }; + + if (!legendScrollbar) { + legendScrollbar = new PerfectScrollbar(elem[0], scrollbarOptions); + } else { + legendScrollbar.update(); + } + } + + function destroyScrollbar() { + if (legendScrollbar) { + legendScrollbar.destroy(); + legendScrollbar = null; + } + } + } + }; + }); + } + }; +}); +//# sourceMappingURL=legend.js.map diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js.map b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js.map new file mode 100644 index 0000000..8f9beb6 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/legend.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/legend.js"],"names":["angular","kbn","$","PerfectScrollbar","module","directive","popoverSrv","$timeout","link","scope","elem","$container","firstRender","ctrl","panel","data","seriesList","dataList","i","legendScrollbar","$on","destroy","events","on","series","color","render","getSeriesIndexForElement","el","parents","toggleSeries","e","currentTarget","index","seriesInfo","scrollPosition","children","scrollTop","sortLegend","stat","legend","sort","sortDesc","getLegendHeaderHtml","statName","name","header","html","cssClass","getLegendPercentageHtml","openColorSelector","target","length","find","show","element","position","template","openOn","model","autoClose","toggleAxis","colorSelected","changeSeriesColor","legendType","empty","css","append","width","sideWidth","ieWidth","showValues","values","percentage","tableLayout","toggleClass","legendHeader","valueName","total","stats","seriesShown","seriesElements","seriesData","hideEmpty","allIsNull","decimal","percentageDecimals","hiddenSeries","label","value","legendData","formatValue","pvalue","toFixed","push","topPadding","tbodyElem","addScrollbar","destroyScrollbar","scrollbarOptions","scrollYMarginOffset","suppressScrollX","update"],"mappings":";;;;;;;;AAAOA,a;;AACAC,S;;AACAC,O;;AAGAC,sB;;;;AAEPH,cACGI,MADH,CACU,oBADV,EAEGC,SAFH,CAEa,gBAFb,EAE+B,UAASC,UAAT,EAAqBC,QAArB,EAA+B;AAC1D,eAAO;AACLC,gBAAM,cAASC,KAAT,EAAgBC,IAAhB,EAAsB;AAC1B,gBAAIC,aAAaT,EAAE,gDAAF,CAAjB;AACA,gBAAIU,cAAc,IAAlB;AACA,gBAAIC,OAAOJ,MAAMI,IAAjB;AACA,gBAAIC,QAAQD,KAAKC,KAAjB;AACA,gBAAIC,IAAJ;AACA,gBAAIC,UAAJ;AACA,gBAAIC,QAAJ;AACA,gBAAIC,CAAJ;AACA,gBAAIC,eAAJ;;AAEAV,kBAAMW,GAAN,CAAU,UAAV,EAAsB,YAAW;AAC/B,kBAAID,eAAJ,EAAqB;AACnBA,gCAAgBE,OAAhB;AACD;AACF,aAJD;;AAMAR,iBAAKS,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,YAAW;AAClCR,qBAAOF,KAAKW,MAAZ;AACA,kBAAIT,IAAJ,EAAU;AACN,qBAAK,IAAIG,CAAT,IAAcH,IAAd,EAAoB;AAClBA,uBAAKG,CAAL,EAAQO,KAAR,GAAgBZ,KAAKE,IAAL,CAAUG,CAAV,EAAaO,KAA7B;AACD;AACHC;AACD;AACF,aARD;;AAUA,qBAASC,wBAAT,CAAkCC,EAAlC,EAAsC;AACpC,qBAAOA,GAAGC,OAAH,CAAW,qBAAX,EAAkCd,IAAlC,CAAuC,cAAvC,CAAP;AACD;;AAED,qBAASe,YAAT,CAAsBC,CAAtB,EAAyB;AACvB,kBAAIH,KAAK1B,EAAE6B,EAAEC,aAAJ,CA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qBAASD,YAAT,GAAwB;AACtB,kBAAME,mBAAmB;AACvB;AACAC,qCAAqB,CAFE;AAGvBC,iCAAiB;AAHM,eAAzB;;AAMA,kBAAI,CAAClF,eAAL,EAAsB;AACpBA,kCAAkB,IAAIhB,gBAAJ,CAChBO,KAAK,CAAL,CADgB,EAEhByF,gBAFgB,CAAlB;AAID,eALD,MAKO;AACLhF,gCAAgBmF,MAAhB;AACD;AACF;;AAED,qBAASJ,gBAAT,GAA4B;AAC1B,kBAAI/E,eAAJ,EAAqB;AACnBA,gCAAgBE,OAAhB;AACAF,kCAAkB,IAAlB;AACD;AACF;AACF;AAtRI,SAAP;AAwRD,OA3RH","file":"legend.js","sourcesContent":["import angular from \"angular\";\nimport kbn from \"app/core/utils/kbn\";\nimport $ from \"jquery\";\nimport \"jquery.flot\";\nimport \"jquery.flot.time\";\nimport PerfectScrollbar from \"./lib/perfect-scrollbar.min\";\n\nangular\n .module(\"grafana.directives\")\n .directive(\"piechartLegend\", function(popoverSrv, $timeout) {\n return {\n link: function(scope, elem) {\n var $container = $('
');\n var firstRender = true;\n var ctrl = scope.ctrl;\n var panel = ctrl.panel;\n var data;\n var seriesList;\n var dataList;\n var i;\n var legendScrollbar;\n\n scope.$on(\"$destroy\", function() {\n if (legendScrollbar) {\n legendScrollbar.destroy();\n }\n });\n\n ctrl.events.on(\"render\", function() {\n data = ctrl.series;\n if (data) {\n for (var i in data) {\n data[i].color = ctrl.data[i].color;\n }\n render();\n }\n });\n\n function getSeriesIndexForElement(el) {\n return el.parents(\"[data-series-index]\").data(\"series-index\");\n }\n\n function toggleSeries(e) {\n var el = $(e.currentTarget);\n var index = getSeriesIndexForElement(el);\n var seriesInfo = dataList[index];\n var scrollPosition = $($container.children(\"tbody\")).scrollTop();\n ctrl.toggleSeries(seriesInfo);\n $($container.children(\"tbody\")).scrollTop(scrollPosition);\n }\n\n function sortLegend(e) {\n var el = $(e.currentTarget);\n var stat = el.data(\"stat\");\n\n if (stat !== panel.legend.sort) {\n panel.legend.sortDesc = null;\n }\n\n // if already sort ascending, disable sorting\n if (panel.legend.sortDesc === false) {\n panel.legend.sort = null;\n panel.legend.sortDesc = null;\n ctrl.render();\n return;\n }\n\n panel.legend.sortDesc = !panel.legend.sortDesc;\n panel.legend.sort = stat;\n ctrl.render();\n }\n\n function getLegendHeaderHtml(statName) {\n var name = statName;\n\n if (panel.legend.header) {\n name = panel.legend.header;\n }\n\n var html = '' + name;\n\n if (panel.legend.sort === statName) {\n var cssClass = panel.legend.sortDesc\n ? \"fa fa-caret-down\"\n : \"fa fa-caret-up\";\n html += ' ';\n }\n\n return html + \"\";\n }\n\n function getLegendPercentageHtml(statName) {\n var name = \"percentage\";\n var html = '' + name;\n\n if (panel.legend.sort === statName) {\n var cssClass = panel.legend.sortDesc\n ? \"fa fa-caret-down\"\n : \"fa fa-caret-up\";\n html += ' ';\n }\n\n return html + \"\";\n }\n\n function openColorSelector(e) {\n // if we clicked inside poup container ignore click\n if ($(e.target).parents(\".popover\").length) {\n return;\n }\n\n var el = $(e.currentTarget).find(\".fa-minus\");\n var index = getSeriesIndexForElement(el);\n var series = seriesList[index];\n\n $timeout(function() {\n popoverSrv.show({\n element: el[0],\n position: \"bottom center\",\n template:\n '' +\n \"\",\n openOn: \"hover\",\n model: {\n autoClose: true,\n series: series,\n toggleAxis: function() {},\n colorSelected: function(color) {\n ctrl.changeSeriesColor(series, color);\n }\n }\n });\n });\n }\n\n function render() {\n if (panel.legendType === \"On graph\" || !panel.legend.show) {\n $container.empty();\n elem.find(\".piechart-legend\").css(\"padding-top\", 0);\n return;\n } else {\n elem.find(\".piechart-legend\").css(\"padding-top\", 6);\n }\n\n\n if (firstRender) {\n elem.append($container);\n $container.on(\"click\", \".piechart-legend-icon\", openColorSelector);\n $container.on(\"click\", \".piechart-legend-alias\", toggleSeries);\n $container.on(\"click\", \"th\", sortLegend);\n firstRender = false;\n }\n\n seriesList = data;\n dataList = ctrl.data;\n\n $container.empty();\n\n var width = panel.legendType == \"Right side\" && panel.legend.sideWidth ? panel.legend.sideWidth + \"px\" : \"\";\n var ieWidth = panel.legendType == \"Right side\" && panel.legend.sideWidth ? panel.legend.sideWidth - 1 + \"px\" : \"\";\n elem.css(\"min-width\", width);\n elem.css(\"width\", ieWidth);\n\n var showValues = panel.legend.values || panel.legend.percentage;\n var tableLayout =\n (panel.legendType === \"Under graph\" ||\n panel.legendType === \"Right side\") &&\n showValues;\n\n $container.toggleClass(\"piechart-legend-table\", tableLayout);\n\n var legendHeader;\n if (tableLayout) {\n var header = '';\n if (panel.legend.values) {\n header += getLegendHeaderHtml(ctrl.panel.valueName);\n }\n if (panel.legend.percentage) {\n header += getLegendPercentageHtml(ctrl.panel.valueName);\n }\n header += \"\";\n legendHeader = $(header);\n }\n\n if (panel.legend.percentage) {\n var total = 0;\n for (i = 0; i < seriesList.length; i++) {\n total += seriesList[i].stats[ctrl.panel.valueName];\n }\n }\n\n var seriesShown = 0;\n var seriesElements = [];\n\n for (i = 0; i < seriesList.length; i++) {\n var series = seriesList[i];\n var seriesData = dataList[i];\n\n // ignore empty series\n if (panel.legend.hideEmpty && series.allIsNull) {\n continue;\n }\n // ignore series excluded via override\n if (!series.legend) {\n continue;\n }\n\n var decimal = 0;\n if (ctrl.panel.legend.percentageDecimals) {\n decimal = ctrl.panel.legend.percentageDecimals;\n }\n\n var html = '
';\n html += '';\n html +=\n '';\n html += \"\";\n\n html +=\n '' +\n seriesData.label +\n \"\";\n\n if (showValues && tableLayout) {\n var value = seriesData.legendData;\n if (panel.legend.values) {\n html +=\n '
' +\n ctrl.formatValue(value) +\n \"
\";\n }\n if (total) {\n var pvalue = (value / total * 100).toFixed(decimal) + \"%\";\n html += '
' + pvalue + \"
\";\n }\n }\n\n html += \"
\";\n\n seriesElements.push($(html));\n seriesShown++;\n }\n if (tableLayout) {\n var topPadding = 6;\n var tbodyElem = $(\"\");\n // tbodyElem.css(\"max-height\", maxHeight - topPadding);\n tbodyElem.append(legendHeader);\n tbodyElem.append(seriesElements);\n $container.append(tbodyElem);\n } else {\n $container.append(seriesElements);\n }\n\n if (panel.legendType === \"Under graph\") {\n addScrollbar();\n } else {\n destroyScrollbar();\n }\n }\n function addScrollbar() {\n const scrollbarOptions = {\n // Number of pixels the content height can surpass the container height without enabling the scroll bar.\n scrollYMarginOffset: 2,\n suppressScrollX: true\n };\n\n if (!legendScrollbar) {\n legendScrollbar = new PerfectScrollbar(\n elem[0],\n scrollbarOptions\n );\n } else {\n legendScrollbar.update();\n }\n }\n\n function destroyScrollbar() {\n if (legendScrollbar) {\n legendScrollbar.destroy();\n legendScrollbar = null;\n }\n }\n }\n };\n });\n"]} \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/lib/perfect-scrollbar.min.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/lib/perfect-scrollbar.min.js new file mode 100644 index 0000000..b5d61d2 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/lib/perfect-scrollbar.min.js @@ -0,0 +1,6 @@ +/*! + * perfect-scrollbar v1.2.0 + * (c) 2017 Hyunje Jun + * @license MIT + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.PerfectScrollbar=e()}(this,function(){"use strict";function t(t){return getComputedStyle(t)}function e(t,e){for(var i in e){var n=e[i];"number"==typeof n&&(n+="px"),t.style[i]=n}return t}function i(t){var e=document.createElement("div");return e.className=t,e}function n(t,e){if(!v)throw new Error("No element matching method supported");return v.call(t,e)}function r(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function l(t,e){return Array.prototype.filter.call(t.children,function(t){return n(t,e)})}function o(t,e){var i=t.element.classList,n=m.state.scrolling(e);i.contains(n)?clearTimeout(w[e]):i.add(n)}function s(t,e){w[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(m.state.scrolling(e))},t.settings.scrollingThreshold)}function a(t,e){o(t,e),s(t,e)}function c(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function h(t,e,i,n,r){var l=i[0],o=i[1],s=i[2],h=i[3],u=i[4],d=i[5];void 0===n&&(n=!0),void 0===r&&(r=!1);var p=t.element;t.reach[h]=null,p[s]<1&&(t.reach[h]="start"),p[s]>t[l]-t[o]-1&&(t.reach[h]="end"),e&&(p.dispatchEvent(c("ps-scroll-"+h)),e<0?p.dispatchEvent(c("ps-scroll-"+u)):e>0&&p.dispatchEvent(c("ps-scroll-"+d)),n&&a(t,h)),t.reach[h]&&(e||r)&&p.dispatchEvent(c("ps-"+h+"-reach-"+t.reach[h]))}function u(t){return parseInt(t,10)||0}function d(t){return n(t,"input,[contenteditable]")||n(t,"select,[contenteditable]")||n(t,"textarea,[contenteditable]")||n(t,"button,[contenteditable]")}function p(e){var i=t(e);return u(i.width)+u(i.paddingLeft)+u(i.paddingRight)+u(i.borderLeftWidth)+u(i.borderRightWidth)}function f(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function b(t,i){var n={width:i.railXWidth};i.isRtl?n.left=i.negativeScrollAdjustment+t.scrollLeft+i.containerWidth-i.contentWidth:n.left=t.scrollLeft,i.isScrollbarXUsingBottom?n.bottom=i.scrollbarXBottom-t.scrollTop:n.top=i.scrollbarXTop+t.scrollTop,e(i.scrollbarXRail,n);var r={top:t.scrollTop,height:i.railYHeight};i.isScrollbarYUsingRight?i.isRtl?r.right=i.contentWidth-(i.negativeScrollAdjustment+t.scrollLeft)-i.scrollbarYRight-i.scrollbarYOuterWidth:r.right=i.scrollbarYRight-t.scrollLeft:i.isRtl?r.left=i.negativeScrollAdjustment+t.scrollLeft+2*i.containerWidth-i.contentWidth-i.scrollbarYLeft-i.scrollbarYOuterWidth:r.left=i.scrollbarYLeft+t.scrollLeft,e(i.scrollbarYRail,r),e(i.scrollbarX,{left:i.scrollbarXLeft,width:i.scrollbarXWidth-i.railBorderXWidth}),e(i.scrollbarY,{top:i.scrollbarYTop,height:i.scrollbarYHeight-i.railBorderYWidth})}function g(t,e){function i(e){f[d]=b+v*(e[a]-g),o(t,p),R(t),e.stopPropagation(),e.preventDefault()}function n(){s(t,p),t.event.unbind(t.ownerDocument,"mousemove",i)}var r=e[0],l=e[1],a=e[2],c=e[3],h=e[4],u=e[5],d=e[6],p=e[7],f=t.element,b=null,g=null,v=null;t.event.bind(t[h],"mousedown",function(e){b=f[d],g=e[a],v=(t[l]-t[r])/(t[c]-t[u]),t.event.bind(t.ownerDocument,"mousemove",i),t.event.once(t.ownerDocument,"mouseup",n),e.stopPropagation(),e.preventDefault()})}var v=Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.msMatchesSelector,m={main:"ps",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},w={x:null,y:null},Y=function(t){this.element=t,this.handlers={}},X={isEmpty:{configurable:!0}};Y.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},Y.prototype.unbind=function(t,e){var i=this;this.handlers[t]=this.handlers[t].filter(function(n){return!(!e||n===e)||(i.element.removeEventListener(t,n,!1),!1)})},Y.prototype.unbindAll=function(){var t=this;for(var e in t.handlers)t.unbind(e)},X.isEmpty.get=function(){var t=this;return Object.keys(this.handlers).every(function(e){return 0===t.handlers[e].length})},Object.defineProperties(Y.prototype,X);var W=function(){this.eventElements=[]};W.prototype.eventElement=function(t){var e=this.eventElements.filter(function(e){return e.element===t})[0];return e||(e=new Y(t),this.eventElements.push(e)),e},W.prototype.bind=function(t,e,i){this.eventElement(t).bind(e,i)},W.prototype.unbind=function(t,e,i){var n=this.eventElement(t);n.unbind(e,i),n.isEmpty&&this.eventElements.splice(this.eventElements.indexOf(n),1)},W.prototype.unbindAll=function(){this.eventElements.forEach(function(t){return t.unbindAll()}),this.eventElements=[]},W.prototype.once=function(t,e,i){var n=this.eventElement(t),r=function(t){n.unbind(e,r),i(t)};n.bind(e,r)};var y=function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=!1);var l;if("top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}h(t,i,l,n,r)},L={isWebKit:document&&"WebkitAppearance"in document.documentElement.style,supportsTouch:window&&("ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),supportsIePointer:navigator&&navigator.msMaxTouchPoints},R=function(t){var e=t.element;t.containerWidth=e.clientWidth,t.containerHeight=e.clientHeight,t.contentWidth=e.scrollWidth,t.contentHeight=e.scrollHeight,e.contains(t.scrollbarXRail)||(l(e,m.element.rail("x")).forEach(function(t){return r(t)}),e.appendChild(t.scrollbarXRail)),e.contains(t.scrollbarYRail)||(l(e,m.element.rail("y")).forEach(function(t){return r(t)}),e.appendChild(t.scrollbarYRail)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),b(e,t),t.scrollbarXActive?e.classList.add(m.state.active("x")):(e.classList.remove(m.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=0),t.scrollbarYActive?e.classList.add(m.state.active("y")):(e.classList.remove(m.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)},T={"click-rail":function(t){t.event.bind(t.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarYRail,"mousedown",function(e){var i=e.pageY-window.pageYOffset-t.scrollbarYRail.getBoundingClientRect().top>t.scrollbarYTop?1:-1;t.element.scrollTop+=i*t.containerHeight,R(t),e.stopPropagation()}),t.event.bind(t.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarXRail,"mousedown",function(e){var i=e.pageX-window.pageXOffset-t.scrollbarXRail.getBoundingClientRect().left>t.scrollbarXLeft?1:-1;t.element.scrollLeft+=i*t.containerWidth,R(t),e.stopPropagation()})},"drag-thumb":function(t){g(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x"]),g(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y"])},keyboard:function(t){function e(e,n){var r=i.scrollTop;if(0===e){if(!t.scrollbarYActive)return!1;if(0===r&&n>0||r>=t.contentHeight-t.containerHeight&&n<0)return!t.settings.wheelPropagation}var l=i.scrollLeft;if(0===n){if(!t.scrollbarXActive)return!1;if(0===l&&e<0||l>=t.contentWidth-t.containerWidth&&e>0)return!t.settings.wheelPropagation}return!0}var i=t.element,r=function(){return n(i,":hover")},l=function(){return n(t.scrollbarX,":focus")||n(t.scrollbarY,":focus")};t.event.bind(t.ownerDocument,"keydown",function(n){if(!(n.isDefaultPrevented&&n.isDefaultPrevented()||n.defaultPrevented)&&(r()||l())){var o=document.activeElement?document.activeElement:t.ownerDocument.activeElement;if(o){if("IFRAME"===o.tagName)o=o.contentDocument.activeElement;else for(;o.shadowRoot;)o=o.shadowRoot.activeElement;if(d(o))return}var s=0,a=0;switch(n.which){case 37:s=n.metaKey?-t.contentWidth:n.altKey?-t.containerWidth:-30;break;case 38:a=n.metaKey?t.contentHeight:n.altKey?t.containerHeight:30;break;case 39:s=n.metaKey?t.contentWidth:n.altKey?t.containerWidth:30;break;case 40:a=n.metaKey?-t.contentHeight:n.altKey?-t.containerHeight:-30;break;case 32:a=n.shiftKey?t.containerHeight:-t.containerHeight;break;case 33:a=t.containerHeight;break;case 34:a=-t.containerHeight;break;case 36:a=t.contentHeight;break;case 35:a=-t.contentHeight;break;default:return}t.settings.suppressScrollX&&0!==s||t.settings.suppressScrollY&&0!==a||(i.scrollTop-=a,i.scrollLeft+=s,R(t),e(s,a)&&n.preventDefault())}})},wheel:function(e){function i(t,i){var n=o.scrollTop;if(0===t){if(!e.scrollbarYActive)return!1;if(0===n&&i>0||n>=e.contentHeight-e.containerHeight&&i<0)return!e.settings.wheelPropagation}var r=o.scrollLeft;if(0===i){if(!e.scrollbarXActive)return!1;if(0===r&&t<0||r>=e.contentWidth-e.containerWidth&&t>0)return!e.settings.wheelPropagation}return!0}function n(t){var e=t.deltaX,i=-1*t.deltaY;return void 0!==e&&void 0!==i||(e=-1*t.wheelDeltaX/6,i=t.wheelDeltaY/6),t.deltaMode&&1===t.deltaMode&&(e*=10,i*=10),e!==e&&i!==i&&(e=0,i=t.wheelDelta),t.shiftKey?[-i,-e]:[e,i]}function r(e,i,n){if(!L.isWebKit&&o.querySelector("select:focus"))return!0;if(!o.contains(e))return!1;for(var r=e;r&&r!==o;){if(r.classList.contains(m.element.consuming))return!0;var l=t(r);if([l.overflow,l.overflowX,l.overflowY].join("").match(/(scroll|auto)/)){var s=r.scrollHeight-r.clientHeight;if(s>0&&!(0===r.scrollTop&&n>0||r.scrollTop===s&&n<0))return!0;var a=r.scrollLeft-r.clientWidth;if(a>0&&!(0===r.scrollLeft&&i<0||r.scrollLeft===a&&i>0))return!0}r=r.parentNode}return!1}function l(t){var l=n(t),s=l[0],a=l[1];if(!r(t.target,s,a)){var c=!1;e.settings.useBothWheelAxes?e.scrollbarYActive&&!e.scrollbarXActive?(a?o.scrollTop-=a*e.settings.wheelSpeed:o.scrollTop+=s*e.settings.wheelSpeed,c=!0):e.scrollbarXActive&&!e.scrollbarYActive&&(s?o.scrollLeft+=s*e.settings.wheelSpeed:o.scrollLeft-=a*e.settings.wheelSpeed,c=!0):(o.scrollTop-=a*e.settings.wheelSpeed,o.scrollLeft+=s*e.settings.wheelSpeed),R(e),(c=c||i(s,a))&&!t.ctrlKey&&(t.stopPropagation(),t.preventDefault())}}var o=e.element;void 0!==window.onwheel?e.event.bind(o,"wheel",l):void 0!==window.onmousewheel&&e.event.bind(o,"mousewheel",l)},touch:function(t){function e(e,i){var n=h.scrollTop,r=h.scrollLeft,l=Math.abs(e),o=Math.abs(i);if(o>l){if(i<0&&n===t.contentHeight-t.containerHeight||i>0&&0===n)return{stop:!t.settings.swipePropagation,prevent:0===window.scrollY}}else if(l>o&&(e<0&&r===t.contentWidth-t.containerWidth||e>0&&0===r))return{stop:!t.settings.swipePropagation,prevent:!0};return{stop:!0,prevent:!0}}function i(e,i){h.scrollTop-=i,h.scrollLeft-=e,R(t)}function n(){b=!0}function r(){b=!1}function l(t){return t.targetTouches?t.targetTouches[0]:t}function o(t){return!(t.pointerType&&"pen"===t.pointerType&&0===t.buttons||(!t.targetTouches||1!==t.targetTouches.length)&&(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function s(t){if(o(t)){g=!0;var e=l(t);u.pageX=e.pageX,u.pageY=e.pageY,d=(new Date).getTime(),null!==f&&clearInterval(f),t.stopPropagation()}}function a(n){if(!g&&t.settings.swipePropagation&&s(n),!b&&g&&o(n)){var r=l(n),a={pageX:r.pageX,pageY:r.pageY},c=a.pageX-u.pageX,h=a.pageY-u.pageY;i(c,h),u=a;var f=(new Date).getTime(),v=f-d;v>0&&(p.x=c/v,p.y=h/v,d=f);var m=e(c,h),w=m.stop,Y=m.prevent;w&&n.stopPropagation(),Y&&n.preventDefault()}}function c(){!b&&g&&(g=!1,t.settings.swipeEasing&&(clearInterval(f),f=setInterval(function(){t.isInitialized?clearInterval(f):p.x||p.y?Math.abs(p.x)<.01&&Math.abs(p.y)<.01?clearInterval(f):(i(30*p.x,30*p.y),p.x*=.8,p.y*=.8):clearInterval(f)},10)))}if(L.supportsTouch||L.supportsIePointer){var h=t.element,u={},d=0,p={},f=null,b=!1,g=!1;L.supportsTouch?(t.event.bind(window,"touchstart",n),t.event.bind(window,"touchend",r),t.event.bind(h,"touchstart",s),t.event.bind(h,"touchmove",a),t.event.bind(h,"touchend",c)):L.supportsIePointer&&(window.PointerEvent?(t.event.bind(window,"pointerdown",n),t.event.bind(window,"pointerup",r),t.event.bind(h,"pointerdown",s),t.event.bind(h,"pointermove",a),t.event.bind(h,"pointerup",c)):window.MSPointerEvent&&(t.event.bind(window,"MSPointerDown",n),t.event.bind(window,"MSPointerUp",r),t.event.bind(h,"MSPointerDown",s),t.event.bind(h,"MSPointerMove",a),t.event.bind(h,"MSPointerUp",c)))}}},H=function(n,r){var l=this;if(void 0===r&&(r={}),"string"==typeof n&&(n=document.querySelector(n)),!n||!n.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");this.element=n,n.classList.add(m.main),this.settings={handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxScrollbarLength:null,minScrollbarLength:null,scrollingThreshold:1e3,scrollXMarginOffset:0,scrollYMarginOffset:0,suppressScrollX:!1,suppressScrollY:!1,swipePropagation:!0,swipeEasing:!0,useBothWheelAxes:!1,wheelPropagation:!1,wheelSpeed:1};for(var o in r)l.settings[o]=r[o];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var s=function(){return n.classList.add(m.state.focus)},a=function(){return n.classList.remove(m.state.focus)};this.isRtl="rtl"===t(n).direction,this.isNegativeScroll=function(){var t=n.scrollLeft,e=null;return n.scrollLeft=-1,e=n.scrollLeft<0,n.scrollLeft=t,e}(),this.negativeScrollAdjustment=this.isNegativeScroll?n.scrollWidth-n.clientWidth:0,this.event=new W,this.ownerDocument=n.ownerDocument||document,this.scrollbarXRail=i(m.element.rail("x")),n.appendChild(this.scrollbarXRail),this.scrollbarX=i(m.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",s),this.event.bind(this.scrollbarX,"blur",a),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var c=t(this.scrollbarXRail);this.scrollbarXBottom=parseInt(c.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=u(c.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=u(c.borderLeftWidth)+u(c.borderRightWidth),e(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=u(c.marginLeft)+u(c.marginRight),e(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=i(m.element.rail("y")),n.appendChild(this.scrollbarYRail),this.scrollbarY=i(m.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",s),this.event.bind(this.scrollbarY,"blur",a),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var h=t(this.scrollbarYRail);this.scrollbarYRight=parseInt(h.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=u(h.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?p(this.scrollbarY):null,this.railBorderYWidth=u(h.borderTopWidth)+u(h.borderBottomWidth),e(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=u(h.marginTop)+u(h.marginBottom),e(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:n.scrollLeft<=0?"start":n.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:n.scrollTop<=0?"start":n.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return T[t](l)}),this.lastScrollTop=n.scrollTop,this.lastScrollLeft=n.scrollLeft,this.event.bind(this.element,"scroll",function(t){return l.onScroll(t)}),R(this)};return H.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,e(this.scrollbarXRail,{display:"block"}),e(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=u(t(this.scrollbarXRail).marginLeft)+u(t(this.scrollbarXRail).marginRight),this.railYMarginHeight=u(t(this.scrollbarYRail).marginTop)+u(t(this.scrollbarYRail).marginBottom),e(this.scrollbarXRail,{display:"none"}),e(this.scrollbarYRail,{display:"none"}),R(this),y(this,"top",0,!1,!0),y(this,"left",0,!1,!0),e(this.scrollbarXRail,{display:""}),e(this.scrollbarYRail,{display:""}))},H.prototype.onScroll=function(t){this.isAlive&&(R(this),y(this,"top",this.element.scrollTop-this.lastScrollTop),y(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=this.element.scrollTop,this.lastScrollLeft=this.element.scrollLeft)},H.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),r(this.scrollbarX),r(this.scrollbarY),r(this.scrollbarXRail),r(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},H.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")},H}); \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.html b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.html new file mode 100644 index 0000000..e0faed5 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.html @@ -0,0 +1,5 @@ +
+
+
+
+
diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js new file mode 100644 index 0000000..7064342 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js @@ -0,0 +1,24 @@ +'use strict'; + +System.register(['./piechart_ctrl', 'app/plugins/sdk'], function (_export, _context) { + "use strict"; + + var PieChartCtrl, loadPluginCss; + return { + setters: [function (_piechart_ctrl) { + PieChartCtrl = _piechart_ctrl.PieChartCtrl; + }, function (_appPluginsSdk) { + loadPluginCss = _appPluginsSdk.loadPluginCss; + }], + execute: function () { + + loadPluginCss({ + dark: 'plugins/grafana-piechart-panel/css/piechart.dark.css', + light: 'plugins/grafana-piechart-panel/css/piechart.light.css' + }); + + _export('PanelCtrl', PieChartCtrl); + } + }; +}); +//# sourceMappingURL=module.js.map diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js.map b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js.map new file mode 100644 index 0000000..abbcb8f --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/module.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/module.js"],"names":["PieChartCtrl","loadPluginCss","dark","light"],"mappings":";;;;;;;;AAASA,kB,kBAAAA,Y;;AACAC,mB,kBAAAA,a;;;;AAETA,oBAAc;AACZC,cAAM,sDADM;AAEZC,eAAO;AAFK,OAAd;;2BAKSH,Y","file":"module.js","sourcesContent":["import { PieChartCtrl } from './piechart_ctrl';\nimport { loadPluginCss } from 'app/plugins/sdk';\n\nloadPluginCss({\n dark: 'plugins/grafana-piechart-panel/css/piechart.dark.css',\n light: 'plugins/grafana-piechart-panel/css/piechart.light.css',\n});\n\nexport { PieChartCtrl as PanelCtrl };\n"]} \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js new file mode 100644 index 0000000..1371074 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js @@ -0,0 +1,275 @@ +'use strict'; + +System.register(['app/plugins/sdk', 'lodash', 'app/core/utils/kbn', 'app/core/time_series', './rendering', './legend'], function (_export, _context) { + "use strict"; + + var MetricsPanelCtrl, _, kbn, TimeSeries, rendering, legend, _createClass, PieChartCtrl; + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + } + + function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + } + + function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + } + + return { + setters: [function (_appPluginsSdk) { + MetricsPanelCtrl = _appPluginsSdk.MetricsPanelCtrl; + }, function (_lodash) { + _ = _lodash.default; + }, function (_appCoreUtilsKbn) { + kbn = _appCoreUtilsKbn.default; + }, function (_appCoreTime_series) { + TimeSeries = _appCoreTime_series.default; + }, function (_rendering) { + rendering = _rendering.default; + }, function (_legend) { + legend = _legend.default; + }], + execute: function () { + _createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + _export('PieChartCtrl', PieChartCtrl = function (_MetricsPanelCtrl) { + _inherits(PieChartCtrl, _MetricsPanelCtrl); + + function PieChartCtrl($scope, $injector, $rootScope) { + _classCallCheck(this, PieChartCtrl); + + var _this = _possibleConstructorReturn(this, (PieChartCtrl.__proto__ || Object.getPrototypeOf(PieChartCtrl)).call(this, $scope, $injector)); + + _this.$rootScope = $rootScope; + _this.hiddenSeries = {}; + + var panelDefaults = { + pieType: 'pie', + legend: { + show: true, // disable/enable legend + values: true + }, + links: [], + datasource: null, + maxDataPoints: 3, + interval: null, + targets: [{}], + cacheTimeout: null, + nullPointMode: 'connected', + legendType: 'Under graph', + breakPoint: '50%', + aliasColors: {}, + format: 'short', + valueName: 'current', + strokeWidth: 1, + fontSize: '80%', + combine: { + threshold: 0.0, + label: 'Others' + } + }; + + _.defaults(_this.panel, panelDefaults); + _.defaults(_this.panel.legend, panelDefaults.legend); + + _this.events.on('render', _this.onRender.bind(_this)); + _this.events.on('data-received', _this.onDataReceived.bind(_this)); + _this.events.on('data-error', _this.onDataError.bind(_this)); + _this.events.on('data-snapshot-load', _this.onDataReceived.bind(_this)); + _this.events.on('init-edit-mode', _this.onInitEditMode.bind(_this)); + + _this.setLegendWidthForLegacyBrowser(); + return _this; + } + + _createClass(PieChartCtrl, [{ + key: 'onInitEditMode', + value: function onInitEditMode() { + this.addEditorTab('Options', 'public/plugins/grafana-piechart-panel/editor.html', 2); + this.unitFormats = kbn.getUnitFormats(); + } + }, { + key: 'setUnitFormat', + value: function setUnitFormat(subItem) { + this.panel.format = subItem.value; + this.render(); + } + }, { + key: 'onDataError', + value: function onDataError() { + this.series = []; + this.render(); + } + }, { + key: 'changeSeriesColor', + value: function changeSeriesColor(series, color) { + series.color = color; + this.panel.aliasColors[series.alias] = series.color; + this.render(); + } + }, { + key: 'onRender', + value: function onRender() { + this.data = this.parseSeries(this.series); + } + }, { + key: 'parseSeries', + value: function parseSeries(series) { + var _this2 = this; + + return _.map(this.series, function (serie, i) { + return { + label: serie.alias, + data: serie.stats[_this2.panel.valueName], + color: _this2.panel.aliasColors[serie.alias] || _this2.$rootScope.colors[i], + legendData: serie.stats[_this2.panel.valueName] + }; + }); + } + }, { + key: 'onDataReceived', + value: function onDataReceived(dataList) { + this.series = dataList.map(this.seriesHandler.bind(this)); + this.data = this.parseSeries(this.series); + this.render(this.data); + } + }, { + key: 'seriesHandler', + value: function seriesHandler(seriesData) { + var series = new TimeSeries({ + datapoints: seriesData.datapoints, + alias: seriesData.target + }); + + series.flotpairs = series.getFlotPairs(this.panel.nullPointMode); + return series; + } + }, { + key: 'getDecimalsForValue', + value: function getDecimalsForValue(value) { + if (_.isNumber(this.panel.decimals)) { + return { decimals: this.panel.decimals, scaledDecimals: null }; + } + + var delta = value / 2; + var dec = -Math.floor(Math.log(delta) / Math.LN10); + + var magn = Math.pow(10, -dec); + var norm = delta / magn; // norm is between 1.0 and 10.0 + var size; + + if (norm < 1.5) { + size = 1; + } else if (norm < 3) { + size = 2; + // special case for 2.5, requires an extra decimal + if (norm > 2.25) { + size = 2.5; + ++dec; + } + } else if (norm < 7.5) { + size = 5; + } else { + size = 10; + } + + size *= magn; + + // reduce starting decimals if not needed + if (Math.floor(value) === value) { + dec = 0; + } + + var result = {}; + result.decimals = Math.max(0, dec); + result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2; + + return result; + } + }, { + key: 'formatValue', + value: function formatValue(value) { + var decimalInfo = this.getDecimalsForValue(value); + var formatFunc = kbn.valueFormats[this.panel.format]; + if (formatFunc) { + return formatFunc(value, decimalInfo.decimals, decimalInfo.scaledDecimals); + } + return value; + } + }, { + key: 'link', + value: function link(scope, elem, attrs, ctrl) { + rendering(scope, elem, attrs, ctrl); + } + }, { + key: 'toggleSeries', + value: function toggleSeries(serie) { + if (this.hiddenSeries[serie.label]) { + delete this.hiddenSeries[serie.label]; + } else { + this.hiddenSeries[serie.label] = true; + } + this.render(); + } + }, { + key: 'onLegendTypeChanged', + value: function onLegendTypeChanged() { + this.setLegendWidthForLegacyBrowser(); + this.render(); + } + }, { + key: 'setLegendWidthForLegacyBrowser', + value: function setLegendWidthForLegacyBrowser() { + var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; + if (isIE11 && this.panel.legendType === 'Right side' && !this.panel.legend.sideWidth) { + this.panel.legend.sideWidth = 150; + } + } + }]); + + return PieChartCtrl; + }(MetricsPanelCtrl)); + + _export('PieChartCtrl', PieChartCtrl); + + PieChartCtrl.templateUrl = 'module.html'; + } + }; +}); +//# sourceMappingURL=piechart_ctrl.js.map diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js.map b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js.map new file mode 100644 index 0000000..fe025bc --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/piechart_ctrl.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/piechart_ctrl.js"],"names":["MetricsPanelCtrl","_","kbn","TimeSeries","rendering","legend","PieChartCtrl","$scope","$injector","$rootScope","hiddenSeries","panelDefaults","pieType","show","values","links","datasource","maxDataPoints","interval","targets","cacheTimeout","nullPointMode","legendType","breakPoint","aliasColors","format","valueName","strokeWidth","fontSize","combine","threshold","label","defaults","panel","events","on","onRender","bind","onDataReceived","onDataError","onInitEditMode","setLegendWidthForLegacyBrowser","addEditorTab","unitFormats","getUnitFormats","subItem","value","render","series","color","alias","data","parseSeries","map","serie","i","stats","colors","legendData","dataList","seriesHandler","seriesData","datapoints","target","flotpairs","getFlotPairs","isNumber","decimals","scaledDecimals","delta","dec","Math","floor","log","LN10","magn","pow","norm","size","result","max","decimalInfo","getDecimalsForValue","formatFunc","valueFormats","scope","elem","attrs","ctrl","isIE11","window","MSInputMethodContext","document","documentMode","sideWidth","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAQA,sB,kBAAAA,gB;;AACDC,O;;AACAC,S;;AACAC,gB;;AACAC,e;;AACAC,Y;;;;;;;;;;;;;;;;;;;;;8BAEMC,Y;;;AAEX,8BAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,UAA/B,EAA2C;AAAA;;AAAA,kIACnCF,MADmC,EAC3BC,SAD2B;;AAEzC,gBAAKC,UAAL,GAAkBA,UAAlB;AACA,gBAAKC,YAAL,GAAoB,EAApB;;AAEA,cAAIC,gBAAgB;AAClBC,qBAAS,KADS;AAElBP,oBAAQ;AACNQ,oBAAM,IADA,EACM;AACZC,s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;;;sCAEWjC,K,EAAO;AACjB,gBAAImC,cAAc,KAAKC,mBAAL,CAAyBpC,KAAzB,CAAlB;AACA,gBAAIqC,aAAajF,IAAIkF,YAAJ,CAAiB,KAAKnD,KAAL,CAAWR,MAA5B,CAAjB;AACA,gBAAI0D,UAAJ,EAAgB;AACd,qBAAOA,WAAWrC,KAAX,EAAkBmC,YAAYd,QAA9B,EAAwCc,YAAYb,cAApD,CAAP;AACD;AACD,mBAAOtB,KAAP;AACD;;;+BAEIuC,K,EAAOC,I,EAAMC,K,EAAOC,I,EAAM;AAC7BpF,sBAAUiF,KAAV,EAAiBC,IAAjB,EAAuBC,KAAvB,EAA8BC,IAA9B;AACD;;;uCAEYlC,K,EAAO;AAClB,gBAAI,KAAK5C,YAAL,CAAkB4C,MAAMvB,KAAxB,CAAJ,EAAoC;AAClC,qBAAO,KAAKrB,YAAL,CAAkB4C,MAAMvB,KAAxB,CAAP;AACD,aAFD,MAEO;AACL,mBAAKrB,YAAL,CAAkB4C,MAAMvB,KAAxB,IAAiC,IAAjC;AACD;AACD,iBAAKgB,MAAL;AACD;;;gDAEqB;AACpB,iBAAKN,8BAAL;AACA,iBAAKM,MAAL;AACD;;;2DAEgC;AAC/B,gBAAI0C,SAAS,CAAC,CAACC,OAAOC,oBAAT,IAAiC,CAAC,CAACC,SAASC,YAAzD;AACA,gBAAIJ,UAAU,KAAKxD,KAAL,CAAWX,UAAX,KAA0B,YAApC,IAAoD,CAAC,KAAKW,KAAL,CAAW5B,MAAX,CAAkByF,SAA3E,EAAsF;AACpF,mBAAK7D,KAAL,CAAW5B,MAAX,CAAkByF,SAAlB,GAA8B,GAA9B;AACD;AACF;;;;QAxK+B9F,gB;;;;AA2KlCM,mBAAayF,WAAb,GAA2B,aAA3B","file":"piechart_ctrl.js","sourcesContent":["import {MetricsPanelCtrl} from 'app/plugins/sdk';\nimport _ from 'lodash';\nimport kbn from 'app/core/utils/kbn';\nimport TimeSeries from 'app/core/time_series';\nimport rendering from './rendering';\nimport legend from './legend';\n\nexport class PieChartCtrl extends MetricsPanelCtrl {\n\n constructor($scope, $injector, $rootScope) {\n super($scope, $injector);\n this.$rootScope = $rootScope;\n this.hiddenSeries = {};\n\n var panelDefaults = {\n pieType: 'pie',\n legend: {\n show: true, // disable/enable legend\n values: true\n },\n links: [],\n datasource: null,\n maxDataPoints: 3,\n interval: null,\n targets: [{}],\n cacheTimeout: null,\n nullPointMode: 'connected',\n legendType: 'Under graph',\n breakPoint: '50%',\n aliasColors: {},\n format: 'short',\n valueName: 'current',\n strokeWidth: 1,\n fontSize: '80%',\n combine: {\n threshold: 0.0,\n label: 'Others'\n }\n };\n\n _.defaults(this.panel, panelDefaults);\n _.defaults(this.panel.legend, panelDefaults.legend);\n\n this.events.on('render', this.onRender.bind(this));\n this.events.on('data-received', this.onDataReceived.bind(this));\n this.events.on('data-error', this.onDataError.bind(this));\n this.events.on('data-snapshot-load', this.onDataReceived.bind(this));\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n\n this.setLegendWidthForLegacyBrowser();\n }\n\n onInitEditMode() {\n this.addEditorTab('Options', 'public/plugins/grafana-piechart-panel/editor.html', 2);\n this.unitFormats = kbn.getUnitFormats();\n }\n\n setUnitFormat(subItem) {\n this.panel.format = subItem.value;\n this.render();\n }\n\n onDataError() {\n this.series = [];\n this.render();\n }\n\n changeSeriesColor(series, color) {\n series.color = color;\n this.panel.aliasColors[series.alias] = series.color;\n this.render();\n }\n\n onRender() {\n this.data = this.parseSeries(this.series);\n }\n\n parseSeries(series) {\n return _.map(this.series, (serie, i) => {\n return {\n label: serie.alias,\n data: serie.stats[this.panel.valueName],\n color: this.panel.aliasColors[serie.alias] || this.$rootScope.colors[i],\n legendData: serie.stats[this.panel.valueName],\n };\n });\n }\n\n onDataReceived(dataList) {\n this.series = dataList.map(this.seriesHandler.bind(this));\n this.data = this.parseSeries(this.series);\n this.render(this.data);\n }\n\n seriesHandler(seriesData) {\n var series = new TimeSeries({\n datapoints: seriesData.datapoints,\n alias: seriesData.target\n });\n\n series.flotpairs = series.getFlotPairs(this.panel.nullPointMode);\n return series;\n }\n\n getDecimalsForValue(value) {\n if (_.isNumber(this.panel.decimals)) {\n return { decimals: this.panel.decimals, scaledDecimals: null };\n }\n\n var delta = value / 2;\n var dec = -Math.floor(Math.log(delta) / Math.LN10);\n\n var magn = Math.pow(10, -dec);\n var norm = delta / magn; // norm is between 1.0 and 10.0\n var size;\n\n if (norm < 1.5) {\n size = 1;\n } else if (norm < 3) {\n size = 2;\n // special case for 2.5, requires an extra decimal\n if (norm > 2.25) {\n size = 2.5;\n ++dec;\n }\n } else if (norm < 7.5) {\n size = 5;\n } else {\n size = 10;\n }\n\n size *= magn;\n\n // reduce starting decimals if not needed\n if (Math.floor(value) === value) { dec = 0; }\n\n var result = {};\n result.decimals = Math.max(0, dec);\n result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2;\n\n return result;\n }\n\n formatValue(value) {\n var decimalInfo = this.getDecimalsForValue(value);\n var formatFunc = kbn.valueFormats[this.panel.format];\n if (formatFunc) {\n return formatFunc(value, decimalInfo.decimals, decimalInfo.scaledDecimals);\n }\n return value;\n }\n\n link(scope, elem, attrs, ctrl) {\n rendering(scope, elem, attrs, ctrl);\n }\n\n toggleSeries(serie) {\n if (this.hiddenSeries[serie.label]) {\n delete this.hiddenSeries[serie.label];\n } else {\n this.hiddenSeries[serie.label] = true;\n }\n this.render();\n }\n\n onLegendTypeChanged() {\n this.setLegendWidthForLegacyBrowser();\n this.render();\n }\n\n setLegendWidthForLegacyBrowser() {\n var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;\n if (isIE11 && this.panel.legendType === 'Right side' && !this.panel.legend.sideWidth) {\n this.panel.legend.sideWidth = 150;\n }\n }\n}\n\nPieChartCtrl.templateUrl = 'module.html';\n"]} \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/plugin.json b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/plugin.json new file mode 100644 index 0000000..74313c0 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/plugin.json @@ -0,0 +1,37 @@ +{ + "type": "panel", + "name": "Pie Chart", + "id": "grafana-piechart-panel", + + "info": { + "description": "Pie chart panel for grafana", + "author": { + "name": "Grafana Labs", + "url": "http://grafana.com" + }, + "keywords": ["piechart", "panel"], + "logos": { + "small": "src/img/piechart_logo_small.png", + "large": "src/img/piechart_logo_large.png" + }, + "links": [ + {"name": "Project site", "url": "https://github.com/grafana/piechart-panel"}, + {"name": "Blog Post", "url": "https://blog.raintank.io/friends-dont-let-friends-abuse-pie-charts/"}, + {"name": "MIT License", "url": "https://github.com/grafana/piechart-panel/blob/master/LICENSE"} + ], + "screenshots": [ + {"name": "Donut!", "path": "src/img/piechart-donut.png"}, + {"name": "Legend on the graph", "path": "src/img/piechart-legend-on-graph.png"}, + {"name": "Legend to the right", "path": "src/img/piechart-legend-rhs.png"}, + {"name": "Legend underneath", "path": "src/img/piechart-legend-under.png"}, + {"name": "Piechart options", "path": "src/img/piechart-options.png"} + ], + "version": "1.3.3", + "updated": "2018-06-14" + }, + + "dependencies": { + "grafanaVersion": "4.6", + "plugins": [ ] + } +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js new file mode 100644 index 0000000..b3676e3 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js @@ -0,0 +1,189 @@ +'use strict'; + +System.register(['lodash', 'jquery', 'jquery.flot', 'jquery.flot.pie'], function (_export, _context) { + "use strict"; + + var _, $; + + function link(scope, elem, attrs, ctrl) { + var data, panel; + elem = elem.find('.piechart-panel__chart'); + var $tooltip = $('
'); + + ctrl.events.on('render', function () { + render(false); + if (panel.legendType === 'Right side') { + setTimeout(function () { + render(true); + }, 50); + } + }); + + function getLegendHeight(panelHeight) { + if (!ctrl.panel.legend.show || ctrl.panel.legendType === 'Right side' || ctrl.panel.legendType === 'On graph') { + return 20; + } + + if (ctrl.panel.legendType == 'Under graph' && ctrl.panel.legend.percentage || ctrl.panel.legend.values) { + var breakPoint = parseInt(ctrl.panel.breakPoint) / 100; + var total = 23 + 20 * data.length; + return Math.min(total, Math.floor(panelHeight * breakPoint)); + } + } + + function formatter(label, slice) { + var slice_data = slice.data[0][slice.data[0].length - 1]; + var decimal = 2; + var start = "
" + label + "
"; + + if (ctrl.panel.legend.percentageDecimals) { + decimal = ctrl.panel.legend.percentageDecimals; + } + if (ctrl.panel.legend.values && ctrl.panel.legend.percentage) { + return start + ctrl.formatValue(slice_data) + "
" + slice.percent.toFixed(decimal) + "%
"; + } else if (ctrl.panel.legend.values) { + return start + ctrl.formatValue(slice_data) + "
"; + } else if (ctrl.panel.legend.percentage) { + return start + slice.percent.toFixed(decimal) + "%"; + } else { + return start + ''; + } + } + + function noDataPoints() { + var html = '
No data points
'; + elem.html(html); + } + + function addPieChart() { + var width = elem.width(); + var height = ctrl.height - getLegendHeight(ctrl.height); + + var size = Math.min(width, height); + + var plotCanvas = $('
'); + var plotCss = { + margin: 'auto', + position: 'relative', + paddingBottom: 20 + 'px', + height: size + 'px' + }; + + plotCanvas.css(plotCss); + + var backgroundColor = $('body').css('background-color'); + + var options = { + legend: { + show: false + }, + series: { + pie: { + show: true, + stroke: { + color: backgroundColor, + width: parseFloat(ctrl.panel.strokeWidth).toFixed(1) + }, + label: { + show: ctrl.panel.legend.show && ctrl.panel.legendType === 'On graph', + formatter: formatter + }, + highlight: { + opacity: 0.0 + }, + combine: { + threshold: ctrl.panel.combine.threshold, + label: ctrl.panel.combine.label + } + } + }, + grid: { + hoverable: true, + clickable: false + } + }; + + if (panel.pieType === 'donut') { + options.series.pie.innerRadius = 0.5; + } + + data = ctrl.data; + + for (var i = 0; i < data.length; i++) { + var series = data[i]; + + // if hidden remove points + if (ctrl.hiddenSeries[series.label]) { + series.data = {}; + } + } + + if (panel.legend.sort) { + if (ctrl.panel.valueName !== panel.legend.sort) { + panel.legend.sort = ctrl.panel.valueName; + } + if (panel.legend.sortDesc === true) { + data.sort(function (a, b) { + return b.legendData - a.legendData; + }); + } else { + data.sort(function (a, b) { + return a.legendData - b.legendData; + }); + } + } + + elem.html(plotCanvas); + + $.plot(plotCanvas, data, options); + plotCanvas.bind("plothover", function (event, pos, item) { + if (!item) { + $tooltip.detach(); + return; + } + + var body; + var percent = parseFloat(item.series.percent).toFixed(2); + var formatted = ctrl.formatValue(item.series.data[0][1]); + + body = '
'; + body += '
' + item.series.label + ': ' + formatted; + body += " (" + percent + "%)" + '
'; + body += "
"; + + $tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY); + }); + } + + function render(incrementRenderCounter) { + if (!ctrl.data) { + return; + } + + data = ctrl.data; + panel = ctrl.panel; + + if (0 == ctrl.data.length) { + noDataPoints(); + } else { + addPieChart(); + } + + if (incrementRenderCounter) { + ctrl.renderingCompleted(); + } + } + } + + _export('default', link); + + return { + setters: [function (_lodash) { + _ = _lodash.default; + }, function (_jquery) { + $ = _jquery.default; + }, function (_jqueryFlot) {}, function (_jqueryFlotPie) {}], + execute: function () {} + }; +}); +//# sourceMappingURL=rendering.js.map diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js.map b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js.map new file mode 100644 index 0000000..029c073 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/rendering.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/rendering.js"],"names":["link","scope","elem","attrs","ctrl","data","panel","find","$tooltip","$","events","on","render","legendType","setTimeout","getLegendHeight","panelHeight","legend","show","percentage","values","breakPoint","parseInt","total","length","Math","min","floor","formatter","label","slice","slice_data","decimal","start","fontSize","color","percentageDecimals","formatValue","percent","toFixed","noDataPoints","html","addPieChart","width","height","size","plotCanvas","plotCss","margin","position","paddingBottom","css","backgroundColor","options","series","pie","stroke","parseFloat","strokeWidth","highlight","opacity","combine","threshold","grid","hoverable","clickable","pieType","innerRadius","i","hiddenSeries","sort","valueName","sortDesc","a","b","legendData","plot","bind","event","pos","item","detach","body","formatted","place_tt","pageX","pageY","incrementRenderCounter","renderingCompleted","_"],"mappings":";;;;;;;AAKe,WAASA,IAAT,CAAcC,KAAd,EAAqBC,IAArB,EAA2BC,KAA3B,EAAkCC,IAAlC,EAAwC;AACrD,QAAIC,IAAJ,EAAUC,KAAV;AACAJ,WAAOA,KAAKK,IAAL,CAAU,wBAAV,CAAP;AACA,QAAIC,WAAWC,EAAE,oBAAF,CAAf;;AAEAL,SAAKM,MAAL,CAAYC,EAAZ,CAAe,QAAf,EAAyB,YAAY;AACnCC,aAAO,KAAP;AACA,UAAIN,MAAMO,UAAN,KAAqB,YAAzB,EAAuC;AACrCC,mBAAW,YAAY;AAAEF,iBAAO,IAAP;AAAe,SAAxC,EAA0C,EAA1C;AACD;AACF,KALD;;AAOA,aAASG,eAAT,CAAyBC,WAAzB,EAAsC;AACpC,UAAI,CAACZ,KAAKE,KAAL,CAAWW,MAAX,CAAkBC,IAAnB,IAA2Bd,KAAKE,KAAL,CAAWO,UAAX,KAA0B,YAArD,IAAqET,KAAKE,KAAL,CAAWO,UAAX,KAA0B,UAAnG,EAA+G;AAC7G,eAAO,EAAP;AACD;;AAED,UAAIT,KAAKE,KAAL,CAAWO,UAAX,IAAyB,aAAzB,IAA0CT,KAAKE,KAAL,CAAWW,MAAX,CAAkBE,UAA5D,IAA0Ef,KAAKE,KAAL,CAAWW,MAAX,CAAkBG,MAAhG,EAAwG;AACtG,YAAIC,aAAaC,SAASlB,KAAKE,KAAL,CAAWe,UAApB,IAAkC,GAAnD;AACA,YAAIE,QAAQ,KAAK,KAAKlB,KAAKmB,MAA3B;AACA,eAAOC,KAAKC,GAAL,CAASH,KAAT,EAAgBE,KAAKE,KAAL,CAAWX,cAAcK,UAAzB,CAAhB,CAAP;AACD;AACF;;AAED,aAASO,SAAT,CAAmBC,KAAnB,EAA0B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AiB,CAAjB,EAAoB,CAApB,CAAjB,CAAhB;;AAEA6E,eAAO,yEAAP;AACAA,gBAAQ,yCAAyCF,KAAK1B,MAAL,CAAYzB,KAArD,GAA6D,IAA7D,GAAoEsD,SAA5E;AACAD,gBAAQ,OAAO5C,OAAP,GAAiB,IAAjB,GAAwB,QAAhC;AACA4C,gBAAQ,cAAR;;AAEA1E,iBAASiC,IAAT,CAAcyC,IAAd,EAAoBE,QAApB,CAA6BL,IAAIM,KAAJ,GAAY,EAAzC,EAA6CN,IAAIO,KAAjD;AACD,OAhBD;AAiBD;;AAED,aAAS1E,MAAT,CAAgB2E,sBAAhB,EAAwC;AACtC,UAAI,CAACnF,KAAKC,IAAV,EAAgB;AAAE;AAAS;;AAE3BA,aAAOD,KAAKC,IAAZ;AACAC,cAAQF,KAAKE,KAAb;;AAEE,UAAI,KAAKF,KAAKC,IAAL,CAAUmB,MAAnB,EAA2B;AACzBgB;AACD,OAFD,MAEO;AACLE;AACD;;AAEH,UAAI6C,sBAAJ,EAA4B;AAC1BnF,aAAKoF,kBAAL;AACD;AACF;AACF;;qBArKuBxF,I;;;;AALjByF,O;;AACAhF,O","file":"rendering.js","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport 'jquery.flot';\nimport 'jquery.flot.pie';\n\nexport default function link(scope, elem, attrs, ctrl) {\n var data, panel;\n elem = elem.find('.piechart-panel__chart');\n var $tooltip = $('
');\n\n ctrl.events.on('render', function () {\n render(false);\n if (panel.legendType === 'Right side') {\n setTimeout(function () { render(true); }, 50);\n }\n });\n\n function getLegendHeight(panelHeight) {\n if (!ctrl.panel.legend.show || ctrl.panel.legendType === 'Right side' || ctrl.panel.legendType === 'On graph') {\n return 20;\n }\n\n if (ctrl.panel.legendType == 'Under graph' && ctrl.panel.legend.percentage || ctrl.panel.legend.values) {\n let breakPoint = parseInt(ctrl.panel.breakPoint) / 100;\n var total = 23 + 20 * data.length;\n return Math.min(total, Math.floor(panelHeight * breakPoint));\n }\n }\n\n function formatter(label, slice) {\n var slice_data = slice.data[0][slice.data[0].length - 1];\n var decimal = 2;\n var start = \"
\" + label + \"
\";\n\n if (ctrl.panel.legend.percentageDecimals) {\n decimal = ctrl.panel.legend.percentageDecimals;\n }\n if (ctrl.panel.legend.values && ctrl.panel.legend.percentage) {\n return start + ctrl.formatValue(slice_data) + \"
\" + slice.percent.toFixed(decimal) + \"%
\";\n } else if (ctrl.panel.legend.values) {\n return start + ctrl.formatValue(slice_data) + \"
\";\n } else if (ctrl.panel.legend.percentage) {\n return start + slice.percent.toFixed(decimal) + \"%\";\n } else {\n return start + '';\n }\n }\n\n function noDataPoints() {\n var html = '
No data points
';\n elem.html(html);\n }\n\n function addPieChart() {\n var width = elem.width();\n var height = ctrl.height - getLegendHeight(ctrl.height);\n\n var size = Math.min(width, height);\n\n var plotCanvas = $('
');\n var plotCss = {\n margin: 'auto',\n position: 'relative',\n paddingBottom: 20 + 'px',\n height: size + 'px'\n };\n\n plotCanvas.css(plotCss);\n\n var backgroundColor = $('body').css('background-color')\n\n var options = {\n legend: {\n show: false\n },\n series: {\n pie: {\n show: true,\n stroke: {\n color: backgroundColor,\n width: parseFloat(ctrl.panel.strokeWidth).toFixed(1)\n },\n label: {\n show: ctrl.panel.legend.show && ctrl.panel.legendType === 'On graph',\n formatter: formatter\n },\n highlight: {\n opacity: 0.0\n },\n combine: {\n threshold: ctrl.panel.combine.threshold,\n label: ctrl.panel.combine.label\n }\n }\n },\n grid: {\n hoverable: true,\n clickable: false\n }\n };\n\n if (panel.pieType === 'donut') {\n options.series.pie.innerRadius = 0.5;\n }\n\n data = ctrl.data;\n\n for (let i = 0; i < data.length; i++) {\n let series = data[i];\n\n // if hidden remove points\n if (ctrl.hiddenSeries[series.label]) {\n series.data = {};\n }\n }\n\n\n if (panel.legend.sort) {\n if (ctrl.panel.valueName !== panel.legend.sort) {\n panel.legend.sort = ctrl.panel.valueName;\n }\n if (panel.legend.sortDesc === true) {\n data.sort(function (a, b) {\n return b.legendData - a.legendData;\n });\n } else {\n data.sort(function (a, b) {\n return a.legendData - b.legendData;\n });\n }\n }\n\n elem.html(plotCanvas);\n\n $.plot(plotCanvas, data, options);\n plotCanvas.bind(\"plothover\", function (event, pos, item) {\n if (!item) {\n $tooltip.detach();\n return;\n }\n\n var body;\n var percent = parseFloat(item.series.percent).toFixed(2);\n var formatted = ctrl.formatValue(item.series.data[0][1]);\n\n body = '
';\n body += '
' + item.series.label + ': ' + formatted;\n body += \" (\" + percent + \"%)\" + '
';\n body += \"
\";\n\n $tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY);\n });\n }\n\n function render(incrementRenderCounter) {\n if (!ctrl.data) { return; }\n\n data = ctrl.data;\n panel = ctrl.panel;\n\n if (0 == ctrl.data.length) {\n noDataPoints();\n } else {\n addPieChart();\n }\n\n if (incrementRenderCounter) {\n ctrl.renderingCompleted();\n }\n }\n}\n\n"]} \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-donut.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-donut.png new file mode 100644 index 0000000..8e54878 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-donut.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-on-graph.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-on-graph.png new file mode 100644 index 0000000..51dfcbc Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-on-graph.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-rhs.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-rhs.png new file mode 100644 index 0000000..9b018c3 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-rhs.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-under.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-under.png new file mode 100644 index 0000000..3284511 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-legend-under.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-options.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-options.png new file mode 100644 index 0000000..117962e Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart-options.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_large.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_large.png new file mode 100644 index 0000000..21b7ab4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_large.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_small.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_small.png new file mode 100644 index 0000000..10d49e4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/dist/src/img/piechart_logo_small.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/package.json b/roles/provision-metrics-apb/files/grafana-piechart-panel/package.json new file mode 100644 index 0000000..2b14143 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/package.json @@ -0,0 +1,30 @@ +{ + "name": "piechart-panel", + "private": true, + "version": "1.0.0", + "description": "", + "repository": { + "type": "git", + "url": "git+https://github.com/grafana/piechart-panel.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "grunt": "^0.4.5", + "babel": "^6.5.1", + "grunt-babel": "^6.0.0", + "grunt-contrib-copy": "^0.8.2", + "grunt-contrib-watch": "^0.6.1", + "grunt-contrib-uglify": "^0.11.0", + "grunt-systemjs-builder": "^0.2.5", + "load-grunt-tasks": "^3.2.0", + "grunt-execute": "^0.2.2", + "grunt-contrib-clean": "0.6.0" + }, + "dependencies": { + "babel-plugin-transform-es2015-modules-systemjs": "^6.5.0", + "babel-plugin-transform-es2015-for-of": "^6.5.0", + "babel-preset-es2015": "^6.5.0", + "lodash": "^4.0.0" + } +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.dark.css b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.dark.css new file mode 100644 index 0000000..7bda621 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.dark.css @@ -0,0 +1,277 @@ +.piechart-panel { + display: flex; + flex-direction: column; + height: 100%; +} + +.piechart-panel--legend-right { + flex-direction: row; +} + +.piechart-panel--legend-right .piechart-legend { + flex: 0 1 10px; + height: 100%; +} + +.piechart-panel--legend-right .piechart-legend-series { + display: block; + padding-left: 0px; +} + +.piechart-panel--legend-right .piechart-legend-table .piechart-legend-series { + display: table-row; +} + +.piechart-legend__container { + height: 100%; +} + +.piechart-panel__chart { + position: relative; + cursor: crosshair; + flex-grow: 1; + top: 10px; +} + +.datapoints-warning { + pointer: none; + position: absolute; + top: 50%; + left: 50%; + z-index: 10; + margin-top: -50px; + margin-left: -100px; + width: 200px; + text-align: center; + cursor: auto; + padding: 10px; +} + +.piechart-legend { + flex: 0 1 auto; + margin: 0 1rem; + text-align: center; + padding-top: 6px; + position: relative; +} + +.piechart-legend .popover-content { + padding: 0; +} + +.piechart-legend-icon { + position: relative; + padding-right: 4px; + top: 1px; +} + +.piechart-legend-icon, +.piechart-legend-alias, +.piechart-legend-value { + cursor: pointer; + float: left; + white-space: nowrap; + font-size: 85%; + text-align: left; + color: #d8d9da; +} + +.piechart-legend-icon.current::before { + content: "Current: "; +} + +.piechart-legend-icon.max::before { + content: "Max: "; +} + +.piechart-legend-icon.min::before { + content: "Min: "; +} + +.piechart-legend-icon.total::before { + content: "Total: "; +} + +.piechart-legend-icon.avg::before { + content: "Avg: "; +} + +.piechart-legend-alias.current::before { + content: "Current: "; +} + +.piechart-legend-alias.max::before { + content: "Max: "; +} + +.piechart-legend-alias.min::before { + content: "Min: "; +} + +.piechart-legend-alias.total::before { + content: "Total: "; +} + +.piechart-legend-alias.avg::before { + content: "Avg: "; +} + +.piechart-legend-value.current::before { + content: "Current: "; +} + +.piechart-legend-value.max::before { + content: "Max: "; +} + +.piechart-legend-value.min::before { + content: "Min: "; +} + +.piechart-legend-value.total::before { + content: "Total: "; +} + +.piechart-legend-value.avg::before { + content: "Avg: "; +} + +.piechart-legend-icon .fa { + font-size: 135%; + position: relative; + top: 1px; +} + +.piechart-legend-series { + float: left; + white-space: nowrap; + padding-left: 10px; +} + +.piechart-legend-series--right-y { + float: right; +} + +.piechart-legend-value { + padding-left: 6px; +} + +.piechart-legend-table tbody { + display: block; + overflow-y: auto; + overflow-x: hidden; + height: 100%; + padding-bottom: 1px; + padding-right: 5px; +} + +.piechart-legend-table .piechart-legend-series { + display: table-row; + float: none; + padding-left: 0; +} + +.piechart-legend-table .piechart-legend-series--right-y { + float: none; +} + +.piechart-legend-table .piechart-legend-series--right-y .piechart-legend-alias::after { + content: "(right-y)"; + padding: 0 5px; + color: #8e8e8e; +} + +.piechart-legend-table td, +.piechart-legend-alias, +.piechart-legend-icon, +.piechart-legend-value { + float: none; + display: table-cell; + white-space: nowrap; + padding: 2px 10px; + text-align: right; +} + +.piechart-legend-table .piechart-legend-icon { + width: 5px; + padding: 0; + top: 0; +} + +.piechart-legend-table .piechart-legend-icon .fa { + top: 4px; +} + +.piechart-legend-table .piechart-legend-value { + padding-left: 15px; +} + +.piechart-legend-table .piechart-legend-alias { + padding-left: 7px; + text-align: left; + width: 95%; + max-width: 650px; + text-overflow: ellipsis; + overflow: hidden; +} + +.piechart-legend-table .piechart-legend-series:nth-child(odd) { + background: #262628; +} + +.piechart-legend-table .piechart-legend-value.current::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.max::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.min::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.total::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.avg::before { + content: ""; +} + +.piechart-legend-table th { + text-align: right; + padding: 0px 10px 1px 0; + font-weight: bold; + color: #33b5e5; + font-size: 85%; + white-space: nowrap; +} + +.piechart-legend-series-hidden .piechart-legend-value, +.piechart-legend-series-hidden .piechart-legend-alias { + color: #8e8e8e; +} + +.piechart-tooltip { + white-space: nowrap; + font-size:12px; + background-color: #141414; + color: #d8d9da; +} + +.piechart-tooltip .piechart-tooltip-time { + text-align: center; + position: relative; + top: -3px; + padding: 0.2rem; + font-weight: bold; + color: #d8d9da; +} + +.piechart-tooltip .piechart-tooltip-value { + display: table-cell; + font-weight: bold; + padding-left: 15px; + text-align: right; +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.light.css b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.light.css new file mode 100644 index 0000000..4ba0f6e --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/css/piechart.light.css @@ -0,0 +1,281 @@ +.piechart-panel { + display: flex; + flex-direction: column; + height: 100%; +} + +.piechart-panel--legend-right { + flex-direction: row; +} + +.piechart-panel--legend-right .piechart-legend { + flex: 0 1 10px; + height: 100%; +} + +_:-ms-fullscreen, :root .piechart-panel--legend-right .piechart-legend { + flex: 0 1 200px; +} + +.piechart-panel--legend-right .piechart-legend-series { + display: block; + padding-left: 0px; +} + +.piechart-panel--legend-right .piechart-legend-table .piechart-legend-series { + display: table-row; +} + +.piechart-legend__container { + height: 100%; +} + +.piechart-panel__chart { + position: relative; + cursor: crosshair; + flex-grow: 1; + top: 10px; +} + +.datapoints-warning { + pointer: none; + position: absolute; + top: 50%; + left: 50%; + z-index: 10; + margin-top: -50px; + margin-left: -100px; + width: 200px; + text-align: center; + cursor: auto; + padding: 10px; +} + +.piechart-legend { + flex: 0 1 auto; + margin: 0 1rem; + text-align: center; + padding-top: 6px; + position: relative; +} + +.piechart-legend .popover-content { + padding: 0; +} + +.piechart-legend-icon { + position: relative; + padding-right: 4px; + top: 1px; +} + +.piechart-legend-icon, +.piechart-legend-alias, +.piechart-legend-value { + cursor: pointer; + float: left; + white-space: nowrap; + font-size: 85%; + text-align: left; + color: 52545c; +} + +.piechart-legend-icon.current::before { + content: "Current: "; +} + +.piechart-legend-icon.max::before { + content: "Max: "; +} + +.piechart-legend-icon.min::before { + content: "Min: "; +} + +.piechart-legend-icon.total::before { + content: "Total: "; +} + +.piechart-legend-icon.avg::before { + content: "Avg: "; +} + +.piechart-legend-alias.current::before { + content: "Current: "; +} + +.piechart-legend-alias.max::before { + content: "Max: "; +} + +.piechart-legend-alias.min::before { + content: "Min: "; +} + +.piechart-legend-alias.total::before { + content: "Total: "; +} + +.piechart-legend-alias.avg::before { + content: "Avg: "; +} + +.piechart-legend-value.current::before { + content: "Current: "; +} + +.piechart-legend-value.max::before { + content: "Max: "; +} + +.piechart-legend-value.min::before { + content: "Min: "; +} + +.piechart-legend-value.total::before { + content: "Total: "; +} + +.piechart-legend-value.avg::before { + content: "Avg: "; +} + +.piechart-legend-icon .fa { + font-size: 135%; + position: relative; + top: 1px; +} + +.piechart-legend-series { + float: left; + white-space: nowrap; + padding-left: 10px; +} + +.piechart-legend-series--right-y { + float: right; +} + +.piechart-legend-value { + padding-left: 6px; +} + +.piechart-legend-table tbody { + display: block; + overflow-y: auto; + overflow-x: hidden; + height: 100%; + padding-bottom: 1px; + padding-right: 5px; +} + +.piechart-legend-table .piechart-legend-series { + display: table-row; + float: none; + padding-left: 0; +} + +.piechart-legend-table .piechart-legend-series--right-y { + float: none; +} + +.piechart-legend-table .piechart-legend-series--right-y .piechart-legend-alias::after { + content: "(right-y)"; + padding: 0 5px; + color: #767980; +} + +.piechart-legend-table td, +.piechart-legend-alias, +.piechart-legend-icon, +.piechart-legend-value { + float: none; + display: table-cell; + white-space: nowrap; + padding: 2px 10px; + text-align: right; +} + +.piechart-legend-table .piechart-legend-icon { + width: 5px; + padding: 0; + top: 0; +} + +.piechart-legend-table .piechart-legend-icon .fa { + top: 4px; +} + +.piechart-legend-table .piechart-legend-value { + padding-left: 15px; +} + +.piechart-legend-table .piechart-legend-alias { + padding-left: 7px; + text-align: left; + width: 95%; + max-width: 650px; + text-overflow: ellipsis; + overflow: hidden; +} + +.piechart-legend-table .piechart-legend-series:nth-child(odd) { + background: #dde4ed; +} + +.piechart-legend-table .piechart-legend-value.current::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.max::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.min::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.total::before { + content: ""; +} + +.piechart-legend-table .piechart-legend-value.avg::before { + content: ""; +} + +.piechart-legend-table th { + text-align: right; + padding: 0px 10px 1px 0; + font-weight: bold; + color: #61c2f2; + font-size: 85%; + white-space: nowrap; +} + +.piechart-legend-series-hidden .piechart-legend-value, +.piechart-legend-series-hidden .piechart-legend-alias { + color: #acb6bf; +} + +.piechart-tooltip { + white-space: nowrap; + font-size: 12px; + background-color: #dde4ed; + color: #35373f; +} + +.piechart-tooltip .piechart-tooltip-time { + text-align: center; + position: relative; + top: -3px; + padding: 0.2rem; + font-weight: bold; + color: #35373f; +} + +.piechart-tooltip .piechart-tooltip-value { + display: table-cell; + font-weight: bold; + padding-left: 15px; + text-align: right; +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/editor.html b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/editor.html new file mode 100644 index 0000000..6ee2e2c --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/editor.html @@ -0,0 +1,89 @@ +
+
+
General
+
+ Type +
+ +
+
+
+ Unit +
+
+
+
+ Value +
+ +
+
+
+ Divider width + +
+
+ +
+
Legend
+ +
+ Position +
+ +
+
+
+ + +
+
+ Legend Breakpoint +
+ +
+
+
+ Font size +
+ +
+
+ +
+ Values Header + +
+
+ Values Decimals + +
+ +
+ Percentage Decimals + +
+
+ +
+
Combine
+
+ Threshold: + + Combines all slices that are smaller than the specified percentage (ranging from 0 to 1) i.e. a value of '0.03' will + combine all slices 3% or less into one slice). +
+
+ Label + + Label text for the combined slice. +
+
+
diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-donut.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-donut.png new file mode 100644 index 0000000..8e54878 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-donut.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-on-graph.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-on-graph.png new file mode 100644 index 0000000..51dfcbc Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-on-graph.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-rhs.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-rhs.png new file mode 100644 index 0000000..9b018c3 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-rhs.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-under.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-under.png new file mode 100644 index 0000000..3284511 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-legend-under.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-options.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-options.png new file mode 100644 index 0000000..117962e Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart-options.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_large.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_large.png new file mode 100644 index 0000000..21b7ab4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_large.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_small.png b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_small.png new file mode 100644 index 0000000..10d49e4 Binary files /dev/null and b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/img/piechart_logo_small.png differ diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/legend.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/legend.js new file mode 100644 index 0000000..6522a4d --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/legend.js @@ -0,0 +1,291 @@ +import angular from "angular"; +import kbn from "app/core/utils/kbn"; +import $ from "jquery"; +import "jquery.flot"; +import "jquery.flot.time"; +import PerfectScrollbar from "./lib/perfect-scrollbar.min"; + +angular + .module("grafana.directives") + .directive("piechartLegend", function(popoverSrv, $timeout) { + return { + link: function(scope, elem) { + var $container = $('
'); + var firstRender = true; + var ctrl = scope.ctrl; + var panel = ctrl.panel; + var data; + var seriesList; + var dataList; + var i; + var legendScrollbar; + + scope.$on("$destroy", function() { + if (legendScrollbar) { + legendScrollbar.destroy(); + } + }); + + ctrl.events.on("render", function() { + data = ctrl.series; + if (data) { + for (var i in data) { + data[i].color = ctrl.data[i].color; + } + render(); + } + }); + + function getSeriesIndexForElement(el) { + return el.parents("[data-series-index]").data("series-index"); + } + + function toggleSeries(e) { + var el = $(e.currentTarget); + var index = getSeriesIndexForElement(el); + var seriesInfo = dataList[index]; + var scrollPosition = $($container.children("tbody")).scrollTop(); + ctrl.toggleSeries(seriesInfo); + $($container.children("tbody")).scrollTop(scrollPosition); + } + + function sortLegend(e) { + var el = $(e.currentTarget); + var stat = el.data("stat"); + + if (stat !== panel.legend.sort) { + panel.legend.sortDesc = null; + } + + // if already sort ascending, disable sorting + if (panel.legend.sortDesc === false) { + panel.legend.sort = null; + panel.legend.sortDesc = null; + ctrl.render(); + return; + } + + panel.legend.sortDesc = !panel.legend.sortDesc; + panel.legend.sort = stat; + ctrl.render(); + } + + function getLegendHeaderHtml(statName) { + var name = statName; + + if (panel.legend.header) { + name = panel.legend.header; + } + + var html = '' + name; + + if (panel.legend.sort === statName) { + var cssClass = panel.legend.sortDesc + ? "fa fa-caret-down" + : "fa fa-caret-up"; + html += ' '; + } + + return html + ""; + } + + function getLegendPercentageHtml(statName) { + var name = "percentage"; + var html = '' + name; + + if (panel.legend.sort === statName) { + var cssClass = panel.legend.sortDesc + ? "fa fa-caret-down" + : "fa fa-caret-up"; + html += ' '; + } + + return html + ""; + } + + function openColorSelector(e) { + // if we clicked inside poup container ignore click + if ($(e.target).parents(".popover").length) { + return; + } + + var el = $(e.currentTarget).find(".fa-minus"); + var index = getSeriesIndexForElement(el); + var series = seriesList[index]; + + $timeout(function() { + popoverSrv.show({ + element: el[0], + position: "bottom center", + template: + '' + + "", + openOn: "hover", + model: { + autoClose: true, + series: series, + toggleAxis: function() {}, + colorSelected: function(color) { + ctrl.changeSeriesColor(series, color); + } + } + }); + }); + } + + function render() { + if (panel.legendType === "On graph" || !panel.legend.show) { + $container.empty(); + elem.find(".piechart-legend").css("padding-top", 0); + return; + } else { + elem.find(".piechart-legend").css("padding-top", 6); + } + + + if (firstRender) { + elem.append($container); + $container.on("click", ".piechart-legend-icon", openColorSelector); + $container.on("click", ".piechart-legend-alias", toggleSeries); + $container.on("click", "th", sortLegend); + firstRender = false; + } + + seriesList = data; + dataList = ctrl.data; + + $container.empty(); + + var width = panel.legendType == "Right side" && panel.legend.sideWidth ? panel.legend.sideWidth + "px" : ""; + var ieWidth = panel.legendType == "Right side" && panel.legend.sideWidth ? panel.legend.sideWidth - 1 + "px" : ""; + elem.css("min-width", width); + elem.css("width", ieWidth); + + var showValues = panel.legend.values || panel.legend.percentage; + var tableLayout = + (panel.legendType === "Under graph" || + panel.legendType === "Right side") && + showValues; + + $container.toggleClass("piechart-legend-table", tableLayout); + + var legendHeader; + if (tableLayout) { + var header = ''; + if (panel.legend.values) { + header += getLegendHeaderHtml(ctrl.panel.valueName); + } + if (panel.legend.percentage) { + header += getLegendPercentageHtml(ctrl.panel.valueName); + } + header += ""; + legendHeader = $(header); + } + + if (panel.legend.percentage) { + var total = 0; + for (i = 0; i < seriesList.length; i++) { + total += seriesList[i].stats[ctrl.panel.valueName]; + } + } + + var seriesShown = 0; + var seriesElements = []; + + for (i = 0; i < seriesList.length; i++) { + var series = seriesList[i]; + var seriesData = dataList[i]; + + // ignore empty series + if (panel.legend.hideEmpty && series.allIsNull) { + continue; + } + // ignore series excluded via override + if (!series.legend) { + continue; + } + + var decimal = 0; + if (ctrl.panel.legend.percentageDecimals) { + decimal = ctrl.panel.legend.percentageDecimals; + } + + var html = '
'; + html += ''; + html += + ''; + html += ""; + + html += + '' + + seriesData.label + + ""; + + if (showValues && tableLayout) { + var value = seriesData.legendData; + if (panel.legend.values) { + html += + '
' + + ctrl.formatValue(value) + + "
"; + } + if (total) { + var pvalue = (value / total * 100).toFixed(decimal) + "%"; + html += '
' + pvalue + "
"; + } + } + + html += "
"; + + seriesElements.push($(html)); + seriesShown++; + } + if (tableLayout) { + var topPadding = 6; + var tbodyElem = $(""); + // tbodyElem.css("max-height", maxHeight - topPadding); + tbodyElem.append(legendHeader); + tbodyElem.append(seriesElements); + $container.append(tbodyElem); + } else { + $container.append(seriesElements); + } + + if (panel.legendType === "Under graph") { + addScrollbar(); + } else { + destroyScrollbar(); + } + } + function addScrollbar() { + const scrollbarOptions = { + // Number of pixels the content height can surpass the container height without enabling the scroll bar. + scrollYMarginOffset: 2, + suppressScrollX: true + }; + + if (!legendScrollbar) { + legendScrollbar = new PerfectScrollbar( + elem[0], + scrollbarOptions + ); + } else { + legendScrollbar.update(); + } + } + + function destroyScrollbar() { + if (legendScrollbar) { + legendScrollbar.destroy(); + legendScrollbar = null; + } + } + } + }; + }); diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/lib/perfect-scrollbar.min.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/lib/perfect-scrollbar.min.js new file mode 100644 index 0000000..b5d61d2 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/lib/perfect-scrollbar.min.js @@ -0,0 +1,6 @@ +/*! + * perfect-scrollbar v1.2.0 + * (c) 2017 Hyunje Jun + * @license MIT + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.PerfectScrollbar=e()}(this,function(){"use strict";function t(t){return getComputedStyle(t)}function e(t,e){for(var i in e){var n=e[i];"number"==typeof n&&(n+="px"),t.style[i]=n}return t}function i(t){var e=document.createElement("div");return e.className=t,e}function n(t,e){if(!v)throw new Error("No element matching method supported");return v.call(t,e)}function r(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function l(t,e){return Array.prototype.filter.call(t.children,function(t){return n(t,e)})}function o(t,e){var i=t.element.classList,n=m.state.scrolling(e);i.contains(n)?clearTimeout(w[e]):i.add(n)}function s(t,e){w[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(m.state.scrolling(e))},t.settings.scrollingThreshold)}function a(t,e){o(t,e),s(t,e)}function c(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function h(t,e,i,n,r){var l=i[0],o=i[1],s=i[2],h=i[3],u=i[4],d=i[5];void 0===n&&(n=!0),void 0===r&&(r=!1);var p=t.element;t.reach[h]=null,p[s]<1&&(t.reach[h]="start"),p[s]>t[l]-t[o]-1&&(t.reach[h]="end"),e&&(p.dispatchEvent(c("ps-scroll-"+h)),e<0?p.dispatchEvent(c("ps-scroll-"+u)):e>0&&p.dispatchEvent(c("ps-scroll-"+d)),n&&a(t,h)),t.reach[h]&&(e||r)&&p.dispatchEvent(c("ps-"+h+"-reach-"+t.reach[h]))}function u(t){return parseInt(t,10)||0}function d(t){return n(t,"input,[contenteditable]")||n(t,"select,[contenteditable]")||n(t,"textarea,[contenteditable]")||n(t,"button,[contenteditable]")}function p(e){var i=t(e);return u(i.width)+u(i.paddingLeft)+u(i.paddingRight)+u(i.borderLeftWidth)+u(i.borderRightWidth)}function f(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function b(t,i){var n={width:i.railXWidth};i.isRtl?n.left=i.negativeScrollAdjustment+t.scrollLeft+i.containerWidth-i.contentWidth:n.left=t.scrollLeft,i.isScrollbarXUsingBottom?n.bottom=i.scrollbarXBottom-t.scrollTop:n.top=i.scrollbarXTop+t.scrollTop,e(i.scrollbarXRail,n);var r={top:t.scrollTop,height:i.railYHeight};i.isScrollbarYUsingRight?i.isRtl?r.right=i.contentWidth-(i.negativeScrollAdjustment+t.scrollLeft)-i.scrollbarYRight-i.scrollbarYOuterWidth:r.right=i.scrollbarYRight-t.scrollLeft:i.isRtl?r.left=i.negativeScrollAdjustment+t.scrollLeft+2*i.containerWidth-i.contentWidth-i.scrollbarYLeft-i.scrollbarYOuterWidth:r.left=i.scrollbarYLeft+t.scrollLeft,e(i.scrollbarYRail,r),e(i.scrollbarX,{left:i.scrollbarXLeft,width:i.scrollbarXWidth-i.railBorderXWidth}),e(i.scrollbarY,{top:i.scrollbarYTop,height:i.scrollbarYHeight-i.railBorderYWidth})}function g(t,e){function i(e){f[d]=b+v*(e[a]-g),o(t,p),R(t),e.stopPropagation(),e.preventDefault()}function n(){s(t,p),t.event.unbind(t.ownerDocument,"mousemove",i)}var r=e[0],l=e[1],a=e[2],c=e[3],h=e[4],u=e[5],d=e[6],p=e[7],f=t.element,b=null,g=null,v=null;t.event.bind(t[h],"mousedown",function(e){b=f[d],g=e[a],v=(t[l]-t[r])/(t[c]-t[u]),t.event.bind(t.ownerDocument,"mousemove",i),t.event.once(t.ownerDocument,"mouseup",n),e.stopPropagation(),e.preventDefault()})}var v=Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.msMatchesSelector,m={main:"ps",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},w={x:null,y:null},Y=function(t){this.element=t,this.handlers={}},X={isEmpty:{configurable:!0}};Y.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},Y.prototype.unbind=function(t,e){var i=this;this.handlers[t]=this.handlers[t].filter(function(n){return!(!e||n===e)||(i.element.removeEventListener(t,n,!1),!1)})},Y.prototype.unbindAll=function(){var t=this;for(var e in t.handlers)t.unbind(e)},X.isEmpty.get=function(){var t=this;return Object.keys(this.handlers).every(function(e){return 0===t.handlers[e].length})},Object.defineProperties(Y.prototype,X);var W=function(){this.eventElements=[]};W.prototype.eventElement=function(t){var e=this.eventElements.filter(function(e){return e.element===t})[0];return e||(e=new Y(t),this.eventElements.push(e)),e},W.prototype.bind=function(t,e,i){this.eventElement(t).bind(e,i)},W.prototype.unbind=function(t,e,i){var n=this.eventElement(t);n.unbind(e,i),n.isEmpty&&this.eventElements.splice(this.eventElements.indexOf(n),1)},W.prototype.unbindAll=function(){this.eventElements.forEach(function(t){return t.unbindAll()}),this.eventElements=[]},W.prototype.once=function(t,e,i){var n=this.eventElement(t),r=function(t){n.unbind(e,r),i(t)};n.bind(e,r)};var y=function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=!1);var l;if("top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}h(t,i,l,n,r)},L={isWebKit:document&&"WebkitAppearance"in document.documentElement.style,supportsTouch:window&&("ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch),supportsIePointer:navigator&&navigator.msMaxTouchPoints},R=function(t){var e=t.element;t.containerWidth=e.clientWidth,t.containerHeight=e.clientHeight,t.contentWidth=e.scrollWidth,t.contentHeight=e.scrollHeight,e.contains(t.scrollbarXRail)||(l(e,m.element.rail("x")).forEach(function(t){return r(t)}),e.appendChild(t.scrollbarXRail)),e.contains(t.scrollbarYRail)||(l(e,m.element.rail("y")).forEach(function(t){return r(t)}),e.appendChild(t.scrollbarYRail)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),b(e,t),t.scrollbarXActive?e.classList.add(m.state.active("x")):(e.classList.remove(m.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=0),t.scrollbarYActive?e.classList.add(m.state.active("y")):(e.classList.remove(m.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)},T={"click-rail":function(t){t.event.bind(t.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarYRail,"mousedown",function(e){var i=e.pageY-window.pageYOffset-t.scrollbarYRail.getBoundingClientRect().top>t.scrollbarYTop?1:-1;t.element.scrollTop+=i*t.containerHeight,R(t),e.stopPropagation()}),t.event.bind(t.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),t.event.bind(t.scrollbarXRail,"mousedown",function(e){var i=e.pageX-window.pageXOffset-t.scrollbarXRail.getBoundingClientRect().left>t.scrollbarXLeft?1:-1;t.element.scrollLeft+=i*t.containerWidth,R(t),e.stopPropagation()})},"drag-thumb":function(t){g(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x"]),g(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y"])},keyboard:function(t){function e(e,n){var r=i.scrollTop;if(0===e){if(!t.scrollbarYActive)return!1;if(0===r&&n>0||r>=t.contentHeight-t.containerHeight&&n<0)return!t.settings.wheelPropagation}var l=i.scrollLeft;if(0===n){if(!t.scrollbarXActive)return!1;if(0===l&&e<0||l>=t.contentWidth-t.containerWidth&&e>0)return!t.settings.wheelPropagation}return!0}var i=t.element,r=function(){return n(i,":hover")},l=function(){return n(t.scrollbarX,":focus")||n(t.scrollbarY,":focus")};t.event.bind(t.ownerDocument,"keydown",function(n){if(!(n.isDefaultPrevented&&n.isDefaultPrevented()||n.defaultPrevented)&&(r()||l())){var o=document.activeElement?document.activeElement:t.ownerDocument.activeElement;if(o){if("IFRAME"===o.tagName)o=o.contentDocument.activeElement;else for(;o.shadowRoot;)o=o.shadowRoot.activeElement;if(d(o))return}var s=0,a=0;switch(n.which){case 37:s=n.metaKey?-t.contentWidth:n.altKey?-t.containerWidth:-30;break;case 38:a=n.metaKey?t.contentHeight:n.altKey?t.containerHeight:30;break;case 39:s=n.metaKey?t.contentWidth:n.altKey?t.containerWidth:30;break;case 40:a=n.metaKey?-t.contentHeight:n.altKey?-t.containerHeight:-30;break;case 32:a=n.shiftKey?t.containerHeight:-t.containerHeight;break;case 33:a=t.containerHeight;break;case 34:a=-t.containerHeight;break;case 36:a=t.contentHeight;break;case 35:a=-t.contentHeight;break;default:return}t.settings.suppressScrollX&&0!==s||t.settings.suppressScrollY&&0!==a||(i.scrollTop-=a,i.scrollLeft+=s,R(t),e(s,a)&&n.preventDefault())}})},wheel:function(e){function i(t,i){var n=o.scrollTop;if(0===t){if(!e.scrollbarYActive)return!1;if(0===n&&i>0||n>=e.contentHeight-e.containerHeight&&i<0)return!e.settings.wheelPropagation}var r=o.scrollLeft;if(0===i){if(!e.scrollbarXActive)return!1;if(0===r&&t<0||r>=e.contentWidth-e.containerWidth&&t>0)return!e.settings.wheelPropagation}return!0}function n(t){var e=t.deltaX,i=-1*t.deltaY;return void 0!==e&&void 0!==i||(e=-1*t.wheelDeltaX/6,i=t.wheelDeltaY/6),t.deltaMode&&1===t.deltaMode&&(e*=10,i*=10),e!==e&&i!==i&&(e=0,i=t.wheelDelta),t.shiftKey?[-i,-e]:[e,i]}function r(e,i,n){if(!L.isWebKit&&o.querySelector("select:focus"))return!0;if(!o.contains(e))return!1;for(var r=e;r&&r!==o;){if(r.classList.contains(m.element.consuming))return!0;var l=t(r);if([l.overflow,l.overflowX,l.overflowY].join("").match(/(scroll|auto)/)){var s=r.scrollHeight-r.clientHeight;if(s>0&&!(0===r.scrollTop&&n>0||r.scrollTop===s&&n<0))return!0;var a=r.scrollLeft-r.clientWidth;if(a>0&&!(0===r.scrollLeft&&i<0||r.scrollLeft===a&&i>0))return!0}r=r.parentNode}return!1}function l(t){var l=n(t),s=l[0],a=l[1];if(!r(t.target,s,a)){var c=!1;e.settings.useBothWheelAxes?e.scrollbarYActive&&!e.scrollbarXActive?(a?o.scrollTop-=a*e.settings.wheelSpeed:o.scrollTop+=s*e.settings.wheelSpeed,c=!0):e.scrollbarXActive&&!e.scrollbarYActive&&(s?o.scrollLeft+=s*e.settings.wheelSpeed:o.scrollLeft-=a*e.settings.wheelSpeed,c=!0):(o.scrollTop-=a*e.settings.wheelSpeed,o.scrollLeft+=s*e.settings.wheelSpeed),R(e),(c=c||i(s,a))&&!t.ctrlKey&&(t.stopPropagation(),t.preventDefault())}}var o=e.element;void 0!==window.onwheel?e.event.bind(o,"wheel",l):void 0!==window.onmousewheel&&e.event.bind(o,"mousewheel",l)},touch:function(t){function e(e,i){var n=h.scrollTop,r=h.scrollLeft,l=Math.abs(e),o=Math.abs(i);if(o>l){if(i<0&&n===t.contentHeight-t.containerHeight||i>0&&0===n)return{stop:!t.settings.swipePropagation,prevent:0===window.scrollY}}else if(l>o&&(e<0&&r===t.contentWidth-t.containerWidth||e>0&&0===r))return{stop:!t.settings.swipePropagation,prevent:!0};return{stop:!0,prevent:!0}}function i(e,i){h.scrollTop-=i,h.scrollLeft-=e,R(t)}function n(){b=!0}function r(){b=!1}function l(t){return t.targetTouches?t.targetTouches[0]:t}function o(t){return!(t.pointerType&&"pen"===t.pointerType&&0===t.buttons||(!t.targetTouches||1!==t.targetTouches.length)&&(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function s(t){if(o(t)){g=!0;var e=l(t);u.pageX=e.pageX,u.pageY=e.pageY,d=(new Date).getTime(),null!==f&&clearInterval(f),t.stopPropagation()}}function a(n){if(!g&&t.settings.swipePropagation&&s(n),!b&&g&&o(n)){var r=l(n),a={pageX:r.pageX,pageY:r.pageY},c=a.pageX-u.pageX,h=a.pageY-u.pageY;i(c,h),u=a;var f=(new Date).getTime(),v=f-d;v>0&&(p.x=c/v,p.y=h/v,d=f);var m=e(c,h),w=m.stop,Y=m.prevent;w&&n.stopPropagation(),Y&&n.preventDefault()}}function c(){!b&&g&&(g=!1,t.settings.swipeEasing&&(clearInterval(f),f=setInterval(function(){t.isInitialized?clearInterval(f):p.x||p.y?Math.abs(p.x)<.01&&Math.abs(p.y)<.01?clearInterval(f):(i(30*p.x,30*p.y),p.x*=.8,p.y*=.8):clearInterval(f)},10)))}if(L.supportsTouch||L.supportsIePointer){var h=t.element,u={},d=0,p={},f=null,b=!1,g=!1;L.supportsTouch?(t.event.bind(window,"touchstart",n),t.event.bind(window,"touchend",r),t.event.bind(h,"touchstart",s),t.event.bind(h,"touchmove",a),t.event.bind(h,"touchend",c)):L.supportsIePointer&&(window.PointerEvent?(t.event.bind(window,"pointerdown",n),t.event.bind(window,"pointerup",r),t.event.bind(h,"pointerdown",s),t.event.bind(h,"pointermove",a),t.event.bind(h,"pointerup",c)):window.MSPointerEvent&&(t.event.bind(window,"MSPointerDown",n),t.event.bind(window,"MSPointerUp",r),t.event.bind(h,"MSPointerDown",s),t.event.bind(h,"MSPointerMove",a),t.event.bind(h,"MSPointerUp",c)))}}},H=function(n,r){var l=this;if(void 0===r&&(r={}),"string"==typeof n&&(n=document.querySelector(n)),!n||!n.nodeName)throw new Error("no element is specified to initialize PerfectScrollbar");this.element=n,n.classList.add(m.main),this.settings={handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxScrollbarLength:null,minScrollbarLength:null,scrollingThreshold:1e3,scrollXMarginOffset:0,scrollYMarginOffset:0,suppressScrollX:!1,suppressScrollY:!1,swipePropagation:!0,swipeEasing:!0,useBothWheelAxes:!1,wheelPropagation:!1,wheelSpeed:1};for(var o in r)l.settings[o]=r[o];this.containerWidth=null,this.containerHeight=null,this.contentWidth=null,this.contentHeight=null;var s=function(){return n.classList.add(m.state.focus)},a=function(){return n.classList.remove(m.state.focus)};this.isRtl="rtl"===t(n).direction,this.isNegativeScroll=function(){var t=n.scrollLeft,e=null;return n.scrollLeft=-1,e=n.scrollLeft<0,n.scrollLeft=t,e}(),this.negativeScrollAdjustment=this.isNegativeScroll?n.scrollWidth-n.clientWidth:0,this.event=new W,this.ownerDocument=n.ownerDocument||document,this.scrollbarXRail=i(m.element.rail("x")),n.appendChild(this.scrollbarXRail),this.scrollbarX=i(m.element.thumb("x")),this.scrollbarXRail.appendChild(this.scrollbarX),this.scrollbarX.setAttribute("tabindex",0),this.event.bind(this.scrollbarX,"focus",s),this.event.bind(this.scrollbarX,"blur",a),this.scrollbarXActive=null,this.scrollbarXWidth=null,this.scrollbarXLeft=null;var c=t(this.scrollbarXRail);this.scrollbarXBottom=parseInt(c.bottom,10),isNaN(this.scrollbarXBottom)?(this.isScrollbarXUsingBottom=!1,this.scrollbarXTop=u(c.top)):this.isScrollbarXUsingBottom=!0,this.railBorderXWidth=u(c.borderLeftWidth)+u(c.borderRightWidth),e(this.scrollbarXRail,{display:"block"}),this.railXMarginWidth=u(c.marginLeft)+u(c.marginRight),e(this.scrollbarXRail,{display:""}),this.railXWidth=null,this.railXRatio=null,this.scrollbarYRail=i(m.element.rail("y")),n.appendChild(this.scrollbarYRail),this.scrollbarY=i(m.element.thumb("y")),this.scrollbarYRail.appendChild(this.scrollbarY),this.scrollbarY.setAttribute("tabindex",0),this.event.bind(this.scrollbarY,"focus",s),this.event.bind(this.scrollbarY,"blur",a),this.scrollbarYActive=null,this.scrollbarYHeight=null,this.scrollbarYTop=null;var h=t(this.scrollbarYRail);this.scrollbarYRight=parseInt(h.right,10),isNaN(this.scrollbarYRight)?(this.isScrollbarYUsingRight=!1,this.scrollbarYLeft=u(h.left)):this.isScrollbarYUsingRight=!0,this.scrollbarYOuterWidth=this.isRtl?p(this.scrollbarY):null,this.railBorderYWidth=u(h.borderTopWidth)+u(h.borderBottomWidth),e(this.scrollbarYRail,{display:"block"}),this.railYMarginHeight=u(h.marginTop)+u(h.marginBottom),e(this.scrollbarYRail,{display:""}),this.railYHeight=null,this.railYRatio=null,this.reach={x:n.scrollLeft<=0?"start":n.scrollLeft>=this.contentWidth-this.containerWidth?"end":null,y:n.scrollTop<=0?"start":n.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return T[t](l)}),this.lastScrollTop=n.scrollTop,this.lastScrollLeft=n.scrollLeft,this.event.bind(this.element,"scroll",function(t){return l.onScroll(t)}),R(this)};return H.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,e(this.scrollbarXRail,{display:"block"}),e(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=u(t(this.scrollbarXRail).marginLeft)+u(t(this.scrollbarXRail).marginRight),this.railYMarginHeight=u(t(this.scrollbarYRail).marginTop)+u(t(this.scrollbarYRail).marginBottom),e(this.scrollbarXRail,{display:"none"}),e(this.scrollbarYRail,{display:"none"}),R(this),y(this,"top",0,!1,!0),y(this,"left",0,!1,!0),e(this.scrollbarXRail,{display:""}),e(this.scrollbarYRail,{display:""}))},H.prototype.onScroll=function(t){this.isAlive&&(R(this),y(this,"top",this.element.scrollTop-this.lastScrollTop),y(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=this.element.scrollTop,this.lastScrollLeft=this.element.scrollLeft)},H.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),r(this.scrollbarX),r(this.scrollbarY),r(this.scrollbarXRail),r(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},H.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")},H}); \ No newline at end of file diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.html b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.html new file mode 100644 index 0000000..e0faed5 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.html @@ -0,0 +1,5 @@ +
+
+
+
+
diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.js new file mode 100644 index 0000000..234ac91 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/module.js @@ -0,0 +1,9 @@ +import { PieChartCtrl } from './piechart_ctrl'; +import { loadPluginCss } from 'app/plugins/sdk'; + +loadPluginCss({ + dark: 'plugins/grafana-piechart-panel/css/piechart.dark.css', + light: 'plugins/grafana-piechart-panel/css/piechart.light.css', +}); + +export { PieChartCtrl as PanelCtrl }; diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/piechart_ctrl.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/piechart_ctrl.js new file mode 100644 index 0000000..2b84149 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/piechart_ctrl.js @@ -0,0 +1,179 @@ +import {MetricsPanelCtrl} from 'app/plugins/sdk'; +import _ from 'lodash'; +import kbn from 'app/core/utils/kbn'; +import TimeSeries from 'app/core/time_series'; +import rendering from './rendering'; +import legend from './legend'; + +export class PieChartCtrl extends MetricsPanelCtrl { + + constructor($scope, $injector, $rootScope) { + super($scope, $injector); + this.$rootScope = $rootScope; + this.hiddenSeries = {}; + + var panelDefaults = { + pieType: 'pie', + legend: { + show: true, // disable/enable legend + values: true + }, + links: [], + datasource: null, + maxDataPoints: 3, + interval: null, + targets: [{}], + cacheTimeout: null, + nullPointMode: 'connected', + legendType: 'Under graph', + breakPoint: '50%', + aliasColors: {}, + format: 'short', + valueName: 'current', + strokeWidth: 1, + fontSize: '80%', + combine: { + threshold: 0.0, + label: 'Others' + } + }; + + _.defaults(this.panel, panelDefaults); + _.defaults(this.panel.legend, panelDefaults.legend); + + this.events.on('render', this.onRender.bind(this)); + this.events.on('data-received', this.onDataReceived.bind(this)); + this.events.on('data-error', this.onDataError.bind(this)); + this.events.on('data-snapshot-load', this.onDataReceived.bind(this)); + this.events.on('init-edit-mode', this.onInitEditMode.bind(this)); + + this.setLegendWidthForLegacyBrowser(); + } + + onInitEditMode() { + this.addEditorTab('Options', 'public/plugins/grafana-piechart-panel/editor.html', 2); + this.unitFormats = kbn.getUnitFormats(); + } + + setUnitFormat(subItem) { + this.panel.format = subItem.value; + this.render(); + } + + onDataError() { + this.series = []; + this.render(); + } + + changeSeriesColor(series, color) { + series.color = color; + this.panel.aliasColors[series.alias] = series.color; + this.render(); + } + + onRender() { + this.data = this.parseSeries(this.series); + } + + parseSeries(series) { + return _.map(this.series, (serie, i) => { + return { + label: serie.alias, + data: serie.stats[this.panel.valueName], + color: this.panel.aliasColors[serie.alias] || this.$rootScope.colors[i], + legendData: serie.stats[this.panel.valueName], + }; + }); + } + + onDataReceived(dataList) { + this.series = dataList.map(this.seriesHandler.bind(this)); + this.data = this.parseSeries(this.series); + this.render(this.data); + } + + seriesHandler(seriesData) { + var series = new TimeSeries({ + datapoints: seriesData.datapoints, + alias: seriesData.target + }); + + series.flotpairs = series.getFlotPairs(this.panel.nullPointMode); + return series; + } + + getDecimalsForValue(value) { + if (_.isNumber(this.panel.decimals)) { + return { decimals: this.panel.decimals, scaledDecimals: null }; + } + + var delta = value / 2; + var dec = -Math.floor(Math.log(delta) / Math.LN10); + + var magn = Math.pow(10, -dec); + var norm = delta / magn; // norm is between 1.0 and 10.0 + var size; + + if (norm < 1.5) { + size = 1; + } else if (norm < 3) { + size = 2; + // special case for 2.5, requires an extra decimal + if (norm > 2.25) { + size = 2.5; + ++dec; + } + } else if (norm < 7.5) { + size = 5; + } else { + size = 10; + } + + size *= magn; + + // reduce starting decimals if not needed + if (Math.floor(value) === value) { dec = 0; } + + var result = {}; + result.decimals = Math.max(0, dec); + result.scaledDecimals = result.decimals - Math.floor(Math.log(size) / Math.LN10) + 2; + + return result; + } + + formatValue(value) { + var decimalInfo = this.getDecimalsForValue(value); + var formatFunc = kbn.valueFormats[this.panel.format]; + if (formatFunc) { + return formatFunc(value, decimalInfo.decimals, decimalInfo.scaledDecimals); + } + return value; + } + + link(scope, elem, attrs, ctrl) { + rendering(scope, elem, attrs, ctrl); + } + + toggleSeries(serie) { + if (this.hiddenSeries[serie.label]) { + delete this.hiddenSeries[serie.label]; + } else { + this.hiddenSeries[serie.label] = true; + } + this.render(); + } + + onLegendTypeChanged() { + this.setLegendWidthForLegacyBrowser(); + this.render(); + } + + setLegendWidthForLegacyBrowser() { + var isIE11 = !!window.MSInputMethodContext && !!document.documentMode; + if (isIE11 && this.panel.legendType === 'Right side' && !this.panel.legend.sideWidth) { + this.panel.legend.sideWidth = 150; + } + } +} + +PieChartCtrl.templateUrl = 'module.html'; diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/plugin.json b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/plugin.json new file mode 100644 index 0000000..74313c0 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/plugin.json @@ -0,0 +1,37 @@ +{ + "type": "panel", + "name": "Pie Chart", + "id": "grafana-piechart-panel", + + "info": { + "description": "Pie chart panel for grafana", + "author": { + "name": "Grafana Labs", + "url": "http://grafana.com" + }, + "keywords": ["piechart", "panel"], + "logos": { + "small": "src/img/piechart_logo_small.png", + "large": "src/img/piechart_logo_large.png" + }, + "links": [ + {"name": "Project site", "url": "https://github.com/grafana/piechart-panel"}, + {"name": "Blog Post", "url": "https://blog.raintank.io/friends-dont-let-friends-abuse-pie-charts/"}, + {"name": "MIT License", "url": "https://github.com/grafana/piechart-panel/blob/master/LICENSE"} + ], + "screenshots": [ + {"name": "Donut!", "path": "src/img/piechart-donut.png"}, + {"name": "Legend on the graph", "path": "src/img/piechart-legend-on-graph.png"}, + {"name": "Legend to the right", "path": "src/img/piechart-legend-rhs.png"}, + {"name": "Legend underneath", "path": "src/img/piechart-legend-under.png"}, + {"name": "Piechart options", "path": "src/img/piechart-options.png"} + ], + "version": "1.3.3", + "updated": "2018-06-14" + }, + + "dependencies": { + "grafanaVersion": "4.6", + "plugins": [ ] + } +} diff --git a/roles/provision-metrics-apb/files/grafana-piechart-panel/src/rendering.js b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/rendering.js new file mode 100644 index 0000000..c832114 --- /dev/null +++ b/roles/provision-metrics-apb/files/grafana-piechart-panel/src/rendering.js @@ -0,0 +1,172 @@ +import _ from 'lodash'; +import $ from 'jquery'; +import 'jquery.flot'; +import 'jquery.flot.pie'; + +export default function link(scope, elem, attrs, ctrl) { + var data, panel; + elem = elem.find('.piechart-panel__chart'); + var $tooltip = $('
'); + + ctrl.events.on('render', function () { + render(false); + if (panel.legendType === 'Right side') { + setTimeout(function () { render(true); }, 50); + } + }); + + function getLegendHeight(panelHeight) { + if (!ctrl.panel.legend.show || ctrl.panel.legendType === 'Right side' || ctrl.panel.legendType === 'On graph') { + return 20; + } + + if (ctrl.panel.legendType == 'Under graph' && ctrl.panel.legend.percentage || ctrl.panel.legend.values) { + let breakPoint = parseInt(ctrl.panel.breakPoint) / 100; + var total = 23 + 20 * data.length; + return Math.min(total, Math.floor(panelHeight * breakPoint)); + } + } + + function formatter(label, slice) { + var slice_data = slice.data[0][slice.data[0].length - 1]; + var decimal = 2; + var start = "
" + label + "
"; + + if (ctrl.panel.legend.percentageDecimals) { + decimal = ctrl.panel.legend.percentageDecimals; + } + if (ctrl.panel.legend.values && ctrl.panel.legend.percentage) { + return start + ctrl.formatValue(slice_data) + "
" + slice.percent.toFixed(decimal) + "%
"; + } else if (ctrl.panel.legend.values) { + return start + ctrl.formatValue(slice_data) + "
"; + } else if (ctrl.panel.legend.percentage) { + return start + slice.percent.toFixed(decimal) + "%"; + } else { + return start + ''; + } + } + + function noDataPoints() { + var html = '
No data points
'; + elem.html(html); + } + + function addPieChart() { + var width = elem.width(); + var height = ctrl.height - getLegendHeight(ctrl.height); + + var size = Math.min(width, height); + + var plotCanvas = $('
'); + var plotCss = { + margin: 'auto', + position: 'relative', + paddingBottom: 20 + 'px', + height: size + 'px' + }; + + plotCanvas.css(plotCss); + + var backgroundColor = $('body').css('background-color') + + var options = { + legend: { + show: false + }, + series: { + pie: { + show: true, + stroke: { + color: backgroundColor, + width: parseFloat(ctrl.panel.strokeWidth).toFixed(1) + }, + label: { + show: ctrl.panel.legend.show && ctrl.panel.legendType === 'On graph', + formatter: formatter + }, + highlight: { + opacity: 0.0 + }, + combine: { + threshold: ctrl.panel.combine.threshold, + label: ctrl.panel.combine.label + } + } + }, + grid: { + hoverable: true, + clickable: false + } + }; + + if (panel.pieType === 'donut') { + options.series.pie.innerRadius = 0.5; + } + + data = ctrl.data; + + for (let i = 0; i < data.length; i++) { + let series = data[i]; + + // if hidden remove points + if (ctrl.hiddenSeries[series.label]) { + series.data = {}; + } + } + + + if (panel.legend.sort) { + if (ctrl.panel.valueName !== panel.legend.sort) { + panel.legend.sort = ctrl.panel.valueName; + } + if (panel.legend.sortDesc === true) { + data.sort(function (a, b) { + return b.legendData - a.legendData; + }); + } else { + data.sort(function (a, b) { + return a.legendData - b.legendData; + }); + } + } + + elem.html(plotCanvas); + + $.plot(plotCanvas, data, options); + plotCanvas.bind("plothover", function (event, pos, item) { + if (!item) { + $tooltip.detach(); + return; + } + + var body; + var percent = parseFloat(item.series.percent).toFixed(2); + var formatted = ctrl.formatValue(item.series.data[0][1]); + + body = '
'; + body += '
' + item.series.label + ': ' + formatted; + body += " (" + percent + "%)" + '
'; + body += "
"; + + $tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY); + }); + } + + function render(incrementRenderCounter) { + if (!ctrl.data) { return; } + + data = ctrl.data; + panel = ctrl.panel; + + if (0 == ctrl.data.length) { + noDataPoints(); + } else { + addPieChart(); + } + + if (incrementRenderCounter) { + ctrl.renderingCompleted(); + } + } +} + diff --git a/roles/provision-metrics-apb/tasks/main.yml b/roles/provision-metrics-apb/tasks/main.yml index 94ba72e..48fbe51 100644 --- a/roles/provision-metrics-apb/tasks/main.yml +++ b/roles/provision-metrics-apb/tasks/main.yml @@ -9,12 +9,12 @@ - name: "Create OAuth Proxy Serviceaccount" shell: "oc create -f /tmp/oauth-proxy-sa.yaml -n {{ namespace }}" -- include_tasks: provision-prometheus.yml +- include_tasks: provision-prometheus.yml - include_tasks: provision-grafana.yml - include_tasks: provision-app-metrics.yml # This is currently needed until https://github.com/openshift/ansible-service-broker/issues/847 is resolved -- name: "Make data availble for binding" +- name: "Make data available for binding" asb_encode_binding: fields: namespace: "{{ namespace }}" @@ -29,4 +29,4 @@ - {name: grafanaUrl, value: "https://{{ grafana_route.route.spec.host }}"} - {name: metricsEndpoint, value: "https://{{ app_metrics_route.route.spec.host }}/metrics"} when: not encode_asb_binding - no_log: yes \ No newline at end of file + no_log: yes diff --git a/roles/provision-metrics-apb/tasks/provision-grafana.yml b/roles/provision-metrics-apb/tasks/provision-grafana.yml index 80ef968..682724e 100644 --- a/roles/provision-metrics-apb/tasks/provision-grafana.yml +++ b/roles/provision-metrics-apb/tasks/provision-grafana.yml @@ -1,4 +1,3 @@ - - name: Create Grafana config from template template: src: grafana-config-map.ini.j2 @@ -73,6 +72,8 @@ - --cookie-secret=SECRET - name: grafana image: '{{ grafana_image }}:{{ grafana_version }}' + args: + - -config=/etc/grafana/grafana.ini ports: - container_port: '{{ grafana_port }}' protocol: TCP @@ -208,3 +209,41 @@ until: org_pref_update_response.status == 200 delay: 5 register: org_pref_update_response + +- name: Get the name of the Grafana pod + shell: oc get pods -n '{{ namespace }}' --selector="deploymentconfig=grafana" -o jsonpath='{.items[0].metadata.name}' + register: grafana_pod_name + retries: 10 + until: '"grafana" in grafana_pod_name.stdout' + delay: 5 + +# +# Add plugins to PV and restart grafana +# curl -L -o piechart-panel-1.3.3.zip https://grafana.com/api/plugins/grafana-piechart-panel/versions/1.3.3/download +# + +- name: Copy Grafana piechart-panel plugin into temp directory + copy: + src: grafana-piechart-panel + dest: /tmp/grafana-piechart-panel + +- name: Copy piechart-panel plugin into grafana container + shell: oc cp /tmp/grafana-piechart-panel {{ namespace }}/{{ grafana_pod_name.stdout }}:/var/lib/grafana/plugins -c grafana + register: copy_plugin + retries: 60 + until: copy_plugin.rc == 0 + delay: 5 + +- name: Restart grafana to pick up on the new plugin (scale down) + shell: oc scale --replicas=0 --namespace={{ namespace }} dc grafana + +- name: Restart grafana to pick up on the new plugin (scale up) + shell: oc scale --replicas=1 --namespace={{ namespace }} dc grafana + delay: 10 + +- name: Wait for all grafana containers to become ready again + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=grafana" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w + register: grafana_result + until: grafana_result.stdout.find("2") != -1 + retries: 30 + delay: 10