2021-02-15 15:18:40 +01:00
|
|
|
<template>
|
2024-03-11 14:40:44 +01:00
|
|
|
<div v-bind="$attrs" class="query-header w-100">
|
2021-02-15 15:18:40 +01:00
|
|
|
<!-- STATUS -->
|
2024-02-24 18:25:12 +01:00
|
|
|
<span
|
|
|
|
class="status"
|
|
|
|
:class="['bg-' + color, statusSize]"
|
|
|
|
:aria-label="$t('api.query_status.' + request.status)"
|
|
|
|
/>
|
2021-02-15 15:18:40 +01:00
|
|
|
|
2021-02-19 18:36:22 +01:00
|
|
|
<!-- REQUEST DESCRIPTION -->
|
|
|
|
<strong class="request-desc">
|
2021-04-09 21:43:56 +02:00
|
|
|
{{ request.humanRoute }}
|
2021-02-15 15:18:40 +01:00
|
|
|
</strong>
|
|
|
|
|
2021-02-19 18:36:22 +01:00
|
|
|
<div v-if="request.errors || request.warnings">
|
2021-02-15 15:18:40 +01:00
|
|
|
<!-- WEBSOCKET ERRORS COUNT -->
|
2021-02-19 18:36:22 +01:00
|
|
|
<span class="count" v-if="request.errors">
|
2024-02-24 16:05:31 +01:00
|
|
|
{{ request.errors }}<YIcon iname="bug" class="text-danger ml-1" />
|
2021-02-15 15:18:40 +01:00
|
|
|
</span>
|
|
|
|
<!-- WEBSOCKET WARNINGS COUNT -->
|
2021-02-19 18:36:22 +01:00
|
|
|
<span class="count" v-if="request.warnings">
|
2024-02-24 18:25:12 +01:00
|
|
|
{{ request.warnings
|
|
|
|
}}<YIcon iname="warning" class="text-warning ml-1" />
|
2021-02-15 15:18:40 +01:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
2021-02-19 18:36:22 +01:00
|
|
|
<!-- VIEW ERROR BUTTON -->
|
2024-02-24 14:33:11 +01:00
|
|
|
<BButton
|
2021-02-19 18:36:22 +01:00
|
|
|
v-if="showError && request.error"
|
2024-02-24 18:25:12 +01:00
|
|
|
size="sm"
|
|
|
|
pill
|
2021-02-15 15:18:40 +01:00
|
|
|
class="error-btn ml-auto py-0"
|
|
|
|
variant="danger"
|
2021-02-19 18:36:22 +01:00
|
|
|
@click="reviewError"
|
2021-02-15 15:18:40 +01:00
|
|
|
>
|
2021-02-15 15:37:34 +01:00
|
|
|
<small v-t="'api_error.view_error'" />
|
2024-02-24 14:33:11 +01:00
|
|
|
</BButton>
|
2021-02-15 15:18:40 +01:00
|
|
|
|
|
|
|
<!-- TIME DISPLAY -->
|
2024-02-24 18:25:12 +01:00
|
|
|
<time
|
|
|
|
v-if="showTime"
|
|
|
|
:datetime="hour(request.date)"
|
|
|
|
:class="request.error ? 'ml-2' : 'ml-auto'"
|
|
|
|
>
|
2024-02-24 16:42:14 +01:00
|
|
|
{{ hour(request.date) }}
|
2021-02-15 15:18:40 +01:00
|
|
|
</time>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'QueryHeader',
|
|
|
|
|
|
|
|
props: {
|
2021-02-19 18:36:22 +01:00
|
|
|
request: { type: Object, required: true },
|
2021-02-15 15:18:40 +01:00
|
|
|
statusSize: { type: String, default: '' },
|
|
|
|
showTime: { type: Boolean, default: false },
|
2024-02-24 18:25:12 +01:00
|
|
|
showError: { type: Boolean, default: false },
|
2021-02-15 15:18:40 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2024-02-24 18:25:12 +01:00
|
|
|
color() {
|
2021-02-15 15:18:40 +01:00
|
|
|
const statuses = {
|
|
|
|
pending: 'primary',
|
|
|
|
success: 'success',
|
|
|
|
warning: 'warning',
|
2024-02-24 18:25:12 +01:00
|
|
|
error: 'danger',
|
2021-02-15 15:18:40 +01:00
|
|
|
}
|
2021-02-19 18:36:22 +01:00
|
|
|
return statuses[this.request.status]
|
2021-02-15 15:18:40 +01:00
|
|
|
},
|
|
|
|
|
2024-02-24 18:25:12 +01:00
|
|
|
errorsCount() {
|
|
|
|
return this.request.messages.filter(({ type }) => type === 'danger')
|
|
|
|
.length
|
2021-02-15 15:18:40 +01:00
|
|
|
},
|
|
|
|
|
2024-02-24 18:25:12 +01:00
|
|
|
warningsCount() {
|
|
|
|
return this.request.messages.filter(({ type }) => type === 'warning')
|
|
|
|
.length
|
|
|
|
},
|
2021-02-19 18:36:22 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2024-02-24 18:25:12 +01:00
|
|
|
reviewError() {
|
2021-02-19 18:36:22 +01:00
|
|
|
this.$store.dispatch('REVIEW_ERROR', this.request)
|
2021-02-15 15:18:40 +01:00
|
|
|
},
|
|
|
|
|
2024-02-24 18:25:12 +01:00
|
|
|
hour(date) {
|
2021-02-15 15:18:40 +01:00
|
|
|
return new Date(date).toLocaleTimeString()
|
2024-02-24 18:25:12 +01:00
|
|
|
},
|
|
|
|
},
|
2021-02-15 15:18:40 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
div {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: $font-size-sm;
|
|
|
|
}
|
|
|
|
|
|
|
|
.error-btn {
|
|
|
|
height: 1.25rem;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2021-04-08 13:24:12 +02:00
|
|
|
justify-content: center;
|
2021-02-15 15:18:40 +01:00
|
|
|
min-width: 70px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.status {
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 50%;
|
2024-02-24 18:25:12 +01:00
|
|
|
width: 0.75rem;
|
|
|
|
min-width: 0.75rem;
|
|
|
|
height: 0.75rem;
|
|
|
|
margin-right: 0.25rem;
|
2021-02-15 15:18:40 +01:00
|
|
|
|
|
|
|
&.lg {
|
|
|
|
width: 1rem;
|
|
|
|
height: 1rem;
|
2024-02-24 18:25:12 +01:00
|
|
|
margin-right: 0.5rem;
|
2021-02-15 15:18:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 18:36:22 +01:00
|
|
|
time {
|
|
|
|
min-width: 3.5rem;
|
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
|
2021-02-15 15:18:40 +01:00
|
|
|
.count {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2024-02-24 18:25:12 +01:00
|
|
|
margin-left: 0.5rem;
|
2021-02-15 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@include media-breakpoint-down(xs) {
|
2021-02-19 18:36:22 +01:00
|
|
|
.xs-hide .request-desc {
|
2021-02-15 15:18:40 +01:00
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|