From be284adaccaafb8dcc07dd5ce7278c354c7c6f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 8 May 2017 15:26:05 +0200 Subject: [PATCH] table: more table options refactoring --- public/app/plugins/panel/table/editor.html | 117 ++++++++++----------- public/app/plugins/panel/table/editor.ts | 18 +++- 2 files changed, 69 insertions(+), 66 deletions(-) diff --git a/public/app/plugins/panel/table/editor.html b/public/app/plugins/panel/table/editor.html index 657771d8338..5697bebe97d 100644 --- a/public/app/plugins/panel/table/editor.html +++ b/public/app/plugins/panel/table/editor.html @@ -53,7 +53,7 @@
- Style Rules + Column Style Rules @@ -69,90 +69,81 @@
-
+
+
Options
-
- -
- -
-
- +
-
-
Date options
+
+
Type
+
+ +
+ +
+
+
-
-
-
String options
- -
- -
- -
-
Number options
- -
-
- -
-
-
-
-
- - -
-
+
+
-
-
Thresholds & Coloring
-
-
- - -
-
- -
- -
-
- -
- - - - - - - - - - -
- Invert -
-
+
+
+ +
+
+
+ +
+
+
Thresholds
+
+ + +
+
+ +
+ +
+
+
+ + + + + + + + + + +
+ Invert +
+
+
+ +
+ diff --git a/public/app/plugins/panel/table/editor.ts b/public/app/plugins/panel/table/editor.ts index fca7b8a90fb..9379702e7db 100644 --- a/public/app/plugins/panel/table/editor.ts +++ b/public/app/plugins/panel/table/editor.ts @@ -106,7 +106,7 @@ export class TablePanelEditorCtrl { } addColumnStyle() { - var columnStyleDefaults = { + var newStyleRule = { unit: 'short', type: 'number', alias: '', @@ -118,8 +118,20 @@ export class TablePanelEditorCtrl { thresholds: [], }; - this.panel.styles.push(angular.copy(columnStyleDefaults)); - this.activeStyleIndex = this.panel.styles.length-1; + var styles = this.panel.styles; + var stylesCount = styles.length; + var indexToInsert = stylesCount; + + // check if last is a catch all rule, then add it before that one + if (stylesCount > 0) { + var last = styles[stylesCount-1]; + if (last.pattern === '/.*/') { + indexToInsert = stylesCount-1; + } + } + + styles.splice(indexToInsert, 0, newStyleRule); + this.activeStyleIndex = indexToInsert; } removeColumnStyle(style) {