debian-mirror-gitlab/app/assets/javascripts/grafana_integration/components/grafana_integration.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

132 lines
3.7 KiB
Vue
Raw Normal View History

2019-12-26 22:10:19 +05:30
<script>
2021-09-04 01:27:46 +05:30
import {
GlButton,
GlFormGroup,
GlFormInput,
GlFormCheckbox,
GlIcon,
GlLink,
GlSprintf,
} from '@gitlab/ui';
2019-12-26 22:10:19 +05:30
import { mapState, mapActions } from 'vuex';
2021-04-17 20:07:23 +05:30
import { helpPagePath } from '~/helpers/help_page_helper';
2019-12-26 22:10:19 +05:30
export default {
components: {
2020-10-24 23:57:45 +05:30
GlButton,
2019-12-26 22:10:19 +05:30
GlFormCheckbox,
GlFormGroup,
GlFormInput,
2020-11-24 15:15:51 +05:30
GlIcon,
2021-04-17 20:07:23 +05:30
GlLink,
2021-09-04 01:27:46 +05:30
GlSprintf,
2019-12-26 22:10:19 +05:30
},
data() {
2021-04-17 20:07:23 +05:30
return {
helpUrl: helpPagePath('operations/metrics/embed_grafana', {
anchor: 'use-integration-with-grafana-api',
}),
placeholderUrl: 'https://my-grafana.example.com/',
};
2019-12-26 22:10:19 +05:30
},
computed: {
...mapState(['operationsSettingsEndpoint', 'grafanaToken', 'grafanaUrl', 'grafanaEnabled']),
integrationEnabled: {
get() {
return this.grafanaEnabled;
},
set(grafanaEnabled) {
this.setGrafanaEnabled(grafanaEnabled);
},
},
localGrafanaToken: {
get() {
return this.grafanaToken;
},
set(token) {
this.setGrafanaToken(token);
},
},
localGrafanaUrl: {
get() {
return this.grafanaUrl;
},
set(url) {
this.setGrafanaUrl(url);
},
},
},
methods: {
...mapActions([
'setGrafanaUrl',
'setGrafanaToken',
'setGrafanaEnabled',
'updateGrafanaIntegration',
]),
},
};
</script>
<template>
<section id="grafana" class="settings no-animate js-grafana-integration">
<div class="settings-header">
2021-04-29 21:17:54 +05:30
<h4
class="js-section-header settings-title js-settings-toggle js-settings-toggle-trigger-only"
>
2020-10-24 23:57:45 +05:30
{{ s__('GrafanaIntegration|Grafana authentication') }}
2021-03-11 19:13:27 +05:30
</h4>
2020-10-24 23:57:45 +05:30
<gl-button class="js-settings-toggle">{{ __('Expand') }}</gl-button>
2019-12-26 22:10:19 +05:30
<p class="js-section-sub-header">
2021-04-17 20:07:23 +05:30
{{
s__(
'GrafanaIntegration|Set up Grafana authentication to embed Grafana panels in GitLab Flavored Markdown.',
)
}}
<gl-link :href="helpUrl">{{ __('Learn more.') }}</gl-link>
2019-12-26 22:10:19 +05:30
</p>
</div>
<div class="settings-content">
<form>
2021-09-04 01:27:46 +05:30
<gl-form-group :label="__('Enable authentication')" label-for="grafana-integration-enabled">
<gl-form-checkbox id="grafana-integration-enabled" v-model="integrationEnabled">
{{ s__('GrafanaIntegration|Active') }}
</gl-form-checkbox>
</gl-form-group>
2019-12-26 22:10:19 +05:30
<gl-form-group
:label="s__('GrafanaIntegration|Grafana URL')"
label-for="grafana-url"
:description="s__('GrafanaIntegration|Enter the base URL of the Grafana instance.')"
>
<gl-form-input id="grafana-url" v-model="localGrafanaUrl" :placeholder="placeholderUrl" />
</gl-form-group>
2021-04-17 20:07:23 +05:30
<gl-form-group :label="s__('GrafanaIntegration|API token')" label-for="grafana-token">
2019-12-26 22:10:19 +05:30
<gl-form-input id="grafana-token" v-model="localGrafanaToken" />
<p class="form-text text-muted">
2021-09-04 01:27:46 +05:30
<gl-sprintf
:message="
s__('GrafanaIntegration|Enter the %{docLinkStart}Grafana API token%{docLinkEnd}.')
"
2019-12-26 22:10:19 +05:30
>
2021-09-04 01:27:46 +05:30
<template #docLink="{ content }">
<gl-link
href="https://grafana.com/docs/http_api/auth/#create-api-token"
target="_blank"
>{{ content }} <gl-icon name="external-link" class="gl-vertical-align-middle"
/></gl-link>
</template>
</gl-sprintf>
2019-12-26 22:10:19 +05:30
</p>
</gl-form-group>
2021-09-04 01:27:46 +05:30
<gl-button
variant="confirm"
category="primary"
data-testid="save-grafana-settings-button"
@click="updateGrafanaIntegration"
>
2021-04-17 20:07:23 +05:30
{{ __('Save changes') }}
2021-01-03 14:25:43 +05:30
</gl-button>
2019-12-26 22:10:19 +05:30
</form>
</div>
</section>
</template>