Commit 556829ed by Torkel Ödegaard

table: began table options redesign

parent e8fbfce5
...@@ -52,58 +52,62 @@ ...@@ -52,58 +52,62 @@
</div> </div>
</div> </div>
<div class="editor-row"> <h5 class="section-heading">
<div class="section gf-form-group"> <span style="padding-right: 10px;">Style Rules</span>
<h5 class="section-heading">Column Styles</h5> <button class="btn btn-secondary btn-small" ng-click="editor.addColumnStyle()">
<div ng-repeat="style in editor.panel.styles"> <i class="fa fa-plus"></i>&nbsp;Add
<div class="gf-form-inline"> </button>
<div class="gf-form"> </h5>
<label class="gf-form-label">Name or regex</label>
<input type="text" class="gf-form-input" ng-model="style.pattern" bs-typeahead="editor.getColumnNames" ng-blur="editor.render()" data-min-length=0 data-items=100 ng-model-onblur>
</div>
<div class="gf-form">
<label class="gf-form-label">Type</label>
<div class="gf-form-select-wrapper">
<select class="gf-form-input" ng-model="style.type" ng-options="c.value as c.text for c in editor.columnTypes" ng-change="editor.render()"></select>
</div>
</div>
<div class="gf-form" ng-if="style.type !== 'hidden'">
<label class="gf-form-label">Title</label>
<input type="text" class="gf-form-input" ng-model="style.alias" ng-change="editor.render()" ng-model-onblur>
</div>
<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div>
</div>
<div class="gf-form">
<label class="gf-form-label">
<a class="pointer" ng-click="editor.removeColumnStyle(style)">
<i class="fa fa-trash"></i>
</a>
</label>
</div>
</div>
<div class="gf-form-inline" ng-if="style.type === 'date'"> <div class="form-tabs-wrapper">
<div class="gf-form offset-width-8"> <ul class="gf-tabs">
<label class="gf-form-label width-8">Format</label> <li class="gf-tabs-item" ng-repeat="style in editor.panel.styles">
</div> <a class="gf-tabs-link" ng-click="editor.activeStyleIndex = $index" ng-class="{active: editor.activeStyleIndex === $index}">{{style.pattern || 'New rule'}}</a>
<div class="gf-form"> </li>
<metric-segment-model property="style.dateFormat" options="editor.dateFormats" on-change="editor.render()" custom="true"></metric-segment-model> </ul>
</div> </div>
<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div> <div class="form-tabs-content" ng-repeat="style in editor.panel.styles" ng-if="editor.activeStyleIndex === $index">
</div>
</div>
<div class="gf-form-inline" ng-if="style.type === 'string'"> <div class="gf-form-group">
<gf-form-switch class="gf-form offset-width-8" label-class="width-8" ng-if="style.type === 'string'" label="Sanitize HTML" checked="style.sanitize" change="editor.render()"></gf-form-switch> <div class="gf-form-inline">
<div class="gf-form gf-form--grow"> <div class="gf-form">
<div class="gf-form-label gf-form-label--grow"></div> <label class="gf-form-label width-13">Apply to columns named</label>
<input type="text" placeholder="Name or regex" class="gf-form-input width-13" ng-model="style.pattern" bs-tooltip="'Specify regex using /my.*regex/ syntax'" bs-typeahead="editor.getColumnNames" ng-blur="editor.render()" data-min-length=0 data-items=100 ng-model-onblur data-placement="right">
</div>
<div class="gf-form">
<label class="gf-form-label">Type</label>
<div class="gf-form-select-wrapper">
<select class="gf-form-input" ng-model="style.type" ng-options="c.value as c.text for c in editor.columnTypes" ng-change="editor.render()"></select>
</div> </div>
</div> </div>
</div>
<div class="gf-form" ng-if="style.type !== 'hidden'">
<label class="gf-form-label width-13">Custom Header Label</label>
<input type="text" class="gf-form-input width-13" ng-model="style.alias" ng-change="editor.render()" ng-model-onblur placeholder="Override header label">
</div>
</div>
<div class="gf-form-group" ng-if="style.type === 'date'">
<h5 class="section-heading">Date options</h5>
<div class="gf-form">
<label class="gf-form-label width-8">Date Format</label>
<metric-segment-model property="style.dateFormat" options="editor.dateFormats" on-change="editor.render()" custom="true"></metric-segment-model>
</div>
</div>
<div class="gf-form-group" ng-if="style.type === 'string'">
<h5 class="section-heading">String options</h5>
<gf-form-switch class="gf-form" label-class="width-8" ng-if="style.type === 'string'" label="Sanitize HTML" checked="style.sanitize" change="editor.render()"></gf-form-switch>
</div>
<div ng-if="style.type === 'number'">
<div class="gf-form-inline" ng-if="style.type === 'number'"> <div class="gf-form-group">
<div class="gf-form offset-width-8"> <h5 class="section-heading">Number options</h5>
<div class="gf-form-inline">
<div class="gf-form">
<label class="gf-form-label width-8">Unit</label> <label class="gf-form-label width-8">Unit</label>
</div> </div>
<div class="gf-form"> <div class="gf-form">
...@@ -113,22 +117,23 @@ ...@@ -113,22 +117,23 @@
<label class="gf-form-label">Decimals</label> <label class="gf-form-label">Decimals</label>
<input type="number" class="gf-form-input width-4" data-placement="right" ng-model="style.decimals" ng-change="editor.render()" ng-model-onblur> <input type="number" class="gf-form-input width-4" data-placement="right" ng-model="style.decimals" ng-change="editor.render()" ng-model-onblur>
</div> </div>
</div>
</div>
<div class="gf-form-group">
<h5 class="section-heading">Thresholds & Coloring</h5>
<div class="gf-form-inline">
<div class="gf-form">
<label class="gf-form-label width-8">Thresholds<tip>Comma separated values</tip></label>
<input type="text" class="gf-form-input width-10" ng-model="style.thresholds" placeholder="50,80" ng-blur="editor.render()" array-join ng-model-onblur>
</div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label">Coloring</label> <label class="gf-form-label">Coloring</label>
<div class="gf-form-select-wrapper"> <div class="gf-form-select-wrapper">
<select class="gf-form-input" ng-model="style.colorMode" ng-options="c.value as c.text for c in editor.colorModes" ng-change="editor.render()"></select> <select class="gf-form-input" ng-model="style.colorMode" ng-options="c.value as c.text for c in editor.colorModes" ng-change="editor.render()"></select>
</div> </div>
</div> </div>
<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow"></div>
</div>
</div>
<div class="gf-form-inline" ng-if="style.type === 'number'">
<div class="gf-form offset-width-8">
<label class="gf-form-label width-8">Thresholds<tip>Comma separated values</tip></label>
<input type="text" class="gf-form-input width-10" ng-model="style.thresholds" placeholder="50,80" ng-blur="editor.render()" array-join ng-model-onblur>
</div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-5">Colors</label> <label class="gf-form-label width-5">Colors</label>
<span class="gf-form-label"> <span class="gf-form-label">
...@@ -140,19 +145,17 @@ ...@@ -140,19 +145,17 @@
<span class="gf-form-label"> <span class="gf-form-label">
<spectrum-picker ng-model="style.colors[2]" ng-change="editor.render()"></spectrum-picker> <spectrum-picker ng-model="style.colors[2]" ng-change="editor.render()"></spectrum-picker>
</span> </span>
</div> <div class="gf-form-label">
<div class="gf-form gf-form--grow">
<div class="gf-form-label gf-form-label--grow">
<a class="pointer" ng-click="editor.invertColorOrder($index)">Invert</a> <a class="pointer" ng-click="editor.invertColorOrder($index)">Invert</a>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div> <button class="btn btn-danger btn-small" ng-click="editor.removeColumnStyle(style)">
</div> <i class="fa fa-trash"></i> Remove Rule
<div class="gf-form-button"> </button>
<button class="btn btn-inverse" ng-click="editor.addColumnStyle()"> <br />
<i class="fa fa-plus"></i>&nbsp;Add column style rule <br />
</button>
</div>
</div> </div>
...@@ -21,10 +21,12 @@ export class TablePanelEditorCtrl { ...@@ -21,10 +21,12 @@ export class TablePanelEditorCtrl {
addColumnSegment: any; addColumnSegment: any;
unitFormats: any; unitFormats: any;
getColumnNames: any; getColumnNames: any;
activeStyleIndex: number;
/** @ngInject */ /** @ngInject */
constructor($scope, private $q, private uiSegmentSrv) { constructor($scope, private $q, private uiSegmentSrv) {
$scope.editor = this; $scope.editor = this;
this.activeStyleIndex = 0;
this.panelCtrl = $scope.ctrl; this.panelCtrl = $scope.ctrl;
this.panel = this.panelCtrl.panel; this.panel = this.panelCtrl.panel;
this.transformers = transformers; this.transformers = transformers;
...@@ -111,12 +113,13 @@ export class TablePanelEditorCtrl { ...@@ -111,12 +113,13 @@ export class TablePanelEditorCtrl {
decimals: 2, decimals: 2,
colors: ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"], colors: ["rgba(245, 54, 54, 0.9)", "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)"],
colorMode: null, colorMode: null,
pattern: '/.*/', pattern: '',
dateFormat: 'YYYY-MM-DD HH:mm:ss', dateFormat: 'YYYY-MM-DD HH:mm:ss',
thresholds: [], thresholds: [],
}; };
this.panel.styles.push(angular.copy(columnStyleDefaults)); this.panel.styles.push(angular.copy(columnStyleDefaults));
this.activeStyleIndex = this.panel.styles.length-1;
} }
removeColumnStyle(style) { removeColumnStyle(style) {
......
...@@ -68,3 +68,12 @@ ...@@ -68,3 +68,12 @@
top: 1px; top: 1px;
} }
} }
.form-tabs-wrapper {
@include brand-bottom-border();
@include clearfix();
}
.form-tabs-content {
padding: $spacer*2 $spacer;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment