From 395213abd75a899da58a42dc57bf76e82c5db2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 5 Sep 2016 11:46:16 +0200 Subject: [PATCH] feat(graph panel): more refactoring of #5917 --- public/app/core/directives/metric_segment.js | 5 +- public/app/core/services/segment_srv.js | 1 + .../app/features/panel/metrics_ds_selector.ts | 4 +- public/app/plugins/panel/graph/module.ts | 20 +++++- public/app/plugins/panel/graph/tab_axes.html | 63 +++---------------- public/sass/components/_gf-form.scss | 2 +- 6 files changed, 33 insertions(+), 62 deletions(-) diff --git a/public/app/core/directives/metric_segment.js b/public/app/core/directives/metric_segment.js index 7669f2fb709..36eac942c3e 100644 --- a/public/app/core/directives/metric_segment.js +++ b/public/app/core/directives/metric_segment.js @@ -23,10 +23,10 @@ function (_, $, coreModule) { getOptions: "&", onChange: "&", }, - link: function($scope, elem, attrs) { + link: function($scope, elem) { var $input = $(inputTemplate); - var $button = $(attrs.styleMode === 'select' ? selectTemplate : linkTemplate); var segment = $scope.segment; + var $button = $(segment.selectMode ? selectTemplate : linkTemplate); var options = null; var cancelBlur = null; var linkMode = true; @@ -179,6 +179,7 @@ function (_, $, coreModule) { cssClass: attrs.cssClass, custom: attrs.custom, value: option ? option.text : value, + selectMode: attrs.selectMode, }; return uiSegmentSrv.newSegment(segment); }; diff --git a/public/app/core/services/segment_srv.js b/public/app/core/services/segment_srv.js index d05a2bb011f..9d13e8e27e3 100644 --- a/public/app/core/services/segment_srv.js +++ b/public/app/core/services/segment_srv.js @@ -28,6 +28,7 @@ function (angular, _, coreModule) { this.type = options.type; this.fake = options.fake; this.value = options.value; + this.selectMode = options.selectMode; this.type = options.type; this.expandable = options.expandable; this.html = options.html || $sce.trustAsHtml(templateSrv.highlightVariablesAsHtml(this.value)); diff --git a/public/app/features/panel/metrics_ds_selector.ts b/public/app/features/panel/metrics_ds_selector.ts index c0e1b776062..f925b2afb42 100644 --- a/public/app/features/panel/metrics_ds_selector.ts +++ b/public/app/features/panel/metrics_ds_selector.ts @@ -16,7 +16,7 @@ var template = ` Panel data source - @@ -67,7 +67,7 @@ export class MetricsDsSelectorCtrl { this.current = {name: dsValue + ' not found', value: null}; } - this.dsSegment = uiSegmentSrv.newSegment(this.current.name); + this.dsSegment = uiSegmentSrv.newSegment({value: this.current.name, selectMode: true}); } getOptions() { diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index f1b54c03e11..cd2ac329ef5 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -23,7 +23,7 @@ class GraphCtrl extends MetricsPanelCtrl { logScales: any; unitFormats: any; xAxisModes: any; - xAxisSeriesStats: any; + xNameSegment: any; annotationsPromise: any; datapointsCount: number; datapointsOutside: boolean; @@ -154,7 +154,6 @@ class GraphCtrl extends MetricsPanelCtrl { 'Json': 'json' }; - this.xAxisSeriesStats = ['min', 'max', 'avg', 'current', 'count', 'total']; this.subTabIndex = 0; } @@ -288,7 +287,6 @@ class GraphCtrl extends MetricsPanelCtrl { }); var alias = valueField; - return this.seriesHandler(seriesData, index, datapoints, alias); } @@ -396,6 +394,22 @@ class GraphCtrl extends MetricsPanelCtrl { fileExport.exportSeriesListToCsvColumns(this.seriesList); } + xAxisModeChanged() { + // set defaults + this.refresh(); + } + + getXAxisNameOptions() { + return this.$q.when([ + {text: 'Avg', value: 'avg'} + ]); + } + + getXAxisValueOptions() { + return this.$q.when([ + {text: 'Avg', value: 'avg'} + ]); + } } function getFieldsFromESDoc(doc) { diff --git a/public/app/plugins/panel/graph/tab_axes.html b/public/app/plugins/panel/graph/tab_axes.html index c5ebfcc92d0..d939c61c7ff 100644 --- a/public/app/plugins/panel/graph/tab_axes.html +++ b/public/app/plugins/panel/graph/tab_axes.html @@ -47,68 +47,23 @@ + +
+ + +
+ -
+
-
- -
+
- -
- -
- -
-
- -
- -
- -
-
- - -
- -
- -
-
- -
- -
- -
-
diff --git a/public/sass/components/_gf-form.scss b/public/sass/components/_gf-form.scss index 82ca9073a4a..f8f92e9ebf8 100644 --- a/public/sass/components/_gf-form.scss +++ b/public/sass/components/_gf-form.scss @@ -135,7 +135,7 @@ $gf-form-margin: 0.25rem; &::after { position: absolute; top: 35%; - right: $input-padding-x/2; + right: $input-padding-x; background-color: transparent; color: $input-color; font: normal normal normal $font-size-sm/1 FontAwesome;