debian-mirror-gitlab/app/assets/javascripts/performance_bar/components/performance_bar_app.vue

131 lines
3.1 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2018-12-13 13:39:08 +05:30
import { glEmojiTag } from '~/emoji';
2018-05-09 12:01:36 +05:30
import detailedMetric from './detailed_metric.vue';
import requestSelector from './request_selector.vue';
2019-09-30 21:07:59 +05:30
import { s__ } from '~/locale';
2018-05-09 12:01:36 +05:30
export default {
components: {
detailedMetric,
requestSelector,
},
props: {
store: {
type: Object,
required: true,
},
env: {
type: String,
required: true,
},
requestId: {
type: String,
required: true,
},
peekUrl: {
type: String,
required: true,
},
},
detailedMetrics: [
2019-10-12 21:52:04 +05:30
{
metric: 'active-record',
title: 'pg',
header: s__('PerformanceBar|SQL queries'),
keys: ['sql'],
},
2018-05-09 12:01:36 +05:30
{
metric: 'gitaly',
2019-09-30 21:07:59 +05:30
header: s__('PerformanceBar|Gitaly calls'),
2018-05-09 12:01:36 +05:30
keys: ['feature', 'request'],
},
2019-10-12 21:52:04 +05:30
{
metric: 'rugged',
header: s__('PerformanceBar|Rugged calls'),
keys: ['feature', 'args'],
},
2019-09-30 21:07:59 +05:30
{
metric: 'redis',
2019-10-12 21:52:04 +05:30
header: s__('PerformanceBar|Redis calls'),
2019-09-30 21:07:59 +05:30
keys: ['cmd'],
},
2018-05-09 12:01:36 +05:30
],
data() {
return { currentRequestId: '' };
},
computed: {
requests() {
return this.store.requestsWithDetails();
},
currentRequest: {
get() {
return this.store.findRequest(this.currentRequestId);
},
set(requestId) {
this.currentRequestId = requestId;
},
},
initialRequest() {
return this.currentRequestId === this.requestId;
},
2018-12-13 13:39:08 +05:30
hasHost() {
return this.currentRequest && this.currentRequest.details && this.currentRequest.details.host;
},
birdEmoji() {
if (this.hasHost && this.currentRequest.details.host.canary) {
return glEmojiTag('baby_chick');
}
return '';
},
2018-05-09 12:01:36 +05:30
},
mounted() {
this.currentRequest = this.requestId;
},
methods: {
changeCurrentRequest(newRequestId) {
this.currentRequest = newRequestId;
},
},
};
</script>
<template>
2019-02-15 15:39:39 +05:30
<div id="js-peek" :class="env">
2019-07-31 22:56:46 +05:30
<div v-if="currentRequest" class="d-flex container-fluid container-limited qa-performance-bar">
2019-02-15 15:39:39 +05:30
<div id="peek-view-host" class="view">
2018-05-09 12:01:36 +05:30
<span
2018-12-13 13:39:08 +05:30
v-if="hasHost"
2018-05-09 12:01:36 +05:30
class="current-host"
2019-02-15 15:39:39 +05:30
:class="{ canary: currentRequest.details.host.canary }"
2018-05-09 12:01:36 +05:30
>
2019-09-30 21:07:59 +05:30
<span v-html="birdEmoji"></span>
{{ currentRequest.details.host.hostname }}
2018-05-09 12:01:36 +05:30
</span>
</div>
<detailed-metric
v-for="metric in $options.detailedMetrics"
:key="metric.metric"
:current-request="currentRequest"
:metric="metric.metric"
2019-10-12 21:52:04 +05:30
:title="metric.title"
2018-05-09 12:01:36 +05:30
:header="metric.header"
:keys="metric.keys"
/>
2019-07-07 11:18:12 +05:30
<div
v-if="currentRequest.details && currentRequest.details.tracing"
id="peek-view-trace"
class="view"
>
2019-09-30 21:07:59 +05:30
<a :href="currentRequest.details.tracing.tracing_url">{{ s__('PerformanceBar|trace') }}</a>
2019-07-07 11:18:12 +05:30
</div>
2018-05-09 12:01:36 +05:30
<request-selector
v-if="currentRequest"
:current-request="currentRequest"
:requests="requests"
2018-11-08 19:23:39 +05:30
class="ml-auto"
2018-05-09 12:01:36 +05:30
@change-current-request="changeCurrentRequest"
/>
</div>
</div>
</template>