fix: wire response + init error handling
This commit is contained in:
@@ -1,44 +1,59 @@
|
||||
<template>
|
||||
<div class="flex bg-primary border-b border-dividerLight">
|
||||
<SmartLink
|
||||
to="https://forms.gle/8yFiEynXB7h477Ns6"
|
||||
blank
|
||||
class="
|
||||
relative
|
||||
flex
|
||||
items-center
|
||||
justify-center
|
||||
px-4
|
||||
py-3
|
||||
transition
|
||||
group
|
||||
"
|
||||
>
|
||||
<i class="material-icons mr-4">science</i>
|
||||
<span class="text-secondaryDark text-xs">
|
||||
<span class="md:hidden"> Beta Layout </span>
|
||||
<span class="hidden md:inline">
|
||||
You're currently viewing experimental beta layout
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
<div class="flex bg-primary border-b justify-between border-dividerLight">
|
||||
<span class="flex">
|
||||
<SmartLink
|
||||
to="https://forms.gle/8yFiEynXB7h477Ns6"
|
||||
blank
|
||||
class="
|
||||
relative
|
||||
flex
|
||||
items-center
|
||||
justify-center
|
||||
pl-4
|
||||
ml-4
|
||||
font-semibold
|
||||
px-4
|
||||
py-3
|
||||
transition
|
||||
border-l
|
||||
group-hover:text-accentDark
|
||||
border-divider
|
||||
text-accent text-xs
|
||||
group
|
||||
"
|
||||
>
|
||||
<span class="md:hidden"> Give Feedback </span>
|
||||
<span class="hidden md:inline"> Report a problem </span>
|
||||
</span>
|
||||
</SmartLink>
|
||||
<i class="material-icons mr-4">science</i>
|
||||
<span class="text-secondaryDark text-xs">
|
||||
<span class="md:hidden"> Beta Layout </span>
|
||||
<span class="hidden md:inline">
|
||||
You're currently viewing an experimental beta layout
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="
|
||||
flex
|
||||
items-center
|
||||
justify-center
|
||||
pl-4
|
||||
ml-4
|
||||
font-semibold
|
||||
transition
|
||||
border-l
|
||||
group-hover:text-accentDark
|
||||
border-divider
|
||||
text-accent text-xs
|
||||
"
|
||||
>
|
||||
<span class="md:hidden"> Give Feedback </span>
|
||||
<span class="hidden md:inline"> Report a problem </span>
|
||||
</span>
|
||||
</SmartLink>
|
||||
<SmartLink
|
||||
to="https://hoppscotch.io"
|
||||
class="flex items-center justify-center transition group"
|
||||
>
|
||||
<span class="text-secondaryDark text-xs">
|
||||
Switch back to the Hoppscotch website
|
||||
</span>
|
||||
</SmartLink>
|
||||
</span>
|
||||
<ButtonSecondary
|
||||
v-tippy="{ theme: 'tooltip' }"
|
||||
icon="close"
|
||||
:title="$t('close')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -418,45 +418,45 @@ export default {
|
||||
})
|
||||
},
|
||||
parsePostmanCollection({ info, name, item }) {
|
||||
const postwomanCollection = {
|
||||
const hoppscotchCollection = {
|
||||
name: "",
|
||||
folders: [],
|
||||
requests: [],
|
||||
}
|
||||
|
||||
postwomanCollection.name = info ? info.name : name
|
||||
hoppscotchCollection.name = info ? info.name : name
|
||||
|
||||
if (item && item.length > 0) {
|
||||
for (const collectionItem of item) {
|
||||
if (collectionItem.request) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
postwomanCollection,
|
||||
hoppscotchCollection,
|
||||
"folders"
|
||||
)
|
||||
) {
|
||||
postwomanCollection.name = info ? info.name : name
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.name = info ? info.name : name
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
} else {
|
||||
postwomanCollection.name = name || ""
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.name = name || ""
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
}
|
||||
} else if (this.hasFolder(collectionItem)) {
|
||||
postwomanCollection.folders.push(
|
||||
hoppscotchCollection.folders.push(
|
||||
this.parsePostmanCollection(collectionItem)
|
||||
)
|
||||
} else {
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return postwomanCollection
|
||||
return hoppscotchCollection
|
||||
},
|
||||
parsePostmanRequest({ name, request }) {
|
||||
const pwRequest = {
|
||||
|
||||
@@ -271,45 +271,45 @@ export default {
|
||||
})
|
||||
},
|
||||
parsePostmanCollection({ info, name, item }) {
|
||||
const postwomanCollection = {
|
||||
const hoppscotchCollection = {
|
||||
name: "",
|
||||
folders: [],
|
||||
requests: [],
|
||||
}
|
||||
|
||||
postwomanCollection.name = info ? info.name : name
|
||||
hoppscotchCollection.name = info ? info.name : name
|
||||
|
||||
if (item && item.length > 0) {
|
||||
for (const collectionItem of item) {
|
||||
if (collectionItem.request) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
postwomanCollection,
|
||||
hoppscotchCollection,
|
||||
"folders"
|
||||
)
|
||||
) {
|
||||
postwomanCollection.name = info ? info.name : name
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.name = info ? info.name : name
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
} else {
|
||||
postwomanCollection.name = name || ""
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.name = name || ""
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
}
|
||||
} else if (this.hasFolder(collectionItem)) {
|
||||
postwomanCollection.folders.push(
|
||||
hoppscotchCollection.folders.push(
|
||||
this.parsePostmanCollection(collectionItem)
|
||||
)
|
||||
} else {
|
||||
postwomanCollection.requests.push(
|
||||
hoppscotchCollection.requests.push(
|
||||
this.parsePostmanRequest(collectionItem)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return postwomanCollection
|
||||
return hoppscotchCollection
|
||||
},
|
||||
parsePostmanRequest({ name, request }) {
|
||||
const pwRequest = {
|
||||
|
||||
@@ -204,13 +204,13 @@ export default {
|
||||
) {
|
||||
this.importFromPostman(importFileObj)
|
||||
} else {
|
||||
this.importFromPostwoman(importFileObj)
|
||||
this.importFromHoppscotch(importFileObj)
|
||||
}
|
||||
}
|
||||
reader.readAsText(this.$refs.inputChooseFileToImportFrom.files[0])
|
||||
this.$refs.inputChooseFileToImportFrom.value = ""
|
||||
},
|
||||
importFromPostwoman(environments) {
|
||||
importFromHoppscotch(environments) {
|
||||
appendEnvironments(environments)
|
||||
this.fileImported()
|
||||
},
|
||||
@@ -220,7 +220,7 @@ export default {
|
||||
environment.variables.push({ key, value })
|
||||
)
|
||||
const environments = [environment]
|
||||
this.importFromPostwoman(environments)
|
||||
this.importFromHoppscotch(environments)
|
||||
},
|
||||
exportJSON() {
|
||||
let text = this.environmentJson
|
||||
|
||||
@@ -92,6 +92,7 @@ import {
|
||||
deleteGraphqlHistoryEntry,
|
||||
deleteRESTHistoryEntry,
|
||||
} from "~/newstore/history"
|
||||
import { setRESTRequest } from "~/newstore/RESTSession"
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -133,7 +134,7 @@ export default {
|
||||
})
|
||||
},
|
||||
useHistory(entry) {
|
||||
this.$emit("useHistory", entry)
|
||||
setRESTRequest(entry)
|
||||
},
|
||||
deleteHistory(entry) {
|
||||
if (this.page === "rest") deleteRESTHistoryEntry(entry)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
@click="$emit('use-entry')"
|
||||
>
|
||||
<span class="truncate">
|
||||
{{ `${entry.url}${entry.path}` }}
|
||||
{{ `${entry.endpoint}` }}
|
||||
</span>
|
||||
</span>
|
||||
<ButtonSecondary
|
||||
@@ -70,13 +70,15 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
duration() {
|
||||
const { duration } = this.entry
|
||||
return duration > 0
|
||||
? `${this.$t("duration")}: ${duration}ms`
|
||||
: this.$t("no_duration")
|
||||
if (this.entry.meta.responseDuration) {
|
||||
const responseDuration = this.entry.meta.responseDuration
|
||||
return responseDuration > 0
|
||||
? `${this.$t("duration")}: ${responseDuration}ms`
|
||||
: this.$t("no_duration")
|
||||
} else return this.$t("no_duration")
|
||||
},
|
||||
entryStatus() {
|
||||
const foundStatusGroup = findStatusGroup(this.entry.status)
|
||||
const foundStatusGroup = findStatusGroup(this.entry.statusCode)
|
||||
return (
|
||||
foundStatusGroup || {
|
||||
className: "",
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
:spellcheck="false"
|
||||
:value="header.key"
|
||||
autofocus
|
||||
@change="
|
||||
@input="
|
||||
updateHeader(index, {
|
||||
key: $event.target.value,
|
||||
key: $event,
|
||||
value: header.value,
|
||||
active: header.active,
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<AppSection label="response">
|
||||
<HttpResponseMeta v-if="!loading" :response="response" />
|
||||
<HttpResponseMeta :response="response" />
|
||||
<LensesResponseBodyRenderer v-if="!loading" :response="response" />
|
||||
</AppSection>
|
||||
</template>
|
||||
|
||||
@@ -1,33 +1,39 @@
|
||||
<template>
|
||||
<div
|
||||
class="
|
||||
flex
|
||||
sticky
|
||||
top-0
|
||||
z-10
|
||||
bg-primary
|
||||
items-center
|
||||
p-4
|
||||
font-mono font-semibold
|
||||
space-x-8
|
||||
"
|
||||
>
|
||||
<i v-if="response.type === 'loading'" class="animate-spin material-icons">
|
||||
refresh
|
||||
</i>
|
||||
<div v-else :class="statusCategory.className">
|
||||
<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>
|
||||
<span v-if="response == null">
|
||||
{{ $t("waiting_send_req") }}
|
||||
</span>
|
||||
<div
|
||||
v-else
|
||||
class="
|
||||
flex
|
||||
sticky
|
||||
top-0
|
||||
z-10
|
||||
bg-primary
|
||||
items-center
|
||||
p-4
|
||||
font-mono font-semibold
|
||||
space-x-8
|
||||
"
|
||||
>
|
||||
<i v-if="response.type === 'loading'" class="animate-spin material-icons">
|
||||
refresh
|
||||
</i>
|
||||
<div v-else :class="statusCategory.className">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -194,7 +194,7 @@ export default {
|
||||
this.client = new Paho.Client(
|
||||
parseUrl.hostname,
|
||||
parseUrl.port !== "" ? Number(parseUrl.port) : 8081,
|
||||
"postwoman"
|
||||
"hoppscotch"
|
||||
)
|
||||
this.client.connect({
|
||||
onSuccess: this.onConnectionSuccess,
|
||||
|
||||
Reference in New Issue
Block a user