102 lines
2.7 KiB
Vue
102 lines
2.7 KiB
Vue
<template>
|
|
<div class="bg-primary flex p-4 top-0 z-10 sticky items-center">
|
|
<div
|
|
v-if="response == null"
|
|
class="
|
|
flex flex-col flex-1
|
|
text-secondaryLight
|
|
items-center
|
|
justify-center
|
|
"
|
|
>
|
|
<ButtonSecondary
|
|
:label="$t('app.documentation')"
|
|
to="https://docs.hoppscotch.io"
|
|
svg="external-link"
|
|
blank
|
|
outline
|
|
reverse
|
|
/>
|
|
</div>
|
|
<div v-else class="flex flex-col flex-1">
|
|
<div v-if="response.type === 'loading'">
|
|
<i class="animate-spin material-icons"> refresh </i>
|
|
</div>
|
|
<div
|
|
v-if="response.type === 'network_fail'"
|
|
class="
|
|
flex flex-col flex-1
|
|
text-secondaryLight
|
|
p-4
|
|
items-center
|
|
justify-center
|
|
"
|
|
>
|
|
<i class="opacity-75 pb-2 material-icons">cloud_off</i>
|
|
<span class="text-center pb-2">
|
|
{{ $t("error.network_fail") }}
|
|
</span>
|
|
<span class="text-center pb-4">
|
|
{{ $t("helpers.network_fail") }}
|
|
</span>
|
|
<ButtonSecondary
|
|
outline
|
|
:label="$t('action.learn_more')"
|
|
to="https://docs.hoppscotch.io"
|
|
blank
|
|
svg="external-link"
|
|
reverse
|
|
/>
|
|
</div>
|
|
<div
|
|
v-if="response.type === 'success' || 'fail'"
|
|
:class="statusCategory.className"
|
|
class="font-semibold space-x-4"
|
|
>
|
|
<span v-if="response.statusCode">
|
|
<span class="text-secondary"> {{ $t("response.status") }}: </span>
|
|
{{ response.statusCode || $t("state.waiting_send_request") }}
|
|
</span>
|
|
<span v-if="response.meta && response.meta.responseDuration">
|
|
<span class="text-secondary"> {{ $t("response.time") }}: </span>
|
|
{{ `${response.meta.responseDuration} ms` }}
|
|
</span>
|
|
<span v-if="response.meta && response.meta.responseSize">
|
|
<span class="text-secondary"> {{ $t("response.size") }}: </span>
|
|
{{ `${response.meta.responseSize} B` }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from "@nuxtjs/composition-api"
|
|
import findStatusGroup from "~/helpers/findStatusGroup"
|
|
import { HoppRESTResponse } from "~/helpers/types/HoppRESTResponse"
|
|
|
|
const props = defineProps<{
|
|
response: HoppRESTResponse
|
|
}>()
|
|
|
|
const statusCategory = computed(() => {
|
|
if (
|
|
props.response.type === "loading" ||
|
|
props.response.type === "network_fail"
|
|
)
|
|
return ""
|
|
return findStatusGroup(props.response.statusCode)
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.shortcut-key {
|
|
@apply bg-dividerLight;
|
|
@apply rounded;
|
|
@apply ml-2;
|
|
@apply py-1;
|
|
@apply px-2;
|
|
@apply inline-flex;
|
|
}
|
|
</style>
|