grafana/public/sass/components/_gf-form.scss

478 lines
7.9 KiB
SCSS
Raw Normal View History

@use 'sass:list';
$input-border: 1px solid $input-border-color;
2016-02-15 08:27:41 -06:00
.gf-form {
display: flex;
flex-direction: row;
align-items: flex-start;
text-align: left;
2016-04-15 18:56:39 -05:00
position: relative;
margin-bottom: $space-xs;
2016-02-15 08:27:41 -06:00
&--offset-1 {
margin-left: $spacer;
2016-02-15 08:27:41 -06:00
}
&--grow {
flex-grow: 1;
}
2017-08-31 09:38:49 -05:00
&--flex-end {
justify-content: flex-end;
}
2017-11-29 10:13:50 -06:00
&--align-center {
align-content: center;
}
2017-11-29 10:13:50 -06:00
&--alt {
flex-direction: column;
align-items: flex-start;
.gf-form-label {
padding: 4px 0;
}
}
2016-02-15 08:27:41 -06:00
}
.gf-form--has-input-icon {
position: relative;
margin-right: $space-xs;
.gf-form-input-icon {
position: absolute;
top: 8px;
font-size: $font-size-lg;
left: 10px;
color: $input-color-placeholder;
}
> input {
2017-12-14 06:08:32 -06:00
padding-left: 35px;
&:focus + .gf-form-input-icon {
2017-12-19 09:22:41 -06:00
color: $text-muted;
}
}
.Select--multi .Select-multi-value-wrapper,
.Select-placeholder {
padding-left: 30px;
}
}
.gf-form-disabled {
color: $text-color-weak;
2017-06-22 16:10:43 -05:00
.gf-form-select-wrapper::after {
color: $text-color-weak;
}
a,
.gf-form-input {
color: $text-color-weak;
}
}
2016-02-15 08:27:41 -06:00
.gf-form-group {
margin-bottom: $spacer * 2.5;
2016-02-15 08:27:41 -06:00
}
.gf-form-inline {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
&--nowrap {
flex-wrap: nowrap;
}
&--xs-view-flex-column {
flex-direction: row;
flex-wrap: nowrap;
@include media-breakpoint-down(xs) {
flex-direction: column;
}
}
.select-container {
margin-right: $space-xs;
}
.gf-form-spacing {
margin-right: $space-xs;
}
2016-02-15 08:27:41 -06:00
}
.gf-form-button-row {
2016-02-24 10:49:08 -06:00
padding-top: $spacer * 1.5;
2017-12-19 09:22:41 -06:00
a,
button {
margin-right: $spacer;
}
2016-02-15 08:27:41 -06:00
}
.gf-form-label {
display: flex;
align-items: center;
padding: $input-padding;
flex-shrink: 0;
font-weight: $font-weight-semi-bold;
2017-12-10 05:21:04 -06:00
font-size: $font-size-sm;
background-color: $input-label-bg;
height: $input-height;
line-height: $input-height;
margin-right: $space-xs;
border-radius: $input-border-radius;
justify-content: space-between;
border: none;
&--grow {
flex-grow: 1;
}
&--error {
color: $critical;
}
&--transparent {
background-color: transparent;
border: 0;
text-align: right;
padding-left: 0px;
}
&--variable {
color: $variable;
background: $panel-bg;
border: $panel-border;
}
&--dashlink {
background: $panel-bg;
border: $panel-border;
}
2020-04-14 14:17:44 -05:00
&--justify-left {
justify-content: left;
}
2018-12-17 10:54:40 -06:00
&--btn {
border: none;
2018-12-17 10:54:40 -06:00
border-radius: $border-radius;
&:hover {
background: $list-item-hover-bg;
color: $link-color;
}
2018-12-17 10:54:40 -06:00
}
&:disabled {
color: $text-color-weak;
}
}
.gf-form-label + .gf-form-label {
margin-right: $space-xs;
}
2017-04-21 08:52:42 -05:00
.gf-form-pre {
2020-05-14 09:04:53 -05:00
display: block !important;
2017-04-21 08:52:42 -05:00
flex-grow: 1;
margin: 0;
margin-right: $space-xs;
border: $border-width solid transparent;
border-left: none;
@include border-radius($input-border-radius);
2017-04-21 08:52:42 -05:00
}
.gf-form-textarea {
max-width: 650px;
}
2016-02-16 07:07:41 -06:00
.gf-form-input {
display: block;
width: 100%;
height: $input-height;
padding: $input-padding;
font-size: $font-size-md;
2016-02-16 07:07:41 -06:00
line-height: $input-line-height;
color: $input-color;
background-color: $input-bg;
background-image: none;
background-clip: padding-box;
border: $input-border;
border-radius: $input-border-radius;
margin-right: $space-xs;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
2016-02-16 07:07:41 -06:00
// text areas should be scrollable
@at-root textarea#{&} {
overflow: auto;
2017-10-16 06:39:16 -05:00
white-space: pre-wrap;
padding: 6px $space-sm;
min-height: $input-height;
height: auto;
}
2016-02-16 07:07:41 -06:00
// Unstyle the caret on `<select>`s in IE10+.
&::-ms-expand {
background-color: transparent;
border: 0;
display: none;
2016-02-16 07:07:41 -06:00
}
// Customize the `:focus` state to imitate native WebKit styles.
@include form-control-focus();
// Placeholder
&::placeholder {
color: $input-color-placeholder;
opacity: 1;
}
&:disabled,
&[readonly] {
background-color: $input-bg-disabled;
// iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
opacity: 1;
}
2016-02-16 07:07:41 -06:00
&:disabled {
cursor: $cursor-disabled;
}
2017-12-19 09:22:41 -06:00
&.gf-size-auto {
width: auto;
}
&--dropdown {
padding-right: $space-lg;
position: relative;
display: flex;
align-items: center;
&::after {
position: absolute;
2017-06-22 14:16:41 -05:00
top: 36%;
right: 11px;
font-size: 11px;
background-color: transparent;
2017-06-22 14:16:41 -05:00
color: $text-color;
2022-01-06 07:09:52 -06:00
font: normal normal normal list.slash($font-size-sm, 1) FontAwesome;
content: '\f0d7';
pointer-events: none;
}
}
&--small {
padding-top: 4px;
padding-bottom: 4px;
font-size: $font-size-sm;
}
&--plaintext {
white-space: unset;
}
&--has-help-icon {
padding-right: $space-xl;
}
}
History and Version Control for Dashboard Updates A simple version control system for dashboards. Closes #1504. Goals 1. To create a new dashboard version every time a dashboard is saved. 2. To allow users to view all versions of a given dashboard. 3. To allow users to rollback to a previous version of a dashboard. 4. To allow users to compare two versions of a dashboard. Usage Navigate to a dashboard, and click the settings cog. From there, click the "Changelog" button to be brought to the Changelog view. In this view, a table containing each version of a dashboard can be seen. Each entry in the table represents a dashboard version. A selectable checkbox, the version number, date created, name of the user who created that version, and commit message is shown in the table, along with a button that allows a user to restore to a previous version of that dashboard. If a user wants to restore to a previous version of their dashboard, they can do so by clicking the previously mentioned button. If a user wants to compare two different versions of a dashboard, they can do so by clicking the checkbox of two different dashboard versions, then clicking the "Compare versions" button located below the dashboard. From there, the user is brought to a view showing a summary of the dashboard differences. Each summarized change contains a link that can be clicked to take the user a JSON diff highlighting the changes line by line. Overview of Changes Backend Changes - A `dashboard_version` table was created to store each dashboard version, along with a dashboard version model and structs to represent the queries and commands necessary for the dashboard version API methods. - API endpoints were created to support working with dashboard versions. - Methods were added to create, update, read, and destroy dashboard versions in the database. - Logic was added to compute the diff between two versions, and display it to the user. - The dashboard migration logic was updated to save a "Version 1" of each existing dashboard in the database. Frontend Changes - New views - Methods to pull JSON and HTML from endpoints New API Endpoints Each endpoint requires the authorization header to be sent in the format, ``` Authorization: Bearer <jwt> ``` where `<jwt>` is a JSON web token obtained from the Grafana admin panel. `GET "/api/dashboards/db/:dashboardId/versions?orderBy=<string>&limit=<int>&start=<int>"` Get all dashboard versions for the given dashboard ID. Accepts three URL parameters: - `orderBy` String to order the results by. Possible values are `version`, `created`, `created_by`, `message`. Default is `versions`. Ordering is always in descending order. - `limit` Maximum number of results to return - `start` Position in results to start from `GET "/api/dashboards/db/:dashboardId/versions/:id"` Get an individual dashboard version by ID, for the given dashboard ID. `POST "/api/dashboards/db/:dashboardId/restore"` Restore to the given dashboard version. Post body is of content-type `application/json`, and must contain. ```json { "dashboardId": <int>, "version": <int> } ``` `GET "/api/dashboards/db/:dashboardId/compare/:versionA...:versionB"` Compare two dashboard versions by ID for the given dashboard ID, returning a JSON delta formatted representation of the diff. The URL format follows what GitHub does. For example, visiting [/api/dashboards/db/18/compare/22...33](http://ec2-54-80-139-44.compute-1.amazonaws.com:3000/api/dashboards/db/18/compare/22...33) will return the diff between versions 22 and 33 for the dashboard ID 18. Dependencies Added - The Go package [gojsondiff](https://github.com/yudai/gojsondiff) was added and vendored.
2017-05-24 18:14:39 -05:00
.gf-form-hint {
width: 100%;
}
.gf-form-hint-text {
display: block;
text-align: right;
padding-top: 0.5em;
}
2016-02-20 10:21:35 -06:00
.gf-form-select-wrapper {
position: relative;
background-color: $input-bg;
margin-right: $space-xs;
2016-02-20 10:21:35 -06:00
.gf-form-select-icon {
position: absolute;
z-index: 1;
left: $input-padding;
top: 50%;
margin-top: -7px;
+ .gf-form-input {
position: relative;
z-index: 2;
padding-left: $space-xl;
background-color: transparent;
option {
// Firefox
color: $black;
}
}
}
.gf-form-input {
margin-right: 0;
line-height: $input-height;
}
2016-02-20 10:21:35 -06:00
select.gf-form-input {
2017-12-19 09:22:41 -06:00
text-indent: 0.01px;
text-overflow: '';
padding-right: $space-xl;
2016-02-20 10:21:35 -06:00
appearance: none;
&:-moz-focusring {
outline: none;
2016-02-20 10:21:35 -06:00
color: transparent;
text-shadow: 0 0 0 $text-color;
2016-02-20 10:21:35 -06:00
}
&.ng-empty {
color: $text-color-weak;
}
2016-02-20 10:21:35 -06:00
}
&::after {
2016-02-20 10:21:35 -06:00
position: absolute;
2017-06-22 14:16:41 -05:00
top: 36%;
right: 11px;
2016-02-20 10:21:35 -06:00
background-color: transparent;
2017-06-22 14:16:41 -05:00
color: $text-color;
2022-01-06 07:09:52 -06:00
font: normal normal normal list.slash($font-size-sm, 1) FontAwesome;
content: '\f0d7';
2016-02-20 10:21:35 -06:00
pointer-events: none;
2017-06-22 14:16:41 -05:00
font-size: 11px;
2016-02-20 10:21:35 -06:00
}
2016-04-15 18:56:39 -05:00
&--has-help-icon {
&::after {
right: $space-xl;
2016-04-15 18:56:39 -05:00
}
}
2016-02-20 10:21:35 -06:00
}
2016-03-23 09:09:48 -05:00
.gf-form--v-stretch {
align-items: stretch;
}
.gf-form-btn {
padding: $input-padding;
margin-right: $space-xs;
line-height: $input-line-height;
font-size: $font-size-sm;
flex-shrink: 0;
flex-grow: 0;
}
2016-03-20 10:18:31 -05:00
2016-03-23 09:42:46 -05:00
.natural-language-input {
&input[type='number'] {
font-size: $font-size-base;
line-height: $input-line-height;
margin: -6px -5px 0 5px;
padding: $space-xs;
}
}
2016-03-29 05:32:40 -05:00
.gf-form-dropdown-typeahead {
//margin-right: $space-xs; ?
2016-03-29 05:32:40 -05:00
position: relative;
2016-03-20 10:18:31 -05:00
&::after {
2016-03-29 05:32:40 -05:00
position: absolute;
top: 35%;
right: $space-sm;
2016-03-29 05:32:40 -05:00
background-color: transparent;
color: $input-color;
2022-01-06 07:09:52 -06:00
font: normal normal normal list.slash($font-size-sm, 1) FontAwesome;
content: '\f0d7';
2016-03-29 05:32:40 -05:00
pointer-events: none;
2018-04-18 03:21:48 -05:00
font-size: 11px;
2016-03-29 05:32:40 -05:00
}
2016-03-20 10:18:31 -05:00
}
2016-04-15 18:56:39 -05:00
.gf-form-help-icon {
flex-grow: 0;
color: $text-color-weak;
2016-12-06 05:54:44 -06:00
&--bold {
color: $text-color-emphasis;
2016-12-06 07:53:33 -06:00
padding-left: 0;
2016-12-06 05:54:44 -06:00
}
2016-04-15 18:56:39 -05:00
&--right-absolute {
position: absolute;
right: $spacer;
top: 6px;
2016-04-15 18:56:39 -05:00
}
&--right-normal {
float: right;
}
&--header {
margin-bottom: $space-xxs;
}
&--small-padding {
padding-left: 4px;
}
2019-01-29 06:42:29 -06:00
&:hover {
color: $text-color;
}
2016-04-15 18:56:39 -05:00
}
select.gf-form-input ~ .gf-form-help-icon {
right: 10px;
}
.gf-form-icon--right-absolute {
position: absolute;
right: $spacer;
top: 10px;
color: $text-muted;
}
.cta-form {
position: relative;
padding: $space-lg;
background-color: $empty-list-cta-bg;
margin-bottom: $space-lg;
border-top: 3px solid $green-base;
}
.cta-form__close {
2018-11-06 11:14:29 -06:00
background: transparent;
padding: 4px 8px 4px 9px;
border: none;
position: absolute;
right: 0;
2018-11-06 11:14:29 -06:00
top: -2px;
font-size: $font-size-md;
2018-11-06 11:14:29 -06:00
&:hover {
color: $text-color-strong;
}
}
.cta-form__bar {
display: flex;
align-items: center;
align-content: center;
margin-bottom: 20px;
}
.cta-form__bar-header {
font-size: $font-size-h4;
padding-right: 20px;
}