api-client/components/http/ResponseMeta.vue

61 lines
1.5 KiB
Vue
Raw Normal View History

<template>
2021-07-17 17:40:28 +00:00
<div class="bg-primary flex p-4 top-0 z-10 sticky items-center">
<div
2021-07-16 15:04:35 +00:00
v-if="response == null"
class="
2021-07-17 17:40:28 +00:00
flex flex-col flex-1
2021-07-16 15:04:35 +00:00
text-secondaryLight
p-4
2021-07-17 17:40:28 +00:00
items-center
2021-07-16 15:04:35 +00:00
justify-center
"
>
2021-07-17 17:40:28 +00:00
<i class="opacity-50 pb-2 material-icons">send</i>
2021-07-16 15:04:35 +00:00
<span class="text-xs text-center">
{{ $t("waiting_send_req") }}
</span>
</div>
<div v-else>
<i v-if="response.type === 'loading'" class="animate-spin material-icons">
refresh
</i>
2021-07-16 15:04:35 +00:00
<div
v-else
:class="statusCategory.className"
class="font-mono font-semibold space-x-4"
>
<span v-if="response.statusCode">
<span class="text-secondaryDark"> Status: </span>
{{ response.statusCode || $t("waiting_send_req") }}
</span>
<span v-if="response.meta.responseDuration" class="text-xs">
<span class="text-secondaryDark"> Time: </span>
{{ `${response.meta.responseDuration} ms` }}
</span>
<span v-if="response.meta.responseSize" class="text-xs">
<span class="text-secondaryDark"> Size: </span>
{{ `${response.meta.responseSize} B` }}
</span>
</div>
2021-07-13 07:18:57 +00:00
</div>
</div>
</template>
<script>
import findStatusGroup from "~/helpers/findStatusGroup"
export default {
props: {
response: {
type: Object,
2021-05-18 09:27:29 +00:00
default: () => {},
},
},
computed: {
statusCategory() {
2021-07-13 05:37:29 +00:00
return findStatusGroup(this.response.statusCode)
},
},
}
</script>