2019-12-26 22:10:19 +05:30
|
|
|
<script>
|
2021-04-17 20:07:23 +05:30
|
|
|
import { GlButton, GlFormGroup, GlFormInput, GlFormCheckbox, GlIcon, GlLink } 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,
|
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>
|
|
|
|
<gl-form-checkbox
|
|
|
|
id="grafana-integration-enabled"
|
|
|
|
v-model="integrationEnabled"
|
|
|
|
class="mb-4"
|
|
|
|
>
|
|
|
|
{{ s__('GrafanaIntegration|Active') }}
|
|
|
|
</gl-form-checkbox>
|
|
|
|
<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-04-17 20:07:23 +05:30
|
|
|
{{ s__('GrafanaIntegration|Enter the Grafana API token.') }}
|
2019-12-26 22:10:19 +05:30
|
|
|
<a
|
|
|
|
href="https://grafana.com/docs/http_api/auth/#create-api-token"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
2021-04-17 20:07:23 +05:30
|
|
|
{{ __('More information.') }}
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-icon name="external-link" class="vertical-align-middle" />
|
2019-12-26 22:10:19 +05:30
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</gl-form-group>
|
2021-01-03 14:25:43 +05:30
|
|
|
<gl-button variant="success" category="primary" @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>
|