mirror of https://github.com/grafana/grafana.git
ux: dashboard settings progress
This commit is contained in:
parent
8354c64ff5
commit
05ec7541c8
|
|
@ -26,7 +26,7 @@ export class AnnotationsEditorCtrl {
|
|||
];
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $scope, private datasourceSrv) {
|
||||
constructor($scope, private datasourceSrv) {
|
||||
$scope.ctrl = this;
|
||||
|
||||
this.mode = 'list';
|
||||
|
|
@ -62,7 +62,6 @@ export class AnnotationsEditorCtrl {
|
|||
update() {
|
||||
this.reset();
|
||||
this.mode = 'list';
|
||||
this.$scope.broadcastRefresh();
|
||||
}
|
||||
|
||||
setupNew() {
|
||||
|
|
@ -74,28 +73,16 @@ export class AnnotationsEditorCtrl {
|
|||
this.annotations.push(this.currentAnnotation);
|
||||
this.reset();
|
||||
this.mode = 'list';
|
||||
this.$scope.broadcastRefresh();
|
||||
this.$scope.dashboard.updateSubmenuVisibility();
|
||||
}
|
||||
|
||||
removeAnnotation(annotation) {
|
||||
var index = _.indexOf(this.annotations, annotation);
|
||||
this.annotations.splice(index, 1);
|
||||
this.$scope.dashboard.updateSubmenuVisibility();
|
||||
this.$scope.broadcastRefresh();
|
||||
}
|
||||
|
||||
onColorChange(newColor) {
|
||||
this.currentAnnotation.iconColor = newColor;
|
||||
}
|
||||
|
||||
annotationEnabledChange() {
|
||||
this.$scope.broadcastRefresh();
|
||||
}
|
||||
|
||||
annotationHiddenChanged() {
|
||||
this.$scope.dashboard.updateSubmenuVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
coreModule.controller('AnnotationsEditorCtrl', AnnotationsEditorCtrl);
|
||||
|
|
|
|||
|
|
@ -1,147 +1,113 @@
|
|||
<h3 class="dashboard-settings__header">Annotations</h3>
|
||||
|
||||
<div ng-controller="AnnotationsEditorCtrl">
|
||||
<h3 class="dashboard-settings__header">
|
||||
<a ng-click="ctrl.setMode('list')">Annotations</a>
|
||||
<span ng-show="ctrl.mode === 'new'">> New</span>
|
||||
<span ng-show="ctrl.mode === 'edit'">> Edit</span>
|
||||
</h3>
|
||||
|
||||
<!-- <div class="tabbed-view-header"> -->
|
||||
<!-- <h2 class="tabbed-view-title"> -->
|
||||
<!-- Annotations -->
|
||||
<!-- </h2> -->
|
||||
<!-- -->
|
||||
<!-- <ul class="gf-tabs"> -->
|
||||
<!-- <li class="gf-tabs-item" > -->
|
||||
<!-- <a class="gf-tabs-link" ng-click="ctrl.mode = 'list';" ng-class="{active: ctrl.mode === 'list'}"> -->
|
||||
<!-- Queries -->
|
||||
<!-- </a> -->
|
||||
<!-- </li> -->
|
||||
<!-- <li class="gf-tabs-item" ng-show="ctrl.mode === 'edit'"> -->
|
||||
<!-- <a class="gf-tabs-link" ng-class="{active: ctrl.mode === 'edit'}"> -->
|
||||
<!-- Edit Query -->
|
||||
<!-- </a> -->
|
||||
<!-- </li> -->
|
||||
<!-- <li class="gf-tabs-item" ng-show="ctrl.mode === 'new'"> -->
|
||||
<!-- <span class="active gf-tabs-link">New Query</span> -->
|
||||
<!-- </li> -->
|
||||
<!-- -->
|
||||
<!-- <li class="gf-tabs-item" > -->
|
||||
<!-- <a class="gf-tabs-link" ng-click="ctrl.mode = 'help';" ng-class="{active: ctrl.mode === 'help'}"> -->
|
||||
<!-- Help -->
|
||||
<!-- </a> -->
|
||||
<!-- </li> -->
|
||||
<!-- </ul> -->
|
||||
<!-- -->
|
||||
<!-- <button class="tabbed-view-close-btn" ng-click="dismiss();"> -->
|
||||
<!-- <i class="fa fa-remove"></i> -->
|
||||
<!-- </button> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<!-- <div ng-show="ctrl.mode === 'help'"> -->
|
||||
<!-- <div class="grafana-info-box col-lg-8"> -->
|
||||
<!-- <h5>What are Annotations?</h5> -->
|
||||
<!-- <p> -->
|
||||
<!-- Annotations provide a way to integrate event data into your graphs. They are visualized as vertical lines and icons -->
|
||||
<!-- on all graph panels. When you hover over an annotation icon you can get title, tags, and text information for the event. -->
|
||||
<!-- In the <i>Queries</i> tab you can add queries that return annotation events. -->
|
||||
<!-- </p> -->
|
||||
<!-- <p> -->
|
||||
<!-- You can add annotations directly from grafana by holding CTRL or CMD + click on graph (or drag region). These will be stored in Grafana's annotation database. -->
|
||||
<!-- </p> -->
|
||||
<!-- Checkout the <a class="external-link" target="_blank" href="http://docs.grafana.org/reference/annotations/">Annotations documentation</a> for more information. -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
<div class="editor-row row">
|
||||
<div ng-if="ctrl.annotations.length === 0">
|
||||
<em>No annotation queries defined</em>
|
||||
<div ng-if="ctrl.mode === 'list'">
|
||||
<!-- empty list cta, there is always one built in query -->
|
||||
<div ng-if="ctrl.annotations.length === 1">
|
||||
<div class="empty-list-cta">
|
||||
<div class="empty-list-cta__title">There are no custom annotation queries added yet</div>
|
||||
<a ng-click="ctrl.setupNew()" class="empty-list-cta__button btn btn-xlarge btn-success">
|
||||
<i class="gicon gicon-dashboard-new"></i>
|
||||
Add Annotation Query
|
||||
</a>
|
||||
<div class="grafana-info-box">
|
||||
<h5>What are Annotations?</h5>
|
||||
<p>
|
||||
Annotations provide a way to integrate event data into your graphs. They are visualized as vertical lines and icons
|
||||
on all graph panels. When you hover over an annotation icon you can get event text & tags for the event. You can add annotation events
|
||||
directly from grafana by holding CTRL or CMD + click on graph (or drag region). These will be stored in Grafana's annotation database.
|
||||
</p>
|
||||
Checkout the <a class="external-link" target="_blank" href="http://docs.grafana.org/reference/annotations/">Annotations documentation</a> for more information.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="grafana-options-table">
|
||||
<div class="page-action-bar" ng-if="ctrl.annotations.length > 1">
|
||||
<div class="page-action-bar__spacer"></div>
|
||||
<a type="button" class="btn btn-success" ng-click="ctrl.setupNew();"><i class="fa fa-plus" ></i> New</a>
|
||||
</div>
|
||||
|
||||
<table class="filter-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Query name</th>
|
||||
<th>Data source</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="annotation in ctrl.annotations">
|
||||
<td style="width:90%" ng-hide="annotation.builtIn">
|
||||
<td style="width:90%" ng-hide="annotation.builtIn" class="pointer" ng-click="ctrl.edit(annotation)">
|
||||
<i class="fa fa-comment" style="color:{{annotation.iconColor}}"></i>
|
||||
{{annotation.name}}
|
||||
</td>
|
||||
<td style="width:90%" ng-show="annotation.builtIn">
|
||||
<td style="width:90%" ng-show="annotation.builtIn" class="pointer" ng-click="ctrl.edit(annotation)">
|
||||
<i class="fa fa-comment"></i>
|
||||
<em class="muted">{{annotation.name}} (Built-in)</em>
|
||||
</td>
|
||||
<td class="pointer" ng-click="ctrl.edit(annotation)">
|
||||
{{annotation.datasource || 'Default'}}
|
||||
</td>
|
||||
<td style="width: 1%"><i ng-click="_.move(ctrl.annotations,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
|
||||
<td style="width: 1%"><i ng-click="_.move(ctrl.annotations,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
|
||||
<td style="width: 1%">
|
||||
<a ng-click="ctrl.edit(annotation)" class="btn btn-inverse btn-mini">
|
||||
<i class="fa fa-edit"></i>
|
||||
Edit
|
||||
</a>
|
||||
</td>
|
||||
<td style="width: 1%">
|
||||
<a ng-click="ctrl.removeAnnotation(annotation)" class="btn btn-danger btn-mini" ng-hide="annotation.builtIn">
|
||||
<i class="fa fa-remove"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<div class="gf-form-button-row">
|
||||
<a type="button" class="btn gf-form-button btn-success" ng-click="ctrl.setupNew()"><i class="fa fa-plus" ></i> New</a>
|
||||
<div class="annotations-basic-settings" ng-if="ctrl.mode === 'edit' || ctrl.mode === 'new'">
|
||||
<div class="gf-form-group">
|
||||
<h5 class="section-heading">General</h5>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">Name</span>
|
||||
<input type="text" class="gf-form-input width-20" ng-model='ctrl.currentAnnotation.name' placeholder="name"></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">Data source</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input" ng-model="ctrl.currentAnnotation.datasource" ng-options="f.name as f.name for f in ctrl.datasources" ng-change="ctrl.datasourceChanged()"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="annotations-basic-settings" ng-if="ctrl.mode === 'edit' || ctrl.mode === 'new'"> -->
|
||||
<!-- <div> -->
|
||||
<!-- <div class="gf-form-group"> -->
|
||||
<!-- <h5 class="section-heading">General</h5> -->
|
||||
<!-- <div class="gf-form-inline"> -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <span class="gf-form-label width-7">Name</span> -->
|
||||
<!-- <input type="text" class="gf-form-input width-20" ng-model='ctrl.currentAnnotation.name' placeholder="name"></input> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <span class="gf-form-label width-7">Data source</span> -->
|
||||
<!-- <div class="gf-form-select-wrapper"> -->
|
||||
<!-- <select class="gf-form-input" ng-model="ctrl.currentAnnotation.datasource" ng-options="f.name as f.name for f in ctrl.datasources" ng-change="ctrl.datasourceChanged()"></select> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- -->
|
||||
<!-- <div class="gf-form-group"> -->
|
||||
<!-- <div class="gf-form-inline"> -->
|
||||
<!-- <gf-form-switch class="gf-form" -->
|
||||
<!-- label="Enabled" -->
|
||||
<!-- checked="ctrl.currentAnnotation.enable" -->
|
||||
<!-- on-change="ctrl.annotationEnabledChange()" -->
|
||||
<!-- label-class="width-7"> -->
|
||||
<!-- </gf-form-switch> -->
|
||||
<!-- <gf-form-switch class="gf-form" -->
|
||||
<!-- label="Hidden" -->
|
||||
<!-- tooltip="Hides the annotation query toggle from showing at the top of the dashboard" -->
|
||||
<!-- checked="ctrl.currentAnnotation.hide" -->
|
||||
<!-- on-change="ctrl.annotationHiddenChanged()" -->
|
||||
<!-- label-class="width-7"> -->
|
||||
<!-- </gf-form-switch> -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <label class="gf-form-label width-9">Color</label> -->
|
||||
<!-- <span class="gf-form-label"> -->
|
||||
<!-- <color-picker color="ctrl.currentAnnotation.iconColor" onChange="ctrl.onColorChange"></color-picker> -->
|
||||
<!-- </span> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- -->
|
||||
<!-- <h5 class="section-heading">Query</h5> -->
|
||||
<!-- <rebuild-on-change property="ctrl.currentDatasource"> -->
|
||||
<!-- <plugin-component type="annotations-query-ctrl"> -->
|
||||
<!-- </plugin-component> -->
|
||||
<!-- </rebuild-on-change> -->
|
||||
<!-- -->
|
||||
<!-- <div class="gf-form"> -->
|
||||
<!-- <div class="gf-form-button-row p-y-0"> -->
|
||||
<!-- <button ng-show="ctrl.mode === 'new'" type="button" class="btn gf-form-button btn-success" ng-click="ctrl.add()">Add</button> -->
|
||||
<!-- <button ng-show="ctrl.mode === 'edit'" type="button" class="btn btn-success pull-left" ng-click="ctrl.update()">Update</button> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<gf-form-switch class="gf-form" label="Enabled" checked="ctrl.currentAnnotation.enable" label-class="width-7">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" label="Hidden" tooltip="Hides the annotation query toggle from showing at the top of the dashboard" checked="ctrl.currentAnnotation.hide" label-class="width-7">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-9">Color</label>
|
||||
<span class="gf-form-label">
|
||||
<color-picker color="ctrl.currentAnnotation.iconColor" onChange="ctrl.onColorChange"></color-picker>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="section-heading">Query</h5>
|
||||
<rebuild-on-change property="ctrl.currentDatasource">
|
||||
<plugin-component type="annotations-query-ctrl">
|
||||
</plugin-component>
|
||||
</rebuild-on-change>
|
||||
|
||||
<div class="gf-form">
|
||||
<div class="gf-form-button-row p-y-0">
|
||||
<button ng-show="ctrl.mode === 'new'" type="button" class="btn gf-form-button btn-success" ng-click="ctrl.add()">Add</button>
|
||||
<button ng-show="ctrl.mode === 'edit'" type="button" class="btn btn-success pull-left" ng-click="ctrl.update()">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ export class SettingsCtrl {
|
|||
];
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, private $location, private $rootScope) {
|
||||
constructor(private $scope, private $location, private $rootScope) {
|
||||
// temp hack
|
||||
$scope.dashboard = this.dashboard;
|
||||
this.$scope.dashboard = this.dashboard;
|
||||
|
||||
const params = this.$location.search();
|
||||
const url = $location.path();
|
||||
|
|
@ -35,6 +35,11 @@ export class SettingsCtrl {
|
|||
|
||||
this.viewId = params.editview;
|
||||
$rootScope.onAppEvent("$routeUpdate", this.onRouteUpdated.bind(this), $scope);
|
||||
|
||||
this.$scope.$on('$destroy', () => {
|
||||
this.dashboard.updateSubmenuVisibility();
|
||||
this.$rootScope.$broadcast("refresh");
|
||||
});
|
||||
}
|
||||
|
||||
onRouteUpdated() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
///<reference path="../../headers/common.d.ts" />
|
||||
|
||||
import _ from 'lodash';
|
||||
import coreModule from 'app/core/core_module';
|
||||
import {variableTypes} from './variable';
|
||||
|
|
@ -45,6 +43,10 @@ export class VariableEditorCtrl {
|
|||
});
|
||||
};
|
||||
|
||||
$scope.setMode = function(mode) {
|
||||
$scope.mode = mode;
|
||||
};
|
||||
|
||||
$scope.add = function() {
|
||||
if ($scope.isValid()) {
|
||||
variableSrv.addVariable($scope.current);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
<h3 class="dashboard-settings__header">Variables</h3>
|
||||
|
||||
<div ng-controller="VariableEditorCtrl" ng-init="init()">
|
||||
|
||||
<h3 class="dashboard-settings__header">
|
||||
<a ng-click="setMode('list')">Variables</a>
|
||||
<span ng-show="mode === 'new'">> New</span>
|
||||
<span ng-show="mode === 'edit'">> Edit</span>
|
||||
</h3>
|
||||
|
||||
<div ng-if="mode === 'list'">
|
||||
|
||||
<div ng-if="variables.length === 0">
|
||||
<div class="empty-list-cta">
|
||||
<div class="empty-list-cta__title">There are no template variables added yet</div>
|
||||
<a ng-click="mode = 'new';" class="empty-list-cta__button btn btn-xlarge btn-success">
|
||||
<a ng-click="setMode('new')" class="empty-list-cta__button btn btn-xlarge btn-success">
|
||||
<i class="gicon gicon-dashboard-new"></i>
|
||||
Add variable
|
||||
</a>
|
||||
<div class="grafana-info-box">
|
||||
<h5>
|
||||
What does variables do?
|
||||
</h5>
|
||||
<h5>What does variables do?</h5>
|
||||
<p>Variables enables more interactive and dynamic dashboards. Instead of hard-coding things like server or sensor names
|
||||
in your metric queries you can use variables in their place. Variables are shown as dropdown select boxes at the top of
|
||||
the dashboard. These dropdowns make it easy to change the data being displayed in your dashboard.
|
||||
|
|
@ -29,7 +32,7 @@
|
|||
<div ng-if="variables.length">
|
||||
<div class="page-action-bar">
|
||||
<div class="page-action-bar__spacer"></div>
|
||||
<a type="button" class="btn btn-success" ng-click="mode = 'new';"><i class="fa fa-plus" ></i> New</a>
|
||||
<a type="button" class="btn btn-success" ng-click="setMode('new');"><i class="fa fa-plus" ></i> New</a>
|
||||
</div>
|
||||
|
||||
<table class="filter-table filter-table--hover">
|
||||
|
|
@ -50,7 +53,6 @@
|
|||
<td style="max-width: 200px;" ng-click="edit(variable)" class="pointer max-width">
|
||||
{{variable.query}}
|
||||
</td>
|
||||
|
||||
<td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
|
||||
<td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
|
||||
<td style="width: 1%">
|
||||
|
|
@ -70,7 +72,7 @@
|
|||
</div>
|
||||
|
||||
<form ng-if="mode === 'edit' || mode === 'new'" name="ctrl.form">
|
||||
<h5 class="section-heading">Variable</h5>
|
||||
<h5 class="section-heading">General</h5>
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-19">
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ $form-icon-danger: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www
|
|||
// Try to avoid customizing these :)
|
||||
$zindex-dropdown: 1000;
|
||||
$zindex-navbar-fixed: 1020;
|
||||
$zindex-sidemenu: 1025;
|
||||
$zindex-tooltip: 1030;
|
||||
$zindex-modal-backdrop: 1040;
|
||||
$zindex-modal: 1050;
|
||||
$zindex-typeahead: 1060;
|
||||
$zindex-sidemenu: $zindex-navbar-fixed;
|
||||
|
||||
// Buttons
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
.empty-list-cta {
|
||||
background-color: $search-filter-box-bg;
|
||||
text-align: center;
|
||||
padding: 2rem 2rem 1rem 2rem;
|
||||
padding: 2rem;
|
||||
border-radius: $border-radius;
|
||||
|
||||
.grafana-info-box {
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-list-cta__title {
|
||||
|
|
@ -14,10 +19,6 @@
|
|||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.empty-list-cta__pro-tip {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.empty-list-cta__pro-tip-link {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@
|
|||
|
||||
.sidemenu-open {
|
||||
.navbar {
|
||||
margin-left: 15px;
|
||||
padding-left: 15px;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue