mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
query: more work on metrics tab changes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
///<reference path="../../headers/common.d.ts" />
|
///<reference path="../../headers/common.d.ts" />
|
||||||
|
|
||||||
|
import angular from 'angular';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -33,6 +34,7 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|||||||
dataStream: any;
|
dataStream: any;
|
||||||
dataSubscription: any;
|
dataSubscription: any;
|
||||||
dataList: any;
|
dataList: any;
|
||||||
|
nextRefId: string;
|
||||||
|
|
||||||
constructor($scope, $injector) {
|
constructor($scope, $injector) {
|
||||||
super($scope, $injector);
|
super($scope, $injector);
|
||||||
@@ -307,6 +309,25 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|||||||
this.datasource = null;
|
this.datasource = null;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addQuery(target) {
|
||||||
|
target.refId = this.dashboard.getNextQueryLetter(this.panel);
|
||||||
|
|
||||||
|
this.panel.targets.push(target);
|
||||||
|
this.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeQuery(target) {
|
||||||
|
var index = _.indexOf(this.panel.targets, target);
|
||||||
|
this.panel.targets.splice(index, 1);
|
||||||
|
this.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
moveQuery(target, direction) {
|
||||||
|
var index = _.indexOf(this.panel.targets, target);
|
||||||
|
_.move(this.panel.targets, index, index + direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {MetricsPanelCtrl};
|
export {MetricsPanelCtrl};
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ export class MetricsTabCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.dsSegment = uiSegmentSrv.newSegment({value: this.current.name, selectMode: true});
|
this.dsSegment = uiSegmentSrv.newSegment({value: this.current.name, selectMode: true});
|
||||||
this.mixedDsSegment = uiSegmentSrv.newSegment({value: 'Add Query', selectMode: true});
|
this.mixedDsSegment = uiSegmentSrv.newSegment({value: 'Add Query', selectMode: true, fake: true});
|
||||||
this.nextRefId = this.getNextQueryLetter();
|
|
||||||
|
// update next ref id
|
||||||
|
this.panelCtrl.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOptions(includeBuiltin) {
|
getOptions(includeBuiltin) {
|
||||||
@@ -61,22 +63,13 @@ export class MetricsTabCtrl {
|
|||||||
var ds = _.find(this.datasources, {name: this.mixedDsSegment.value});
|
var ds = _.find(this.datasources, {name: this.mixedDsSegment.value});
|
||||||
if (ds) {
|
if (ds) {
|
||||||
target.datasource = ds.name;
|
target.datasource = ds.name;
|
||||||
this.panelCtrl.panel.targets.push(target);
|
this.panelCtrl.addDataQuery(target);
|
||||||
this.mixedDsSegment.value = '';
|
this.mixedDsSegment.value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getNextQueryLetter() {
|
addQuery() {
|
||||||
return this.dashboard.getNextQueryLetter(this.panel);
|
this.panelCtrl.addQuery({isNew: true});
|
||||||
}
|
|
||||||
|
|
||||||
addDataQuery() {
|
|
||||||
var target: any = {
|
|
||||||
isNew: true,
|
|
||||||
refId: this.getNextQueryLetter()
|
|
||||||
};
|
|
||||||
this.panelCtrl.panel.targets.push(target);
|
|
||||||
this.nextRefId = this.getNextQueryLetter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,18 @@ export class PanelCtrl {
|
|||||||
profiler.renderingCompleted(this.panel.id, this.timing);
|
profiler.renderingCompleted(this.panel.id, this.timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldSkipRefresh() {
|
||||||
|
// some scenarios we should never ignore refresh
|
||||||
|
if (this.fullscreen || this.dashboard.meta.soloMode || this.dashboard.snapshot) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !this.isPanelVisible();
|
||||||
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
if (!this.isPanelVisible() && !this.dashboard.meta.soloMode && !this.dashboard.snapshot) {
|
// somet
|
||||||
|
if (this.shouldSkipRefresh()) {
|
||||||
this.skippedLastRefresh = true;
|
this.skippedLastRefresh = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class QueryRowCtrl {
|
|||||||
this.panel = this.panelCtrl.panel;
|
this.panel = this.panelCtrl.panel;
|
||||||
|
|
||||||
if (!this.target.refId) {
|
if (!this.target.refId) {
|
||||||
this.target.refId = this.getNextQueryLetter();
|
this.target.refId = this.panelCtrl.dashboard.getNextQueryLetter(this.panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toggleCollapse(true);
|
this.toggleCollapse(true);
|
||||||
@@ -40,16 +40,6 @@ export class QueryRowCtrl {
|
|||||||
this.panelCtrl.refresh();
|
this.panelCtrl.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
getNextQueryLetter() {
|
|
||||||
var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
||||||
|
|
||||||
return _.find(letters, refId => {
|
|
||||||
return _.every(this.panel.targets, function(other) {
|
|
||||||
return other.refId !== refId;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleCollapse(init) {
|
toggleCollapse(init) {
|
||||||
if (!this.canCollapse) {
|
if (!this.canCollapse) {
|
||||||
return;
|
return;
|
||||||
@@ -87,19 +77,16 @@ export class QueryRowCtrl {
|
|||||||
delete this.panelCtrl.__collapsedQueryCache[this.target.refId];
|
delete this.panelCtrl.__collapsedQueryCache[this.target.refId];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.panel.targets = _.without(this.panel.targets, this.target);
|
this.panelCtrl.removeQuery(this.target);
|
||||||
this.panelCtrl.refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
duplicateQuery() {
|
duplicateQuery() {
|
||||||
var clone = angular.copy(this.target);
|
var clone = angular.copy(this.target);
|
||||||
clone.refId = this.getNextQueryLetter();
|
this.panelCtrl.addQuery(clone);
|
||||||
this.panel.targets.push(clone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
moveQuery(direction) {
|
moveQuery(direction) {
|
||||||
var index = _.indexOf(this.panel.targets, this.target);
|
this.panelCtrl.moveQuery(this.target, direction);
|
||||||
_.move(this.panel.targets, index, index + direction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,6 @@
|
|||||||
<div class="gf-form-group">
|
<div class="gf-form-group">
|
||||||
<div class="gf-form-inline">
|
<div class="gf-form-inline">
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<label class="gf-form-label">
|
|
||||||
<i class="icon-gf icon-gf-datasources"></i>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label class="gf-form-label">
|
<label class="gf-form-label">
|
||||||
Data Source
|
Data Source
|
||||||
</label>
|
</label>
|
||||||
@@ -31,9 +27,9 @@
|
|||||||
<span class="gf-form-query-letter-cell-carret">
|
<span class="gf-form-query-letter-cell-carret">
|
||||||
<i class="fa fa-caret-down"></i>
|
<i class="fa fa-caret-down"></i>
|
||||||
</span>
|
</span>
|
||||||
<span class="gf-form-query-letter-cell-letter">{{ctrl.nextRefId}}</span>
|
<span class="gf-form-query-letter-cell-letter">{{ctrl.panelCtrl.nextRefId}}</span>
|
||||||
</label>
|
</label>
|
||||||
<button class="btn btn-inverse gf-form-btn" ng-click="ctrl.addDataQuery()" ng-hide="ctrl.current.meta.mixed">
|
<button class="btn btn-inverse gf-form-btn" ng-click="ctrl.addQuery()" ng-hide="ctrl.current.meta.mixed">
|
||||||
Add Query
|
Add Query
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ $gf-form-margin: 0.25rem;
|
|||||||
padding: $input-padding-y $input-padding-x;
|
padding: $input-padding-y $input-padding-x;
|
||||||
margin-right: $gf-form-margin;
|
margin-right: $gf-form-margin;
|
||||||
font-size: $font-size-base;
|
font-size: $font-size-base;
|
||||||
|
margin-right: $gf-form-margin;
|
||||||
line-height: $input-line-height;
|
line-height: $input-line-height;
|
||||||
color: $input-color;
|
color: $input-color;
|
||||||
background-color: $input-bg;
|
background-color: $input-bg;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.edit-sidemenu-aside {
|
.edit-sidemenu-aside {
|
||||||
min-width: 6rem;
|
|
||||||
margin-right: $spacer*2;
|
margin-right: $spacer*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user