Skip to content

Commit

Permalink
fix the default link to vmui (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loori-R authored Jan 25, 2024
1 parent c644bec commit 55d34fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## tip

* BUGFIX: fix the default link to vmui. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/132)

## [v0.5.1](https://github.com/VictoriaMetrics/grafana-datasource/releases/tag/v0.5.1)

* BUGFIX: fix query builder logic to correctly parse metric names with dots. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/128)
Expand Down
4 changes: 3 additions & 1 deletion src/components/VmuiLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface Props {
dashboardUID: string;
}

export const getDefaultVmuiUrl = (serverUrl = "#") => `${serverUrl.replace(/\/$/, "")}/vmui/`

export const relativeTimeOptionsVMUI = [
{ title: "Last 5 minutes", duration: "5m" },
{ title: "Last 15 minutes", duration: "15m" },
Expand Down Expand Up @@ -124,7 +126,7 @@ const VmuiLink: FC<Props> = ({
return k + '=' + encodeURIComponent(v);
}).join('&');

const vmuiUrl = dsSettings.jsonData.vmuiUrl || `${dsSettings.url}/graph`
const vmuiUrl = dsSettings.jsonData.vmuiUrl || getDefaultVmuiUrl(dsSettings.url)
setHref(`${vmuiUrl}?${args}`);
};

Expand Down
3 changes: 2 additions & 1 deletion src/configuration/PromSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
regexValidation,
} from '@grafana/ui';

import { getDefaultVmuiUrl } from "../components/VmuiLink";
import { PromOptions } from '../types';

const { Input, FormField } = LegacyForms;
Expand Down Expand Up @@ -154,7 +155,7 @@ export const PromSettings = (props: Props) => {
value={options.jsonData.vmuiUrl}
onChange={onChangeHandler('vmuiUrl', options, onOptionsChange)}
spellCheck={false}
placeholder={`${options.url}/graph?`}
placeholder={getDefaultVmuiUrl(options.url)}
/>
}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/datasource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {

import { addLabelToQuery } from './add_label_to_query';
import { AnnotationQueryEditor } from "./components/Annotations/AnnotationQueryEditor";
import { getDefaultVmuiUrl } from "./components/VmuiLink";
import { WithTemplate } from "./components/WithTemplateConfig/types";
import { mergeTemplateWithQuery } from "./components/WithTemplateConfig/utils/getArrayFromTemplate";
import { ANNOTATION_QUERY_STEP_DEFAULT, DATASOURCE_TYPE } from "./consts";
Expand Down Expand Up @@ -134,7 +135,7 @@ export class PrometheusDatasource
this.queryTimeout = instanceSettings.jsonData.queryTimeout;
this.httpMethod = instanceSettings.jsonData.httpMethod || 'GET';
this.directUrl = instanceSettings.jsonData.directUrl ?? this.url;
this.vmuiUrl = instanceSettings.jsonData.vmuiUrl || `${this.url}/graph`;
this.vmuiUrl = instanceSettings.jsonData.vmuiUrl || getDefaultVmuiUrl(this.url);
this.exemplarTraceIdDestinations = instanceSettings.jsonData.exemplarTraceIdDestinations;
this.ruleMappings = {};
this.languageProvider = languageProvider ?? new PrometheusLanguageProvider(this);
Expand Down

0 comments on commit 55d34fa

Please sign in to comment.