mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
table: more table options refactoring
This commit is contained in:
parent
556829eda9
commit
be284adacc
@ -53,7 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h5 class="section-heading">
|
<h5 class="section-heading">
|
||||||
<span style="padding-right: 10px;">Style Rules</span>
|
<span style="padding-right: 10px;">Column Style Rules</span>
|
||||||
<button class="btn btn-secondary btn-small" ng-click="editor.addColumnStyle()">
|
<button class="btn btn-secondary btn-small" ng-click="editor.addColumnStyle()">
|
||||||
<i class="fa fa-plus"></i> Add
|
<i class="fa fa-plus"></i> Add
|
||||||
</button>
|
</button>
|
||||||
@ -69,90 +69,81 @@
|
|||||||
|
|
||||||
<div class="form-tabs-content" ng-repeat="style in editor.panel.styles" ng-if="editor.activeStyleIndex === $index">
|
<div class="form-tabs-content" ng-repeat="style in editor.panel.styles" ng-if="editor.activeStyleIndex === $index">
|
||||||
|
|
||||||
<div class="gf-form-group">
|
<div class="section gf-form-group">
|
||||||
|
<h5 class="section-heading">Options</h5>
|
||||||
<div class="gf-form-inline">
|
<div class="gf-form-inline">
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<label class="gf-form-label width-13">Apply to columns named</label>
|
<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">
|
<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>
|
||||||
<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 class="gf-form" ng-if="style.type !== 'hidden'">
|
<div class="gf-form" ng-if="style.type !== 'hidden'">
|
||||||
<label class="gf-form-label width-13">Custom Header Label</label>
|
<label class="gf-form-label width-13">Column Header</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">
|
<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>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form-group" ng-if="style.type === 'date'">
|
<div class="section gf-form-group">
|
||||||
<h5 class="section-heading">Date options</h5>
|
<h5 class="section-heading">Type</h5>
|
||||||
|
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
|
<label class="gf-form-label width-8">Type</label>
|
||||||
|
<div class="gf-form-select-wrapper width-12">
|
||||||
|
<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 === 'date'">
|
||||||
<label class="gf-form-label width-8">Date Format</label>
|
<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>
|
<metric-segment-model property="style.dateFormat" options="editor.dateFormats" on-change="editor.render()" custom="true"></metric-segment-model>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gf-form-group" ng-if="style.type === 'string'">
|
<div 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>
|
||||||
<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-group">
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<div class="gf-form-dropdown-typeahead" ng-model="style.unit" dropdown-typeahead2="editor.unitFormats" dropdown-typeahead-on-select="editor.setUnitFormat(style, $subItem)"></div>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form-group">
|
<div ng-if="style.type === 'number'">
|
||||||
<h5 class="section-heading">Thresholds & Coloring</h5>
|
<div class="gf-form">
|
||||||
<div class="gf-form-inline">
|
<label class="gf-form-label width-8">Unit</label>
|
||||||
<div class="gf-form">
|
<div class="gf-form-dropdown-typeahead width-12" ng-model="style.unit" dropdown-typeahead2="editor.unitFormats" dropdown-typeahead-on-select="editor.setUnitFormat(style, $subItem)"></div>
|
||||||
<label class="gf-form-label width-8">Thresholds<tip>Comma separated values</tip></label>
|
</div>
|
||||||
<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 class="gf-form">
|
||||||
</div>
|
<label class="gf-form-label width-8">Decimals</label>
|
||||||
<div class="gf-form">
|
<input type="number" class="gf-form-input width-4" data-placement="right" ng-model="style.decimals" ng-change="editor.render()" ng-model-onblur>
|
||||||
<label class="gf-form-label">Coloring</label>
|
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label width-5">Colors</label>
|
|
||||||
<span class="gf-form-label">
|
|
||||||
<spectrum-picker ng-model="style.colors[0]" ng-change="editor.render()"></spectrum-picker>
|
|
||||||
</span>
|
|
||||||
<span class="gf-form-label">
|
|
||||||
<spectrum-picker ng-model="style.colors[1]" ng-change="editor.render()"></spectrum-picker>
|
|
||||||
</span>
|
|
||||||
<span class="gf-form-label">
|
|
||||||
<spectrum-picker ng-model="style.colors[2]" ng-change="editor.render()"></spectrum-picker>
|
|
||||||
</span>
|
|
||||||
<div class="gf-form-label">
|
|
||||||
<a class="pointer" ng-click="editor.invertColorOrder($index)">Invert</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="section gf-form-group" ng-if="style.type === 'number'">
|
||||||
|
<h5 class="section-heading">Thresholds</h5>
|
||||||
|
<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">
|
||||||
|
<label class="gf-form-label width-8">Color Mode</label>
|
||||||
|
<div class="gf-form-select-wrapper width-10">
|
||||||
|
<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 class="gf-form">
|
||||||
|
<label class="gf-form-label width-8">Colors</label>
|
||||||
|
<span class="gf-form-label">
|
||||||
|
<spectrum-picker ng-model="style.colors[0]" ng-change="editor.render()"></spectrum-picker>
|
||||||
|
</span>
|
||||||
|
<span class="gf-form-label">
|
||||||
|
<spectrum-picker ng-model="style.colors[1]" ng-change="editor.render()"></spectrum-picker>
|
||||||
|
</span>
|
||||||
|
<span class="gf-form-label">
|
||||||
|
<spectrum-picker ng-model="style.colors[2]" ng-change="editor.render()"></spectrum-picker>
|
||||||
|
</span>
|
||||||
|
<div class="gf-form-label">
|
||||||
|
<a class="pointer" ng-click="editor.invertColorOrder($index)">Invert</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
<button class="btn btn-danger btn-small" ng-click="editor.removeColumnStyle(style)">
|
<button class="btn btn-danger btn-small" ng-click="editor.removeColumnStyle(style)">
|
||||||
<i class="fa fa-trash"></i> Remove Rule
|
<i class="fa fa-trash"></i> Remove Rule
|
||||||
</button>
|
</button>
|
||||||
|
@ -106,7 +106,7 @@ export class TablePanelEditorCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addColumnStyle() {
|
addColumnStyle() {
|
||||||
var columnStyleDefaults = {
|
var newStyleRule = {
|
||||||
unit: 'short',
|
unit: 'short',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
alias: '',
|
alias: '',
|
||||||
@ -118,8 +118,20 @@ export class TablePanelEditorCtrl {
|
|||||||
thresholds: [],
|
thresholds: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
this.panel.styles.push(angular.copy(columnStyleDefaults));
|
var styles = this.panel.styles;
|
||||||
this.activeStyleIndex = this.panel.styles.length-1;
|
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) {
|
removeColumnStyle(style) {
|
||||||
|
Loading…
Reference in New Issue
Block a user