RequestOptions.vue 2.1 KB

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