ux: dashboard settings progress

This commit is contained in:
Torkel Ödegaard 2017-12-11 13:04:06 +01:00
parent 8354c64ff5
commit 05ec7541c8
8 changed files with 121 additions and 157 deletions

View File

@ -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);

View File

@ -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'">&gt; New</span>
<span ng-show="ctrl.mode === 'edit'">&gt; Edit</span>
</h3>
<!-- <div class="tabbed&#45;view&#45;header"> -->
<!-- <h2 class="tabbed&#45;view&#45;title"> -->
<!-- Annotations -->
<!-- </h2> -->
<!-- -->
<!-- <ul class="gf&#45;tabs"> -->
<!-- <li class="gf&#45;tabs&#45;item" > -->
<!-- <a class="gf&#45;tabs&#45;link" ng&#45;click="ctrl.mode = 'list';" ng&#45;class="{active: ctrl.mode === 'list'}"> -->
<!-- Queries -->
<!-- </a> -->
<!-- </li> -->
<!-- <li class="gf&#45;tabs&#45;item" ng&#45;show="ctrl.mode === 'edit'"> -->
<!-- <a class="gf&#45;tabs&#45;link" ng&#45;class="{active: ctrl.mode === 'edit'}"> -->
<!-- Edit Query -->
<!-- </a> -->
<!-- </li> -->
<!-- <li class="gf&#45;tabs&#45;item" ng&#45;show="ctrl.mode === 'new'"> -->
<!-- <span class="active gf&#45;tabs&#45;link">New Query</span> -->
<!-- </li> -->
<!-- -->
<!-- <li class="gf&#45;tabs&#45;item" > -->
<!-- <a class="gf&#45;tabs&#45;link" ng&#45;click="ctrl.mode = 'help';" ng&#45;class="{active: ctrl.mode === 'help'}"> -->
<!-- Help -->
<!-- </a> -->
<!-- </li> -->
<!-- </ul> -->
<!-- -->
<!-- <button class="tabbed&#45;view&#45;close&#45;btn" ng&#45;click="dismiss();"> -->
<!-- <i class="fa fa&#45;remove"></i> -->
<!-- </button> -->
<!-- </div> -->
<!-- <div ng&#45;show="ctrl.mode === 'help'"> -->
<!-- <div class="grafana&#45;info&#45;box col&#45;lg&#45;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&#45;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 &amp; 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> &nbsp;
{{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> &nbsp;
<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>&nbsp;&nbsp;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&#45;basic&#45;settings" ng&#45;if="ctrl.mode === 'edit' || ctrl.mode === 'new'"> -->
<!-- <div> -->
<!-- <div class="gf&#45;form&#45;group"> -->
<!-- <h5 class="section&#45;heading">General</h5> -->
<!-- <div class="gf&#45;form&#45;inline"> -->
<!-- <div class="gf&#45;form"> -->
<!-- <span class="gf&#45;form&#45;label width&#45;7">Name</span> -->
<!-- <input type="text" class="gf&#45;form&#45;input width&#45;20" ng&#45;model='ctrl.currentAnnotation.name' placeholder="name"></input> -->
<!-- </div> -->
<!-- <div class="gf&#45;form"> -->
<!-- <span class="gf&#45;form&#45;label width&#45;7">Data source</span> -->
<!-- <div class="gf&#45;form&#45;select&#45;wrapper"> -->
<!-- <select class="gf&#45;form&#45;input" ng&#45;model="ctrl.currentAnnotation.datasource" ng&#45;options="f.name as f.name for f in ctrl.datasources" ng&#45;change="ctrl.datasourceChanged()"></select> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- -->
<!-- <div class="gf&#45;form&#45;group"> -->
<!-- <div class="gf&#45;form&#45;inline"> -->
<!-- <gf&#45;form&#45;switch class="gf&#45;form" -->
<!-- label="Enabled" -->
<!-- checked="ctrl.currentAnnotation.enable" -->
<!-- on&#45;change="ctrl.annotationEnabledChange()" -->
<!-- label&#45;class="width&#45;7"> -->
<!-- </gf&#45;form&#45;switch> -->
<!-- <gf&#45;form&#45;switch class="gf&#45;form" -->
<!-- label="Hidden" -->
<!-- tooltip="Hides the annotation query toggle from showing at the top of the dashboard" -->
<!-- checked="ctrl.currentAnnotation.hide" -->
<!-- on&#45;change="ctrl.annotationHiddenChanged()" -->
<!-- label&#45;class="width&#45;7"> -->
<!-- </gf&#45;form&#45;switch> -->
<!-- <div class="gf&#45;form"> -->
<!-- <label class="gf&#45;form&#45;label width&#45;9">Color</label> -->
<!-- <span class="gf&#45;form&#45;label"> -->
<!-- <color&#45;picker color="ctrl.currentAnnotation.iconColor" onChange="ctrl.onColorChange"></color&#45;picker> -->
<!-- </span> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- -->
<!-- <h5 class="section&#45;heading">Query</h5> -->
<!-- <rebuild&#45;on&#45;change property="ctrl.currentDatasource"> -->
<!-- <plugin&#45;component type="annotations&#45;query&#45;ctrl"> -->
<!-- </plugin&#45;component> -->
<!-- </rebuild&#45;on&#45;change> -->
<!-- -->
<!-- <div class="gf&#45;form"> -->
<!-- <div class="gf&#45;form&#45;button&#45;row p&#45;y&#45;0"> -->
<!-- <button ng&#45;show="ctrl.mode === 'new'" type="button" class="btn gf&#45;form&#45;button btn&#45;success" ng&#45;click="ctrl.add()">Add</button> -->
<!-- <button ng&#45;show="ctrl.mode === 'edit'" type="button" class="btn btn&#45;success pull&#45;left" ng&#45;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>

View File

@ -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() {

View File

@ -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);

View File

@ -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'">&gt; New</span>
<span ng-show="mode === 'edit'">&gt; 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">

View File

@ -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
//

View File

@ -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;
}

View File

@ -147,7 +147,8 @@
.sidemenu-open {
.navbar {
margin-left: 15px;
padding-left: 15px;
margin-left: 0;
}
}