mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
add initial panel on did mount
Signed-off-by: blalov <boyko.lalov@tick42.com>
This commit is contained in:
parent
ebe5380433
commit
77da5e7ab4
|
@ -20,29 +20,21 @@ interface PanelListState {
|
||||||
timeDriftError: string | null;
|
timeDriftError: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialPanel = {
|
|
||||||
id: generateID(),
|
|
||||||
key: '0',
|
|
||||||
options: PanelDefaultOptions,
|
|
||||||
};
|
|
||||||
|
|
||||||
class PanelList extends Component<RouteComponentProps & PathPrefixProps, PanelListState> {
|
class PanelList extends Component<RouteComponentProps & PathPrefixProps, PanelListState> {
|
||||||
constructor(props: PathPrefixProps) {
|
constructor(props: PathPrefixProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
const urlPanels = decodePanelOptionsFromQueryString(window.location.search);
|
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
panels: urlPanels.length ? urlPanels : [initialPanel],
|
panels: decodePanelOptionsFromQueryString(window.location.search),
|
||||||
pastQueries: [],
|
pastQueries: [],
|
||||||
metricNames: [],
|
metricNames: [],
|
||||||
fetchMetricsError: null,
|
fetchMetricsError: null,
|
||||||
timeDriftError: null,
|
timeDriftError: null,
|
||||||
};
|
};
|
||||||
!urlPanels.length && this.updateURL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
!this.state.panels.length && this.addPanel()
|
||||||
fetch(`${this.props.pathPrefix}/api/v1/label/__name__/values`, { cache: 'no-store' })
|
fetch(`${this.props.pathPrefix}/api/v1/label/__name__/values`, { cache: 'no-store' })
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
|
|
Loading…
Reference in a new issue