|
@@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';
|
|
|
import { FormLabel, Select } from '@grafana/ui';
|
|
import { FormLabel, Select } from '@grafana/ui';
|
|
|
import { getBackendSrv, BackendSrv } from 'app/core/services/backend_srv';
|
|
import { getBackendSrv, BackendSrv } from 'app/core/services/backend_srv';
|
|
|
|
|
|
|
|
-import { DashboardSearchHit } from 'app/types';
|
|
|
|
|
|
|
+import { DashboardSearchHit, DashboardSearchHitType } from 'app/types';
|
|
|
|
|
|
|
|
export interface Props {
|
|
export interface Props {
|
|
|
resourceUri: string;
|
|
resourceUri: string;
|
|
@@ -41,6 +41,21 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
|
|
async componentDidMount() {
|
|
async componentDidMount() {
|
|
|
const prefs = await this.backendSrv.get(`/api/${this.props.resourceUri}/preferences`);
|
|
const prefs = await this.backendSrv.get(`/api/${this.props.resourceUri}/preferences`);
|
|
|
const dashboards = await this.backendSrv.search({ starred: true });
|
|
const dashboards = await this.backendSrv.search({ starred: true });
|
|
|
|
|
+ const defaultDashboardHit: DashboardSearchHit = {
|
|
|
|
|
+ id: 0,
|
|
|
|
|
+ title: 'Default',
|
|
|
|
|
+ tags: [],
|
|
|
|
|
+ type: '' as DashboardSearchHitType,
|
|
|
|
|
+ uid: '',
|
|
|
|
|
+ uri: '',
|
|
|
|
|
+ url: '',
|
|
|
|
|
+ folderId: 0,
|
|
|
|
|
+ folderTitle: '',
|
|
|
|
|
+ folderUid: '',
|
|
|
|
|
+ folderUrl: '',
|
|
|
|
|
+ isStarred: false,
|
|
|
|
|
+ slug: '',
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
if (prefs.homeDashboardId > 0 && !dashboards.find(d => d.id === prefs.homeDashboardId)) {
|
|
if (prefs.homeDashboardId > 0 && !dashboards.find(d => d.id === prefs.homeDashboardId)) {
|
|
|
const missing = await this.backendSrv.search({ dashboardIds: [prefs.homeDashboardId] });
|
|
const missing = await this.backendSrv.search({ dashboardIds: [prefs.homeDashboardId] });
|
|
@@ -53,7 +68,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
|
|
|
homeDashboardId: prefs.homeDashboardId,
|
|
homeDashboardId: prefs.homeDashboardId,
|
|
|
theme: prefs.theme,
|
|
theme: prefs.theme,
|
|
|
timezone: prefs.timezone,
|
|
timezone: prefs.timezone,
|
|
|
- dashboards: [{ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' }, ...dashboards],
|
|
|
|
|
|
|
+ dashboards: [defaultDashboardHit, ...dashboards],
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|