RequestOptions.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <SmartTabs
  3. v-model="selectedRealtimeTab"
  4. styles="sticky bg-primary top-upperMobilePrimaryStickyFold sm:top-upperPrimaryStickyFold z-10"
  5. render-inactive-tabs
  6. >
  7. <SmartTab
  8. :id="'params'"
  9. :label="`${$t('tab.parameters')}`"
  10. :info="`${Number(newActiveParamsCount$) + Number(newActiveVarsCount$)}`"
  11. >
  12. <HttpParameters />
  13. </SmartTab>
  14. <SmartTab :id="'bodyParams'" :label="`${$t('tab.body')}`">
  15. <HttpBody @change-tab="changeTab" />
  16. </SmartTab>
  17. <SmartTab
  18. :id="'headers'"
  19. :label="`${$t('tab.headers')}`"
  20. :info="`${newActiveHeadersCount$}`"
  21. >
  22. <HttpHeaders @change-tab="changeTab" />
  23. </SmartTab>
  24. <SmartTab :id="'authorization'" :label="`${$t('tab.authorization')}`">
  25. <HttpAuthorization />
  26. </SmartTab>
  27. <SmartTab
  28. :id="'preRequestScript'"
  29. :label="`${$t('tab.pre_request_script')}`"
  30. :indicator="
  31. preRequestScript && preRequestScript.length > 0 ? true : false
  32. "
  33. >
  34. <HttpPreRequestScript />
  35. </SmartTab>
  36. <SmartTab
  37. :id="'tests'"
  38. :label="`${$t('tab.tests')}`"
  39. :indicator="testScript && testScript.length > 0 ? true : false"
  40. >
  41. <HttpTests />
  42. </SmartTab>
  43. </SmartTabs>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref } from "@nuxtjs/composition-api"
  47. import { map } from "rxjs/operators"
  48. import { useReadonlyStream } from "~/helpers/utils/composables"
  49. import {
  50. restActiveHeadersCount$,
  51. restActiveParamsCount$,
  52. restActiveVarsCount$,
  53. usePreRequestScript,
  54. useTestScript,
  55. } from "~/newstore/RESTSession"
  56. export type RequestOptionTabs =
  57. | "params"
  58. | "bodyParams"
  59. | "headers"
  60. | "authorization"
  61. const selectedRealtimeTab = ref<RequestOptionTabs>("params")
  62. const changeTab = (e: RequestOptionTabs) => {
  63. selectedRealtimeTab.value = e
  64. }
  65. const newActiveParamsCount$ = useReadonlyStream(
  66. restActiveParamsCount$.pipe(
  67. map((e) => {
  68. if (e === 0) return null
  69. return `${e}`
  70. })
  71. ),
  72. null
  73. )
  74. const newActiveVarsCount$ = useReadonlyStream(
  75. restActiveVarsCount$.pipe(
  76. map((e) => {
  77. if (e === 0) return null
  78. return `${e}`
  79. })
  80. ),
  81. null
  82. )
  83. const newActiveHeadersCount$ = useReadonlyStream(
  84. restActiveHeadersCount$.pipe(
  85. map((e) => {
  86. if (e === 0) return null
  87. return `${e}`
  88. })
  89. ),
  90. null
  91. )
  92. const preRequestScript = usePreRequestScript()
  93. const testScript = useTestScript()
  94. </script>