mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
wip: testing new query editor row design
This commit is contained in:
parent
4bad76c0f4
commit
166e5edebd
@ -171,7 +171,6 @@ export class QueriesTab extends PureComponent<Props, State> {
|
|||||||
return (
|
return (
|
||||||
<EditorTabBody heading="Queries" renderToolbar={this.renderToolbar} toolbarItems={[queryInspector, dsHelp]}>
|
<EditorTabBody heading="Queries" renderToolbar={this.renderToolbar} toolbarItems={[queryInspector, dsHelp]}>
|
||||||
<>
|
<>
|
||||||
<PanelOptionsGroup>
|
|
||||||
<div className="query-editor-rows">
|
<div className="query-editor-rows">
|
||||||
{panel.targets.map((query, index) => (
|
{panel.targets.map((query, index) => (
|
||||||
<QueryEditorRow
|
<QueryEditorRow
|
||||||
@ -184,7 +183,8 @@ export class QueriesTab extends PureComponent<Props, State> {
|
|||||||
onMoveQuery={this.onMoveQuery}
|
onMoveQuery={this.onMoveQuery}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<div className="gf-form-query">
|
<div className="gf-form-query">
|
||||||
<div className="gf-form gf-form-query-letter-cell">
|
<div className="gf-form gf-form-query-letter-cell">
|
||||||
<label className="gf-form-label">
|
<label className="gf-form-label">
|
||||||
@ -204,7 +204,6 @@ export class QueriesTab extends PureComponent<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</PanelOptionsGroup>
|
|
||||||
<PanelOptionsGroup>
|
<PanelOptionsGroup>
|
||||||
<QueryOptions panel={panel} datasource={currentDS} />
|
<QueryOptions panel={panel} datasource={currentDS} />
|
||||||
</PanelOptionsGroup>
|
</PanelOptionsGroup>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
// Utils & Services
|
// Utils & Services
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
@ -21,6 +22,7 @@ interface Props {
|
|||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
datasource: DataSourceApi | null;
|
datasource: DataSourceApi | null;
|
||||||
|
isCollapsed: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class QueryEditorRow extends PureComponent<Props, State> {
|
export class QueryEditorRow extends PureComponent<Props, State> {
|
||||||
@ -29,6 +31,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
state: State = {
|
state: State = {
|
||||||
datasource: null,
|
datasource: null,
|
||||||
|
isCollapsed: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -90,15 +93,51 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onToggleCollapse = () => {
|
||||||
|
this.setState({ isCollapsed: !this.state.isCollapsed });
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { datasource } = this.state;
|
const { query } = this.props;
|
||||||
|
const { datasource, isCollapsed } = this.state;
|
||||||
|
const bodyClasses = classNames('query-editor-box__body gf-form-query', {hide: isCollapsed});
|
||||||
|
|
||||||
if (!datasource) {
|
if (!datasource) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datasource.pluginExports.QueryCtrl) {
|
if (datasource.pluginExports.QueryCtrl) {
|
||||||
return <div ref={element => (this.element = element)} />;
|
return (
|
||||||
|
<div className="query-editor-box">
|
||||||
|
<div className="query-editor-box__header">
|
||||||
|
<div className="query-editor-box__ref-id" onClick={this.onToggleCollapse}>
|
||||||
|
{isCollapsed && <i className="fa fa-caret-right" />}
|
||||||
|
{!isCollapsed && <i className="fa fa-caret-down" />}
|
||||||
|
<span>{query.refId}</span>
|
||||||
|
</div>
|
||||||
|
<div className="query-editor-box__actions">
|
||||||
|
<button className="query-editor-box__action">
|
||||||
|
<i className="fa fa-fw fa-arrow-down" />
|
||||||
|
</button>
|
||||||
|
<button className="query-editor-box__action">
|
||||||
|
<i className="fa fa-fw fa-arrow-up" />
|
||||||
|
</button>
|
||||||
|
<button className="query-editor-box__action">
|
||||||
|
<i className="fa fa-fw fa-copy" />
|
||||||
|
</button>
|
||||||
|
<button className="query-editor-box__action">
|
||||||
|
<i className="fa fa-fw fa-eye" />
|
||||||
|
</button>
|
||||||
|
<button className="query-editor-box__action">
|
||||||
|
<i className="fa fa-fw fa-trash" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={bodyClasses}>
|
||||||
|
<div ref={element => (this.element = element)} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
} else if (datasource.pluginExports.QueryEditor) {
|
} else if (datasource.pluginExports.QueryEditor) {
|
||||||
const QueryEditor = datasource.pluginExports.QueryEditor;
|
const QueryEditor = datasource.pluginExports.QueryEditor;
|
||||||
return <QueryEditor />;
|
return <QueryEditor />;
|
||||||
@ -119,4 +158,3 @@ export interface AngularQueryComponentScope {
|
|||||||
moveQuery: (query: DataQuery, direction: number) => void;
|
moveQuery: (query: DataQuery, direction: number) => void;
|
||||||
datasource: DataSourceApi;
|
datasource: DataSourceApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,44 +1,2 @@
|
|||||||
<div class="gf-form-query">
|
<div ng-transclude class="gf-form-query-content"></div>
|
||||||
<div ng-if="!ctrl.hideEditorRowActions" class="gf-form gf-form-query-letter-cell">
|
|
||||||
<label class="gf-form-label">
|
|
||||||
<a class="pointer" tabindex="1" ng-click="ctrl.toggleCollapse()">
|
|
||||||
<span ng-class="{muted: !ctrl.canCollapse}" class="gf-form-query-letter-cell-carret">
|
|
||||||
<i class="fa fa-caret-down" ng-hide="ctrl.collapsed"></i>
|
|
||||||
<i class="fa fa-caret-right" ng-show="ctrl.collapsed"></i>
|
|
||||||
</span>
|
|
||||||
<span class="gf-form-query-letter-cell-letter">{{ ctrl.target.refId }}</span>
|
|
||||||
<em class="gf-form-query-letter-cell-ds" ng-show="ctrl.target.datasource">({{ ctrl.target.datasource }})</em>
|
|
||||||
</a>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gf-form-query-content gf-form-query-content--collapsed" ng-if="ctrl.collapsed">
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label pointer gf-form-label--grow" ng-click="ctrl.toggleCollapse()">
|
|
||||||
{{ ctrl.collapsedText }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-transclude class="gf-form-query-content" ng-if="!ctrl.collapsed"></div>
|
|
||||||
|
|
||||||
<div ng-if="!ctrl.hideEditorRowActions" class="gf-form">
|
|
||||||
<label class="gf-form-label dropdown">
|
|
||||||
<a class="pointer dropdown-toggle" data-toggle="dropdown" tabindex="1"> <i class="fa fa-bars"></i> </a>
|
|
||||||
<ul class="dropdown-menu pull-right" role="menu">
|
|
||||||
<li role="menuitem" ng-if="ctrl.hasTextEditMode">
|
|
||||||
<a tabindex="1" ng-click="ctrl.toggleEditorMode()">Toggle Edit Mode</a>
|
|
||||||
</li>
|
|
||||||
<li role="menuitem"><a tabindex="1" ng-click="ctrl.duplicateQuery()">Duplicate</a></li>
|
|
||||||
<li role="menuitem"><a tabindex="1" ng-click="ctrl.moveQuery(-1)">Move up</a></li>
|
|
||||||
<li role="menuitem"><a tabindex="1" ng-click="ctrl.moveQuery(1)">Move down</a></li>
|
|
||||||
</ul>
|
|
||||||
</label>
|
|
||||||
<label class="gf-form-label">
|
|
||||||
<a ng-click="ctrl.toggleHideQuery()" role="menuitem"> <i class="fa fa-eye"></i> </a>
|
|
||||||
</label>
|
|
||||||
<label class="gf-form-label">
|
|
||||||
<a class="pointer" tabindex="1" ng-click="ctrl.removeQuery(ctrl.target)"> <i class="fa fa-trash"></i> </a>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@ -18,12 +18,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.gf-form-query {
|
.gf-form-query {
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
align-content: flex-start;
|
|
||||||
align-items: flex-start;
|
|
||||||
|
|
||||||
.gf-form,
|
.gf-form,
|
||||||
.gf-form-filler {
|
.gf-form-filler {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
@ -188,3 +182,53 @@ input[type='text'].tight-form-func-param {
|
|||||||
.rst-literal-block .rst-text {
|
.rst-literal-block .rst-text {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.query-editor-box {
|
||||||
|
background: $page-bg;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.query-editor-box__actions {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor-box__header {
|
||||||
|
display: flex;
|
||||||
|
padding: 4px 0px 4px 8px;
|
||||||
|
position: relative;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor-box__ref-id {
|
||||||
|
font-weight: $font-weight-semi-bold;
|
||||||
|
color: $blue;
|
||||||
|
font-size: $font-size-md;
|
||||||
|
flex-grow: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
i {
|
||||||
|
padding-right: 5px;
|
||||||
|
color: $text-muted;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor-box__actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor-box__action {
|
||||||
|
@include buttonBackground($btn-inverse-bg, $btn-inverse-bg-hl, $btn-inverse-text-color, $btn-inverse-text-shadow);
|
||||||
|
border: 1px solid $navbar-button-border;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.query-editor-box__body {
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user