Fix template layout ordering

This divides templates into two classes: autoflow and static. This is
controlled by a boolean "autoflow" property on templates. Any autoflow
templates that will be rendered for a host, have their cells arranged in
a left-to-right, top-to-bottom fashion.

Static templates, are assumed to have precise positioning information
for their graphs. The only adjustment made to them will be a translation
of their Y coords so they do not overlap other layouts.

The autoflow templates, after processing, become a static layout as
defined above and are positioned accordingly.
pull/10616/head
Tim Raymond 2016-11-15 13:11:32 -05:00
parent 6a348d0dd4
commit 4ba7e10931
40 changed files with 138 additions and 45 deletions

View File

@ -129,6 +129,7 @@ func MarshalLayout(l chronograf.Layout) ([]byte, error) {
ID: l.ID,
Measurement: l.Measurement,
Application: l.Application,
Autoflow: l.Autoflow,
Cells: cells,
})
}
@ -143,6 +144,7 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
l.ID = pb.ID
l.Measurement = pb.Measurement
l.Application = pb.Application
l.Autoflow = pb.Autoflow
cells := make([]chronograf.Cell, len(pb.Cells))
for i, c := range pb.Cells {
queries := make([]chronograf.Query, len(c.Queries))

View File

@ -85,6 +85,7 @@ type Layout struct {
Application string `protobuf:"bytes,2,opt,name=Application,proto3" json:"Application,omitempty"`
Measurement string `protobuf:"bytes,3,opt,name=Measurement,proto3" json:"Measurement,omitempty"`
Cells []*Cell `protobuf:"bytes,4,rep,name=Cells" json:"Cells,omitempty"`
Autoflow bool `protobuf:"varint,5,opt,name=Autoflow,proto3" json:"Autoflow,omitempty"`
}
func (m *Layout) Reset() { *m = Layout{} }
@ -170,39 +171,40 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{
// 541 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0x4b, 0x8e, 0xd3, 0x4c,
0x10, 0xc7, 0xd5, 0xb1, 0x3b, 0x89, 0x2b, 0x9f, 0xf2, 0xa1, 0xd6, 0x08, 0x59, 0x88, 0x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10, 0xef, 0x4a, 0x54, 0x95, 0x68, 0xea, 0x74, 0x30, 0xb6,
0x1b, 0x66, 0x31, 0xad, 0xc3, 0xd8, 0x3e, 0xa8, 0xd7, 0x41, 0x71, 0x58, 0x82, 0x67, 0xce, 0xd0,
0xf2, 0xe7, 0xd9, 0xe1, 0x20, 0xd3, 0xad, 0x75, 0xac, 0x91, 0x64, 0x63, 0x34, 0xb3, 0x6e, 0xf5,
0xa2, 0x19, 0x69, 0xb1, 0xb4, 0xde, 0xf4, 0xc4, 0x92, 0x2e, 0xfb, 0x52, 0x65, 0x65, 0x3e, 0xab,
0x6a, 0x57, 0x7c, 0xd1, 0x6a, 0xfa, 0x87, 0xbd, 0xdf, 0xa3, 0xb2, 0xa8, 0xbe, 0xb0, 0x2a, 0xfc,
0x00, 0xfe, 0x34, 0x41, 0xa5, 0x45, 0x99, 0xe0, 0x6f, 0x7b, 0xe2, 0xe0, 0xbe, 0x5a, 0xbd, 0xbd,
0x6d, 0x9e, 0x0d, 0xc5, 0xe7, 0x65, 0x3b, 0x9d, 0x65, 0xd3, 0xf8, 0xd7, 0x32, 0x97, 0x8b, 0xc8,
0xb8, 0xe3, 0x08, 0xab, 0xc2, 0x67, 0xe0, 0xd2, 0xa3, 0xea, 0x4c, 0x76, 0xcd, 0xe4, 0x4b, 0xf0,
0xae, 0x0f, 0x32, 0x4e, 0xec, 0xe8, 0x5a, 0x7c, 0xec, 0x9b, 0x6f, 0xc9, 0x8b, 0x5f, 0x01, 0x00,
0x00, 0xff, 0xff, 0x92, 0xf3, 0x5a, 0x42, 0x5d, 0x04, 0x00, 0x00,
}

View File

@ -36,6 +36,7 @@ message Layout {
string Application = 2; // Application is the user facing name of this Layout.
string Measurement = 3; // Measurement is the descriptive name of the time series data.
repeated Cell Cells = 4; // Cells are the individual visualization elements.
bool Autoflow = 5; // Autoflow indicates whether the frontend should layout the cells automatically.
}
message Cell {

View File

@ -2,6 +2,7 @@
"id": "6dfb4d49-20dc-4157-9018-2b1b1cb75c2d",
"measurement": "apache",
"app": "apache",
"autoflow": false,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "f3bec493-0bc1-49d5-a40a-a09bd5cfb60c",
"measurement": "consul_health_checks",
"app": "consul",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "0fa47984-825b-46f1-9ca5-0366e3281cc5",
"measurement": "cpu",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,9 +2,10 @@
"id": "0b75be4e-3454-4d5d-9a98-ca77c81397f6",
"measurement": "disk",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,
"x": 4,
"y": 0,
"w": 4,
"h": 4,

View File

@ -2,6 +2,7 @@
"id": "0e980b97-c162-487b-a815-3f955df6243f",
"measurement": "docker",
"app": "docker",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "1f3ac9d0-bfb3-4e13-91a6-8949f7643ee9",
"measurement": "elasticsearch_indices",
"app": "elasticsearch",
"autoflow": false,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "45c064fd-ebf7-45a1-bf8d-f53746d38a03",
"measurement": "haproxy",
"app": "haproxy",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "543aa120-14ba-46a2-8ef9-6e6c7be3d600",
"measurement": "influxdb_database",
"app": "influxdb",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "e0d70dc9-538a-4b29-8d27-4a76d5fc8a09",
"measurement": "influxdb_httpd",
"app": "influxdb",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "543aa120-14ba-46a2-8ef9-6e6c7be3d60e",
"measurement": "influxdb_queryExecutor",
"app": "influxdb",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "74fe93bf-14d6-40d4-af8f-335554f4acf3",
"measurement": "influxdb_write",
"app": "influxdb",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "4a1efaec-57cf-4aeb-8dea-8a015f8ec3c5",
"measurement": "kubernetes_node",
"app": "kubernetes",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "50a14fed-6d0c-4c8a-a142-ad9276bee245",
"measurement": "kubernetes_pod_container",
"app": "kubernetes",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "45845136-bcb7-41ad-a02e-c63e9d3452de",
"measurement": "kubernetes_pod_network",
"app": "kubernetes",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "05dde59a-a52f-4ede-81fa-0c6011f29287",
"measurement": "kubernetes_system_container",
"app": "kubernetes",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "ec6c48f4-48ca-4ba7-a842-5b700e19f274",
"measurement": "system",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "4a805493-f7ef-4da0-8de8-e78afd899722",
"measurement": "mem",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "f280c8c7-0530-425c-b281-788d8ded7676",
"measurement": "memcached",
"app": "memcached",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,7 +2,27 @@
"id": "921298ad-0cdd-44f4-839b-10c319e7fcc7",
"measurement": "mongodb",
"app": "mongodb",
"autoflow": true,
"cells": [
{
"id": "921298ad-0cdd-44f4-839b-10c319e7fcc7",
"measurement": "mongodb",
"app": "mongodb",
"cells": [{
"x": 0,
"y": 0,
"w": 4,
"h": 4,
"i": "b2631fd5-7d32-4a31-9edf-98362fd3626e",
"name": "MongoDB Read/Second",
"queries": [{
"query": "SELECT mean(queries_per_sec) AS queries_per_second, mean(getmores_per_sec) AS getmores_per_second FROM mongodb",
"db": "telegraf",
"rp": "",
"groupbys": [],
"wheres": []
}]
},
{
"x": 0,
"y": 0,

View File

@ -2,6 +2,7 @@
"id": "c1aa88c7-a047-4b52-85c4-0eec21b357ef",
"measurement": "mysql",
"app": "mysql",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "ff41d044-f61a-4522-8de7-9e39e3a1b5de",
"measurement": "netstat",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "b805d661-e5a3-45e4-af18-de0e9360e6e7",
"measurement": "nginx",
"app": "nginx",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "7b035812-182a-4a94-ba2e-902dfb81e0a2",
"measurement": "nsq_channel",
"app": "nsq",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "6c351881-05ec-48f1-b11b-9c36d2c7cc80",
"measurement": "nsq_server",
"app": "nsq",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "f7be6717-61df-4e58-ac4a-e4f49f95d847",
"measurement": "nsq_topic",
"app": "nsq",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "6fba9b06-b9d3-4e67-a41e-177d585dfe28",
"measurement": "ping",
"app": "ping",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "0975a073-9eb8-471c-aaf2-692b65f9fe5c",
"measurement": "postgresql",
"app": "postgresql",
"autoflow": false,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "ffad2dff-d263-412e-806a-1e836af87942",
"measurement": "processes",
"app": "system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "793e6cca-7d7f-48e4-8db2-7b81761cc6ff",
"measurement": "redis",
"app": "redis",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "f56fd522-3e9c-492d-88fe-34e05d6d2462",
"measurement": "riak",
"app": "riak",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "188b7f23-648f-4c54-99f6-6a0e2e90a2fc",
"measurement": "win_cpu",
"app": "win_system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "cef6c954-f066-4348-9425-4132429fe817",
"measurement": "win_mem",
"app": "win_system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "d795c66f-0d8a-4fc0-b7bf-2cef1d2f4519",
"measurement": "win_net",
"app": "win_system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "96bd0303-19b6-4f87-a0f9-2755c6178ba7",
"measurement": "win_system",
"app": "win_system",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -2,6 +2,7 @@
"id": "c7644755-505d-46f0-b278-5c29268293b2",
"measurement": "win_websvc",
"app": "iis",
"autoflow": true,
"cells": [
{
"x": 0,

View File

@ -259,6 +259,7 @@ type Layout struct {
ID string `json:"id"`
Application string `json:"app"`
Measurement string `json:"measurement"`
Autoflow bool `json:"autoflow"`
Cells []Cell `json:"cells"`
}

View File

@ -4,6 +4,7 @@ import TimeRangeDropdown from '../../shared/components/TimeRangeDropdown';
import timeRanges from 'hson!../../shared/data/timeRanges.hson';
import {getMappings, getAppsForHosts, getMeasurementsForHost} from 'src/hosts/apis';
import {fetchLayouts} from 'shared/apis';
import _ from 'lodash';
export const HostPage = React.createClass({
propTypes: {
@ -67,19 +68,51 @@ export const HostPage = React.createClass({
const {timeRange} = this.state;
const {source} = this.props;
const autoflowLayouts = _.remove(layouts, (layout) => {
return layout.autoflow === true;
});
let autoflowCells = [];
const cellWidth = 4;
const pageWidth = 12;
autoflowLayouts.forEach((layout, i) => {
layout.cells.forEach((cell, j) => {
cell.x = ((i + j) * cellWidth % pageWidth);
cell.y = Math.floor(((i + j) * cellWidth / pageWidth));
autoflowCells = autoflowCells.concat(cell);
});
});
const autoflowLayout = {
cells: autoflowCells,
autoflow: false,
};
const staticLayouts = _.remove(layouts, (layout) => {
return layout.autoflow === false;
});
staticLayouts.unshift(autoflowLayout);
let layoutCells = [];
layouts.forEach((layout) => {
let translateY = 0;
staticLayouts.forEach((layout) => {
let maxY = 0;
layout.cells.forEach((cell) => {
cell.y += translateY;
if (cell.y > translateY) {
maxY = cell.y;
}
cell.queries.forEach((q) => {
q.text = q.query;
q.database = source.telegraf;
});
});
translateY = maxY;
layoutCells = layoutCells.concat(layout.cells);
});
layoutCells.forEach((cell, i) => {
cell.queries.forEach((q) => {
q.text = q.query;
q.database = source.telegraf;
});
cell.x = (i * 4 % 12); // eslint-disable-line no-magic-numbers
cell.y = 0;
});
return (
<LayoutRenderer